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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
| <?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.zt.modules.sys.dao.SysDeptDao">
|
| <select id="getAll" resultType="com.zt.core.sys.model.SysDept">
| select a.id as id
| , a.name as name
| , a.pid as pid
| , a.code as code
| , a.pids as pids
| , a.IS_COMPANY
| , a.nature as nature
| , a.sort as sort
| , (select t2.name from SYS_DEPT t2 where t2.id = a.pid) parentName
| , (select t2.name from SYS_DEPT t2 where t2.id = a.pid) companyName
| from SYS_DEPT a
| where a.is_delete = 0
| order by a.nature, a.sort asc
| </select>
|
| <select id="getList" resultType="com.zt.core.sys.model.SysDept">
| select a.id as id
| ,a.name as name
| ,a.code as code
| ,a.pid as pid
| ,a.pids as pids
| ,a.nature as nature
| ,a.sort as sort
| ,(select t2.name from SYS_DEPT t2 where t2.id=a.pid) parentName
| from SYS_DEPT a
| where a.is_delete=0
| <if test="isCompany != null">
| and a.is_company = #{isCompany}
| </if>
| <if test="companyId != null">
| and a.company_id = #{companyId}
| </if>
| <if test="tenantId != null">
| and a.tenant_id = #{tenantId}
| </if>
| <if test="deptIds != null">
| and a.id in
| <foreach item="id" collection="deptIds" open="(" separator="," close=")">
| #{id}
| </foreach>
| </if>
| order by a.sort asc
| </select>
|
| <select id="getById" resultType="com.zt.core.sys.model.SysDept">
| select a.id
| , a.name
| , a.code
| , a.pid
| , a.pids
| , a.nature
| , a.sort
| , (select t2.name from SYS_DEPT t2 where t2.id = a.pid) parentName
| from SYS_DEPT a
| where a.is_delete = 0
| and a.id = #{value}
| </select>
|
| <select id="getListByParent" resultType="com.zt.core.sys.model.SysDept">
| select a.id
| ,a.name
| ,a.code
| ,a.pid
| ,a.pids
| ,a.nature
| ,a.sort
| ,(select t2.name from SYS_DEPT t2 where t2.id=a.pid) parentName
| from SYS_DEPT a
| where a.is_delete=0
| <if test="pCode != null">
| and pid in (select id from SYS_DEPT where code= #{pCode})
| </if>
| <if test="code != null">
| and code= #{code}
| </if>
| <if test="pId != null">
| and pid = #{pId}
| </if>
| </select>
| <select id="getDeptList3" resultType="com.zt.core.sys.model.SysDept">
| select id, name
| from sys_dept
| where IS_COMPANY = 0
| order by sort
| </select>
| </mapper>
|
|