<?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.TSupervisionUnitEnergyTypeMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.nantian.cloud.jljc.entity.TSupervisionUnitEnergyType">
        <id column="id" property="id"/>
        <id column="pid" property="pid"/>
        <id column="name" property="name"/>
        <result column="userid" property="userid"/>
        <result column="update_time" property="updateTime"/>
        <result column="del_flag" property="delFlag"/>
        <result column="dept_id" property="deptId"/>
        <result column="gov_target_id" property="govTargetId"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, pid, name, userid, update_time, del_flag, dept_id, gov_target_id
    </sql>

    <select id="getTree" resultType="com.nantian.cloud.jljc.vo.TreeVo">
        select t.value, t.label, t.plabel, t.pvalue from(
            select t1.id as value, t1.`name` as label, t2.`name` as plabel, t2.id as pvalue
            from t_supervision_unit_energy_type t1 left join t_supervision_unit_energy_type t2 on t1.pid = t2.id
        ) t
        <if test="query.name !=null and query.name!=''">
            where t.label like concat("%",#{query.name},"%") or t.plabel like concat("%",#{query.name},"%")
        </if>
    </select>

</mapper>
