admin
2019-07-30 573c491b4a1ba60e12a5678a01c1546c0077c1ee
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
<?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.push.PushGoodsGroupMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.push.PushGoodsGroup">
    <id column="gro_id" property="id" jdbcType="BIGINT"/>
    <result column="gro_push_id" property="pushId" jdbcType="BIGINT"/>
  
    <association property="commonGoods" column="gro_goods_id"
        resultMap="com.yeshi.fanli.dao.mybatis.goods.CommonGoodsMapper.BaseResultMap" />
    
  </resultMap>
  <sql id="Base_Column_List">gro_id,gro_push_id,gro_goods_id</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_push_goods_group where gro_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_push_goods_group where gro_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.push.PushGoodsGroup" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_push_goods_group (gro_id,gro_push_id,gro_goods_id) values (#{id,jdbcType=BIGINT},#{pushId,jdbcType=BIGINT},#{commonGoods.id,jdbcType=BIGINT})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.push.PushGoodsGroup" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_push_goods_group
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">gro_id,</if>
      <if test="pushId != null">gro_push_id,</if>
      <if test="commonGoods != null">gro_goods_id,</if>
    </trim>values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">#{id,jdbcType=BIGINT},</if>
      <if test="pushId != null">#{pushId,jdbcType=BIGINT},</if>
      <if test="commonGoods != null">#{commonGoods.id,jdbcType=BIGINT},</if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.push.PushGoodsGroup">update yeshi_ec_push_goods_group set gro_push_id = #{pushId,jdbcType=BIGINT},gro_goods_id = #{commonGoods.id,jdbcType=BIGINT} where gro_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.push.PushGoodsGroup">update yeshi_ec_push_goods_group
    <set>
      <if test="pushId != null">gro_push_id=#{pushId,jdbcType=BIGINT},</if>
      <if test="commonGoods != null">gro_goods_id=#{commonGoods.id,jdbcType=BIGINT},</if>
    </set> where gro_id = #{id,jdbcType=BIGINT}
  </update>
  
   <delete id="deleteBatchByPrimaryKey"  parameterType="java.util.List">
        delete from yeshi_ec_push_goods_group where gro_id in
        <foreach item="item" collection="list" open="(" separator=","
            close=")">#{item}</foreach>
   </delete>
   
  <delete id="deleteByPushId" parameterType="java.lang.Long">
      delete from yeshi_ec_push_goods_group 
      where gro_push_id = #{pushId,jdbcType=BIGINT}
  </delete>
  
  
  <delete id="deleteBatchByPushId"  parameterType="java.util.List">
        delete from yeshi_ec_push_goods_group where gro_push_id in
        <foreach item="item" collection="list" open="(" separator=","
            close=")">#{item}</foreach>
   </delete>
  
   <select id="selectByPushId" resultMap="BaseResultMap" parameterType="java.lang.Long">
           select gro_id,gro_push_id,gro_goods_id as cg_id from yeshi_ec_push_goods_group 
           where gro_push_id = #{pushId,jdbcType=BIGINT}
  </select>
  
   <insert id="insertBatch" parameterType="java.util.List">
          insert into yeshi_ec_push_goods_group
        (<include refid="Base_Column_List" />)
        values
          <foreach collection="list" item="item" separator=",">
          (
             #{item.id,jdbcType=BIGINT},
             #{item.pushId,jdbcType=BIGINT},
             #{item.commonGoods.id,jdbcType=BIGINT}
         )
          </foreach>
  </insert>
  
  <select id="countByPushId" resultType="java.lang.Long" parameterType="java.lang.Long">
           SELECT IFNULL(count(gro_id),0)  from yeshi_ec_push_goods_group 
           where gro_push_id = #{pushId,jdbcType=BIGINT} 
  </select>
  
  <select id="getAllInfoByPushId" resultMap="BaseResultMap" parameterType="java.lang.Long">
          SELECT * FROM yeshi_ec_push_goods_group ph 
          LEFT JOIN `yeshi_ec_common_goods` gg ON ph.`gro_goods_id` = gg.`cg_id`
           WHERE gro_push_id =  #{pushId,jdbcType=BIGINT} 
  </select>
  
</mapper>