Blame view

src/main/resources/mybatis/system/DictDataMapper.xml 6.51 KB
tangying authored
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
<?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"/>
53
		where warehouseCode = #{warehouseCode} AND dictType = #{dictType} AND enable=true  order by dictSort asc
tangying authored
54
55
56
57
	</select>

	<select id="selectDictLabel" resultType="String">
		select dictLabel from sys_dict_data
58
		where warehouseCode = #{warehouseCode} AND dictType = #{dictType} and dictValue = #{dictValue}
tangying authored
59
60
61
62
	</select>

	<select id="selectDictDataById" resultMap="DictDataResult">
		<include refid="selectDictDataVo"/>
63
		where warehouseCode = #{warehouseCode} AND id = #{id}
tangying authored
64
65
66
	</select>

	<select id="countDictDataByType" resultType="Integer">
67
	    select count(1) from sys_dict_data where warehouseCode = #{warehouseCode} AND dictType=#{dictType}
tangying authored
68
69
70
71
72
	</select>

    <select id="checkConfig" resultType="java.lang.Integer">
		select id from sys_dict_data
		<where>
73
74
			<if test="warehouseCode != null">
				AND warehouseCode = #{warehouseCode}
tangying authored
75
76
77
78
79
80
81
82
83
84
85
			</if>
			<if test="dictType != null">
				AND dictType = #{dictType}
			</if>
			<if test="dictValue != null">
				AND dictValue = #{dictValue}
			</if>
		</where>
	</select>

    <delete id="deleteDictDataById">
86
 		delete from sys_dict_data where warehouseCode = #{warehouseCode} AND id = #{id}
tangying authored
87
88
89
 	</delete>

 	<delete id="deleteDictDataByIds">
90
 		delete from sys_dict_data where warehouseCode = #{warehouseCode} AND id in
tangying authored
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
 		<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>
111
 		where warehouseCode = #{warehouseCode} AND id = #{id}
tangying authored
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
	</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>
150
151
	<delete id="deleteDictDataByWarehouseCode">
 		delete from sys_dict_data where warehouseCode = #{warehouseCode}
tangying authored
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
 	</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 warehouseCode=#{warehouseCode} and  dictType=#{dictType} and dictValue=#{dictValue} limit 1
	</select>

</mapper>