<?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.ScanHistoryV2Mapper">
|
<resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.goods.ScanHistoryV2">
|
<id column="s_id" property="id" jdbcType="BIGINT" />
|
<result column="s_device" property="device" jdbcType="VARCHAR" />
|
<result column="s_createtime" property="createTime" jdbcType="TIMESTAMP" />
|
<result column="s_updatetime" property="updateTime" jdbcType="TIMESTAMP" />
|
|
<association property="userInfo" column="s_uid"
|
javaType="com.yeshi.fanli.entity.bus.user.UserInfo">
|
<id column="s_uid" property="id" jdbcType="BIGINT" />
|
</association>
|
|
<association property="commonGoods" column="s_common_goods_id"
|
select="com.yeshi.fanli.dao.mybatis.goods.CommonGoodsMapper.selectByPrimaryKey">
|
</association>
|
|
</resultMap>
|
<sql id="Base_Column_List">s_id,s_device,s_uid,s_common_goods_id,s_createtime,s_updatetime
|
</sql>
|
<select id="selectByPrimaryKey" resultMap="BaseResultMap"
|
parameterType="java.lang.Long">
|
select
|
<include refid="Base_Column_List" />
|
from yeshi_ec_scanhistory_v2 where s_id = #{id,jdbcType=BIGINT}
|
</select>
|
|
<!-- 根据UID或者设备号获取浏览记录 -->
|
<select id="selectByDeviceOrUid" resultMap="BaseResultMap">
|
SELECT s.*,MAX(s.`s_id`) AS orderid FROM yeshi_ec_scanhistory_v2 s
|
WHERE
|
<trim prefix="(" suffix=")" suffixOverrides="or">
|
<if test="uid != null"> s.`s_uid`=#{uid,jdbcType=BIGINT} or</if>
|
<if test="device != null">s.`s_device`=#{device,jdbcType=VARCHAR} or</if>
|
</trim>
|
GROUP BY s.`s_common_goods_id` ORDER BY orderid DESC limit
|
#{start},#{count}
|
</select>
|
|
|
<!-- 根据UID或者设备号获取浏览记录条数 -->
|
|
<select id="selectCountByDeviceOrUid" resultType="java.lang.Long">
|
SELECT count(s.`s_id`) FROM yeshi_ec_scanhistory_v2 s
|
WHERE
|
<trim prefix="(" suffix=")" suffixOverrides="or">
|
<if test="uid != null"> s.`s_uid`=#{uid,jdbcType=BIGINT} or</if>
|
<if test="device != null">s.`s_device`=#{device,jdbcType=VARCHAR} or</if>
|
</trim>
|
</select>
|
|
|
|
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
|
yeshi_ec_scanhistory_v2 where s_id = #{id,jdbcType=BIGINT}
|
</delete>
|
|
<!-- 根据设备或用户ID删除 -->
|
|
<delete id="deleteByDeviceOrUid">
|
delete from
|
yeshi_ec_scanhistory_v2 where
|
<trim prefix="(" suffix=")" suffixOverrides="or">
|
<if test="uid != null"> `s_uid`=#{uid,jdbcType=BIGINT} or</if>
|
<if test="device != null">`s_device`=#{device,jdbcType=VARCHAR} or</if>
|
</trim>
|
</delete>
|
|
|
<!-- 根据设备或用户ID与商品信息检索 -->
|
<select id="selectByDeviceOrUidAndGoodsIdAndGoodsType"
|
resultMap="BaseResultMap">
|
SELECT s.* FROM yeshi_ec_scanhistory_v2 s left join
|
yeshi_ec_common_goods g on g.cg_id=s.s_common_goods_id
|
WHERE
|
<trim prefix="(" suffix=")" suffixOverrides="or">
|
<if test="uid != null"> s.`s_uid`=#{uid,jdbcType=BIGINT} or</if>
|
<if test="device != null">s.`s_device`=#{device,jdbcType=VARCHAR} or</if>
|
</trim>
|
and g.cg_goods_id=#{goodsId} and g.cg_goods_type=#{goodsType}
|
</select>
|
|
|
<insert id="insert" parameterType="com.yeshi.fanli.entity.goods.ScanHistoryV2"
|
useGeneratedKeys="true" keyProperty="id">insert into
|
yeshi_ec_scanhistory_v2
|
(s_id,s_device,s_uid,s_common_goods_id,s_createtime,s_updatetime)
|
values
|
(#{id,jdbcType=BIGINT},#{device,jdbcType=VARCHAR},#{userInfo.id,jdbcType=BIGINT},#{commonGoods.id,jdbcType=BIGINT},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})
|
</insert>
|
|
<insert id="insertSelective" parameterType="com.yeshi.fanli.entity.goods.ScanHistoryV2"
|
useGeneratedKeys="true" keyProperty="id">
|
insert into yeshi_ec_scanhistory_v2
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="id != null">s_id,</if>
|
<if test="device != null">s_device,</if>
|
<if test="userInfo != null">s_uid,</if>
|
<if test="commonGoods != null">s_common_goods_id,</if>
|
<if test="createTime != null">s_createtime,</if>
|
<if test="updateTime != null">s_updatetime,</if>
|
</trim>
|
values
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="id != null">#{id,jdbcType=BIGINT},</if>
|
<if test="device != null">#{device,jdbcType=VARCHAR},</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.ScanHistoryV2">update
|
yeshi_ec_scanhistory_v2 set s_device =
|
#{device,jdbcType=VARCHAR},s_uid =
|
#{userInfo.id,jdbcType=BIGINT},s_common_goods_id =
|
#{commonGoods.id,jdbcType=BIGINT},s_createtime =
|
#{createTime,jdbcType=TIMESTAMP},s_updatetime =
|
#{updateTime,jdbcType=TIMESTAMP} where s_id = #{id,jdbcType=BIGINT}
|
</update>
|
<update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.goods.ScanHistoryV2">
|
update yeshi_ec_scanhistory_v2
|
<set>
|
<if test="device != null">s_device=#{device,jdbcType=VARCHAR},</if>
|
<if test="userInfo != null">s_uid=#{userInfo.id,jdbcType=BIGINT},</if>
|
<if test="commonGoods != null">s_common_goods_id=#{commonGoods.id,jdbcType=BIGINT},
|
</if>
|
<if test="createTime != null">s_createtime=#{createTime,jdbcType=TIMESTAMP},</if>
|
<if test="updateTime != null">s_updatetime=#{updateTime,jdbcType=TIMESTAMP},</if>
|
</set>
|
where s_id = #{id,jdbcType=BIGINT}
|
</update>
|
</mapper>
|