<?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.auth.dao.base.mapper.v1.DictMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.auth.dao.base.entity.DictEntity">
        <id column="id" property="id"/>
        <id column="dict_type" property="dictType"/>
        <id column="dict_code" property="dictCode"/>
        <id column="dict_value" property="dictValue"/>
        <id column="dict_label" property="dictLabel"/>
        <id column="css_class" property="cssClass"/>
        <id column="list_class" property="listClass"/>
        <id column="is_default" property="isDefault"/>
        <id column="order_num" property="orderNum"/>
        <id column="status" property="status"/>
        <id column="remark" property="remark"/>
        <id column="is_deleted" property="isDeleted"/>
        <id column="create_time" property="createTime"/>
        <id column="update_time" property="updateTime"/>
        <id column="create_user" property="createUser"/>
        <id column="update_user" property="updateUser"/>
        <id column="is_deleted" property="isDeleted"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id,
        dict_type,dict_code,dict_value,dict_label,css_class,list_class,is_default,order_num,status,remark,is_deleted,
        create_time, update_time, create_user, update_user, is_deleted
    </sql>

    <!-- 分页查询系统数据字典内容 -->
    <select id="selectListByPage" resultType="com.auth.model.base.vo.DictVo">
        select
        base.*,
        create_user.username as create_username,
        update_user.username as update_username
        from sys_dict base
        left join sys_user create_user on create_user.id = base.create_user
        left join sys_user update_user on update_user.id = base.update_user
        <where>
            base.is_deleted = 0
            <if test="dto.dictType != null and dto.dictType != ''">
                and base.dict_type like CONCAT('%',#{dto.dictType},'%')
            </if>
            <if test="dto.dictCode != null and dto.dictCode != ''">
                and base.dict_code like CONCAT('%',#{dto.dictCode},'%')
            </if>
            <if test="dto.dictValue != null and dto.dictValue != ''">
                and base.dict_value like CONCAT('%',#{dto.dictValue},'%')
            </if>
            <if test="dto.dictLabel != null and dto.dictLabel != ''">
                and base.dict_label like CONCAT('%',#{dto.dictLabel},'%')
            </if>
            <if test="dto.cssClass != null and dto.cssClass != ''">
                and base.css_class like CONCAT('%',#{dto.cssClass},'%')
            </if>
            <if test="dto.listClass != null and dto.listClass != ''">
                and base.list_class like CONCAT('%',#{dto.listClass},'%')
            </if>
            <if test="dto.isDefault != null and dto.isDefault != ''">
                and base.is_default like CONCAT('%',#{dto.isDefault},'%')
            </if>
            <if test="dto.orderNum != null and dto.orderNum != ''">
                and base.order_num like CONCAT('%',#{dto.orderNum},'%')
            </if>
            <if test="dto.status != null and dto.status != ''">
                and base.status like CONCAT('%',#{dto.status},'%')
            </if>
            <if test="dto.remark != null and dto.remark != ''">
                and base.remark like CONCAT('%',#{dto.remark},'%')
            </if>
            <if test="dto.isDeleted != null and dto.isDeleted != ''">
                and base.is_deleted like CONCAT('%',#{dto.isDeleted},'%')
            </if>
        </where>
    </select>

</mapper>
