<?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.CollectionGoodsV2Mapper">
|
<resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.goods.CollectionGoodsV2">
|
<id column="cg_id" property="id" jdbcType="BIGINT" />
|
<result column="cg_createtime" property="createTime" jdbcType="TIMESTAMP" />
|
<result column="cg_updatetime" property="updateTime" jdbcType="TIMESTAMP" />
|
<association property="userInfo" column="cg_uid"
|
javaType="com.yeshi.fanli.entity.bus.user.UserInfo">
|
<id column="cg_uid" property="id" jdbcType="BIGINT" />
|
</association>
|
|
<association property="commonGoods" column="cg_common_goods_id"
|
select="com.yeshi.fanli.dao.mybatis.goods.CommonGoodsMapper.selectByPrimaryKey">
|
</association>
|
|
</resultMap>
|
<sql id="Base_Column_List">cg_id,cg_uid,cg_common_goods_id,cg_createtime,cg_updatetime
|
</sql>
|
<select id="selectByPrimaryKey" resultMap="BaseResultMap"
|
parameterType="java.lang.Long">
|
select
|
<include refid="Base_Column_List" />
|
from yeshi_ec_collection_goods_v2 where cg_id = #{id,jdbcType=BIGINT}
|
</select>
|
|
|
|
<!-- 根据用户ID和商品ID获取收藏记录 -->
|
<select id="selectByUidAndCommonGoodsId" resultMap="BaseResultMap">
|
select
|
<include refid="Base_Column_List" />
|
from yeshi_ec_collection_goods_v2 where cg_uid = #{uid} and
|
cg_common_goods_id=#{commonGoodsId} limit 1
|
</select>
|
|
|
<!-- 根据用户ID获取收藏记录,按照收藏时间倒叙 -->
|
<select id="selectByUidOrderByCreateTimeDesc" resultMap="BaseResultMap">
|
select
|
<include refid="Base_Column_List" />
|
from yeshi_ec_collection_goods_v2 where cg_uid = #{uid} order by
|
cg_createtime desc limit #{start},#{count}
|
</select>
|
|
|
<!-- 获取收藏的数量 -->
|
<select id="selectCountByUid" resultType="java.lang.Long"
|
parameterType="java.lang.Long">
|
select
|
count(cg_id)
|
from yeshi_ec_collection_goods_v2
|
where cg_uid = #{uid}
|
</select>
|
|
|
<select id="selectByUidAndGoodsTypeAndGoodsId" resultMap="BaseResultMap">
|
select
|
v2.*
|
from yeshi_ec_collection_goods_v2 v2 left join
|
yeshi_ec_common_goods g
|
on g.cg_id=v2.cg_common_goods_id
|
where v2.cg_uid
|
= #{uid} and
|
g.cg_goods_id=#{goodsId} and g.cg_goods_type=#{goodsType}
|
limit 1
|
</select>
|
|
|
|
<!-- 根据UID删除收藏 -->
|
<delete id="deleteByUid" parameterType="java.lang.Long">delete from
|
yeshi_ec_collection_goods_v2 where cg_uid = #{uid}
|
</delete>
|
|
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
|
yeshi_ec_collection_goods_v2 where cg_id = #{id,jdbcType=BIGINT}
|
</delete>
|
<insert id="insert" parameterType="com.yeshi.fanli.entity.goods.CollectionGoodsV2"
|
useGeneratedKeys="true" keyProperty="id">insert into
|
yeshi_ec_collection_goods_v2
|
(cg_id,cg_uid,cg_common_goods_id,cg_createtime,cg_updatetime) values
|
(#{id,jdbcType=BIGINT},#{userInfo.id,jdbcType=BIGINT},#{commonGoods.id,jdbcType=BIGINT},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})
|
</insert>
|
<insert id="insertSelective" parameterType="com.yeshi.fanli.entity.goods.CollectionGoodsV2"
|
useGeneratedKeys="true" keyProperty="id">
|
insert into yeshi_ec_collection_goods_v2
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="id != null">cg_id,</if>
|
<if test="userInfo != null">cg_uid,</if>
|
<if test="commonGoods != null">cg_common_goods_id,</if>
|
<if test="createTime != null">cg_createtime,</if>
|
<if test="updateTime != null">cg_updatetime,</if>
|
</trim>
|
values
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="id != null">#{id,jdbcType=BIGINT},</if>
|
<if test="userInfo != null">#{userInfo.id,jdbcType=BIGINT},</if>
|
<if test="commonGoods != null">#{commonGoods.id,jdbcType=BIGINT},</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.goods.CollectionGoodsV2">update
|
yeshi_ec_collection_goods_v2 set cg_uid =
|
#{userInfo.id,jdbcType=BIGINT},cg_common_goods_id =
|
#{commonGoods.id,jdbcType=BIGINT},cg_createtime =
|
#{createTime,jdbcType=TIMESTAMP},cg_updatetime =
|
#{updateTime,jdbcType=TIMESTAMP} where cg_id = #{id,jdbcType=BIGINT}
|
</update>
|
<update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.goods.CollectionGoodsV2">
|
update yeshi_ec_collection_goods_v2
|
<set>
|
<if test="userInfo != null">cg_uid=#{userInfo.id,jdbcType=BIGINT},</if>
|
<if test="commonGoods != null">cg_common_goods_id=#{commonGoods.id,jdbcType=BIGINT},
|
</if>
|
<if test="createTime != null">cg_createtime=#{createTime,jdbcType=TIMESTAMP},</if>
|
<if test="updateTime != null">cg_updatetime=#{updateTime,jdbcType=TIMESTAMP},</if>
|
</set>
|
where cg_id = #{id,jdbcType=BIGINT}
|
</update>
|
</mapper>
|