admin
2020-07-03 651a15c78f668bef3859d9ed1bb7ad0b669d3600
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
<?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.SpecialCardMapper">
    <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.homemodule.SpecialCard">
        <id column="cd_id" property="id" jdbcType="BIGINT"/>
        <result column="cd_name" property="name" jdbcType="VARCHAR"/>
        <result column="cd_card" property="card" jdbcType="VARCHAR"/>
        <result column="cd_state" property="state" jdbcType="INTEGER"/>
        <result column="cd_place_id" property="placeId" jdbcType="BIGINT"/>
        <result column="cd_bottom_picture" property="bottomPicture" jdbcType="VARCHAR"/>
        <result column="cd_start_time" property="startTime" jdbcType="TIMESTAMP"/>
        <result column="cd_end_time" property="endTime" jdbcType="TIMESTAMP"/>
        <result column="cd_createtime" property="createtime" jdbcType="TIMESTAMP"/>
        <result column="cd_updatetime" property="updatetime" jdbcType="TIMESTAMP"/>
        <result column="cd_system" property="system" jdbcType="VARCHAR"/>
    </resultMap>
    <sql id="Base_Column_List">cd_id,cd_name,cd_card,cd_state,cd_place_id,cd_bottom_picture,cd_start_time,cd_end_time,cd_createtime,cd_updatetime,cd_system</sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
        <include refid="Base_Column_List"/>from yeshi_ec_special_card where cd_id = #{id,jdbcType=BIGINT}
    </select>
    <delete id="deleteByPrimaryKey"
            parameterType="java.lang.Long">delete from yeshi_ec_special_card where cd_id = #{id,jdbcType=BIGINT}</delete>
    <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.homemodule.SpecialCard" useGeneratedKeys="true"
            keyProperty="id">insert into yeshi_ec_special_card (cd_id,cd_name,cd_card,cd_state,cd_place_id,cd_bottom_picture,cd_start_time,cd_end_time,cd_createtime,cd_updatetime,cd_system) values (#{id,jdbcType=BIGINT},#{name,jdbcType=VARCHAR},#{card,jdbcType=VARCHAR},#{state,jdbcType=INTEGER},#{placeId,jdbcType=BIGINT},#{bottomPicture,jdbcType=VARCHAR},#{startTime,jdbcType=TIMESTAMP},#{endTime,jdbcType=TIMESTAMP},#{createtime,jdbcType=TIMESTAMP},#{updatetime,jdbcType=TIMESTAMP},#{system,jdbcType=VARCHAR})</insert>
    <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.homemodule.SpecialCard"
            useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_special_card
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">cd_id,</if>
            <if test="name != null">cd_name,</if>
            <if test="card != null">cd_card,</if>
            <if test="state != null">cd_state,</if>
            <if test="placeId != null">cd_place_id,</if>
            <if test="bottomPicture != null">cd_bottom_picture,</if>
            <if test="startTime != null">cd_start_time,</if>
            <if test="endTime != null">cd_end_time,</if>
            <if test="createtime != null">cd_createtime,</if>
            <if test="updatetime != null">cd_updatetime,</if>
            <if test="system != null">cd_system,</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="state != null">#{state,jdbcType=INTEGER},</if>
            <if test="placeId != null">#{placeId,jdbcType=BIGINT},</if>
            <if test="bottomPicture != null">#{bottomPicture,jdbcType=VARCHAR},</if>
            <if test="startTime != null">#{startTime,jdbcType=TIMESTAMP},</if>
            <if test="endTime != null">#{endTime,jdbcType=TIMESTAMP},</if>
            <if test="createtime != null">#{createtime,jdbcType=TIMESTAMP},</if>
            <if test="updatetime != null">#{updatetime,jdbcType=TIMESTAMP},</if>
            <if test="system != null">#{system,jdbcType=VARCHAR},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey"
            parameterType="com.yeshi.fanli.entity.bus.homemodule.SpecialCard">update yeshi_ec_special_card set cd_name = #{name,jdbcType=VARCHAR},cd_card = #{card,jdbcType=VARCHAR},cd_state = #{state,jdbcType=INTEGER},cd_place_id = #{placeId,jdbcType=BIGINT},cd_bottom_picture = #{bottomPicture,jdbcType=VARCHAR},cd_start_time = #{startTime,jdbcType=TIMESTAMP},cd_end_time = #{endTime,jdbcType=TIMESTAMP},cd_createtime = #{createtime,jdbcType=TIMESTAMP},cd_updatetime = #{updatetime,jdbcType=TIMESTAMP},cd_system = #{system,jdbcType=VARCHAR} where cd_id = #{id,jdbcType=BIGINT}</update>
    <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.homemodule.SpecialCard">update
        yeshi_ec_special_card
        <set>
            <if test="name != null">cd_name=#{name,jdbcType=VARCHAR},</if>
            <if test="card != null">cd_card=#{card,jdbcType=VARCHAR},</if>
            <if test="state != null">cd_state=#{state,jdbcType=INTEGER},</if>
            <if test="placeId != null">cd_place_id=#{placeId,jdbcType=BIGINT},</if>
            <if test="bottomPicture != null">cd_bottom_picture=#{bottomPicture,jdbcType=VARCHAR},</if>
            <if test="startTime != null">cd_start_time=#{startTime,jdbcType=TIMESTAMP},</if>
            <if test="endTime != null">cd_end_time=#{endTime,jdbcType=TIMESTAMP},</if>
            <if test="createtime != null">cd_createtime=#{createtime,jdbcType=TIMESTAMP},</if>
            <if test="updatetime != null">cd_updatetime=#{updatetime,jdbcType=TIMESTAMP},</if>
            <if test="system != null">cd_system=#{system,jdbcType=VARCHAR},</if>
        </set>
        where cd_id = #{id,jdbcType=BIGINT}
    </update>
 
    <select id="listQuery" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM yeshi_ec_special_card
        WHERE 1=1
        <if test='key != null and key != ""'>
            AND cd_name like '%${key}%'
        </if>
        <if test="listPid != null">
            AND cd_place_id in
            <foreach collection="listPid" item="item" open="(" close=")" separator=",">#{item}</foreach>
        </if>
        AND cd_system=#{system}
        ORDER BY cd_place_id,cd_state DESC
        LIMIT ${start},${count}
    </select>
 
    <select id="countlistQuery" resultType="java.lang.Long">
        SELECT IFNULL(count(cd_id),0) FROM yeshi_ec_special_card
        WHERE 1=1
        <if test='key != null and key != ""'>
            AND cd_name like '%${key}%'
        </if>
        <if test="listPid != null">
            AND cd_place_id in
            <foreach collection="listPid" item="item" open="(" close=")" separator=",">#{item}</foreach>
        </if>
 
        AND cd_system=#{system}
    </select>
 
    <delete id="deleteBatchByPrimaryKey" parameterType="java.util.List">
        delete from yeshi_ec_special_card WHERE cd_id in
        <foreach collection="list" item="item" open="(" close=")"
                 separator=",">#{item}
        </foreach>
    </delete>
 
    <select id="getbottomPicture" resultType="java.lang.String">
        SELECT c.`cd_bottom_picture` 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 pc.`sp_key` = #{placeKey}   AND cd_system=#{system}
             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())
        LIMIT 1;
   </select>
 
</mapper>