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
<?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.goods.RecommendUserGoodsMapMapper">
    <resultMap id="BaseResultMap"
        type="com.yeshi.fanli.entity.goods.RecommendUserGoodsMap">
        <id column="rugm_id" property="id" jdbcType="BIGINT" />
        <result column="rugm_create_time" property="createTime"
            jdbcType="TIMESTAMP" />
        <association property="recommend" column="rugm_recommend_id"
            javaType="com.yeshi.fanli.entity.goods.RecommendUserGoods">
            <id column="rugm_recommend_id" property="id" jdbcType="BIGINT" />
        </association>
        <association property="goods" column="rugm_common_goods_id"
            javaType="com.yeshi.fanli.entity.goods.CommonGoods">
            <id column="rugm_common_goods_id" property="id" jdbcType="BIGINT" />
        </association>
    </resultMap>
    <sql id="Base_Column_List">rugm_id,rugm_common_goods_id,rugm_recommend_id,rugm_create_time
    </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_recommend_user_goods_map where rugm_id =
        #{id,jdbcType=BIGINT}
    </select>
 
    <select id="selectGoodsByRecommendId"
        resultMap="com.yeshi.fanli.dao.mybatis.goods.CommonGoodsMapper.BaseResultMap"
        parameterType="java.lang.Long">
        SELECT cg.* FROM `yeshi_ec_recommend_user_goods_map` m
        LEFT JOIN yeshi_ec_common_goods cg ON
        cg.`cg_id`=m.`rugm_common_goods_id` WHERE m.`rugm_recommend_id`=#{id}
    </select>
 
 
    <select id="listByUidAndCommonGoodsId" resultMap="BaseResultMap">
        SELECT m.* FROM
        yeshi_ec_recommend_user_goods_map m LEFT JOIN
        yeshi_ec_recommend_user_goods g ON m.`rugm_recommend_id`=g.`rug_id`
        WHERE g.`rug_uid`=#{uid} AND m.`rugm_common_goods_id`=#{commonGoodsId}
    </select>
 
    <select id="countByUidAndCommonGoodsId" resultType="java.lang.Long">
        SELECT
        count(m.id) FROM yeshi_ec_recommend_user_goods_map m LEFT JOIN
        yeshi_ec_recommend_user_goods g ON m.`rugm_recommend_id`=g.`rug_id`
        WHERE g.`rug_uid`=#{uid} AND m.`rugm_common_goods_id`=#{commonGoodsId}
    </select>
 
 
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
        yeshi_ec_recommend_user_goods_map where rugm_id =
        #{id,jdbcType=BIGINT}
    </delete>
    <insert id="insert" parameterType="com.yeshi.fanli.entity.goods.RecommendUserGoodsMap"
        useGeneratedKeys="true" keyProperty="id">insert into
        yeshi_ec_recommend_user_goods_map
        (rugm_id,rugm_common_goods_id,rugm_recommend_id,rugm_create_time)
        values
        (#{id,jdbcType=BIGINT},#{goods.id,jdbcType=BIGINT},#{recommend.id,jdbcType=BIGINT},#{createTime,jdbcType=TIMESTAMP})
    </insert>
    <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.goods.RecommendUserGoodsMap"
        useGeneratedKeys="true" keyProperty="id">
        insert into yeshi_ec_recommend_user_goods_map
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">rugm_id,</if>
            <if test="goods != null">rugm_common_goods_id,</if>
            <if test="recommend != null">rugm_recommend_id,</if>
            <if test="createTime != null">rugm_create_time,</if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=BIGINT},</if>
            <if test="goods != null">#{goods.id,jdbcType=BIGINT},</if>
            <if test="recommend != null">#{recommend.id,jdbcType=BIGINT},</if>
            <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.goods.RecommendUserGoodsMap">update
        yeshi_ec_recommend_user_goods_map set rugm_common_goods_id =
        #{goods.id,jdbcType=BIGINT},rugm_recommend_id =
        #{recommend.id,jdbcType=BIGINT},rugm_create_time =
        #{createTime,jdbcType=TIMESTAMP} where rugm_id = #{id,jdbcType=BIGINT}
    </update>
    <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.goods.RecommendUserGoodsMap">
        update yeshi_ec_recommend_user_goods_map
        <set>
            <if test="goods != null">rugm_common_goods_id=#{goods.id,jdbcType=BIGINT},</if>
            <if test="recommend != null">rugm_recommend_id=#{recommend.id,jdbcType=BIGINT},</if>
            <if test="createTime != null">rugm_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
        </set>
        where rugm_id = #{id,jdbcType=BIGINT}
    </update>
</mapper>