yujian
2019-09-02 9eeda0d3049b71877c373c04d65533939b5582ef
fanli/src/main/java/com/yeshi/fanli/mapping/share/UserShareGoodsGroupMapper.xml
@@ -1,160 +1,162 @@
<?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.share.UserShareGoodsGroupMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup">
    <id column="gu_id" property="id" jdbcType="BIGINT"/>
    <result column="gu_record_id" property="recordId" jdbcType="BIGINT"/>
    <result column="gu_today_browse" property="todayBrowse" jdbcType="INTEGER"/>
    <result column="gu_total_browse" property="totalBrowse" jdbcType="INTEGER"/>
    <result column="gu_total_order" property="totalOrder" jdbcType="INTEGER"/>
    <result column="gu_total_money" property="totalMoney" jdbcType="DECIMAL"/>
    <result column="gu_browse_time" property="browseTime" jdbcType="TIMESTAMP"/>
    <result column="gu_createtime" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="gu_updatetime" property="updateTime" jdbcType="TIMESTAMP"/>
         <!-- 记录组中的总商品数量 -->
    <result column="totalGoods" property="totalGoods" jdbcType="INTEGER"/>
    <association property="commonGoods" column="gu_common_goods_id"
      resultMap="com.yeshi.fanli.dao.mybatis.goods.CommonGoodsMapper.BaseResultMap" />
  </resultMap>
  <sql id="Base_Column_List">gu_id,gu_record_id,gu_common_goods_id,gu_today_browse,gu_total_browse,gu_total_order,gu_total_money,gu_browse_time,gu_createtime,gu_updatetime</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_share_goods_group where gu_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_share_goods_group where gu_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_share_goods_group (gu_id,gu_record_id,gu_common_goods_id,gu_today_browse,gu_total_browse,gu_total_order,gu_total_money,gu_browse_time,gu_createtime,gu_updatetime) values (#{id,jdbcType=BIGINT},#{recordId,jdbcType=BIGINT},#{commonGoods.id,jdbcType=BIGINT},#{todayBrowse,jdbcType=INTEGER},#{totalBrowse,jdbcType=INTEGER},#{totalOrder,jdbcType=INTEGER},#{totalMoney,jdbcType=DECIMAL},#{browseTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_share_goods_group
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">gu_id,</if>
      <if test="recordId != null">gu_record_id,</if>
      <if test="commonGoods != null">gu_common_goods_id,</if>
      <if test="todayBrowse != null">gu_today_browse,</if>
      <if test="totalBrowse != null">gu_total_browse,</if>
      <if test="totalOrder != null">gu_total_order,</if>
      <if test="totalMoney != null">gu_total_money,</if>
      <if test="browseTime != null">gu_browse_time,</if>
      <if test="createTime != null">gu_createtime,</if>
      <if test="updateTime != null">gu_updatetime,</if>
    </trim>values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">#{id,jdbcType=BIGINT},</if>
      <if test="recordId != null">#{recordId,jdbcType=BIGINT},</if>
      <if test="commonGoods != null">#{commonGoods.id,jdbcType=BIGINT},</if>
      <if test="todayBrowse != null">#{todayBrowse,jdbcType=INTEGER},</if>
      <if test="totalBrowse != null">#{totalBrowse,jdbcType=INTEGER},</if>
      <if test="totalOrder != null">#{totalOrder,jdbcType=INTEGER},</if>
      <if test="totalMoney != null">#{totalMoney,jdbcType=DECIMAL},</if>
      <if test="browseTime != null">#{browseTime,jdbcType=TIMESTAMP},</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.share.UserShareGoodsGroup">update yeshi_ec_share_goods_group set gu_record_id = #{recordId,jdbcType=BIGINT},gu_common_goods_id = #{commonGoods.id,jdbcType=BIGINT},gu_today_browse = #{todayBrowse,jdbcType=INTEGER},gu_total_browse = #{totalBrowse,jdbcType=INTEGER},gu_total_order = #{totalOrder,jdbcType=INTEGER},gu_total_money = #{totalMoney,jdbcType=DECIMAL},gu_browse_time = #{browseTime,jdbcType=TIMESTAMP},gu_createtime = #{createTime,jdbcType=TIMESTAMP},gu_updatetime = #{updateTime,jdbcType=TIMESTAMP} where gu_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup">update yeshi_ec_share_goods_group
    <set>
      <if test="recordId != null">gu_record_id=#{recordId,jdbcType=BIGINT},</if>
      <if test="commonGoods != null">gu_common_goods_id=#{commonGoods.id,jdbcType=BIGINT},</if>
      <if test="todayBrowse != null">gu_today_browse=#{todayBrowse,jdbcType=INTEGER},</if>
      <if test="totalBrowse != null">gu_total_browse=#{totalBrowse,jdbcType=INTEGER},</if>
      <if test="totalOrder != null">gu_total_order=#{totalOrder,jdbcType=INTEGER},</if>
      <if test="totalMoney != null">gu_total_money=#{totalMoney,jdbcType=DECIMAL},</if>
      <if test="browseTime != null">gu_browse_time=#{browseTime,jdbcType=TIMESTAMP},</if>
      <if test="createTime != null">gu_createtime=#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">gu_updatetime=#{updateTime,jdbcType=TIMESTAMP},</if>
    </set> where gu_id = #{id,jdbcType=BIGINT}
  </update>
   <insert id="insertBatch"  useGeneratedKeys="true" keyProperty="id"  parameterType="java.util.List">
        insert into yeshi_ec_share_goods_group
        (<include refid="Base_Column_List" />)
       values
        <foreach collection="list" item="item" separator=",">
         (
          #{item.id,jdbcType=BIGINT},
          #{item.recordId,jdbcType=BIGINT},
          #{item.commonGoods.id,jdbcType=BIGINT},
          #{item.todayBrowse,jdbcType=INTEGER},
          #{item.totalBrowse,jdbcType=INTEGER},
          #{item.totalOrder,jdbcType=INTEGER},
          #{item.totalMoney,jdbcType=DECIMAL},
          #{item.browseTime,jdbcType=TIMESTAMP},
          #{item.createTime,jdbcType=TIMESTAMP},
          #{item.updateTime,jdbcType=TIMESTAMP}
        )
        </foreach>
  </insert>
  <update id="updateBatchSelective" parameterType="java.util.List">
        update yeshi_ec_share_goods_group
        <trim prefix="set" suffixOverrides=",">
             <trim prefix="gu_today_browse =case" suffix="end,">
                <foreach collection="list" item="item" index="index">
                      <if test="item.todayBrowse !=null">
                     when gu_id=#{item.id} then #{item.todayBrowse}
                     </if>
                </foreach>
            </trim>
            <trim prefix="gu_total_browse =case" suffix="end,">
                <foreach collection="list" item="item" index="index">
                      <if test="item.totalBrowse !=null">
                     when gu_id=#{item.id} then #{item.totalBrowse}
                     </if>
                </foreach>
            </trim>
             <trim prefix="gu_total_order =case" suffix="end,">
                <foreach collection="list" item="item" index="index">
                      <if test="item.totalOrder !=null">
                     when gu_id=#{item.id} then #{item.totalOrder}
                     </if>
                </foreach>
            </trim>
             <trim prefix="gu_total_money =case" suffix="end,">
                <foreach collection="list" item="item" index="index">
                      <if test="item.totalMoney !=null">
                     when gu_id=#{item.id} then #{item.totalMoney}
                     </if>
                </foreach>
            </trim>
            <trim prefix="gu_browse_time =case" suffix="end,">
                <foreach collection="list" item="item" index="index">
                      <if test="item.browseTime !=null">
                     when gu_id=#{item.id} then #{item.browseTime}
                     </if>
                </foreach>
            </trim>
        </trim>
        where gu_id in
        <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
            #{item.id,jdbcType=BIGINT}
        </foreach>
    </update>
   <select id="listByRecordId" resultMap="BaseResultMap">
    SELECT * FROM yeshi_ec_share_goods_group  tg
    LEFT JOIN  `yeshi_ec_common_goods` cg ON tg.`gu_common_goods_id` = cg.`cg_id`
    WHERE tg.`gu_record_id` = #{recordId}
    ORDER BY tg.`gu_createtime`
   </select>
  <select id="getSingleGoods" resultMap="BaseResultMap">
   SELECT * FROM yeshi_ec_share_goods_group g
   LEFT JOIN `yeshi_ec_share_goods_record` r ON g.`gu_record_id` = r.`sgr_id`
   WHERE  r.sgr_share_state = 1 AND  r.`sgr_source` = #{source}
          AND  g.`gu_common_goods_id` = #{cid} AND r.`sgr_uid` = #{uid}
   </select>
   <select id="getNewestRecord" resultMap="BaseResultMap">
   SELECT tg.* FROM yeshi_ec_share_goods_group tg
   RIGHT JOIN `yeshi_ec_share_goods_record` r ON tg.`gu_record_id` = r.`sgr_id`
   LEFT JOIN  `yeshi_ec_common_goods` cg ON tg.`gu_common_goods_id` = cg.`cg_id`
   WHERE r.`sgr_uid` = #{uid} AND cg.`cg_goods_id` = #{auctionId}  AND r.sgr_share_state = 1
   ORDER BY tg.gu_updatetime desc LIMIT 1
   </select>
</mapper>
<?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.share.UserShareGoodsGroupMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup">
    <id column="gu_id" property="id" jdbcType="BIGINT"/>
    <result column="gu_record_id" property="recordId" jdbcType="BIGINT"/>
    <result column="gu_today_browse" property="todayBrowse" jdbcType="INTEGER"/>
    <result column="gu_total_browse" property="totalBrowse" jdbcType="INTEGER"/>
    <result column="gu_total_order" property="totalOrder" jdbcType="INTEGER"/>
    <result column="gu_total_money" property="totalMoney" jdbcType="DECIMAL"/>
    <result column="gu_browse_time" property="browseTime" jdbcType="TIMESTAMP"/>
    <result column="gu_createtime" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="gu_updatetime" property="updateTime" jdbcType="TIMESTAMP"/>
         <!-- 记录组中的总商品数量 -->
    <result column="totalGoods" property="totalGoods" jdbcType="INTEGER"/>
    <association property="commonGoods" column="gu_common_goods_id"
      resultMap="com.yeshi.fanli.dao.mybatis.goods.CommonGoodsMapper.BaseResultMap" />
  </resultMap>
  <sql id="Base_Column_List">gu_id,gu_record_id,gu_common_goods_id,gu_today_browse,gu_total_browse,gu_total_order,gu_total_money,gu_browse_time,gu_createtime,gu_updatetime</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_share_goods_group where gu_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_share_goods_group where gu_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_share_goods_group (gu_id,gu_record_id,gu_common_goods_id,gu_today_browse,gu_total_browse,gu_total_order,gu_total_money,gu_browse_time,gu_createtime,gu_updatetime) values (#{id,jdbcType=BIGINT},#{recordId,jdbcType=BIGINT},#{commonGoods.id,jdbcType=BIGINT},#{todayBrowse,jdbcType=INTEGER},#{totalBrowse,jdbcType=INTEGER},#{totalOrder,jdbcType=INTEGER},#{totalMoney,jdbcType=DECIMAL},#{browseTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_share_goods_group
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">gu_id,</if>
      <if test="recordId != null">gu_record_id,</if>
      <if test="commonGoods != null">gu_common_goods_id,</if>
      <if test="todayBrowse != null">gu_today_browse,</if>
      <if test="totalBrowse != null">gu_total_browse,</if>
      <if test="totalOrder != null">gu_total_order,</if>
      <if test="totalMoney != null">gu_total_money,</if>
      <if test="browseTime != null">gu_browse_time,</if>
      <if test="createTime != null">gu_createtime,</if>
      <if test="updateTime != null">gu_updatetime,</if>
    </trim>values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">#{id,jdbcType=BIGINT},</if>
      <if test="recordId != null">#{recordId,jdbcType=BIGINT},</if>
      <if test="commonGoods != null">#{commonGoods.id,jdbcType=BIGINT},</if>
      <if test="todayBrowse != null">#{todayBrowse,jdbcType=INTEGER},</if>
      <if test="totalBrowse != null">#{totalBrowse,jdbcType=INTEGER},</if>
      <if test="totalOrder != null">#{totalOrder,jdbcType=INTEGER},</if>
      <if test="totalMoney != null">#{totalMoney,jdbcType=DECIMAL},</if>
      <if test="browseTime != null">#{browseTime,jdbcType=TIMESTAMP},</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.share.UserShareGoodsGroup">update yeshi_ec_share_goods_group set gu_record_id = #{recordId,jdbcType=BIGINT},gu_common_goods_id = #{commonGoods.id,jdbcType=BIGINT},gu_today_browse = #{todayBrowse,jdbcType=INTEGER},gu_total_browse = #{totalBrowse,jdbcType=INTEGER},gu_total_order = #{totalOrder,jdbcType=INTEGER},gu_total_money = #{totalMoney,jdbcType=DECIMAL},gu_browse_time = #{browseTime,jdbcType=TIMESTAMP},gu_createtime = #{createTime,jdbcType=TIMESTAMP},gu_updatetime = #{updateTime,jdbcType=TIMESTAMP} where gu_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup">update yeshi_ec_share_goods_group
    <set>
      <if test="recordId != null">gu_record_id=#{recordId,jdbcType=BIGINT},</if>
      <if test="commonGoods != null">gu_common_goods_id=#{commonGoods.id,jdbcType=BIGINT},</if>
      <if test="todayBrowse != null">gu_today_browse=#{todayBrowse,jdbcType=INTEGER},</if>
      <if test="totalBrowse != null">gu_total_browse=#{totalBrowse,jdbcType=INTEGER},</if>
      <if test="totalOrder != null">gu_total_order=#{totalOrder,jdbcType=INTEGER},</if>
      <if test="totalMoney != null">gu_total_money=#{totalMoney,jdbcType=DECIMAL},</if>
      <if test="browseTime != null">gu_browse_time=#{browseTime,jdbcType=TIMESTAMP},</if>
      <if test="createTime != null">gu_createtime=#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">gu_updatetime=#{updateTime,jdbcType=TIMESTAMP},</if>
    </set> where gu_id = #{id,jdbcType=BIGINT}
  </update>
   <insert id="insertBatch"  useGeneratedKeys="true" keyProperty="id"  parameterType="java.util.List">
        insert into yeshi_ec_share_goods_group
        (<include refid="Base_Column_List" />)
       values
        <foreach collection="list" item="item" separator=",">
         (
          #{item.id,jdbcType=BIGINT},
          #{item.recordId,jdbcType=BIGINT},
          #{item.commonGoods.id,jdbcType=BIGINT},
          #{item.todayBrowse,jdbcType=INTEGER},
          #{item.totalBrowse,jdbcType=INTEGER},
          #{item.totalOrder,jdbcType=INTEGER},
          #{item.totalMoney,jdbcType=DECIMAL},
          #{item.browseTime,jdbcType=TIMESTAMP},
          #{item.createTime,jdbcType=TIMESTAMP},
          #{item.updateTime,jdbcType=TIMESTAMP}
        )
        </foreach>
  </insert>
  <update id="updateBatchSelective" parameterType="java.util.List">
        update yeshi_ec_share_goods_group
        <trim prefix="set" suffixOverrides=",">
             <trim prefix="gu_today_browse =case" suffix="end,">
                <foreach collection="list" item="item" index="index">
                      <if test="item.todayBrowse !=null">
                     when gu_id=#{item.id} then #{item.todayBrowse}
                     </if>
                </foreach>
            </trim>
            <trim prefix="gu_total_browse =case" suffix="end,">
                <foreach collection="list" item="item" index="index">
                      <if test="item.totalBrowse !=null">
                     when gu_id=#{item.id} then #{item.totalBrowse}
                     </if>
                </foreach>
            </trim>
             <trim prefix="gu_total_order =case" suffix="end,">
                <foreach collection="list" item="item" index="index">
                      <if test="item.totalOrder !=null">
                     when gu_id=#{item.id} then #{item.totalOrder}
                     </if>
                </foreach>
            </trim>
             <trim prefix="gu_total_money =case" suffix="end,">
                <foreach collection="list" item="item" index="index">
                      <if test="item.totalMoney !=null">
                     when gu_id=#{item.id} then #{item.totalMoney}
                     </if>
                </foreach>
            </trim>
            <trim prefix="gu_browse_time =case" suffix="end,">
                <foreach collection="list" item="item" index="index">
                      <if test="item.browseTime !=null">
                     when gu_id=#{item.id} then #{item.browseTime}
                     </if>
                </foreach>
            </trim>
        </trim>
        where gu_id in
        <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
            #{item.id,jdbcType=BIGINT}
        </foreach>
    </update>
   <select id="listByRecordId" resultMap="BaseResultMap">
    SELECT * FROM yeshi_ec_share_goods_group  tg
    LEFT JOIN  `yeshi_ec_common_goods` cg ON tg.`gu_common_goods_id` = cg.`cg_id`
    WHERE tg.`gu_record_id` = #{recordId}
    ORDER BY tg.`gu_createtime`
   </select>
  <select id="getSingleGoods" resultMap="BaseResultMap">
   SELECT * FROM yeshi_ec_share_goods_group g
   LEFT JOIN `yeshi_ec_share_goods_record` r ON g.`gu_record_id` = r.`sgr_id`
   WHERE  r.sgr_share_state = 1 AND  r.`sgr_source` = #{source}
          AND  g.`gu_common_goods_id` = #{cid} AND r.`sgr_uid` = #{uid}
   ORDER BY g.gu_updatetime desc LIMIT 1
   </select>
   <select id="getNewestRecord" resultMap="BaseResultMap">
   SELECT tg.* FROM yeshi_ec_share_goods_group tg
   RIGHT JOIN `yeshi_ec_share_goods_record` r ON tg.`gu_record_id` = r.`sgr_id`
   LEFT JOIN  `yeshi_ec_common_goods` cg ON tg.`gu_common_goods_id` = cg.`cg_id`
   WHERE r.`sgr_uid` = #{uid} AND cg.`cg_goods_id` = #{goodsId}  AND r.sgr_share_state = 1
       AND cg.`cg_goods_type` = #{goodsType}
   ORDER BY tg.gu_updatetime desc LIMIT 1
   </select>
</mapper>