<?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.lable.LabelGoodsMapper">
|
<resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.lable.LabelGoods">
|
<id column="lg_id" property="id" jdbcType="BIGINT"/>
|
<result column="lg_weight" property="weight" jdbcType="DOUBLE"/>
|
<result column="lg_createtime" property="createtime" jdbcType="TIMESTAMP"/>
|
<result column="lg_updatetime" property="updatetime" jdbcType="TIMESTAMP"/>
|
|
<association property="taoBaoGoodsBrief" column="sg_goods_id"
|
select="com.yeshi.fanli.dao.mybatis.taobao.TaoBaoGoodsBriefMapper.selectByPrimaryKey">
|
</association>
|
|
<association property="label" column="lg_label_id"
|
select="com.yeshi.fanli.dao.mybatis.lable.LabelMapper.selectByPrimaryKey">
|
</association>
|
|
<association property="createUser" column="lg_create_aid" javaType="com.yeshi.fanli.entity.common.AdminUser">
|
<id column="lg_create_aid" property="id" jdbcType="BIGINT" />
|
</association>
|
</resultMap>
|
|
<resultMap id="ResultMap" type="com.yeshi.fanli.entity.bus.lable.LabelGoods">
|
<id column="lg_id" property="id" jdbcType="BIGINT"/>
|
<result column="lg_weight" property="weight" jdbcType="DOUBLE"/>
|
<result column="lg_createtime" property="createtime" jdbcType="TIMESTAMP"/>
|
<result column="lg_updatetime" property="updatetime" jdbcType="TIMESTAMP"/>
|
|
<association property="label" column="lg_label_id" javaType="com.yeshi.fanli.entity.bus.lable.Label">
|
<id column="lg_label_id" property="id" jdbcType="BIGINT" />
|
</association>
|
|
</resultMap>
|
|
|
<sql id="Base_Column_List">lg_id,lg_label_id,lg_goods_id,lg_create_aid,lg_weight,lg_createtime,lg_updatetime</sql>
|
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
|
<include refid="Base_Column_List"/>from yeshi_ec_label_goods where lg_id = #{id,jdbcType=BIGINT}
|
</select>
|
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_label_goods where lg_id = #{id,jdbcType=BIGINT}</delete>
|
<insert id="insert" parameterType="com.yeshi.fanli.entity.bus.lable.LabelGoods" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_label_goods (lg_id,lg_label_id,lg_goods_id,lg_create_aid,lg_weight,lg_createtime,lg_updatetime) values (#{id,jdbcType=BIGINT},#{label.id,jdbcType=BIGINT},#{taoBaoGoodsBrief.id,jdbcType=BIGINT},#{createUser.id,jdbcType=BIGINT},#{weight,jdbcType=DOUBLE},#{createtime,jdbcType=TIMESTAMP},#{updatetime,jdbcType=TIMESTAMP})</insert>
|
<insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.lable.LabelGoods" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_label_goods
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="id != null">lg_id,</if>
|
<if test="label != null">lg_label_id,</if>
|
<if test="taoBaoGoodsBrief != null">lg_goods_id,</if>
|
<if test="createUser != null">lg_create_aid,</if>
|
<if test="weight != null">lg_weight,</if>
|
<if test="createtime != null">lg_createtime,</if>
|
<if test="updatetime != null">lg_updatetime,</if>
|
</trim>values
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="id != null">#{id,jdbcType=BIGINT},</if>
|
<if test="label != null">#{label.id,jdbcType=BIGINT},</if>
|
<if test="taoBaoGoodsBrief != null">#{taoBaoGoodsBrief.id,jdbcType=BIGINT},</if>
|
<if test="createUser != null">#{createUser.id,jdbcType=BIGINT},</if>
|
<if test="weight != null">#{weight,jdbcType=DOUBLE},</if>
|
<if test="createtime != null">#{createtime,jdbcType=TIMESTAMP},</if>
|
<if test="updatetime != null">#{updatetime,jdbcType=TIMESTAMP},</if>
|
</trim>
|
</insert>
|
|
<insert id="insertBatch" parameterType="java.util.List">
|
INSERT IGNORE yeshi_ec_label_goods
|
(<include refid="Base_Column_List" />)
|
values
|
|
<foreach collection="list" item="item" separator=",">
|
(
|
#{item.id,jdbcType=BIGINT},
|
#{item.label.id,jdbcType=BIGINT},
|
#{item.taoBaoGoodsBrief.id,jdbcType=BIGINT},
|
#{item.createUser.id,jdbcType=BIGINT},
|
#{item.weight,jdbcType=DOUBLE},
|
#{item.createtime,jdbcType=TIMESTAMP},
|
#{item.updatetime,jdbcType=TIMESTAMP}
|
)
|
|
</foreach>
|
</insert>
|
|
<update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.lable.LabelGoods">update yeshi_ec_label_goods set lg_label_id = #{label.id,jdbcType=BIGINT},lg_goods_id = #{taoBaoGoodsBrief.id,jdbcType=BIGINT},lg_create_aid = #{createUser.id,jdbcType=BIGINT},lg_weight = #{weight,jdbcType=DOUBLE},lg_createtime = #{createtime,jdbcType=TIMESTAMP},lg_updatetime = #{updatetime,jdbcType=TIMESTAMP} where lg_id = #{id,jdbcType=BIGINT}</update>
|
<update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.lable.LabelGoods">update yeshi_ec_label_goods
|
<set>
|
<if test="label != null">lg_label_id=#{label.id,jdbcType=BIGINT},</if>
|
<if test="taoBaoGoodsBrief != null">lg_goods_id=#{taoBaoGoodsBrief.id,jdbcType=BIGINT},</if>
|
<if test="createUser != null">lg_create_aid=#{createUser.id,jdbcType=BIGINT},</if>
|
<if test="weight != null">lg_weight=#{weight,jdbcType=DOUBLE},</if>
|
<if test="createtime != null">lg_createtime=#{createtime,jdbcType=TIMESTAMP},</if>
|
<if test="updatetime != null">lg_updatetime=#{updatetime,jdbcType=TIMESTAMP},</if>
|
</set> where lg_id = #{id,jdbcType=BIGINT}
|
</update>
|
|
<delete id="deleteBatchByPrimaryKey" parameterType="int">
|
<!-- 批量删除信息 -->
|
delete from yeshi_ec_label_goods where lg_id in
|
<foreach item="ids" collection="array" open="(" separator=","
|
close=")">#{ids}</foreach>
|
</delete>
|
|
<delete id="deleteBatchByPK" parameterType="java.util.List">
|
delete FROM yeshi_ec_label_goods WHERE lg_id in
|
<foreach collection="list" item="item" open="(" close=")"
|
separator=",">#{item}</foreach>
|
</delete>
|
|
|
<delete id="deleteByAuctionIdAndLabIDs">
|
delete FROM yeshi_ec_label_goods
|
WHERE lg_goods_id = #{auctionId} AND lg_label_id in
|
<foreach collection="list" item="item" open="(" close=")"
|
separator=",">#{item}</foreach>
|
</delete>
|
|
|
|
|
<select id="isExistence" resultType="java.lang.Long">
|
<!-- 判断是否已贴过标签 -->
|
SELECT ifnull(COUNT(g.`lg_id`),0) FROM `yeshi_ec_label_goods` g
|
WHERE g.`lg_goods_id` = #{goodsId}
|
AND g.`lg_label_id`= #{labelId}
|
</select>
|
|
<select id="getCountByGoodsId" resultType="java.lang.Long">
|
<!--统计商品的标签个数 -->
|
SELECT COUNT(g.`lg_id`) FROM `yeshi_ec_label_goods` g WHERE g.`lg_goods_id` = ${goodsId}
|
</select>
|
|
<delete id="deleteByGoodsId" parameterType="java.lang.Long">
|
delete from yeshi_ec_label_goods where lg_goods_id = #{goodsId,jdbcType=BIGINT}
|
</delete>
|
|
|
<delete id="deleteBatchByGoodsId" parameterType="java.util.List">
|
delete FROM yeshi_ec_label_goods WHERE lg_goods_id in
|
<foreach collection="list" item="item" open="(" close=")"
|
separator=",">#{item}</foreach>
|
</delete>
|
|
<delete id="deleteByLabId" parameterType="java.lang.Long">
|
delete from yeshi_ec_label_goods where lg_label_id = #{labId,jdbcType=BIGINT}
|
</delete>
|
|
<delete id="deleteByGoodsIdAndLabId" parameterType="java.lang.Long">
|
delete from yeshi_ec_label_goods where lg_goods_id = #{goodsId,jdbcType=BIGINT} and lg_label_id = #{labId,jdbcType=BIGINT}
|
</delete>
|
|
<select id="getRelationNum" resultType="java.lang.Long">
|
<!--查询商品对应标签 -->
|
SELECT COUNT(DISTINCT lb.`lg_goods_id`) FROM yeshi_ec_label_goods lb WHERE lb.`lg_label_id`=${labelId} GROUP BY lb.`lg_label_id`
|
</select>
|
|
<!--查询子类对应标签(分页) -->
|
<select id="queryByGoodsId" resultMap="BaseResultMap">
|
SELECT <include refid="Base_Column_List"/> FROM yeshi_ec_label_goods
|
WHERE lg_goods_id = ${goodsId} ORDER BY lg_createtime LIMIT ${start},${count}
|
</select>
|
|
<select id="getCountQueryByGoodsId" resultType="java.lang.Integer">
|
SELECT count(lg_id) FROM yeshi_ec_label_goods WHERE lg_goods_id = ${goodsId}
|
</select>
|
|
<select id="listQuery" resultMap="BaseResultMap">
|
SELECT DISTINCT a.lg_goods_id FROM (SELECT <include refid="Base_Column_List" /> FROM yeshi_ec_label_goods
|
WHERE <![CDATA[ 1>0 ]]>
|
<if test="labIds != null">
|
AND lg_label_id in
|
<foreach collection="labIds" item="labId" open="(" separator="," close=")">
|
#{labId}
|
</foreach>
|
</if>
|
|
ORDER BY lg_weight desc
|
)A
|
LIMIT ${start},${count}
|
</select>
|
|
<select id="countQuery" resultType="java.lang.Long">
|
SELECT DISTINCT a.lg_goods_id FROM (SELECT IFNULL(count(lg_id),0) FROM yeshi_ec_label_goods
|
WHERE <![CDATA[ 1>0 ]]>
|
<if test="labIds != null">
|
AND lg_label_id in
|
<foreach collection="labIds" item="labId" open="(" separator="," close=")">
|
#{labId}
|
</foreach>
|
</if>
|
)A
|
</select>
|
|
|
<select id="listQuery9k9Class" resultMap="ResultMap">
|
SELECT <include refid="Base_Column_List"/> FROM yeshi_ec_label_goods g
|
WHERE g.`lg_goods_id` = #{gid}
|
AND g.`lg_label_id` IN
|
<foreach collection="list" item="labId" open="(" separator="," close=")">
|
#{labId}
|
</foreach>
|
</select>
|
|
</mapper>
|