ChannelMapper.xml
8.48 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
<?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.ChannelMapper" >
<resultMap id="BaseResultMap" type="cn.runsa.portal.base.entity.Channel" >
<id column="chId" property="id" jdbcType="INTEGER" />
<result column="chCode" property="code" jdbcType="VARCHAR" />
<result column="chName" property="name" jdbcType="VARCHAR" />
<result column="chDesc" property="desc" jdbcType="VARCHAR" />
<result column="ptValid" property="valid" jdbcType="SMALLINT" />
<result column="ptRemark1" property="remark1" jdbcType="VARCHAR" />
<result column="ptRemark2" property="remark2" jdbcType="VARCHAR" />
<result column="ptUpTime" property="uptime" jdbcType="TIMESTAMP" />
<result column="ptUpdater" property="updater" jdbcType="INTEGER" />
<result column="chLimit" property="limit" jdbcType="BIT"/>
<result column="brName" property="brName" jdbcType="VARCHAR" />
<result column="brIds" property="brIds" jdbcType="VARCHAR" />
<collection property="list" ofType="cn.runsa.portal.base.entity.Brand">
<id column="brId" property="id"/>
</collection>
</resultMap>
<sql id="Base_Column_List" >
chId, chCode, chName, chDesc, ptValid, ptRemark1, ptRemark2, ptUpTime, ptUpdater,chLimit
</sql>
<select id="findListByBeId" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM
mtChannel t1
WHERE
t1.chId NOT IN (
SELECT
t3.chId
FROM
mtBizChannel t3
LEFT JOIN mtBizEntity t4 ON t3.beId = t4.beId
WHERE
t4.beOrgType = 6
AND t4.ptValid = 1
)
AND t1.ptValid = 1;
</select>
<select id="findList" resultMap="BaseResultMap">
SELECT
t2.chId, t2.chCode, t2.chName, t2.chDesc, t2.ptValid, t2.ptRemark1, t2.ptRemark2, t2.ptUpTime, t2.ptUpdater, t2.chLimit
FROM
mtBizChannel t1
LEFT JOIN mtchannel t2 ON t2.chId = t1.chId
WHERE
t1.beId = #{id,jdbcType=INTEGER} and t1.ptValid=1
</select>
<select id="findChannelDetiles" parameterType="java.lang.Integer" resultMap="BaseResultMap" >
SELECT
t1.chId,
t1.chName,
t1.chDesc,
t1.ptValid,
GROUP_CONCAT(DISTINCT t3.brName) brName,
GROUP_CONCAT(DISTINCT t3.brId) brIds
FROM
mtChannel t1
LEFT JOIN mtChannelBrand t2 ON t2.chId = t1.chId
LEFT JOIN mtBrand t3 ON (t3.brId=t2.brId AND t3.ptValid=1 AND t1.chLimit=1) OR (1 = 1 AND t1.chLimit=0 AND t3.ptValid=1)
WHERE
t1.chId=#{chid,jdbcType=INTEGER}
</select>
<select id="findById" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from mtChannel
where chId = #{id,jdbcType=INTEGER}
</select>
<select id="existsChannel" parameterType="java.lang.Integer" resultType="java.lang.Integer">
select
COUNT(*)
from smUsPermission
where chId=#{chId}
</select>
<select id="existsName" resultType="java.lang.Integer">
select
COUNT(*)
from mtChannel
where chName = #{name,jdbcType=VARCHAR}
<if test="chId != null">
AND chId != #{chId,jdbcType=INTEGER}
</if>
</select>
<delete id="delete" parameterType="java.lang.Integer" >
delete from mtChannel where chId = #{id}
</delete>
<delete id="delChannelBrand" parameterType="java.lang.Integer" >
delete from mtChannelBrand where chId = #{id}
</delete>
<insert id="insert" useGeneratedKeys="true" keyProperty="id" parameterType="cn.runsa.portal.base.entity.Channel" >
insert into mtChannel (chCode, chName, chDesc,
ptValid, ptRemark1, ptRemark2,
ptUpTime, ptUpdater,chLimit)
values (#{code,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{desc,jdbcType=VARCHAR},
#{valid,jdbcType=SMALLINT}, #{remark1,jdbcType=VARCHAR}, #{remark2,jdbcType=VARCHAR},
#{uptime,jdbcType=TIMESTAMP}, #{updater,jdbcType=INTEGER},#{limit,jdbcType=BIT})
</insert>
<insert id="insertSelective" useGeneratedKeys="true" keyProperty="id" parameterType="cn.runsa.portal.base.entity.Channel" >
insert into mtChannel
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="code != null" >
chCode,
</if>
<if test="name != null" >
chName,
</if>
<if test="desc != null" >
chDesc,
</if>
<if test="valid != null" >
ptValid,
</if>
<if test="remark1 != null" >
ptRemark1,
</if>
<if test="remark2 != null" >
ptRemark2,
</if>
<if test="uptime != null" >
ptUpTime,
</if>
<if test="updater != null" >
ptUpdater,
</if >
<if test="limit != null">
chLimit
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="code != null" >
#{code,jdbcType=VARCHAR},
</if>
<if test="name != null" >
#{name,jdbcType=VARCHAR},
</if>
<if test="desc != null" >
#{desc,jdbcType=VARCHAR},
</if>
<if test="valid != null" >
#{valid,jdbcType=SMALLINT},
</if>
<if test="remark1 != null" >
#{remark1,jdbcType=VARCHAR},
</if>
<if test="remark2 != null" >
#{remark2,jdbcType=VARCHAR},
</if>
<if test="uptime != null" >
#{uptime,jdbcType=TIMESTAMP},
</if>
<if test="updater != null" >
#{updater,jdbcType=INTEGER},
</if>
<if test="limit != null">
#{limit,jdbcType=BIT}
</if>
</trim>
</insert>
<insert id="insertBrank" parameterType="cn.runsa.portal.base.entity.Channel">
insert into mtChannelBrand
(chId,brId)
values
<foreach collection="list" item="item" index="index" separator=",">
(#{id,jdbcType=BIGINT},#{item.id,jdbcType=INTEGER})
</foreach>
</insert>
<update id="updateSelective" parameterType="cn.runsa.portal.base.entity.Channel">
update mtChannel
<set >
<if test="code != null" >
chCode = #{code,jdbcType=VARCHAR},
</if>
<if test="name != null" >
chName = #{name,jdbcType=VARCHAR},
</if>
<if test="desc != null" >
chDesc = #{desc,jdbcType=VARCHAR},
</if>
<if test="valid != null" >
ptValid = #{valid,jdbcType=SMALLINT},
</if>
<if test="remark1 != null" >
ptRemark1 = #{remark1,jdbcType=VARCHAR},
</if>
<if test="remark2 != null" >
ptRemark2 = #{remark2,jdbcType=VARCHAR},
</if>
<if test="uptime != null" >
ptUpTime = #{uptime,jdbcType=TIMESTAMP},
</if>
<if test="updater != null" >
ptUpdater = #{updater,jdbcType=INTEGER},
</if>
<if test="limit != null">
chLimit = #{limit,jdbcType=BIT}
</if>
</set>
where chId = #{id,jdbcType=INTEGER}
</update>
<update id="update" parameterType="cn.runsa.portal.base.entity.Channel" >
update mtChannel
set chCode = #{code,jdbcType=VARCHAR},
chName = #{name,jdbcType=VARCHAR},
chDesc = #{desc,jdbcType=VARCHAR},
ptValid = #{valid,jdbcType=SMALLINT},
ptRemark1 = #{remark1,jdbcType=VARCHAR},
ptRemark2 = #{remark2,jdbcType=VARCHAR},
ptUpTime = #{uptime,jdbcType=TIMESTAMP},
ptUpdater = #{updater,jdbcType=INTEGER},
chLimit = #{limit,jdbcType=BIT}
where chId = #{id,jdbcType=INTEGER}
</update>
<select id="findChannel" resultMap="BaseResultMap" parameterType="cn.runsa.portal.base.entity.Channel" >
SELECT
ch.chId,
ch.chName
FROM
smUsers us
INNER JOIN smPlatform pl ON us.plId= pl.plId and pl.plId = #{plId,jdbcType=INTEGER}
INNER JOIN mtBizChannel bc ON pl.beId = bc.beId
INNER JOIN mtChannel ch ON bc.chId = ch.chId AND ch.ptValid = '1'
WHERE us.usId = #{usId,jdbcType=INTEGER}
AND NOT EXISTS (
SELECT
usp.chId
FROM
smUsPermission usp
WHERE
usp.chId = ch.chId
AND usp.usId = #{usId,jdbcType=INTEGER}
)
GROUP BY
ch.chId,
ch.chName
</select>
<select id="findChannelByOrId" resultMap="BaseResultMap" parameterType="java.lang.Integer">
select t1.chId,t1.chName from mtChannel t1
inner join mtorgchannel t2
on t1.chId = t2.chId and t2.orId = #{orId,jdbcType=INTEGER};
</select>
<select id="findChannelByOrIdAndUsId" resultMap="BaseResultMap">
select t1.chId,t1.chName from mtChannel t1
inner join mtorgchannel t2
on t1.chId = t2.chId and t2.orId = #{0}
where t1.chId in (select t3.chId from smUsPermission t3 where t3.usId = #{1});
</select>
<select id="existsMtBizChannel" parameterType="java.lang.Integer" resultType="java.lang.Integer">
select
COUNT(*)
from mtBizChannel
where chId=#{chId}
</select>
</mapper>