Blame view

src/main/resources/mybatis/system/DictDataMapper.xml 5.51 KB
1
2
3
4
<?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">
5
<mapper namespace="com.huaheng.pc.system.dict.mapper.DictDataMapper">
6
7
	<resultMap type="com.huaheng.pc.system.dict.domain.DictData" id="DictDataResult">
8
		<id     property="id"   column="id"   />
9
10
11
12
13
14
15
		<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"  />
16
		<result property="enable"     column="enable"      />
17
18
19
20
		<result property="createBy"   column="createBy"   />
		<result property="createTime" column="createTime" />
		<result property="updateBy"   column="updateBy"   />
		<result property="updateTime" column="updateTime" />
21
22
23
	</resultMap>

	<sql id="selectDictDataVo">
24
        select id, dictSort, dictLabel, dictValue, dictType, cssClass, listClass, isDefault, enable, createBy, createTime, remark from sys_dict_data
25
26
    </sql>
27
	<select id="selectDictDataList" resultMap="DictDataResult">
28
29
	    <include refid="selectDictDataVo"/>
		<where>
30
31
32
            <if test="warehouseId != null">
                AND warehouseId = #{warehouseId}
            </if>
33
		    <if test="dictType != null and dictType != ''">
34
				AND dictType = #{dictType}
35
			</if>
36
			<if test="dictLabel != null and dictLabel != ''">
37
				AND dictLabel like concat('%', #{dictLabel}, '%')
38
			</if>
39
40
			<if test="enable != null">
				AND enable = #{enable}
41
42
43
44
			</if>
		</where>
	</select>
45
	<select id="selectDictDataByType" resultMap="DictDataResult">
46
		<include refid="selectDictDataVo"/>
47
		where warehouseId = #{warehouseId} AND dictType = #{dictType} AND enable=true  order by dictSort asc
48
49
50
	</select>

	<select id="selectDictLabel" resultType="String">
51
		select dictLabel from sys_dict_data
52
		where warehouseId = #{warehouseId} AND dictType = #{dictType} and dictValue = #{dictValue}
53
54
	</select>
55
	<select id="selectDictDataById" resultMap="DictDataResult">
56
		<include refid="selectDictDataVo"/>
57
		where warehouseId = #{warehouseId} AND id = #{id}
58
59
60
	</select>

	<select id="countDictDataByType" resultType="Integer">
61
	    select count(1) from sys_dict_data where warehouseId = #{warehouseId} AND dictType=#{dictType}
62
	</select>
63
64
    <select id="checkConfig" resultType="java.lang.Integer">
65
66
67
68
69
70
71
72
73
74
75
		select id from sys_dict_data
		<where>
			<if test="warehouseId != null">
				AND warehouseId = #{warehouseId}
			</if>
			<if test="dictType != null">
				AND dictType = #{dictType}
			</if>
			<if test="dictValue != null">
				AND dictValue = #{dictValue}
			</if>
76
		</where>
77
78
79
	</select>

    <delete id="deleteDictDataById">
80
 		delete from sys_dict_data where warehouseId = #{warehouseId} AND id = #{id}
81
82
 	</delete>
83
84
 	<delete id="deleteDictDataByIds">
 		delete from sys_dict_data where warehouseId = #{warehouseId} AND id in
85
86
 		<foreach collection="array" item="id" open="(" separator="," close=")">
 			#{id}
87
88
89
        </foreach> 
 	</delete>
90
	<update id="updateDictData">
91
92
 		update sys_dict_data
 		<set>
93
94
95
96
97
98
99
 			<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>
100
 			<if test="enable != null">enable = #{enable},</if>
101
 			<if test="remark != null and remark != ''">remark = #{remark},</if>
102
103
 			<if test="updateBy != null and updateBy != ''">updateBy = #{updateBy},</if>
 			updateTime = sysdate()
104
 		</set>
105
 		where warehouseId = #{warehouseId} AND id = #{id}
106
107
	</update>
108
	<update id="updateDictDataType">
109
 		update sys_dict_data set dictType = #{newDictType} where dictType = #{oldDictType}
110
111
	</update>
112
 	<insert id="insertDictData">
113
 		insert into sys_dict_data(
114
115
116
117
118
119
120
121
122
            <if test="warehouseId != null">warehouseId,</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>
123
 			<if test="enable != null">enable,</if>
124
125
 			<if test="remark != null">remark,</if>
 			<if test="createBy != null">createBy,</if>
126
 			createTime
127
 		)values(
128
129
130
131
132
133
134
135
136
            <if test="warehouseId != null">#{warehouseId},</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>
137
 			<if test="enable != null">#{enable},</if>
138
139
 			<if test="remark != null">#{remark},</if>
 			<if test="createBy != null">#{createBy},</if>
140
141
142
143
144
 			sysdate()
 		)
	</insert>

</mapper>