<?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.I18nMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="cn.bunny.dao.entity.i18n.I18n">
        <id column="id" property="id"/>
        <result column="key_name" property="keyName"/>
        <result column="translation" property="translation"/>
        <result column="type_name" property="typeName"/>
        <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"/>
    </resultMap>

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

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

    <!-- 分页查询多语言内容 -->
    <select id="selectListByPage" resultType="cn.bunny.dao.entity.i18n.I18n">
        select
        <include refid="Base_Column_List"/>
        from sys_i18n
        <where>
            is_deleted = 0
            <if test="dto.keyName != null and dto.keyName != ''">
                and key_name like CONCAT('%',#{dto.keyName},'%')
            </if>
            <if test="dto.translation != null and dto.translation != ''">
                and translation like CONCAT('%',#{dto.translation},'%')
            </if>
            <if test="dto.typeName != null and dto.typeName != ''">
                and type_name like CONCAT('%',#{dto.typeName},'%')
            </if>
        </where>
    </select>

</mapper>
