<?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.stylefeng.guns.modular.system.mapper.DictMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="cn.stylefeng.guns.modular.system.entity.Dict">
        <id column="DICT_ID" property="dictId"/>
        <result column="DICT_TYPE_ID" property="dictTypeId"/>
        <result column="CODE" property="code"/>
        <result column="NAME" property="name"/>
        <result column="PARENT_ID" property="parentId"/>
        <result column="PARENT_IDS" property="parentIds"/>
        <result column="STATUS" property="status"/>
        <result column="DESCRIPTION" property="description"/>
        <result column="CREATE_TIME" property="createTime"/>
        <result column="UPDATE_TIME" property="updateTime"/>
        <result column="CREATE_USER" property="createUser"/>
        <result column="UPDATE_USER" property="updateUser"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        base.DICT_ID AS dictId, base.DICT_TYPE_ID AS dictTypeId, base.CODE AS code, base.NAME AS name, base.PARENT_ID AS parentId, base.STATUS AS status, base.DESCRIPTION AS description, base.CREATE_TIME AS createTime, base.UPDATE_TIME AS updateTime, base.CREATE_USER AS createUser, base.UPDATE_USER AS updateUser
    </sql>

    <select id="dictTree" resultType="cn.stylefeng.guns.core.common.node.ZTreeNode">
        select DICT_ID AS id, PARENT_ID as pId, NAME as name,
		(
		CASE
		WHEN (PARENT_ID = 0 OR PARENT_ID IS NULL) THEN
		'true'
		ELSE
		'false'
		END
		) as open from sys_dict where DICT_TYPE_ID = #{dictTypeId}
    </select>

</mapper>
