<?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.nantian.cloud.jly.mapper.DictRegionMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.nantian.cloud.jly.entity.DictRegion">
        <id column="id" property="id"/>
        <result column="pid" property="pid"/>
        <result column="meaning" property="meaning"/>
        <result column="version" property="version"/>
        <result column="userid" property="userid"/>
        <result column="update_time" property="updateTime"/>
        <result column="del_flag" property="delFlag"/>
        <result column="dept_id" property="deptId"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, pid, meaning, version
    </sql>
    <select id="getNameByCode" resultType="com.nantian.cloud.jly.entity.DictRegion">
        select <include refid="Base_Column_List"></include>
        from dict_region
        <if test="id!=null and id!=''">
            where id = #{id}
        </if>
    </select>
    <select id="getDictRegionTree" resultType="com.nantian.cloud.jly.vo.TreeVo">
        select id as value, pid as pvalue, meaning as label
        from dict_region where del_flag="1"
    </select>

    <select id="getDictRegionTrees" resultType="com.nantian.cloud.jly.vo.TreeVo">
        select id as value, pid as pvalue, meaning as label
        from dict_region where del_flag="1" and id=#{id}
        or pid=#{id}
    </select>

</mapper>
