yujian
2019-05-29 0588d6be74335f41c79a8d8e32dbd1c3d3e47fa3
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
<?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.lable.QualityFlashSaleMapper">
    <resultMap id="BaseResultMap"
        type="com.yeshi.fanli.entity.bus.lable.QualityFlashSale">
        <id column="fs_id" property="id" jdbcType="BIGINT" />
        <result column="fs_type" property="type" jdbcType="INTEGER" />
        <result column="fs_weight" property="weight" jdbcType="DOUBLE" />
        <result column="fs_createtime" property="createtime" jdbcType="TIMESTAMP" />
        <result column="fs_updatetime" property="updatetime" jdbcType="TIMESTAMP" />
        
        <association property="taoBaoGoodsBrief" column="fs_qfgoods_id" javaType="com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief">
            <id column="fs_qfgoods_id" property="id" jdbcType="BIGINT" />
        </association>
    </resultMap>
    
    <sql id="Base_Column_List">fs_id,fs_qfgoods_id,fs_type,fs_weight,fs_createtime,fs_updatetime
    </sql>
    
    <select id="selectByPrimaryKey" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_quality_flash_sale where fs_id = #{id,jdbcType=BIGINT}
    </select>
    
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
        yeshi_ec_quality_flash_sale where fs_id = #{id,jdbcType=BIGINT}
    </delete>
    
    <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.lable.QualityFlashSale"
        useGeneratedKeys="true" keyProperty="id">insert into
        yeshi_ec_quality_flash_sale
        (fs_id,fs_qfgoods_id,fs_type,fs_weight,fs_createtime,fs_updatetime) values
        (#{id,jdbcType=BIGINT},#{taoBaoGoodsBrief.id,jdbcType=BIGINT},#{type,jdbcType=INTEGER},#{weight,jdbcType=DOUBLE},#{createtime,jdbcType=TIMESTAMP},#{updatetime,jdbcType=TIMESTAMP})
    </insert>
    
    <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.lable.QualityFlashSale"
        useGeneratedKeys="true" keyProperty="id">
        insert into yeshi_ec_quality_flash_sale
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">fs_id,</if>
            <if test="taoBaoGoodsBrief != null">fs_qfgoods_id,</if>
            <if test="type != null">fs_type,</if>
            <if test="weight != null">fs_weight,</if>
            <if test="createtime != null">fs_createtime,</if>
            <if test="updatetime != null">fs_updatetime,</if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=BIGINT},</if>
            <if test="taoBaoGoodsBrief != null">#{taoBaoGoodsBrief.id,jdbcType=BIGINT},</if>
            <if test="type != null">#{type,jdbcType=INTEGER},</if>
            <if test="weight != null">#{weight,jdbcType=DOUBLE},</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.lable.QualityFlashSale">update
        yeshi_ec_quality_flash_sale set 
        fs_qfgoods_id =    #{taoBaoGoodsBrief.id,jdbcType=BIGINT},
        fs_type =    #{type,jdbcType=INTEGER},
        fs_weight =    #{weight,jdbcType=DOUBLE},
        fs_createtime =    #{createtime,jdbcType=TIMESTAMP},
        fs_updatetime =    #{updatetime,jdbcType=TIMESTAMP} where fs_id = #{id,jdbcType=BIGINT}
    </update>
    
    <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.lable.QualityFlashSale">
        update yeshi_ec_quality_flash_sale
        <set>
            <if test="taoBaoGoodsBrief != null">fs_qfgoods_id=#{taoBaoGoodsBrief.id,jdbcType=BIGINT},</if>
            <if test="type != null">fs_type=#{type,jdbcType=INTEGER},</if>
            <if test="weight != null">fs_weight=#{weight,jdbcType=DOUBLE},</if>
            <if test="createtime != null">fs_createtime=#{createtime,jdbcType=TIMESTAMP},</if>
            <if test="updatetime != null">fs_updatetime=#{updatetime,jdbcType=TIMESTAMP},</if>
        </set>
        where fs_id = #{id,jdbcType=BIGINT}
    </update>
 
    <insert id="insertBatch" parameterType="java.util.List">
        insert into yeshi_ec_quality_flash_sale
        (
        <include refid="Base_Column_List" />
        )
        values
        <foreach collection="list" item="item" separator=",">
            (
            #{item.id,jdbcType=BIGINT},
            #{item.taoBaoGoodsBrief.id,jdbcType=BIGINT},
            #{item.type,jdbcType=INTEGER},
            #{item.weight,jdbcType=DOUBLE},
            #{item.createtime,jdbcType=TIMESTAMP},
            #{item.updatetime,jdbcType=TIMESTAMP}
            )
        </foreach>
    </insert>
 
    <update id="updateBatchSelective" parameterType="java.util.List">
        update yeshi_ec_quality_flash_sale
        <trim prefix="set" suffixOverrides=",">
            <trim prefix="fs_weight =case" suffix="end,">
                <foreach collection="list" item="item" index="index">
                    <if test="item.weight !=null">
                        when fs_id=#{item.id} then #{item.weight}
                    </if>
                </foreach>
            </trim>
            <trim prefix="fs_type =case" suffix="end,">
                <foreach collection="list" item="item" index="index">
                    <if test="item.type !=null">
                        when fs_id=#{item.id} then #{item.type}
                    </if>
                </foreach>
            </trim>
            <trim prefix="fs_updatetime =case" suffix="end,">
                <foreach collection="list" item="item" index="index">
                    <if test="item.updatetime !=null">
                        when fs_id=#{item.id} then #{item.updatetime}
                    </if>
                </foreach>
            </trim>
        </trim>
        where fs_id in
        <foreach collection="list" index="index" item="item"
            separator="," open="(" close=")">
            #{item.id,jdbcType=BIGINT}
        </foreach>
    </update>
    
    <select id="listQueryByQualityID" resultMap="BaseResultMap">
          SELECT <include refid="Base_Column_List" /> FROM yeshi_ec_quality_flash_sale
        WHERE fs_qfgoods_id in
            <foreach collection="list" item="item" open="(" close=")"
                separator=",">#{item}</foreach>
      </select>
      
      <delete id="deleteByGoodsId" parameterType="java.lang.Long">
          delete from yeshi_ec_quality_flash_sale where fs_qfgoods_id = #{qid,jdbcType=BIGINT}
    </delete>
    
    <delete id="deleteBatchByQualityID"  parameterType="java.util.List">
        delete FROM yeshi_ec_quality_flash_sale WHERE fs_qfgoods_id in
        <foreach collection="list" item="item" open="(" close=")"
            separator=",">#{item}</foreach>
    </delete>
    
    <delete id="deleteBatchByPrimaryKey"  parameterType="java.util.List">
        delete FROM yeshi_ec_quality_flash_sale WHERE fs_id in
        <foreach collection="list" item="item" open="(" close=")"
            separator=",">#{item}</foreach>
    </delete>
    
   <select id="queryNeedRemove" resultType="java.lang.Long"> 
         SELECT fs_id  FROM `yeshi_ec_quality_flash_sale` 
      WHERE <![CDATA[TO_DAYS(`fs_updatetime`) < TO_DAYS(NOW()) OR (HOUR(NOW()) -HOUR(`fs_updatetime`)) >= #{hour}]]>
      ORDER BY fs_updatetime  LIMIT ${start},${count}
   </select>
    
      
</mapper>