yujian
2019-09-02 9eeda0d3049b71877c373c04d65533939b5582ef
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
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
<?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.yeshi.fanli.dao.mybatis.homemodule.SpecialMapper">
    <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.homemodule.Special">
        <id column="b_id" property="id" jdbcType="BIGINT" />
        <result column="b_name" property="name" jdbcType="VARCHAR" />
        <result column="b_card" property="card" jdbcType="VARCHAR" />
        <result column="b_card_id" property="cardId" jdbcType="BIGINT" />
        <result column="b_main_picture" property="picture" jdbcType="VARCHAR" />
        <result column="b_icon" property="icon" jdbcType="VARCHAR" />
        <result column="b_sub_picture" property="subPicture" jdbcType="VARCHAR" />
        <result column="b_params" property="params" jdbcType="VARCHAR" />
        <result column="b_jump_login" property="jumpLogin" jdbcType="VARCHAR" />
        <result column="b_orderby" property="orderby" jdbcType="INTEGER" />
        <result column="b_order_man" property="orderMan" jdbcType="INTEGER" />
        <result column="b_order_woman" property="orderWoman" jdbcType="INTEGER" />
        <result column="b_state" property="state" jdbcType="BIGINT" />
        <result column="b_sex" property="sex" jdbcType="INTEGER" />
        <result column="b_show_type" property="showType" jdbcType="VARCHAR" />
        <result column="b_remark" property="remark" jdbcType="VARCHAR" />
        <result column="b_createtime" property="createtime" jdbcType="TIMESTAMP" />
        <result column="b_updatetime" property="updatetime" jdbcType="TIMESTAMP" />
 
        <!-- 背景图片 -->
        <result column="cd_bottom_picture" property="bottomPicture"
            jdbcType="VARCHAR" />
 
        <association property="jumpDetail" column="b_jumpid"
            select="com.yeshi.fanli.dao.mybatis.common.JumpDetailV2Mapper.selectByPrimaryKey">
        </association>
 
    </resultMap>
    <sql id="Base_Column_List">b_id,b_name,b_card,b_card_id,b_main_picture,b_icon,b_sub_picture,b_jumpid,b_params,b_jump_login,b_orderby,b_order_man,b_order_woman,b_state,b_sex,b_show_type,b_remark,b_createtime,b_updatetime</sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_special where b_id = #{id,jdbcType=BIGINT}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
        yeshi_ec_special where b_id = #{id,jdbcType=BIGINT}</delete>
    <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.homemodule.Special"
        useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_special
        (b_id,b_name,b_card,b_card_id,b_main_picture,b_icon,b_sub_picture,b_jumpid,b_params,b_jump_login,b_orderby,b_order_man,b_order_woman,b_state,b_sex,b_show_type,b_remark,b_createtime,b_updatetime)
        values
        (#{id,jdbcType=BIGINT},#{name,jdbcType=VARCHAR},#{card,jdbcType=VARCHAR},#{cardId,jdbcType=BIGINT},#{picture,jdbcType=VARCHAR},#{icon,jdbcType=VARCHAR},#{subPicture,jdbcType=VARCHAR},#{jumpDetail.id,jdbcType=BIGINT},#{params,jdbcType=VARCHAR},#{jumpLogin,jdbcType=VARCHAR},#{orderby,jdbcType=INTEGER},#{orderMan,jdbcType=INTEGER},#{orderWoman,jdbcType=INTEGER},#{state,jdbcType=BIGINT},#{sex,jdbcType=INTEGER},#{showType,jdbcType=VARCHAR},#{remark,jdbcType=VARCHAR},#{createtime,jdbcType=TIMESTAMP},#{updatetime,jdbcType=TIMESTAMP})</insert>
    <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.homemodule.Special"
        useGeneratedKeys="true" keyProperty="id">
        insert into yeshi_ec_special
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">b_id,</if>
            <if test="name != null">b_name,</if>
            <if test="card != null">b_card,</if>
            <if test="cardId != null">b_card_id,</if>
            <if test="picture != null">b_main_picture,</if>
            <if test="icon != null">b_icon,</if>
            <if test="subPicture != null">b_sub_picture,</if>
            <if test="jumpDetail != null">b_jumpid,</if>
            <if test="params != null">b_params,</if>
            <if test="jumpLogin != null">b_jump_login,</if>
            <if test="orderby != null">b_orderby,</if>
            <if test="orderMan != null">b_order_man,</if>
            <if test="orderWoman != null">b_order_woman,</if>
            <if test="state != null">b_state,</if>
            <if test="sex != null">b_sex,</if>
            <if test="showType != null">b_show_type,</if>
            <if test="remark != null">b_remark,</if>
            <if test="createtime != null">b_createtime,</if>
            <if test="updatetime != null">b_updatetime,</if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=BIGINT},</if>
            <if test="name != null">#{name,jdbcType=VARCHAR},</if>
            <if test="card != null">#{card,jdbcType=VARCHAR},</if>
            <if test="cardId != null">#{cardId,jdbcType=BIGINT},</if>
            <if test="picture != null">#{picture,jdbcType=VARCHAR},</if>
            <if test="icon != null">#{icon,jdbcType=VARCHAR},</if>
            <if test="subPicture != null">#{subPicture,jdbcType=VARCHAR},</if>
            <if test="jumpDetail != null">#{jumpDetail.id,jdbcType=BIGINT},</if>
            <if test="params != null">#{params,jdbcType=VARCHAR},</if>
            <if test="jumpLogin != null">#{jumpLogin,jdbcType=VARCHAR},</if>
            <if test="orderby != null">#{orderby,jdbcType=INTEGER},</if>
            <if test="orderMan != null">#{orderMan,jdbcType=INTEGER},</if>
            <if test="orderWoman != null">#{orderWoman,jdbcType=INTEGER},</if>
            <if test="state != null">#{state,jdbcType=BIGINT},</if>
            <if test="sex != null">#{sex,jdbcType=INTEGER},</if>
            <if test="showType != null">#{showType,jdbcType=VARCHAR},</if>
            <if test="remark != null">#{remark,jdbcType=VARCHAR},</if>
            <if test="createtime != null">#{createtime,jdbcType=TIMESTAMP},</if>
            <if test="updatetime != null">#{updatetime,jdbcType=TIMESTAMP},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.homemodule.Special">update
        yeshi_ec_special set b_name = #{name,jdbcType=VARCHAR},b_card =
        #{card,jdbcType=VARCHAR},b_card_id =
        #{cardId,jdbcType=BIGINT},b_main_picture =
        #{picture,jdbcType=VARCHAR},b_icon =
        #{icon,jdbcType=VARCHAR},b_sub_picture =
        #{subPicture,jdbcType=VARCHAR},b_jumpid =
        #{jumpDetail.id,jdbcType=BIGINT},b_params =
        #{params,jdbcType=VARCHAR},b_jump_login =
        #{jumpLogin,jdbcType=VARCHAR},b_orderby =
        #{orderby,jdbcType=INTEGER},b_order_man =
        #{orderMan,jdbcType=INTEGER},b_order_woman =
        #{orderWoman,jdbcType=INTEGER},b_state =
        #{state,jdbcType=BIGINT},b_show_type =
        #{showType,jdbcType=VARCHAR},b_remark =
        #{remark,jdbcType=VARCHAR},b_createtime =
        #{createtime,jdbcType=TIMESTAMP},b_updatetime =
        #{updatetime,jdbcType=TIMESTAMP},b_sex=#{sex,jdbcType=INTEGER} where
        b_id = #{id,jdbcType=BIGINT}</update>
    <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.homemodule.Special">
        update yeshi_ec_special
        <set>
            <if test="name != null">b_name=#{name,jdbcType=VARCHAR},</if>
            <if test="card != null">b_card=#{card,jdbcType=VARCHAR},</if>
            <if test="cardId != null">b_card_id=#{cardId,jdbcType=BIGINT},</if>
            <if test="picture != null">b_main_picture=#{picture,jdbcType=VARCHAR},</if>
            <if test="icon != null">b_icon=#{icon,jdbcType=VARCHAR},</if>
            <if test="subPicture != null">b_sub_picture=#{subPicture,jdbcType=VARCHAR},</if>
            <if test="jumpDetail != null">b_jumpid=#{jumpDetail.id,jdbcType=BIGINT},</if>
            <if test="params != null">b_params=#{params,jdbcType=VARCHAR},</if>
            <if test="jumpLogin != null">b_jump_login=#{jumpLogin,jdbcType=VARCHAR},</if>
            <if test="orderby != null">b_orderby=#{orderby,jdbcType=INTEGER},</if>
            <if test="orderMan != null">b_order_man=#{orderMan,jdbcType=INTEGER},</if>
            <if test="orderWoman != null">b_order_woman=#{orderWoman,jdbcType=INTEGER},</if>
            <if test="state != null">b_state=#{state,jdbcType=BIGINT},</if>
            <if test="sex != null">b_sex=#{sex,jdbcType=INTEGER},</if>
            <if test="showType != null">b_show_type=#{showType,jdbcType=VARCHAR},</if>
            <if test="remark != null">b_remark=#{remark,jdbcType=VARCHAR},</if>
            <if test="createtime != null">b_createtime=#{createtime,jdbcType=TIMESTAMP},</if>
            <if test="updatetime != null">b_updatetime=#{updatetime,jdbcType=TIMESTAMP},</if>
        </set>
        where b_id = #{id,jdbcType=BIGINT}
    </update>
 
    <sql id="Sex_Screen">
        <!-- 通用版 -->
        <if test="sex == 0">
            AND (sp.`b_sex`= 120 OR sp.`b_sex`= 0 OR sp.`b_sex` = 10
            OR sp.`b_sex` =
            20)
            ORDER BY sp.`b_orderby`
        </if>
        <!-- 女版 -->
        <if test="sex == 1">
            AND (sp.`b_sex`= 120 OR sp.`b_sex`= 1 OR sp.`b_sex` = 10
            OR sp.`b_sex` =
            12)
            ORDER BY sp.`b_order_woman`
        </if>
        <!-- 男版 -->
        <if test="sex == 2">
            AND (sp.`b_sex`= 120 OR sp.`b_sex`= 2 OR sp.`b_sex` = 20
            OR sp.`b_sex` =
            12)
            ORDER BY sp.`b_order_man`
        </if>
    </sql>
 
 
    <delete id="deleteBatchByPrimaryKey" parameterType="java.util.List">
        delete from yeshi_ec_special WHERE b_id in
        <foreach collection="list" item="item" open="(" close=")"
            separator=",">#{item}</foreach>
    </delete>
 
    <delete id="deleteBatchByCardID" parameterType="java.util.List">
        delete from yeshi_ec_special WHERE b_card_id in
        <foreach collection="list" item="item" open="(" close=")"
            separator=",">#{item}</foreach>
    </delete>
 
    <select id="queryByListPrimaryKey" parameterType="java.util.List"
        resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List" />
        FROM yeshi_ec_special
        WHERE b_id in
        <foreach collection="list" item="item" open="(" close=")"
            separator=",">#{item}</foreach>
    </select>
 
    <select id="queryByListCardID" parameterType="java.util.List"
        resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List" />
        FROM yeshi_ec_special
        WHERE b_card_id in
        <foreach collection="list" item="item" open="(" close=")"
            separator=",">#{item}</foreach>
    </select>
 
    <select id="listQueryByCard" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List" />
        FROM `yeshi_ec_special` sp
        WHERE sp.`b_card_id` = #{cardId}
        <if test='key != null and key != ""'>
            AND sp.b_name like '%${key}%'
        </if>
        <include refid="Sex_Screen" />
        LIMIT ${start},${count}
    </select>
 
    <select id="countlistQueryByCard" resultType="java.lang.Long">
        SELECT IFNULL(count(b_id),0) FROM `yeshi_ec_special` sp
        WHERE
        sp.`b_card_id` = #{cardId}
        <if test='key != null and key != ""'>
            AND sp.b_name like '%${key}%'
        </if>
        <include refid="Sex_Screen" />
    </select>
 
    <select id="getDefaultMaxOrder" resultType="java.lang.Integer">
        SELECT
        IFNULL(MAX(pp.b_orderby),0) FROM yeshi_ec_special pp
        WHERE
        pp.`b_card_id` = #{cardId}
    </select>
 
    <select id="getManMaxOrder" resultType="java.lang.Integer">
        SELECT
        IFNULL(MAX(pp.b_order_man),0) FROM yeshi_ec_special pp
        WHERE
        pp.`b_card_id` = #{cardId}
    </select>
 
 
    <select id="getWomanMaxOrder" resultType="java.lang.Integer">
        SELECT
        IFNULL(MAX(pp.b_order_woman),0) FROM yeshi_ec_special pp
        WHERE
        pp.`b_card_id` = #{cardId}
    </select>
 
 
    <select id="getOrderByCardID" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List" />
        FROM yeshi_ec_special sp
        WHERE sp.b_card_id = #{cardId}
        <!-- 通用版 -->
        <if test="sex == 0 or sex == 120">
            AND (sp.`b_sex`= 120 OR sp.`b_sex`= 0 OR sp.`b_sex` = 10 OR
            sp.`b_sex` = 20)
            <if test="type == -1">
                <![CDATA[and sp.b_orderby < #{order}]]>
                order by sp.b_orderby desc
            </if>
            <if test="type == 1">
                <![CDATA[and sp.b_orderby > #{order} ]]>
                order by sp.b_orderby
            </if>
        </if>
        <!-- 女版 -->
        <if test="sex == 1">
            AND (sp.`b_sex`= 120 OR sp.`b_sex`= 1 OR sp.`b_sex` = 10 OR
            sp.`b_sex` = 12)
            <if test="type == -1">
                <![CDATA[and sp.b_order_woman < #{order}]]>
                order by sp.b_order_woman desc
            </if>
            <if test="type == 1">
                <![CDATA[and sp.b_order_woman > #{order} ]]>
                order by sp.b_order_woman
            </if>
        </if>
        <!-- 男版 -->
        <if test="sex == 2">
            AND (sp.`b_sex`= 120 OR sp.`b_sex`= 2 OR sp.`b_sex` = 20 OR
            sp.`b_sex` = 12)
            <if test="type == -1">
                <![CDATA[and sp.b_order_man < #{order}]]>
                order by sp.b_order_man desc
            </if>
            <if test="type == 1">
                <![CDATA[and sp.b_order_man > #{order} ]]>
                order by sp.b_order_man
            </if>
        </if>
        limit 1
    </select>
 
    <select id="listBySystemAndCard" resultMap="BaseResultMap">
        SELECT p.* FROM
        `yeshi_ec_special` p LEFT JOIN `yeshi_ec_special_card` c ON
        p.`b_card_id` = c.`cd_id`
        LEFT JOIN `yeshi_ec_super_special_card` s ON
        s.`sp_special_cid` = c.`cd_id`
        WHERE p.`b_state` = 0 AND c.`cd_state` =
        0
        AND c.`cd_card` = #{card} AND s.`sp_system_id` = #{systemId}
        ORDER BY
        p.`b_orderby`
    </select>
 
    <select id="listPageBySystemAndCard" resultMap="BaseResultMap">
        SELECT p.* FROM
        `yeshi_ec_special` p LEFT JOIN `yeshi_ec_special_card` c ON
        p.`b_card_id` = c.`cd_id`
        LEFT JOIN `yeshi_ec_super_special_card` s ON
        s.`sp_special_cid` = c.`cd_id`
        WHERE p.`b_state` = 0 AND c.`cd_state` =
        0 AND s.sp_id is not null
        AND c.`cd_card` = #{card} AND
        s.`sp_system_id` = #{systemId}
        ORDER BY
        p.`b_orderby`
        LIMIT
        ${start},${count}
    </select>
 
    <select id="listByPlaceKey" resultMap="BaseResultMap">
        SELECT sp.*,c.`cd_bottom_picture` FROM `yeshi_ec_special` sp
        RIGHT JOIN
        (SELECT c.* FROM yeshi_ec_special_card c
        LEFT JOIN
        `yeshi_ec_special_place` pc ON pc.`sp_id` = c.`cd_place_id`
        WHERE
        c.`cd_state` = 0
        AND IF(c.`cd_start_time` IS NULL,TRUE,
        c.`cd_start_time`<![CDATA[<=]]>NOW())
        AND IF(c.`cd_end_time` IS NULL,TRUE,c.`cd_end_time`<![CDATA[>=]]>NOW())
        AND pc.`sp_key` = #{placeKey}
        LIMIT 1)c ON sp.`b_card_id` = c.`cd_id`
        WHERE sp.`b_state` = 0
        <include refid="Sex_Screen" />
    </select>
</mapper>