<?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="com.starry.admin.modules.system.mapper.SysDictDataMapper">
    <resultMap type="com.starry.admin.modules.system.entity.SysDictDataEntity" id="XlDictDataResult">
        <result property="dictDataId" column="dict_data_id"/>
        <result property="dictType" column="dict_type"/>
        <result property="dictLabel" column="dict_label"/>
        <result property="dictValue" column="dict_value"/>
        <result property="sort" column="sort"/>
        <result property="isDefault" column="is_default"/>
        <result property="listClass" column="list_class"/>
        <result property="status" column="status"/>
        <result property="remark" column="remark"/>
        <result property="updatedTime" column="updated_time"/>
        <result property="updatedBy" column="updated_by"/>
        <result property="createdTime" column="created_time"/>
        <result property="createdBy" column="created_by"/>
        <result property="deleted" column="deleted"/>
        <result property="version" column="version"/>
    </resultMap>

    <sql id="selectXlDictDataVo">
        select dict_data_id,
               dict_type,
               dict_label,
               dict_value,
               sort,
               is_default,
               list_class,
               status,
               remark,
               updated_time,
               updated_by,
               created_time,
               created_by,
               deleted
        from sys_dict_data
    </sql>

    <select id="selectXlDictDataList" resultMap="XlDictDataResult"
            parameterType="com.starry.admin.modules.system.entity.SysDictDataEntity">
        <include refid="selectXlDictDataVo"/>
        <where>
            <if test="vo.dictType != null and vo.dictType != ''">
                AND dict_type = #{vo.dictType}
            </if>
            <if test="vo.dictLabel != null and vo.dictLabel != ''">
                AND dict_label like concat('%', #{vo.dictLabel}, '%')
            </if>
            <if test="vo.status != null and vo.status != ''">
                AND status = #{vo.status}
            </if>
        </where>
    </select>

    <select id="selectXlDictDataByDictDataId" parameterType="Long" resultMap="XlDictDataResult">
        <include refid="selectXlDictDataVo"/>
        where dict_data_id = #{dictDataId}
    </select>

    <select id="selectDictDataByType" resultMap="XlDictDataResult">
        <include refid="selectXlDictDataVo"/>
        where deleted = 0 and status = 0 and dict_type = #{dictType} order by sort asc
    </select>
</mapper>