SysDictMapper.xml
11.5 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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
<?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.pashanhoo.dictionary.dao.SysDictMapper">
<resultMap id="BaseResultMap" type="com.pashanhoo.dictionary.model.dto.SysDict">
<!--@mbg.generated-->
<!--@Table SYS_DICT-->
<id column="DICTID" jdbcType="VARCHAR" property="dictId"/>
<result column="PARENTID" jdbcType="VARCHAR" property="parentId"/>
<result column="DCODE" jdbcType="VARCHAR" property="dcode"/>
<result column="DNAME" jdbcType="VARCHAR" property="dname"/>
<result column="SORT" jdbcType="DECIMAL" property="sort"/>
<result column="ISTREE" jdbcType="CHAR" property="isTree"/>
<result column="TYPEID" jdbcType="VARCHAR" property="typeId"/>
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
DICTID, PARENTID, DCODE, DNAME, SORT, ISTREE, TYPEID
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
<!--@mbg.generated-->
select
<include refid="Base_Column_List"/>
from SYS_DICT
where DICTID = #{dictid,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
<!--@mbg.generated-->
delete
from SYS_DICT
where DICTID = #{dictid,jdbcType=VARCHAR}
</delete>
<insert id="insert" parameterType="com.pashanhoo.dictionary.model.dto.SysDict">
<!--@mbg.generated-->
insert into SYS_DICT (DICTID, PARENTID, DCODE,
DNAME, SORT, ISTREE, TYPEID)
values (#{dictId,jdbcType=VARCHAR}, #{parentId,jdbcType=VARCHAR}, #{dcode,jdbcType=VARCHAR},
#{dname,jdbcType=VARCHAR}, #{sort,jdbcType=DECIMAL}, #{isTree,jdbcType=CHAR},
#{typeId,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.pashanhoo.dictionary.model.dto.SysDict">
<!--@mbg.generated-->
insert into SYS_DICT
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="dictId != null">
DICTID,
</if>
<if test="parentId != null">
PARENTID,
</if>
<if test="dcode != null">
DCODE,
</if>
<if test="dname != null">
DNAME,
</if>
<if test="sort != null">
SORT,
</if>
<if test="isTree != null">
ISTREE,
</if>
<if test="typeId != null">
TYPEID,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="dictId != null">
#{dictId,jdbcType=VARCHAR},
</if>
<if test="parentId != null">
#{parentId,jdbcType=VARCHAR},
</if>
<if test="dcode != null">
#{dcode,jdbcType=VARCHAR},
</if>
<if test="dname != null">
#{dname,jdbcType=VARCHAR},
</if>
<if test="sort != null">
#{sort,jdbcType=DECIMAL},
</if>
<if test="isTree != null">
#{isTree,jdbcType=CHAR},
</if>
<if test="typeId != null">
#{typeId,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.pashanhoo.dictionary.model.dto.SysDict">
<!--@mbg.generated-->
update SYS_DICT
<set>
<if test="parentId != null">
PARENTID = #{parentId,jdbcType=VARCHAR},
</if>
<if test="dcode != null">
DCODE = #{dcode,jdbcType=VARCHAR},
</if>
<if test="dname != null">
DNAME = #{dname,jdbcType=VARCHAR},
</if>
<if test="sort != null">
SORT = #{sort,jdbcType=DECIMAL},
</if>
<if test="isTree != null">
ISTREE = #{isTree,jdbcType=CHAR},
</if>
<if test="typeId != null">
TYPEID = #{typeId,jdbcType=VARCHAR},
</if>
</set>
where DICTID = #{dictId,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.pashanhoo.dictionary.model.dto.SysDict">
<!--@mbg.generated-->
update SYS_DICT
set PARENTID = #{parentId,jdbcType=VARCHAR},
DCODE = #{dcode,jdbcType=VARCHAR},
DNAME = #{dname,jdbcType=VARCHAR},
SORT = #{sort,jdbcType=DECIMAL},
ISTREE = #{isTree,jdbcType=CHAR},
TYPEID = #{typeId,jdbcType=VARCHAR}
where DICTID = #{dictId,jdbcType=VARCHAR}
</update>
<update id="updateBatch" parameterType="java.util.List">
<!--@mbg.generated-->
update SYS_DICT
<trim prefix="set" suffixOverrides=",">
<trim prefix="PARENTID = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when DICTID = #{item.dictId,jdbcType=VARCHAR} then #{item.parentId,jdbcType=VARCHAR}
</foreach>
</trim>
<trim prefix="DCODE = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when DICTID = #{item.dictId,jdbcType=VARCHAR} then #{item.dcode,jdbcType=VARCHAR}
</foreach>
</trim>
<trim prefix="DNAME = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when DICTID = #{item.dictId,jdbcType=VARCHAR} then #{item.dname,jdbcType=VARCHAR}
</foreach>
</trim>
<trim prefix="SORT = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when DICTID = #{item.dictId,jdbcType=VARCHAR} then #{item.sort,jdbcType=DECIMAL}
</foreach>
</trim>
<trim prefix="ISTREE = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when DICTID = #{item.dictId,jdbcType=VARCHAR} then #{item.isTree,jdbcType=CHAR}
</foreach>
</trim>
<trim prefix="TYPEID = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when DICTID = #{item.dictId,jdbcType=VARCHAR} then #{item.typeId,jdbcType=VARCHAR}
</foreach>
</trim>
</trim>
where DICTID in
<foreach close=")" collection="list" item="item" open="(" separator=", ">
#{item.dictId,jdbcType=VARCHAR}
</foreach>
</update>
<update id="updateBatchSelective" parameterType="java.util.List">
<!--@mbg.generated-->
update SYS_DICT
<trim prefix="set" suffixOverrides=",">
<trim prefix="PARENTID = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.parentId != null">
when DICTID = #{item.dictId,jdbcType=VARCHAR} then #{item.parentId,jdbcType=VARCHAR}
</if>
</foreach>
</trim>
<trim prefix="DCODE = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.dcode != null">
when DICTID = #{item.dictId,jdbcType=VARCHAR} then #{item.dcode,jdbcType=VARCHAR}
</if>
</foreach>
</trim>
<trim prefix="DNAME = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.dname != null">
when DICTID = #{item.dictId,jdbcType=VARCHAR} then #{item.dname,jdbcType=VARCHAR}
</if>
</foreach>
</trim>
<trim prefix="SORT = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.sort != null">
when DICTID = #{item.dictId,jdbcType=VARCHAR} then #{item.sort,jdbcType=DECIMAL}
</if>
</foreach>
</trim>
<trim prefix="ISTREE = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.isTree != null">
when DICTID = #{item.dictId,jdbcType=VARCHAR} then #{item.isTree,jdbcType=CHAR}
</if>
</foreach>
</trim>
<trim prefix="TYPEID = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.typeId != null">
when DICTID = #{item.dictId,jdbcType=VARCHAR} then #{item.typeId,jdbcType=VARCHAR}
</if>
</foreach>
</trim>
</trim>
where DICTID in
<foreach close=")" collection="list" item="item" open="(" separator=", ">
#{item.dictId,jdbcType=VARCHAR}
</foreach>
</update>
<insert id="batchInsert" parameterType="map">
<!--@mbg.generated-->
insert into SYS_DICT
(DICTID, PARENTID, DCODE, DNAME, SORT, ISTREE, TYPEID)
<foreach collection="list" item="item" index="index" separator="union all">
(select #{item.dictId,jdbcType=VARCHAR},
#{item.parentId,jdbcType=VARCHAR},
#{item.dcode,jdbcType=VARCHAR},
#{item.dname,jdbcType=VARCHAR},
#{item.sort,jdbcType=DECIMAL},
#{item.isTree,jdbcType=CHAR},
#{item.typeId,jdbcType=VARCHAR}
from dual)
</foreach>
</insert>
<select id="getSysDictParent" resultType="com.pashanhoo.dictionary.model.vo.GetSysDictParentVo">
select rownum,SD.*
from SYS_DICT SD
<where>
PARENTID is null
<if test="request.dcode != null and request.dcode != ''">
and DCODE like '%'||#{request.dcode,jdbcType=VARCHAR}||'%'
</if>
<if test="request.dname != null and request.dname != ''">
and DNAME like '%'||#{request.dname,jdbcType=VARCHAR}||'%'
</if>
</where>
</select>
<select id="getSysDictByTypeId" resultMap="BaseResultMap">
select *
from SYS_DICT
where TYPEID = #{typeId,jdbcType=VARCHAR}
and PARENTID is not null
</select>
<delete id="deleteListByPrimaryKey">
delete
from SYS_DICT
where
DICTID in
<foreach collection="dictWithoutParent" index="index" item="item" open="(" close=")" separator=",">
#{item.dictId,jdbcType=VARCHAR}
</foreach>
</delete>
<select id="selectAll" resultMap="BaseResultMap">
select *
from SYS_DICT
</select>
<select id="getSysDictChildByParentCode" resultType="com.pashanhoo.dictionary.model.dto.SysDict">
select dcode,dname
from sys_dict t where parentid =(select dictid from sys_dict where dcode = #{dcode,jdbcType=VARCHAR} )
CONNECT by PRIOR t.dictid = t.parentid
start with dcode = #{dcode,jdbcType=VARCHAR}
ORDER siblings BY t.sort
</select>
<delete id="deleteByTypeId">
delete from SYS_DICT where TYPEID = #{typeid,jdbcType=VARCHAR} and PARENTID is not null
</delete>
</mapper>