DictDataMapper.xml
7.41 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
<?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.huaheng.pc.system.dict.mapper.DictDataMapper">
<resultMap type="com.huaheng.pc.system.dict.domain.DictData" id="DictDataResult">
<id property="id" column="id" />
<result property="dictSort" column="dictSort" />
<result property="dictLabel" column="dictLabel" />
<result property="dictValue" column="dictValue" />
<result property="dictType" column="dictType" />
<result property="cssClass" column="cssClass" />
<result property="listClass" column="listClass" />
<result property="isDefault" column="isDefault" />
<result property="enable" column="enable" />
<result property="createBy" column="createBy" />
<result property="createTime" column="createTime" />
<result property="updateBy" column="updateBy" />
<result property="updateTime" column="updateTime" />
</resultMap>
<sql id="selectDictDataVo">
select id, dictSort, dictLabel, dictValue, dictType, cssClass, listClass, isDefault, enable, createBy, createTime, remark from sys_dict_data
</sql>
<select id="selectDictDataList" resultMap="DictDataResult">
<include refid="selectDictDataVo"/>
<where>
<if test="warehouseCode != null">
AND warehouseCode = #{warehouseCode}
</if>
<if test="dictType != null and dictType != ''">
AND dictType = #{dictType}
</if>
<if test="dictValue != null and dictValue != ''">
AND dictValue = #{dictValue}
</if>
<if test="dictLabel != null and dictLabel != ''">
AND dictLabel like concat('%', #{dictLabel}, '%')
</if>
<if test="enable != null">
AND enable = #{enable}
</if>
<if test="deleted != null">
AND deleted = #{deleted}
</if>
</where>
</select>
<select id="selectDictDataByType" resultMap="DictDataResult">
<include refid="selectDictDataVo"/>
where warehouseCode = #{warehouseCode} AND dictType = #{dictType} AND enable=true order by dictSort asc
</select>
<select id="selectDictLabel" resultType="String">
select dictLabel from sys_dict_data
where warehouseCode = #{warehouseCode} AND dictType = #{dictType} and dictValue = #{dictValue} limit 1
</select>
<select id="selectDictDataById" resultMap="DictDataResult">
<include refid="selectDictDataVo"/>
where warehouseCode = #{warehouseCode} AND id = #{id}
</select>
<select id="countDictDataByType" resultType="Integer">
select count(1) from sys_dict_data where warehouseCode = #{warehouseCode} AND dictType=#{dictType}
</select>
<select id="checkConfig" resultType="java.lang.Integer">
select id from sys_dict_data
<where>
<if test="warehouseCode != null">
AND warehouseCode = #{warehouseCode}
</if>
<if test="dictType != null">
AND dictType = #{dictType}
</if>
<if test="dictValue != null">
AND dictValue = #{dictValue}
</if>
</where>
</select>
<delete id="deleteDictDataById">
delete from sys_dict_data where warehouseCode = #{warehouseCode} AND id = #{id}
</delete>
<delete id="deleteDictDataByIds">
delete from sys_dict_data where warehouseCode = #{warehouseCode} AND id in
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<update id="updateDictData">
update sys_dict_data
<set>
<if test="dictSort != null and dictSort != ''">dictSort = #{dictSort},</if>
<if test="dictLabel != null and dictLabel != ''">dictLabel = #{dictLabel},</if>
<if test="dictValue != null and dictValue != ''">dictValue = #{dictValue},</if>
<if test="dictType != null and dictType != ''">dictType = #{dictType},</if>
<if test="cssClass != null and cssClass != ''">cssClass = #{cssClass},</if>
<if test="listClass != null and listClass != ''">listClass = #{listClass},</if>
<if test="isDefault != null and isDefault != ''">isDefault = #{isDefault},</if>
<if test="enable != null">enable = #{enable},</if>
<if test="remark != null and remark != ''">remark = #{remark},</if>
<if test="updateBy != null and updateBy != ''">updateBy = #{updateBy},</if>
updateTime = sysdate()
</set>
where warehouseCode = #{warehouseCode} AND id = #{id}
</update>
<update id="updateDictDataType">
update sys_dict_data set dictType = #{newDictType} where dictType = #{oldDictType}
</update>
<insert id="insertDictData">
insert into sys_dict_data(
<if test="headerId !=null">headerId,</if>
<if test="warehouseCode != null">warehouseCode,</if>
<if test="dictSort != null">dictSort,</if>
<if test="dictLabel != null">dictLabel,</if>
<if test="dictValue != null">dictValue,</if>
<if test="dictType != null">dictType,</if>
<if test="cssClass != null ">cssClass,</if>
<if test="listClass != null">listClass,</if>
<if test="isDefault != null">isDefault,</if>
<if test="enable != null">enable,</if>
<if test="remark != null">remark,</if>
<if test="createBy != null">createBy,</if>
createTime
)values(
<if test="headerId !=null">#{headerId},</if>
<if test="warehouseCode != null">#{warehouseCode},</if>
<if test="dictSort != null">#{dictSort},</if>
<if test="dictLabel != null">#{dictLabel},</if>
<if test="dictValue != null">#{dictValue},</if>
<if test="dictType != null">#{dictType},</if>
<if test="cssClass != null">#{cssClass},</if>
<if test="listClass != null">#{listClass},</if>
<if test="isDefault != null">#{isDefault},</if>
<if test="enable != null">#{enable},</if>
<if test="remark != null">#{remark},</if>
<if test="createBy != null">#{createBy},</if>
sysdate()
)
</insert>
<delete id="deleteDictDataByWarehouseCode">
delete from sys_dict_data where warehouseCode = #{warehouseCode}
</delete>
<insert id="insertDictDatas">
insert into sys_dict_data(
headerId,
warehouseCode,
dictLabel,
dictValue,
dictType,
cssClass,
listClass,
remark,
createBy,
createTime
)values
<foreach collection="dictDatas" item="item" index="index" separator=",">
(
#{item.headerId},
#{item.warehouseCode},
#{item.dictLabel},
#{item.dictValue},
#{item.dictType},
#{item.cssClass},
#{item.listClass},
#{item.remark},
#{item.createBy},
sysdate()
)
</foreach>
</insert>
<select id="selectModel" resultType="com.huaheng.pc.system.dict.domain.DictData">
select * from sys_dict_data
<where>
<if test="warehouseCode != null">
AND warehouseCode = #{warehouseCode}
</if>
<if test="headerId != null">
AND headerId = #{headerId}
</if>
<if test="dictValue != null">
AND dictValue = #{dictValue}
</if>
<if test="dictLabel != null">
AND dictLabel = #{dictLabel}
</if>
<if test="dictType != null">
AND dictType = #{dictType}
</if>
<if test="remark != null">
AND remark = #{remark}
</if>
</where>
limit 1
</select>
<insert id="dictDateCopy">
insert into sys_dict_data(warehouseCode,dictSort,dictLabel,dictValue,dictType,cssClass,listClass,isDefault,enable,deleted,remark)
SELECT #{newCode},dictSort,dictLabel,dictValue,dictType,cssClass,listClass,isDefault,enable,deleted,remark from sys_dict_data
where warehouseCode = #{code}
</insert>
<update id="updateHeaderId">
update sys_dict_data d
inner join sys_dict_type t
on t.dictType=d.dictType and d.warehouseCode=t.warehouseCode and d.warehouseCode=#{code}
set d.headerId=t.id
</update>
</mapper>