<?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.csdevice.mapper.CsLedgerMapper">

    <sql id="Base_Column_List">
        id,
        pid,
        pids,
        `name`,
        `level`,
        sort,
        remark,
        `state`,
        create_by,
        create_time,
        update_by,
        update_time
    </sql>
    <resultMap id="BaseResultMap" type="com.njcn.csdevice.pojo.po.CsLedger">
        <result column="id" property="id"/>
        <result column="pid" property="pid"/>
        <result column="pids" property="pids"/>
        <result column="name" property="name"/>
        <result column="level" property="level"/>
        <result column="sort" property="sort"/>
        <result column="remark" property="remark"/>
        <result column="state" property="state"/>
        <result column="create_by" property="createBy"/>
        <result column="create_time" property="createTime"/>
        <result column="update_by" property="updateBy"/>
        <result column="update_time" property="updateTime"/>
    </resultMap>
    <select id="getAll" resultType="CsLedgerVO">
        select
            id,pid,pids,name,level,sort
        from
            cs_ledger
        where
            state = 1
  </select>

    <select id="queryLine" resultType="com.njcn.csdevice.pojo.po.CsLedger">
        select * from cs_ledger a where a.`Level`='3' and a.state='1'
        <if test="lineParamdto.engineerId!=null and lineParamdto.engineerId!=''">
            and  FIND_IN_SET(#{lineParamdto.engineerId}, a.pids )
        </if>
        <if test="lineParamdto.projectId!=null and lineParamdto.projectId!=''">
            and  FIND_IN_SET(#{lineParamdto.projectId}, a.pids )
        </if>
        <if test="lineParamdto.devId!=null and lineParamdto.devId!=''">
            and  FIND_IN_SET(#{lineParamdto.devId}, a.pids )
        </if>
        <if test="lineParamdto.lineId!=null and lineParamdto.lineId!=''">
            and  a.id=#{lineParamdto.lineId}
        </if>


    </select>

</mapper>