DictionaryDataMapper.xml
5.79 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
<?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.glsx.manager.mapper.DictionaryDataMapper">
<resultMap id="baseResultMap" type="com.glsx.manager.pojo.dictionary.DictionaryData">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="dict_type" jdbcType="VARCHAR" property="dictType" />
<result column="data_value" jdbcType="VARCHAR" property="dataValue" />
<result column="data_key" jdbcType="VARCHAR" property="dataKey" />
<result column="data_status" jdbcType="INTEGER" property="dataStatus" />
<result column="sort" jdbcType="INTEGER" property="sort" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_by" jdbcType="VARCHAR" property="updateBy" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap>
<sql id="base_Column">
id, dict_type, data_value, data_key, data_status, sort, remark, create_by, create_time, update_by, update_time
</sql>
<select id="get" parameterType="java.lang.Integer" resultMap="baseResultMap">
select
<include refid="base_Column" />
from sys_dict_data
<where>
<if test="id != null">
id = #{id,jdbcType=INTEGER}
</if>
<if test="dataKey !=null and dataKey != ''">
and data_key = #{dataKey}
</if>
<if test="dictType != null and dictType != ''">
and dict_type = #{dictType}
</if>
</where>
</select>
<select id="list" parameterType="com.glsx.manager.pojo.dictionary.DictionaryData" resultMap="baseResultMap">
<if test="dataValue != null and dataValue != ''">
<bind name="pattern" value="'%' + dataValue + '%'" />
</if>
select
sdd.id, sdd.dict_type, sdd.data_value, sdd.data_key, sdd.data_status,
sdd.sort, sdd.remark, sdd.create_by, sdd.create_time, sdd.update_by,
sdd.update_time
from sys_dict_data sdd
left join sys_dict_type sdt on sdd.dict_type = sdt.dict_type
<where>
sdd.data_status != 3
<if test="name != null">
and sdt.name = #{name}
</if>
<if test="dictType != null">
and sdd.dict_type = #{dictType}
</if>
<if test="dataValue != null and dataValue != ''">
and sdd.data_value like #{pattern}
</if>
<if test="dataStatus != null">
and sdd.data_status = #{dataStatus}
</if>
<if test="beginDate != null and beginDate!= ''">
and DATE_FORMAT(sdd.create_time, '%Y-%m-%d') >= #{beginDate}
</if>
<if test="endDate != null and endDate != ''">
and DATE_FORMAT(sdd.create_time, '%Y-%m-%d') <= #{endDate}
</if>
order by sdd.sort asc, sdd.create_time asc
</where>
</select>
<insert id="save" parameterType="com.glsx.manager.pojo.dictionary.DictionaryData" useGeneratedKeys="true">
insert into sys_dict_data
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="dictType != null">
dict_type,
</if>
<if test="dataValue != null and dataValue != ''">
data_value,
</if>
<if test="dataKey != null and dataKey != ''">
data_key,
</if>
<if test="dataStatus != null">
data_status,
</if>
<if test="sort != null">
sort,
</if>
<if test="remark != null">
remark,
</if>
<if test="createBy != null">
create_by,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateBy != null">
update_by,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="dictType != null and dictType != ''">
#{dictType},
</if>
<if test="dataValue != null and dataValue!= ''">
#{dataValue},
</if>
<if test="dataKey != null and dataKey != ''">
#{dataKey},
</if>
<if test="dataStatus != null">
#{dataStatus},
</if>
<if test="sort != null">
#{sort},
</if>
<if test="remark != null">
#{remark,jdbcType=VARCHAR},
</if>
<if test="createBy != null">
#{createBy,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateBy != null">
#{updateBy,jdbcType=VARCHAR},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="update" parameterType="com.glsx.manager.pojo.dictionary.DictionaryData">
update sys_dict_data
set
data_key = #{dataKey},
data_value = #{dataValue,jdbcType=VARCHAR},
data_status = #{dataStatus,jdbcType=TINYINT},
sort = #{sort},
remark = #{remark,jdbcType=VARCHAR},
update_by = #{updateBy,jdbcType=VARCHAR},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
<delete id="delete" parameterType="com.glsx.manager.pojo.dictionary.DictionaryData">
update sys_dict_data
set data_status = 3,
update_by = #{updateBy},
update_time = #{updateTime}
where id = #{id,jdbcType=INTEGER}
</delete>
<delete id="deleteByDictType" parameterType="com.glsx.manager.pojo.dictionary.DictionaryData">
update sys_dict_data
set data_status = 3,
update_by = #{updateBy},
update_time = #{updateTime}
where dict_type = #{dictType}
</delete>
</mapper>