Newer
Older
casic-metering-biz-xichang / casic-metering-dao / src / main / resources / mapper / system / DeptExtendMapper.xml
<?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.casic.missiles.mapper.system.DeptExtendMapper">

    <sql id="Base_Column_List">
        sd.id AS "id", sd.id as "deptId", sd.num AS "num", sd.pid AS "pid", sd.pids AS "pids", sd.simple_name AS "simpleName",
        sd.full_name AS "fullName", sd.tips AS "tips", sd.version AS "version", sd.dept_type as "deptType", sd.ip_segment as ipSegment,
        GROUP_CONCAT(ss.id) as directorId, GROUP_CONCAT(ss.name) AS directorName, sd.SYNC_ID AS "syncId"
    </sql>

    <select id="listPage" resultType="java.util.Map">
        select
        <include refid="Base_Column_List"/>
        from sys_dept sd
        left join
            (SELECT DISTINCT su.id, su.NAME, su.DEPT_ID FROM sys_role sr
            JOIN sys_ru_relation srr ON sr.ID = srr.ROLEID
            JOIN sys_user su ON srr.USERID = su.ID WHERE sr.TIPS = "director") ss
            on sd.ID = ss.DEPT_ID
        <where>
            and sd.del_flag = '0'
            <if test="deptName != null and deptName != ''">
                and sd.SIMPLE_NAME like concat('%',#{deptName},'%')
            </if>
            <if test="deptId != null and deptId != ''">
                and sd.ID like concat('%',#{deptId},'%')
            </if>
            <if test="deptType != null and deptType != ''">
                and sd.DEPT_TYPE = #{deptType}
            </if>
        </where>
        group by sd.id,sd.num,sd.pid,sd.pids,sd.simple_name,sd.full_name,sd.tips,sd.version,sd.dept_type,sd.ip_segment
        order by sd.num ASC
    </select>

    <select id="selectListByCategory" resultType="com.casic.missiles.dto.business.labExecutive.SampleHandOutInitListResponse">
        select id AS measureSegmentId, simple_name AS measureSegment
        from sys_dept
        where tips = #{category}
        and sync_id = #{location}
    </select>
</mapper>