WeEmpleCodeMapper.xml
9.52 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
<?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.linkwechat.wecom.mapper.WeEmpleCodeMapper">
<resultMap type="WeEmpleCode" id="WeEmpleCodeResult">
<result property="id" column="id"/>
<result property="codeType" column="code_type"/>
<result property="isJoinConfirmFriends" column="is_join_confirm_friends"/>
<result property="activityScene" column="activity_scene"/>
<result property="welcomeMsg" column="welcome_msg"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="delFlag" column="del_flag"/>
<result property="configId" column="config_id"/>
<result property="qrCode" column="qr_code"/>
<result property="mediaId" column="media_id"/>
<collection property="weEmpleCodeUseScops" ofType="com.linkwechat.wecom.domain.WeEmpleCodeUseScop">
<result property="businessId" column="business_id"/>
<result property="businessName" column="business_name"/>
<result property="mobile" column="mobile"/>
</collection>
<collection property="weEmpleCodeTags" ofType="com.linkwechat.wecom.domain.WeEmpleCodeTag">
<result property="tagId" column="tag_id"/>
<result property="tagName" column="tag_name"/>
</collection>
</resultMap>
<sql id="selectWeEmpleCodeVo">
select id, code_type, is_join_confirm_friends, activity_scene, welcome_msg, create_by, create_time, del_flag, config_id,qr_code from we_emple_code
</sql>
<sql id="getQrcodeByUserIdVo">
select
wec.id,
wec.code_type,
wec.is_join_confirm_friends,
wec.activity_scene,
wec.welcome_msg,
wec.create_by,
wec.create_time,
wec.del_flag,
wec.config_id,
wec.qr_code
from we_emple_code wec
left join we_emple_code_use_scop wecus on wec.id = wecus.emple_code_id
and wecus.business_id_type = 2
and wecus.del_flag = 0
</sql>
<sql id="selectWeEmpleCodeLsit">
select
wecode.id,
wecode.code_type,
wecode.media_id,
wecode.is_join_confirm_friends,
wecode.activity_scene,
wecode.welcome_msg,
wecode.create_by,
wecode.create_time,
wecode.del_flag,
wecode.config_id,
wecode.qr_code,
wecusn.business_id,
wecusn.business_name,
wecusn.mobile,
wect.tag_id,
wect.tag_name
from
we_emple_code wecode
left join (
SELECT
wecus.emple_code_id, wecus.business_id, wecus.business_name,wu.mobile
FROM
we_emple_code_use_scop wecus
LEFT JOIN we_user wu ON
wu.user_id = wecus.business_id
WHERE
wecus.del_flag = 0
) as wecusn on
wecode.id = wecusn.emple_code_id
left join we_emple_code_tag wect on
wecode.id = wect.emple_code_id
where 1=1 and wecode.del_flag = 0
</sql>
<select id="selectWeEmpleCodeList" parameterType="WeEmpleCode" resultMap="WeEmpleCodeResult">
<include refid="selectWeEmpleCodeLsit"/>
<if test="codeType != null ">and wecode.code_type = #{codeType}</if>
<if test="isJoinConfirmFriends != null ">and wecode.is_join_confirm_friends = #{isJoinConfirmFriends}</if>
<if test="activityScene != null and activityScene != ''">
and wecode.activity_scene like concat('%', #{activityScene}, '%')
</if>
<if test="welcomeMsg != null ">and wecode.welcome_msg = #{welcomeMsg}</if>
<if test="createBy != null and createBy !=''">
AND wecode.create_by like concat('%', #{createBy}, '%')
</if>
<if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
AND date_format(wecode.create_time,'%y%m%d') >= date_format(#{beginTime},'%y%m%d')
</if>
<if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
AND date_format(wecode.create_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d')
</if>
<if test="mobile != null and mobile !=''">
AND wecusn.mobile like concat('%', #{mobile}, '%')
</if>
<if test="useUserName != null and useUserName !=''">
AND wecusn.business_name like concat('%', #{useUserName}, '%')
</if>
</select>
<select id="selectWeEmpleCodeById" parameterType="Long" resultMap="WeEmpleCodeResult">
<include refid="selectWeEmpleCodeLsit"/>
<if test="id != null and id !=''">
and wecode.id = #{id}
</if>
</select>
<select id="selectWeEmpleCodeByIds" parameterType="java.util.ArrayList" resultMap="WeEmpleCodeResult">
<include refid="selectWeEmpleCodeLsit"/>
<if test="ids != null and ids.size > 0">
and wecode.id in
<foreach collection="ids" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
</select>
<insert id="insertWeEmpleCode" parameterType="WeEmpleCode">
insert into we_emple_code
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="codeType != null">code_type,</if>
<if test="isJoinConfirmFriends != null">is_join_confirm_friends,</if>
<if test="activityScene != null">activity_scene,</if>
<if test="welcomeMsg != null">welcome_msg,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="delFlag != null">del_flag,</if>
<if test="configId != null">config_id,</if>
<if test="qrCode != null">qr_code,</if>
<if test="mediaId != null">media_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="codeType != null">#{codeType},</if>
<if test="isJoinConfirmFriends != null">#{isJoinConfirmFriends},</if>
<if test="activityScene != null">#{activityScene},</if>
<if test="welcomeMsg != null">#{welcomeMsg},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="delFlag != null">#{delFlag},</if>
<if test="configId != null">#{configId},</if>
<if test="qrCode != null">#{qrCode},</if>
<if test="mediaId != null">#{mediaId},</if>
</trim>
</insert>
<update id="updateWeEmpleCode" parameterType="WeEmpleCode">
update we_emple_code
<trim prefix="SET" suffixOverrides=",">
<if test="codeType != null">code_type = #{codeType},</if>
<if test="isJoinConfirmFriends != null">is_join_confirm_friends = #{isJoinConfirmFriends},</if>
<if test="activityScene != null">activity_scene = #{activityScene},</if>
<if test="welcomeMsg != null">welcome_msg = #{welcomeMsg},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="configId != null">config_id = #{configId},</if>
<if test="qrCode != null">qr_code = #{qrCode},</if>
<if test="mediaId != null">media_id = #{mediaId},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteWeEmpleCodeById" parameterType="Long">
delete from we_emple_code where id = #{id}
</delete>
<delete id="deleteWeEmpleCodeByIds" parameterType="String">
delete from we_emple_code where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<update id="batchRemoveWeEmpleCodeIds">
update we_emple_code set
del_flag = 1
where id in
<foreach collection="ids" item="id" index="index"
separator="," open="(" close=")">
#{id}
</foreach>
</update>
<select id="selectWelcomeMsgByActivityScene" parameterType="String"
resultType="com.linkwechat.wecom.domain.dto.WeEmpleCodeDto">
select
wecode.id as emple_code_id,
wecode.welcome_msg ,
wm.category_id,
wm.material_url,
wm.content,
wm.material_name,
wm.digest,
wm.cover_url
from
we_emple_code wecode
left join we_emple_code_use_scop wecus on
wecode.id = wecus.emple_code_id
left join we_material wm on
wm .id = wecode.media_id
where
wecode.del_flag = 0
<if test="activityScene != null and activityScene != ''">
and wecode.activity_scene = #{activityScene}
</if>
<if test="userId != null and userId != ''">
and wecus.business_id = #{userId}
</if>
</select>
<select id="getQrcodeByUserId" parameterType="java.lang.String" resultType="com.linkwechat.wecom.domain.WeEmpleCode">
<include refid="getQrcodeByUserIdVo"/>
<where>
<if test="userId != null and userId != ''">
and wecus.business_id = #{userId}
</if>
</where>
</select>
</mapper>