<?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.njcn.system.mapper.SysDicTreePOMapper">
  <resultMap id="BaseResultMap" type="com.njcn.system.pojo.po.SysDicTreePO">
    <!--@mbg.generated-->
    <!--@Table sys_dic_tree-->
    <id column="id" jdbcType="VARCHAR" property="id" />
    <result column="pid" jdbcType="VARCHAR" property="pid" />
    <result column="pids" jdbcType="LONGVARCHAR" property="pids" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="code" jdbcType="VARCHAR" property="code" />
    <result column="sort" jdbcType="INTEGER" property="sort" />
    <result column="remark" jdbcType="VARCHAR" property="remark" />
    <result column="status" jdbcType="TINYINT" property="status" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="create_by" jdbcType="VARCHAR" property="createBy" />
    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
    <result column="update_by" jdbcType="VARCHAR" property="updateBy" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, pid, pids, `name`, code, sort, remark, `status`, create_time, create_by, update_time, 
    update_by
  </sql>

  <select id="queryByid" resultType="com.njcn.system.pojo.vo.DictTreeVO">
    SELECT
    *
    FROM
    sys_dic_tree a
    WHERE
    a.pids LIKE concat('%',#{id},'%')
    AND NOT EXISTS (
    SELECT
    1
    FROM
    sys_dic_tree b
    WHERE
    b.pids LIKE concat('%',#{id},'%') and a.id = b.pid)

  </select>
</mapper>