admin
2018-12-10 01d627f3c67e2bc5c28b2dd5e23983ddcf7a08f3
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
<?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>
  
  <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 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>
    
</mapper>