<?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.jljc.mapper.HKindMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.nantian.cloud.jljc.entity.HKind">
        <result column="code" property="code"/>
        <result column="name" property="name"/>
        <result column="pcode" property="pcode"/>
        <result column="type" property="type"/>
        <result column="num" property="num"/>
        <result column="is_use" property="isUse"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        code, name, pcode, type, num, is_use
    </sql>

    <select id="getTree" resultType="com.nantian.cloud.jljc.vo.TreeVo">
        select k1.code as value, k1.`name` as label, k2.`name` as plabel, k2.code as pvalue, k1.num
        from h_kind k1 left join h_kind k2 on k1.pcode = k2.code
    </select>

    <select id="treeByLeaf" resultType="com.nantian.cloud.jljc.vo.TreeVo">
        select code as value, name as label, pcode as pvalue
        from h_kind where code = #{code}
    </select>

</mapper>
