yujian
2020-06-09 554de444b87aab5f93cb1593a8095612cf9479a7
fanli/src/main/java/com/yeshi/fanli/mapping/user/UserGoodsStorageMapper.xml
@@ -1,143 +1,144 @@
<?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>
   <insert id="insertBatch"  useGeneratedKeys="true" keyProperty="id"  parameterType="java.util.List">
        insert into yeshi_ec_user_goods_storage
        (<include refid="Base_Column_List" />)
       values
        <foreach collection="list" item="item" separator=",">
            (
             #{item.id,jdbcType=BIGINT},
             #{item.commonGoods.id,jdbcType=BIGINT},
             #{item.uid,jdbcType=BIGINT},
             #{item.state,jdbcType=INTEGER},
             #{item.createTime.id,jdbcType=TIMESTAMP},
             #{item.updateTime,jdbcType=TIMESTAMP}
           )
        </foreach>
  </insert>
     <update id="updateBatchSelective" parameterType="java.util.List">
        update yeshi_ec_user_goods_storage
        <trim prefix="set" suffixOverrides=",">
             <trim prefix="guc_state =case" suffix="end,">
                <foreach collection="list" item="item" index="index">
                      <if test="item.state !=null">
                     when guc_id=#{item.id} then #{item.state}
                     </if>
                </foreach>
            </trim>
             <trim prefix="guc_updatetime =case" suffix="end,">
                <foreach collection="list" item="item" index="index">
                      <if test="item.updateTime !=null">
                     when guc_id=#{item.id} then #{item.updateTime}
                     </if>
                </foreach>
            </trim>
        </trim>
        where guc_id in
        <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
            #{item.id,jdbcType=BIGINT}
        </foreach>
    </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} <if test="source != null">AND cg.`cg_goods_type` = #{source}</if>
    ORDER BY  cg.cg_state, tg.guc_state, 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
    <if test="source != null">LEFT JOIN  `yeshi_ec_common_goods` cg ON tg.`guc_common_id` = cg.`cg_id`</if>
    WHERE tg.`guc_uid` = #{uid} <if test="source != null">AND cg.`cg_goods_type` = #{source}</if>
   </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}   <if test="goodType != null">AND c.`cg_goods_type` = #{goodType}</if>
   </select>
   <select id="listQueryByIds" resultMap="BaseResultMap" parameterType="java.util.List">
      SELECT * 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_id IN <foreach collection="list" item="item" open="(" close=")"
         separator=",">#{item}</foreach>
   </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.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>
   <insert id="insertBatch"  useGeneratedKeys="true" keyProperty="id"  parameterType="java.util.List">
        insert into yeshi_ec_user_goods_storage
        (<include refid="Base_Column_List" />)
       values
        <foreach collection="list" item="item" separator=",">
            (
             #{item.id,jdbcType=BIGINT},
             #{item.commonGoods.id,jdbcType=BIGINT},
             #{item.uid,jdbcType=BIGINT},
             #{item.state,jdbcType=INTEGER},
             #{item.createTime.id,jdbcType=TIMESTAMP},
             #{item.updateTime,jdbcType=TIMESTAMP}
           )
        </foreach>
  </insert>
     <update id="updateBatchSelective" parameterType="java.util.List">
        update yeshi_ec_user_goods_storage
        <trim prefix="set" suffixOverrides=",">
             <trim prefix="guc_state =case" suffix="end,">
                <foreach collection="list" item="item" index="index">
                      <if test="item.state !=null">
                     when guc_id=#{item.id} then #{item.state}
                     </if>
                </foreach>
            </trim>
             <trim prefix="guc_updatetime =case" suffix="end,">
                <foreach collection="list" item="item" index="index">
                      <if test="item.updateTime !=null">
                     when guc_id=#{item.id} then #{item.updateTime}
                     </if>
                </foreach>
            </trim>
        </trim>
        where guc_id in
        <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
            #{item.id,jdbcType=BIGINT}
        </foreach>
    </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} <if test="gooodsType != null">AND cg.cg_goods_type = #{gooodsType}</if>
    ORDER BY  cg.cg_state, tg.guc_state, 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
     <if test="gooodsType != null"> LEFT JOIN  `yeshi_ec_common_goods` cg ON tg.`guc_common_id` = cg.`cg_id`</if>
    WHERE tg.`guc_uid` = #{uid} <if test="gooodsType != null">AND cg.cg_goods_type = #{gooodsType}</if>
   </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}
         <if test="gooodsType != null">AND c.cg_goods_type = #{gooodsType}</if>
   </select>
   <select id="listQueryByIds" resultMap="BaseResultMap" parameterType="java.util.List">
      SELECT * 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_id IN <foreach collection="list" item="item" open="(" close=")"
         separator=",">#{item}</foreach>
   </select>
</mapper>