FrontDeptMapper.xml
13 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
<?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.lhcredit.project.business.frontDept.mapper.FrontDeptMapper">
<resultMap type="FrontDept" id="FrontDeptResult">
<result property="id" column="id" />
<result property="parentId" column="parent_id" />
<result property="ancestors" column="ancestors" />
<result property="deptName" column="dept_name" />
<result property="sort" column="sort" />
<result property="deptType" column="dept_type" />
<result property="isEnable" column="is_enable" />
<result property="contractType" column="contract_type" />
<result property="signingMethod" column="signing_method" />
<result property="contractNum" column="contract_num" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<result property="parentName" column="parent_name" />
<result property="bizTypes" column="biz_types" />
<result property="reportNum" column="report_num" />
<result property="financeNum" column="finance_num" />
<result property="monitorNum" column="monitor_num" />
<result property="reportParams" column="report_params" />
<result property="monitorBegin" column="monitor_begin" />
<result property="monitorEnd" column="monitor_end" />
</resultMap>
<sql id="selectFrontDeptVo">
select id, parent_id, ancestors, dept_name, sort, dept_type, is_enable, contract_type, report_params ,signing_method, contract_num, create_by, create_time, update_by, update_time, remark,biz_types,report_num,finance_num,monitor_num,monitor_begin,monitor_end from front_dept
</sql>
<select id="selectFrontDeptList" parameterType="FrontDept" resultMap="FrontDeptResult">
<include refid="selectFrontDeptVo"/>
<where>
<if test="id != null "> and id = #{id}</if>
<if test="parentId != null "> and parent_id = #{parentId}</if>
<if test="ancestors != null and ancestors != '' "> and ancestors = #{ancestors}</if>
<if test="deptName != null and deptName != '' "> and dept_name like CONCAT('%',#{deptName},'%')</if>
<if test="sort != null "> and sort = #{sort}</if>
<if test="deptType != null and deptType != '' "> and dept_type = #{deptType}</if>
<if test="isEnable != null and isEnable != '' "> and is_enable = #{isEnable}</if>
<if test="contractType != null and contractType != '' "> and contract_type = #{contractType}</if>
<if test="signingMethod != null and signingMethod != '' "> and signing_method = #{signingMethod}</if>
<if test="contractNum != null and contractNum != '' "> and contract_num = #{contractNum}</if>
<if test="monitorBegin != null and monitorBegin != '' "> and monitor_begin = #{monitorBegin}</if>
<if test="monitorEnd != null and monitorEnd != '' "> and monitor_end = #{monitorEnd}</if>
<if test="createBy != null and createBy != '' "> and create_by = #{createBy}</if>
<if test="createTime != null "> and create_time = #{createTime}</if>
<if test="updateBy != null and updateBy != '' "> and update_by = #{updateBy}</if>
<if test="updateTime != null "> and update_time = #{updateTime}</if>
<if test="remark != null and remark != '' "> and remark = #{remark}</if>
</where>
</select>
<select id="getFrontDeptById" parameterType="Long" resultMap="FrontDeptResult">
<include refid="selectFrontDeptVo"></include>
<where>
id=#{id}
</where>
</select>
<select id="getFrontDeptByName" parameterType="Long" resultMap="FrontDeptResult">
<include refid="selectFrontDeptVo"></include>
<where>
dept_name=#{orgName}
</where>
</select>
<select id="selectFrontDeptById" parameterType="Long" resultMap="FrontDeptResult">
select d.id, d.parent_id, d.ancestors, d.dept_name,d.report_params, d.sort, d.dept_type, d.is_enable, d.contract_type, d.contract_num,d.biz_types,d.report_num,d.finance_num,d.monitor_num,d.monitor_begin,d.monitor_end,
(select dept_name from front_dept where id = d.parent_id) parent_name
from front_dept d
where d.id = #{id}
</select>
<select id="selectFrontDeptByName" parameterType="String" resultMap="FrontDeptResult">
<include refid="selectFrontDeptVo"/>
where dept_name = #{deptName}
</select>
<select id="getDeptListByIds" parameterType="long" resultMap="FrontDeptResult">
<include refid="selectFrontDeptVo"/>
<where>
id IN
<foreach item="id" collection="list" open="(" separator="," close=")">
#{id}
</foreach>
</where>
</select>
<insert id="insertFrontDept" parameterType="FrontDept" useGeneratedKeys="true" keyProperty="id">
insert into front_dept
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="parentId != null ">parent_id,</if>
<if test="ancestors != null and ancestors != '' ">ancestors,</if>
<if test="deptName != null and deptName != '' ">dept_name,</if>
<if test="sort != null ">sort,</if>
<if test="deptType != null and deptType != '' ">dept_type,</if>
<if test="isEnable != null and isEnable != '' ">is_enable,</if>
<if test="contractType != null and contractType != '' ">contract_type,</if>
<if test="signingMethod != null and signingMethod != '' ">signing_method,</if>
<if test="contractNum != null and contractNum != '' ">contract_num,</if>
<if test="createBy != null and createBy != '' ">create_by,</if>
<if test="createTime != null ">create_time,</if>
<if test="updateBy != null and updateBy != '' ">update_by,</if>
<if test="updateTime != null ">update_time,</if>
<if test="remark != null and remark != '' ">remark,</if>
<if test="bizTypes != null and bizTypes != '' ">biz_types,</if>
<if test="reportNum != null ">report_num,</if>
<if test="financeNum != null ">finance_num,</if>
<if test="monitorNum != null ">monitor_num,</if>
<if test="reportParams != null and reportParams != '' ">report_params,</if>
<if test="monitorBegin != null and monitorBegin != '' ">monitor_begin,</if>
<if test="monitorEnd != null and monitorEnd != '' ">monitor_end,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="parentId != null ">#{parentId},</if>
<if test="ancestors != null and ancestors != '' ">#{ancestors},</if>
<if test="deptName != null and deptName != '' ">#{deptName},</if>
<if test="sort != null ">#{sort},</if>
<if test="deptType != null and deptType != '' ">#{deptType},</if>
<if test="isEnable != null and isEnable != '' ">#{isEnable},</if>
<if test="contractType != null and contractType != '' ">#{contractType},</if>
<if test="signingMethod != null and signingMethod != '' ">#{signingMethod},</if>
<if test="contractNum != null and contractNum != '' ">#{contractNum},</if>
<if test="createBy != null and createBy != '' ">#{createBy},</if>
<if test="createTime != null ">#{createTime},</if>
<if test="updateBy != null and updateBy != '' ">#{updateBy},</if>
<if test="updateTime != null ">#{updateTime},</if>
<if test="remark != null and remark != '' ">#{remark},</if>
<if test="bizTypes != null and bizTypes != '' ">#{bizTypes},</if>
<if test="reportNum != null ">#{reportNum},</if>
<if test="financeNum != null ">#{financeNum},</if>
<if test="monitorNum != null ">#{monitorNum},</if>
<if test="reportParams != null and reportParams != '' ">#{reportParams},</if>
<if test="monitorBegin != null and monitorBegin != '' ">#{monitorBegin},</if>
<if test="monitorEnd != null and monitorEnd != '' ">#{monitorEnd},</if>
</trim>
</insert>
<update id="updateFrontDept" parameterType="FrontDept">
update front_dept
<trim prefix="SET" suffixOverrides=",">
<if test="parentId != null ">parent_id = #{parentId},</if>
<if test="ancestors != null and ancestors != '' ">ancestors = #{ancestors},</if>
<if test="deptName != null and deptName != '' ">dept_name = #{deptName},</if>
<if test="sort != null ">sort = #{sort},</if>
<if test="deptType != null and deptType != '' ">dept_type = #{deptType},</if>
<if test="isEnable != null and isEnable != '' ">is_enable = #{isEnable},</if>
<if test="contractType != null and contractType != '' ">contract_type = #{contractType},</if>
<if test="signingMethod != null and signingMethod != '' ">signing_method = #{signingMethod},</if>
<if test="contractNum != null and contractNum != '' ">contract_num = #{contractNum},</if>
<if test="createBy != null and createBy != '' ">create_by = #{createBy},</if>
<if test="createTime != null ">create_time = #{createTime},</if>
<if test="updateBy != null and updateBy != '' ">update_by = #{updateBy},</if>
<if test="updateTime != null ">update_time = #{updateTime},</if>
<if test="remark != null and remark != '' ">remark = #{remark},</if>
<if test="bizTypes != null and bizTypes != '' ">biz_types = #{bizTypes},</if>
<if test="reportNum != null ">report_num = #{reportNum},</if>
<if test="financeNum != null ">finance_num = #{financeNum},</if>
<if test="monitorNum != null ">monitor_num = #{monitorNum},</if>
<if test="reportParams != null and reportParams != '' ">report_params = #{reportParams},</if>
<if test="monitorBegin != null and monitorBegin != '' "> monitor_begin = #{monitorBegin},</if>
<if test="monitorEnd != null and monitorEnd != '' "> monitor_end = #{monitorEnd},</if>
</trim>
where id = #{id}
</update>
<update id="updateFrontDeptByAncestors" parameterType="FrontDept">
update front_dept
<trim prefix="SET" suffixOverrides=",">
<if test="bizTypes != null ">biz_types = #{bizTypes},</if>
<if test="updateTime != null ">update_time = #{updateTime},</if>
</trim>
<where>
id = #{id}
OR ancestors LIKE CONCAT('%',#{id},'%')
</where>
</update>
<delete id="deleteFrontDeptById" parameterType="Long">
delete from front_dept where id = #{id}
</delete>
<delete id="deleteFrontDeptByIds" parameterType="String">
delete from front_dept where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="selectFrontDeptByOrgId" resultType="com.lhcredit.project.business.frontDept.domain.FrontDept">
SELECT
id,
parent_id as parentId,
ancestors,
dept_name as deptName,
sort,
dept_type as deptType,
is_enable as isEnable,
contract_type as contractType,
signing_method as signingMethod,
contract_num as contractNum,
biz_types as bizTypes,
monitor_begin as monitorBegin,
monitor_end as monitorEnd
FROM front_dept WHERE id = #{orgId}
</select>
<select id="findDeptTypeAll" resultType="com.lhcredit.project.business.frontDept.domain.FrontDept">
SELECT * FROM front_dept de WHERE
FIND_IN_SET(#{orgId},
de.ancestors) or id = #{orgId}
</select>
<select id="checkDeptNameUnique" resultMap="FrontDeptResult">
<include refid="selectFrontDeptVo"/>
where dept_name=#{deptName} and parent_id = #{parentId}
</select>
<select id="selectDeptTreeByOrgId" resultMap="FrontDeptResult">
SELECT * FROM front_dept WHERE id=#{orgId}
UNION ALL
SELECT * FROM front_dept WHERE id IN(SELECT dept_id FROM org_dept WHERE org_id=#{orgId})
</select>
<select id="likeByName" resultMap="FrontDeptResult">
<include refid="selectFrontDeptVo"/>
where dept_name like CONCAT('%',#{name},'%')
</select>
<select id="getParentOrgInfoByOrgId" parameterType="long" resultMap="FrontDeptResult">
SELECT
f.id,
f.parent_id,
f.dept_name,
d.dept_name AS parent_name
FROM
front_dept f
LEFT JOIN front_dept d ON f.parent_id = d.id
<where>
f.id = #{orgId}
</where>
</select>
<select id="getparentId" parameterType="long" resultMap="FrontDeptResult">
<include refid="selectFrontDeptVo"/>
where parent_id =#{id}
</select>
</mapper>