zhanghua
2023-12-12 bc2da7908a227c09e5cc7b6d8dab3e9c94b784a1
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
<?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.ycl.mapper.user.UmsDepartManageMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.ycl.entity.user.UmsDepartManage">
        <id column="id" property="id"/>
        <result column="user_id" property="userId"/>
        <result column="depart_id" property="departId"/>
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
    </resultMap>
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id
        , user_id,depart_id,create_time,update_time
    </sql>
 
    <delete id="deletedByDepartId">
        delete
        from ums_depart_manager
        where depart_id = #{departId}
    </delete>
    <delete id="deletedByUserId">
        delete
        from ums_depart_manager
        where user_id = #{userId}
    </delete>
 
    <select id="selectPageByUserId" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from ums_depart_manager
        where user_id=#{userId}
        limit #{current},#{pageSize}
    </select>
 
    <select id="selectChildrendIds" resultType="com.ycl.entity.depart.UmsDepart">
        select * from ums_depart where id in (WITH RECURSIVE cte_dept(id) AS (
            SELECT id
            FROM ums_depart
            WHERE id = #{id}
            UNION ALL
            SELECT ums_depart.id
            FROM ums_depart
            JOIN cte_dept ON ums_depart.parent_id = cte_dept.id
        )SELECT id FROM cte_dept) and is_deleted = 0
    </select>
</mapper>