<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.bunny.services.mapper.i18n.I18nTypeMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="cn.bunny.dao.entity.i18n.I18nType">
        <id column="id" property="id"/>
        <result column="type_name" property="typeName"/>
        <result column="summary" property="summary"/>
        <result column="create_user" property="createUser"/>
        <result column="update_user" property="updateUser"/>
        <result column="update_time" property="updateTime"/>
        <result column="create_time" property="createTime"/>
        <result column="is_deleted" property="isDeleted"/>
        <result column="is_default" property="isDefault"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, type_name, summary, create_user, update_user, update_time, create_time, is_deleted,is_default
    </sql>

    <!-- 物理删除多语言类型 -->
    <delete id="deleteBatchIdsWithPhysics">
        delete
        from sys_i18n_type
        where id in
        <foreach collection="ids" item="id" open="(" close=")" separator=",">
            #{id}
        </foreach>
    </delete>

    <!-- 多语言类型查询 -->
    <select id="selectListByPage" resultType="cn.bunny.dao.entity.i18n.I18nType">
        select
        i18n_type.*,
        create_user.username as createUsername,
        update_user.username as updateUsername
        from sys_i18n_type i18n_type
        left join sys_user create_user on create_user.id = i18n_type.create_user
        left join sys_user update_user on update_user.id = i18n_type.update_user
        <where>
            i18n_type.is_deleted = 0
            <if test="dto.typeName != null and dto.typeName != ''">
                and i18n_type.type_name like CONCAT('%',#{dto.typeName},'%')
            </if>
            <if test="dto.summary != null and dto.summary != ''">
                and i18n_type.summary like CONCAT('%',#{dto.summary},'%')
            </if>
        </where>
    </select>

</mapper>
