MsgChannelMapper.xml
11.5 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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
<?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="cn.runsa.portal.base.dao.MsgChannelMapper" >
<resultMap id="BaseResultMap" type="cn.runsa.portal.base.entity.MsgChannel" >
<id column="mcId" property="id" jdbcType="INTEGER" />
<result column="mcName" property="name" jdbcType="VARCHAR" />
<result column="mcDesc" property="desc" jdbcType="VARCHAR" />
<result column="mcType" property="type" jdbcType="SMALLINT" />
<result column="mcProvider" property="provider" jdbcType="VARCHAR" />
<result column="mcAccount" property="account" jdbcType="VARCHAR" />
<result column="mcPassword" property="password" jdbcType="VARCHAR" />
<result column="mcProtocol" property="protocol" jdbcType="SMALLINT" />
<result column="mcRemain" property="remain" jdbcType="INTEGER" />
<result column="mcPort" property="port" jdbcType="INTEGER" />
<result column="mtRemark" property="remark" jdbcType="VARCHAR" />
<result column="mtUpdater" property="updater" jdbcType="INTEGER" />
<result column="mtUpTime" property="upTime" jdbcType="TIMESTAMP" />
<result column="GZH_ID" property="gzhId" jdbcType="VARCHAR" />
<result column="bebLimit" property="bebLimit" jdbcType="BIT" />
<result column="plCreateId" property="createId" jdbcType="INTEGER" />
<association property="msgProvider" javaType="cn.runsa.portal.base.entity.MsgProvider">
<id column="mpId" property="id"/>
<result column="mpName" property="name"/>
<result column="mpUrl" property="url"/>
<result column="mpAuthType" property="authType"/>
<result column="mpServiceType" property="serviceType"/>
<result column="mpClassname" property="classname"/>
</association>
<association property="bizEntity" javaType="cn.runsa.portal.base.entity.BizEntity" column="bizEntity">
<id column="beId" property="id" jdbcType="INTEGER"/>
<result column="beName" property="name"/>
</association>
<association property="platform" javaType="cn.runsa.portal.base.entity.Platform" column="platform">
<id column="plId" property="id" jdbcType="INTEGER"/>
<result column="plName" property="name"/>
</association>
<collection property="bizSetOfBookList" ofType="cn.runsa.portal.base.entity.BizSetOfBook" column="bizSetOfBookList">
<id column="bebId" property="id" />
<result column="bebName" property="name"/>
</collection>
</resultMap>
<sql id="Base_Column_List" >
mc.mcId,mc.mcName,mc.mcDesc,mc.mcType,mc.mcProvider,mc.mcAccount,mc.mcPassword,mc.mcProtocol,mc.mcRemain,mc.mtRemark,mc.mtUpdater
</sql>
<select id="findById" parameterType="Integer" resultMap="BaseResultMap">
select *
from smMsgChannel mc
left join smMsgProvider mp on mc.mcProvider=mp.mpId
where mc.mcId=#{id}
</select>
<!-- 查询所有推送通道 -->
<select id="findList" resultMap="BaseResultMap" parameterType="cn.runsa.portal.base.entity.MsgChannel" >
select
<include refid="Base_Column_List" />
,be.beId,be.beName
from
smMsgChannel mc
LEFT JOIN mtBizMsgChannel bmc ON mc.mcId=bmc.mcId
LEFT JOIN mtBizEntity be ON bmc.beId= be.beId
WHERE 1=1
order by mcType
</select>
<!-- 查询短信推送通道 -->
<select id="findListMsg" resultMap="BaseResultMap" parameterType="cn.runsa.portal.base.entity.MsgChannel" >
select
<include refid="Base_Column_List" />
,be.beId,be.beName
from
smMsgChannel mc
LEFT JOIN mtBizMsgChannel bmc ON mc.mcId=bmc.mcId
LEFT JOIN mtBizEntity be ON bmc.beId= be.beId
WHERE mc.mcType=1 <!-- 1为短信通道 -->
<if test="plid != null" >
and plId = #{plid,jdbcType=INTEGER}
</if>
order by mcType
</select>
<!-- 删除推送通道 -->
<delete id="deteleById" parameterType="java.lang.Integer" >
delete from smMsgChannel
where mcId = #{id,jdbcType=INTEGER}
</delete>
<!-- 编辑推送通道 -->
<update id="update" parameterType="cn.runsa.portal.base.entity.MsgChannel" >
update smMsgChannel
<set >
<if test="name != null" >
mcName = #{name,jdbcType=VARCHAR},
</if>
<if test="desc != null" >
mcDesc = #{desc,jdbcType=VARCHAR},
</if>
<if test="type != null" >
mcType = #{type,jdbcType=SMALLINT},
</if>
<if test="provider != null" >
mcProvider = #{provider,jdbcType=VARCHAR},
</if>
<if test="gzhId != null" >
GZH_ID = #{gzhId,jdbcType=VARCHAR},
</if>
<if test="account != null" >
mcAccount = #{account,jdbcType=VARCHAR},
</if>
<if test="password != null" >
mcPassword = #{password,jdbcType=VARCHAR},
</if>
<if test="protocol != null" >
mcProtocol = #{protocol,jdbcType=SMALLINT},
</if>
<if test="remain != null" >
mcRemain = #{remain,jdbcType=INTEGER},
</if>
<if test="remark != null" >
mtRemark = #{remark,jdbcType=VARCHAR},
</if>
<if test="plid != null" >
plId = #{plid,jdbcType=INTEGER},
</if>
<if test="bizEntity.id != null" >
beId = #{bizEntity.id,jdbcType=INTEGER},
</if>
<if test="updater != null" >
mtUpdater = #{updater,jdbcType=INTEGER},
</if>
<if test="upTime != null" >
mtUpTime = #{upTime,jdbcType=TIMESTAMP},
</if>
<if test="bebLimit != null" >
bebLimit = #{bebLimit,jdbcType=BIT},
</if>
<if test="createId != null" >
plCreateId = #{createId,jdbcType=INTEGER},
</if>
</set>
where mcId = #{id,jdbcType=INTEGER}
</update>
<insert id="insert" useGeneratedKeys="true" keyProperty="id" parameterType="cn.runsa.portal.base.entity.MsgChannel" >
insert into smMsgChannel
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="name != null" >
mcName,
</if>
<if test="desc != null" >
mcDesc,
</if>
<if test="type != null" >
mcType,
</if>
<if test="provider != null" >
mcProvider,
</if>
<if test="gzhId != null" >
GZH_ID,
</if>
<if test="account != null" >
mcAccount,
</if>
<if test="password != null" >
mcPassword,
</if>
<if test="protocol != null" >
mcProtocol,
</if>
<!-- <if test="remain != null" >
mcRemain,
</if> -->
<if test="remark != null" >
mtRemark,
</if>
<if test="platform !=null">
<if test="platform.id != null" >
plId,
</if>
</if>
<if test="bizEntity.id != null" >
beId,
</if>
<if test="updater != null" >
mtUpdater,
</if>
<if test="upTime != null" >
mtUpTime,
</if>
<if test="bebLimit != null" >
bebLimit,
</if>
<if test="createId != null" >
plCreateId,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="name != null" >
#{name,jdbcType=VARCHAR},
</if>
<if test="desc != null" >
#{desc,jdbcType=VARCHAR},
</if>
<if test="type != null" >
#{type,jdbcType=SMALLINT},
</if>
<if test="provider != null" >
#{provider,jdbcType=VARCHAR},
</if>
<if test="gzhId != null" >
#{gzhId,jdbcType=VARCHAR},
</if>
<if test="account != null" >
#{account,jdbcType=VARCHAR},
</if>
<if test="password != null" >
#{password,jdbcType=VARCHAR},
</if>
<if test="protocol != null" >
#{protocol,jdbcType=SMALLINT},
</if>
<!-- <if test="remain != null" >
#{remain,jdbcType=INTEGER},
</if> -->
<if test="remark != null" >
#{remark,jdbcType=VARCHAR},
</if>
<if test="platform !=null">
<if test="platform.id != null" >
#{platform.id,jdbcType=INTEGER},
</if>
</if>
<if test="bizEntity.id != null" >
#{bizEntity.id,jdbcType=INTEGER},
</if>
<if test="updater != null" >
#{updater,jdbcType=INTEGER},
</if>
<if test="upTime != null" >
#{upTime,jdbcType=TIMESTAMP},
</if>
<if test="bebLimit != null" >
#{bebLimit,jdbcType=BIT},
</if>
<if test="createId != null" >
#{createId,jdbcType=INTEGER},
</if>
</trim>
</insert>
<!-- 推送通道名称校验 -->
<select id="existsByName" resultType="Boolean" parameterType="java.lang.String">
select count(*) from smMsgChannel where mcName = #{name,jdbcType=VARCHAR}
<if test="mcId != null" >
AND mcId != #{mcId,jdbcType=INTEGER}
</if>
</select>
<!--删除推送通道经营主体关系 -->
<delete id="deteleBizMsg" parameterType="java.lang.Integer" >
delete from mtBizMsgChannel
where mcId = #{id,jdbcType=INTEGER}
</delete>
<!--新增推送通道经营主体关系 -->
<insert id="insertBizMsg" parameterType="cn.runsa.portal.base.entity.MsgChannel" >
insert into mtBizMsgChannel (beid,mcid) values
(#{bizEntity.id,jdbcType=INTEGER},#{id,jdbcType=INTEGER})
</insert>
<!-- 删除经营主体与结算账套的关系 -->
<delete id="deleteMsgSetOfBook" parameterType="java.lang.Integer" >
delete from smMsgChannelSetOfBook
where mcId = #{id,jdbcType=INTEGER}
</delete>
<!--新增经营主体与结算账套的关系 -->
<insert id="insertbizSetOfBook" parameterType="cn.runsa.portal.base.entity.MsgChannel" >
insert into smMsgChannelSetOfBook (mcId,bebId) values
<foreach collection="bizSetOfBookList" item="item" index="index" separator="," >
(
#{id,jdbcType=INTEGER},
#{item.id,jdbcType=INTEGER}
)
</foreach>
</insert>
<select id="existsPlatMsg" resultType="java.lang.Integer" parameterType="cn.runsa.portal.base.entity.MsgChannel">
SELECT COUNT(*) FROM smPlatMsgChannel WHERE mcId = #{id,jdbcType=INTEGER}
</select>
<select id="existsCRM" resultType="java.lang.Integer" parameterType="cn.runsa.portal.base.entity.MsgChannel">
SELECT count(*) FROM crm_account_set_channel WHERE CHL_ID = #{id,jdbcType=INTEGER}
</select>
<select id="selectAllBybeId" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM smMsgChannel mc LEFT JOIN mtBizMsgChannel b ON mc.mcId = b.mcId
WHERE mc.mcType = #{type,jdbcType=INTEGER}
<if test="protocol != null" >
AND mc.mcProtocol = #{protocol,jdbcType=SMALLINT}
</if>
<if test="beId == 1" >
AND b.beId IN
(SELECT beId FROM mtBizEntity WHERE beOrgType = (SELECT b.vaiId FROM mtVariable a LEFT JOIN mtVarItem b ON a.vaId = b.vaId WHERE a.vaCode = 'OrgType' AND b.vaiCode ='HQ'))
</if>
<if test="beId != 1" >
AND b.beId IN (SELECT beParent FROM mtBizEntityInfo WHERE beId = #{beId,jdbcType=INTEGER})
</if>
</select>
<select id="selectAllByPlId" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM smMsgChannel mc LEFT JOIN mtBizMsgChannel b ON mc.mcId = b.mcId
WHERE mc.mcType = #{type,jdbcType=INTEGER}
<if test="protocol != null" >
AND mc.mcProtocol = #{protocol,jdbcType=SMALLINT}
</if>
<if test="plId == 1" >
AND b.beId IN
(SELECT beId FROM mtBizEntity WHERE beOrgType = (SELECT b.vaiId FROM mtVariable a LEFT JOIN mtVarItem b ON a.vaId = b.vaId WHERE a.vaCode = 'OrgType' AND b.vaiCode ='HQ'))
</if>
<if test="plId != 1" >
AND b.beId IN (SELECT beParent FROM mtBizEntityInfo WHERE beId = (SELECT beId FROM smPlatform WHERE plId = #{plId,jdbcType=INTEGER}))
</if>
</select>
</mapper>