yujian
2019-01-22 88b54772dbcf5ecab1e2316e4e4626ac901b8908
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
<?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.UserShareGoodsHistoryMapper">
    <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.share.UserShareGoodsHistory">
        <id column="sgus_id" property="id" jdbcType="BIGINT" />
        <result column="sgus_goods_type" property="goodsType" jdbcType="INTEGER" />
        <result column="sgus_goods_id" property="goodsId" jdbcType="BIGINT" />
        <result column="sgus_post_picture" property="postPicture"
            jdbcType="VARCHAR" />
        <result column="sgu_pictures" property="pictures" jdbcType="VARCHAR" />
        <result column="sgu_hongbao" property="hongbao" jdbcType="DECIMAL" />
        <result column="sgu_link" property="link" jdbcType="VARCHAR" />
        <result column="sgu_quanlink" property="quanLink" jdbcType="VARCHAR" />
        <result column="sgu_tkcode" property="tkCode" jdbcType="VARCHAR" />
        <result column="sgu_createtime" property="createTime" jdbcType="TIMESTAMP" />
        <result column="sgus_share_img" property="shareImg" jdbcType="VARCHAR" />
        <association property="user" column="sgus_uid"
            resultMap="com.yeshi.fanli.dao.mybatis.UserInfoMapper.BaseResultMap" />
 
 
    </resultMap>
    <sql id="Base_Column_List">sgus_id,sgus_uid as
        uid,sgus_goods_type,sgus_goods_id,sgus_post_picture,sgu_pictures,sgu_hongbao,sgu_link,sgu_quanlink,sgu_tkcode,sgu_createtime,sgus_uid,sgus_share_img
    </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_share_goods_usershare where sgus_id =
        #{id,jdbcType=BIGINT}
    </select>
    <select id="selectByUidAndAuctionId" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_share_goods_usershare where sgus_uid = #{uid} and
        sgus_goods_id=#{auctionId} limit 1
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
        yeshi_ec_share_goods_usershare where sgus_id = #{id,jdbcType=BIGINT}
    </delete>
    <insert id="insert"
        parameterType="com.yeshi.fanli.entity.bus.share.UserShareGoodsHistory"
        useGeneratedKeys="true" keyProperty="id">insert into
        yeshi_ec_share_goods_usershare
        (sgus_id,sgus_uid,sgus_goods_type,sgus_goods_id,sgus_post_picture,sgu_pictures,sgu_hongbao,sgu_link,sgu_quanlink,sgu_tkcode,sgu_createtime,sgus_share_img)
        values
        (#{id,jdbcType=BIGINT},#{user.id,jdbcType=BIGINT},#{goodsType,jdbcType=INTEGER},#{goodsId,jdbcType=BIGINT},#{postPicture,jdbcType=VARCHAR},#{pictures,jdbcType=VARCHAR},#{hongbao,jdbcType=DECIMAL},#{link,jdbcType=VARCHAR},#{quanLink,jdbcType=VARCHAR},#{tkCode,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{shareImg,jdbcType=VARCHAR})
    </insert>
    <insert id="insertSelective"
        parameterType="com.yeshi.fanli.entity.bus.share.UserShareGoodsHistory"
        useGeneratedKeys="true" keyProperty="id">
        insert into yeshi_ec_share_goods_usershare
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">sgus_id,</if>
            <if test="user != null">sgus_uid,</if>
            <if test="goodsType != null">sgus_goods_type,</if>
            <if test="goodsId != null">sgus_goods_id,</if>
            <if test="postPicture != null">sgus_post_picture,</if>
            <if test="pictures != null">sgu_pictures,</if>
            <if test="hongbao != null">sgu_hongbao,</if>
            <if test="link != null">sgu_link,</if>
            <if test="quanLink != null">sgu_quanlink,</if>
            <if test="tkCode != null">sgu_tkcode,</if>
            <if test="createTime != null">sgu_createtime,</if>
            <if test="shareImg != null">sgus_share_img,</if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=BIGINT},</if>
            <if test="user != null">#{user.id,jdbcType=BIGINT},</if>
            <if test="goodsType != null">#{goodsType,jdbcType=INTEGER},</if>
            <if test="goodsId != null">#{goodsId,jdbcType=BIGINT},</if>
            <if test="postPicture != null">#{postPicture,jdbcType=VARCHAR},</if>
            <if test="pictures != null">#{pictures,jdbcType=VARCHAR},</if>
            <if test="hongbao != null">#{hongbao,jdbcType=DECIMAL},</if>
            <if test="link != null">#{link,jdbcType=VARCHAR},</if>
            <if test="quanLink != null">#{quanLink,jdbcType=VARCHAR},</if>
            <if test="tkCode != null">#{tkCode,jdbcType=VARCHAR},</if>
            <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="shareImg != null">#{shareImg,jdbcType=VARCHAR}</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey"
        parameterType="com.yeshi.fanli.entity.bus.share.UserShareGoodsHistory">update yeshi_ec_share_goods_usershare set sgus_uid =
        #{user.id,jdbcType=BIGINT},sgus_goods_type =
        #{goodsType,jdbcType=INTEGER},sgus_goods_id =
        #{goodsId,jdbcType=BIGINT},sgus_post_picture =
        #{postPicture,jdbcType=VARCHAR},sgu_pictures =
        #{pictures,jdbcType=VARCHAR},sgu_hongbao =
        #{hongbao,jdbcType=DECIMAL},sgu_link =
        #{link,jdbcType=VARCHAR},sgu_quanlink =
        #{quanLink,jdbcType=VARCHAR},sgu_tkcode =
        #{tkCode,jdbcType=VARCHAR},sgu_createtime =
        #{createTime,jdbcType=TIMESTAMP} ,sgus_share_img
        =#{shareImg,jdbcType=VARCHAR} where sgus_id = #{id,jdbcType=BIGINT}
    </update>
    <update id="updateByPrimaryKeySelective"
        parameterType="com.yeshi.fanli.entity.bus.share.UserShareGoodsHistory">
        update yeshi_ec_share_goods_usershare
        <set>
            <if test="user != null">sgus_uid=#{user.id,jdbcType=BIGINT},</if>
            <if test="goodsType != null">sgus_goods_type=#{goodsType,jdbcType=INTEGER},</if>
            <if test="goodsId != null">sgus_goods_id=#{goodsId,jdbcType=BIGINT},</if>
            <if test="postPicture != null">sgus_post_picture=#{postPicture,jdbcType=VARCHAR},</if>
            <if test="pictures != null">sgu_pictures=#{pictures,jdbcType=VARCHAR},</if>
            <if test="hongbao != null">sgu_hongbao=#{hongbao,jdbcType=DECIMAL},</if>
            <if test="link != null">sgu_link=#{link,jdbcType=VARCHAR},</if>
            <if test="quanLink != null">sgu_quanlink=#{quanLink,jdbcType=VARCHAR},</if>
            <if test="tkCode != null">sgu_tkcode=#{tkCode,jdbcType=VARCHAR},</if>
            <if test="createTime != null">sgu_createtime=#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="id !=null">sgus_id =#{id,jdbcType=BIGINT},</if>
            <if test="shareImg !=null">sgus_share_img =#{shareImg,jdbcType=VARCHAR},</if>
        </set>
        where sgus_id = #{id,jdbcType=BIGINT}
    </update>
    
    <select id="countUserShares" parameterType="java.lang.Long" resultType="java.lang.Long">
        SELECT IFNULL(COUNT(sgus_id),0) FROM  yeshi_ec_share_goods_usershare WHERE sgus_uid =#{userId,jdbcType=BIGINT}
   </select>
    
    
</mapper>