“djh”
2 days ago aad364bb323a1eaa0389ee5c6389bdc0ea7ed526
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?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.gkhy.hazmat.system.mapper.SysDeptMapper">
 
 
    <update id="updateDeptStatusNormal" parameterType="Long">
        update sys_dept set status = 0 where id in
        <foreach collection="array" item="deptId" open="(" separator="," close=")">
            #{deptId}
        </foreach>
    </update>
 
    <update id="updateDeptChildren" parameterType="java.util.List">
        update sys_dept set ancestors =
        <foreach collection="depts" item="item" index="index"
                 separator=" " open="case id" close="end">
            when #{item.id} then #{item.ancestors}
        </foreach>
        where id in
        <foreach collection="depts" item="item" index="index"
                 separator="," open="(" close=")">
            #{item.deptId}
        </foreach>
    </update>
 
    <select id="selectDeptList" resultType="com.gkhy.hazmat.system.domain.SysDept"
            parameterType="com.gkhy.hazmat.system.domain.SysDept">
        select * from sys_dept
        <where>
             and del_flag=0
             <if test="companyId!=null">
                and company_id=#{companyId}
             </if>
        </where>
    </select>
 
    <select id="selectChildrenDeptById" resultType="com.gkhy.hazmat.system.domain.SysDept"
            parameterType="java.lang.Long">
        select * from sys_dept where parent_id=#{deptId} and del_flag=0
    </select>
 
    <select id="hasChildByDeptId" resultType="java.lang.Integer" parameterType="java.lang.Long">
        select count(1) from sys_dept where parent_id=#{deptId} and del_flag=0
    </select>
 
    <select id="checkDeptExistUser" parameterType="Long" resultType="int">
        select count(1) from sys_user where depart_id = #{deptId} and del_flag = 0
    </select>
 
 
    <select id="selectNormalChildrenDeptById" resultType="java.lang.Integer" parameterType="java.lang.Long"></select>
 
 
    <select id="checkNameUnique" resultType="com.gkhy.hazmat.system.domain.SysDept">
        select id,name from sys_dept where name=#{name} and parent_id=#{parentId} and company_id=#{companyId} limit 1
    </select>
    <select id="selectDeptListByRoleId" resultType="java.lang.Long">
        select d.dept_id
        from sys_dept d
        left join sys_role_dept rd on d.dept_id = rd.dept_id
        where rd.role_id = #{roleId}
        <if test="deptCheckStrictly">
            and d.dept_id not in (select d.parent_id from sys_dept d inner join sys_role_dept rd on d.dept_id = rd.dept_id and rd.role_id = #{roleId})
        </if>
        order by d.parent_id, d.order_num
    </select>
</mapper>