admin
2019-07-11 3824cbcaec6e6c67418d5280a53e9c2fedeef6f9
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
<?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.user.UserGoodsStorageMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.user.UserGoodsStorage">
    <id column="guc_id" property="id" jdbcType="BIGINT"/>
    <result column="guc_uid" property="uid" jdbcType="BIGINT"/>
    <result column="guc_state" property="state" jdbcType="INTEGER"/>
    <result column="guc_createtime" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="guc_updatetime" property="updateTime" jdbcType="TIMESTAMP"/>
    
    <association property="commonGoods" column="guc_common_id"
        resultMap="com.yeshi.fanli.dao.mybatis.goods.CommonGoodsMapper.BaseResultMap" />
    
  </resultMap>
  <sql id="Base_Column_List">guc_id,guc_common_id,guc_uid,guc_state,guc_createtime,guc_updatetime</sql>
  
  <sql id="Convert_Column_List">guc_id,guc_common_id as cg_id,guc_uid,guc_state,guc_createtime,guc_updatetime</sql>
  
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_user_goods_storage where guc_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_user_goods_storage where guc_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.user.UserGoodsStorage" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_user_goods_storage (guc_id,guc_common_id,guc_uid,guc_state,guc_createtime,guc_updatetime) values (#{id,jdbcType=BIGINT},#{commonGoods.id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{state,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.user.UserGoodsStorage" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_user_goods_storage
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">guc_id,</if>
      <if test="commonGoods != null">guc_common_id,</if>
      <if test="uid != null">guc_uid,</if>
      <if test="state != null">guc_state,</if>
      <if test="createTime != null">guc_createtime,</if>
      <if test="updateTime != null">guc_updatetime,</if>
    </trim>values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">#{id,jdbcType=BIGINT},</if>
      <if test="commonGoods != null">#{commonGoods.id,jdbcType=BIGINT},</if>
      <if test="uid != null">#{uid,jdbcType=BIGINT},</if>
      <if test="state != null">#{state,jdbcType=INTEGER},</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.user.UserGoodsStorage">update yeshi_ec_user_goods_storage set guc_common_id = #{commonGoods.id,jdbcType=BIGINT},guc_uid = #{uid,jdbcType=BIGINT},guc_state = #{state,jdbcType=INTEGER},guc_createtime = #{createTime,jdbcType=TIMESTAMP},guc_updatetime = #{updateTime,jdbcType=TIMESTAMP} where guc_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.user.UserGoodsStorage">update yeshi_ec_user_goods_storage
    <set>
      <if test="commonGoods != null">guc_common_id=#{commonGoods.id,jdbcType=BIGINT},</if>
      <if test="uid != null">guc_uid=#{uid,jdbcType=BIGINT},</if>
      <if test="state != null">guc_state=#{state,jdbcType=INTEGER},</if>
      <if test="createTime != null">guc_createtime=#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">guc_updatetime=#{updateTime,jdbcType=TIMESTAMP},</if>
    </set> where guc_id = #{id,jdbcType=BIGINT}
  </update>
  
   <insert id="insertBatch"  useGeneratedKeys="true" keyProperty="id"  parameterType="java.util.List">
          insert into yeshi_ec_user_goods_storage
         (<include refid="Base_Column_List" />)
        values
          
          <foreach collection="list" item="item" separator=",">
              (
                 #{item.id,jdbcType=BIGINT},
                 #{item.commonGoods.id,jdbcType=BIGINT},
                 #{item.uid,jdbcType=BIGINT},
                 #{item.state,jdbcType=INTEGER},
                 #{item.createTime.id,jdbcType=TIMESTAMP},
                 #{item.updateTime,jdbcType=TIMESTAMP}
             )
           
          </foreach>
  </insert>
  
      <update id="updateBatchSelective" parameterType="java.util.List">
        update yeshi_ec_user_goods_storage 
        <trim prefix="set" suffixOverrides=",">
             <trim prefix="guc_state =case" suffix="end,">
                <foreach collection="list" item="item" index="index">
                        <if test="item.state !=null">
                     when guc_id=#{item.id} then #{item.state}
                     </if>
                </foreach>
            </trim>
             <trim prefix="guc_updatetime =case" suffix="end,">
                <foreach collection="list" item="item" index="index">
                        <if test="item.updateTime !=null">
                     when guc_id=#{item.id} then #{item.updateTime}
                     </if>
                </foreach>
            </trim>
        </trim>
        where guc_id in
        <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
            #{item.id,jdbcType=BIGINT}
        </foreach>
     </update>
   
  
  
  <select id="listQueryByUid" resultMap="BaseResultMap">
     SELECT * FROM yeshi_ec_user_goods_storage  tg
     LEFT JOIN  `yeshi_ec_common_goods` cg ON tg.`guc_common_id` = cg.`cg_id`
     WHERE tg.`guc_uid` = #{uid}
     ORDER BY  cg.cg_state, tg.guc_state, tg.`guc_updatetime` DESC
     LIMIT #{start},#{count}
   </select>
   
   <select id="countQueryByUid" resultType="java.lang.Long">
     SELECT IFNULL(count(guc_id),0) FROM yeshi_ec_user_goods_storage  tg
     WHERE tg.`guc_uid` = #{uid}
   </select>
  
   <select id="getByUidAndCid" resultMap="BaseResultMap">
     SELECT  <include refid="Convert_Column_List"/> FROM yeshi_ec_user_goods_storage  tg
     WHERE tg.`guc_uid` = #{uid} AND tg.`guc_common_id`= #{cid}
   </select>
   
       <delete id="deleteBatchByPrimaryKey" parameterType="java.util.List">
        delete from yeshi_ec_user_goods_storage WHERE guc_id in
        <foreach collection="list" item="item" open="(" close=")"
            separator=",">#{item}</foreach>
    </delete>
    
    <delete id="deleteBatchByUidAndPrimaryKey" parameterType="java.util.List">
        delete from yeshi_ec_user_goods_storage WHERE guc_uid = #{uid} AND  guc_id in
        <foreach collection="list" item="item" open="(" close=")"
            separator=",">#{item}</foreach>
    </delete>
    
    
    <select id="getByUidAndAuctionId" resultMap="BaseResultMap">
        SELECT <include refid="Convert_Column_List"/>  FROM `yeshi_ec_user_goods_storage` g 
        LEFT JOIN  `yeshi_ec_common_goods` c ON g.`guc_common_id` = c.`cg_id`
        WHERE g.`guc_uid` = #{uid} AND c.`cg_goods_id`= #{auctionId}  
   </select>
    
   <select id="listQueryByIds" resultMap="BaseResultMap" parameterType="java.util.List">
        SELECT * FROM `yeshi_ec_user_goods_storage` g 
        LEFT JOIN  `yeshi_ec_common_goods` c ON g.`guc_common_id` = c.`cg_id`
        WHERE g.guc_id IN <foreach collection="list" item="item" open="(" close=")"
            separator=",">#{item}</foreach>
   </select>
   
</mapper>