1.0
xin
2025-04-15 e718afd02965c6a4018506acb1ae99baca0c5645
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
68
69
70
<?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.oying.modules.system.mapper.DeptMapper">
    <resultMap id="BaseResultMap" type="com.oying.modules.system.domain.Dept">
        <id column="dept_id" property="id"/>
        <result column="dept_sort" property="deptSort"/>
        <result column="name" property="name"/>
        <result column="enabled" property="enabled"/>
        <result column="pid" property="pid"/>
        <result column="sub_count" property="subCount"/>
        <result column="create_by" property="createBy"/>
        <result column="update_by" property="updateBy"/>
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
    </resultMap>
 
    <sql id="BaseResultMap">
        dept_id, name, pid, sub_count, create_time, update_time, create_by, update_by, enabled, dept_sort
    </sql>
 
    <select id="findAll" resultMap="BaseResultMap">
        select
        <include refid="BaseResultMap"/>
        from sys_dept
        <where>
            <if test="criteria.ids != null and criteria.ids.size() > 0">
                and dept_id in
                <foreach collection="criteria.ids" item="id" open="(" separator="," close=")">
                    #{id}
                </foreach>
            </if>
            <if test="criteria.name != null and criteria.name != ''">
                and name like concat('%', #{criteria.name}, '%')
            </if>
            <if test="criteria.enabled != null">
                and enabled = #{criteria.enabled}
            </if>
            <if test="criteria.pid != null">
                and pid = #{criteria.pid}
            </if>
            <if test="criteria.pidIsNull != null">
                and pid is null
            </if>
            <if test="criteria.createTime != null and criteria.createTime.size() != 0">
                and create_time between #{criteria.createTime[0]} and #{criteria.createTime[1]}
            </if>
        </where>
        order by dept_sort
    </select>
 
    <select id="findByPid" resultMap="BaseResultMap">
        select
        <include refid="BaseResultMap"/>
        from sys_dept
        where pid = #{pid}
    </select>
 
    <select id="findByPidIsNull" resultMap="BaseResultMap">
        select
        <include refid="BaseResultMap"/>
        from sys_dept
        where pid is null
    </select>
 
    <select id="findByRoleId" resultType="com.oying.modules.system.domain.Dept">
        select d.dept_id as id, d.name, d.pid, d.sub_count, d.create_time, d.update_time, d.create_by, d.update_by, d.enabled, d.dept_sort
        from sys_dept d, sys_roles_depts r
        where d.dept_id = r.dept_id and r.role_id = #{roleId}
    </select>
</mapper>