危化品全生命周期管理后端
kongzy
2024-09-14 ed36af4d4cc5feac72a384d85f9032fc6dc1223a
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
<?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>
</mapper>