<?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.LabelMapper">
|
<resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.lable.Label">
|
<id column="lab_id" property="id" jdbcType="BIGINT"/>
|
<result column="lab_title" property="title" jdbcType="VARCHAR"/>
|
<result column="lab_picture" property="picture" jdbcType="VARCHAR"/>
|
<result column="lab_ios_click" property="iosClick" jdbcType="BIGINT"/>
|
<result column="lab_android_click" property="androidClick" jdbcType="BIGINT"/>
|
<result column="lab_entry_mode" property="entrymode" jdbcType="INTEGER"/>
|
<result column="lab_remark" property="remark" jdbcType="VARCHAR"/>
|
<result column="lab_createtime" property="createtime" jdbcType="TIMESTAMP"/>
|
<result column="lab_updatetime" property="updatetime" jdbcType="TIMESTAMP"/>
|
|
<association property="createUser" column="lab_entry_aid"
|
select="com.yeshi.fanli.dao.mybatis.AdminUserMapper.selectByPrimaryKey">
|
</association>
|
|
</resultMap>
|
|
<resultMap id="ResultMap" type="com.yeshi.fanli.entity.bus.lable.Label">
|
<id column="lab_id" property="id" jdbcType="BIGINT"/>
|
<result column="lab_title" property="title" jdbcType="VARCHAR"/>
|
<result column="lab_picture" property="picture" jdbcType="VARCHAR"/>
|
</resultMap>
|
|
<sql id="Base_Column_List">lab_id,lab_title,lab_picture,lab_ios_click,lab_android_click,lab_entry_aid,lab_entry_mode,lab_remark,lab_createtime,lab_updatetime</sql>
|
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
|
<include refid="Base_Column_List"/>from yeshi_ec_label where lab_id = #{id,jdbcType=BIGINT}
|
</select>
|
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_label where lab_id = #{id,jdbcType=BIGINT}</delete>
|
<insert id="insert" parameterType="com.yeshi.fanli.entity.bus.lable.Label" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_label (lab_id,lab_title,lab_picture,lab_ios_click,lab_android_click,lab_entry_aid,lab_entry_mode,lab_remark,lab_createtime,lab_updatetime) values (#{id,jdbcType=BIGINT},#{title,jdbcType=VARCHAR},#{picture,jdbcType=VARCHAR},#{iosClick,jdbcType=BIGINT},#{androidClick,jdbcType=BIGINT},#{createUser.id,jdbcType=BIGINT},#{entrymode,jdbcType=INTEGER},#{remark,jdbcType=VARCHAR},#{createtime,jdbcType=TIMESTAMP},#{updatetime,jdbcType=TIMESTAMP})</insert>
|
<insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.lable.Label" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_label
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="id != null">lab_id,</if>
|
<if test="title != null">lab_title,</if>
|
<if test="picture != null">lab_picture,</if>
|
<if test="iosClick != null">lab_ios_click,</if>
|
<if test="androidClick != null">lab_android_click,</if>
|
<if test="createUser != null">lab_entry_aid,</if>
|
<if test="entrymode != null">lab_entry_mode,</if>
|
<if test="remark != null">lab_remark,</if>
|
<if test="createtime != null">lab_createtime,</if>
|
<if test="updatetime != null">lab_updatetime,</if>
|
</trim>values
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="id != null">#{id,jdbcType=BIGINT},</if>
|
<if test="title != null">#{title,jdbcType=VARCHAR},</if>
|
<if test="picture != null">#{picture,jdbcType=VARCHAR},</if>
|
<if test="iosClick != null">#{iosClick,jdbcType=BIGINT},</if>
|
<if test="androidClick != null">#{androidClick,jdbcType=BIGINT},</if>
|
<if test="createUser != null">#{createUser.id,jdbcType=BIGINT},</if>
|
<if test="entrymode != null">#{entrymode,jdbcType=INTEGER},</if>
|
<if test="remark != null">#{remark,jdbcType=VARCHAR},</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.lable.Label">update yeshi_ec_label set lab_title = #{title,jdbcType=VARCHAR},lab_picture = #{picture,jdbcType=VARCHAR},lab_ios_click = #{iosClick,jdbcType=BIGINT},lab_android_click = #{androidClick,jdbcType=BIGINT},lab_entry_aid = #{createUser.id,jdbcType=BIGINT},lab_entry_mode = #{entrymode,jdbcType=INTEGER},lab_remark = #{remark,jdbcType=VARCHAR},lab_createtime = #{createtime,jdbcType=TIMESTAMP},lab_updatetime = #{updatetime,jdbcType=TIMESTAMP} where lab_id = #{id,jdbcType=BIGINT}</update>
|
<update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.lable.Label">update yeshi_ec_label
|
<set>
|
<if test="title != null">lab_title=#{title,jdbcType=VARCHAR},</if>
|
<if test="picture != null">lab_picture=#{picture,jdbcType=VARCHAR},</if>
|
<if test="iosClick != null">lab_ios_click=#{iosClick,jdbcType=BIGINT},</if>
|
<if test="androidClick != null">lab_android_click=#{androidClick,jdbcType=BIGINT},</if>
|
<if test="createUser != null">lab_entry_aid=#{createUser.id,jdbcType=BIGINT},</if>
|
<if test="entrymode != null">lab_entry_mode=#{entrymode,jdbcType=INTEGER},</if>
|
<if test="remark != null">lab_remark=#{remark,jdbcType=VARCHAR},</if>
|
<if test="createtime != null">lab_createtime=#{createtime,jdbcType=TIMESTAMP},</if>
|
<if test="updatetime != null">lab_updatetime=#{updatetime,jdbcType=TIMESTAMP},</if>
|
</set> where lab_id = #{id,jdbcType=BIGINT}
|
</update>
|
|
<select id="query" resultMap="BaseResultMap">
|
<!-- 根据条件查询所有标签 -->
|
SELECT <include refid="Base_Column_List" /> FROM yeshi_ec_label lb
|
LEFT JOIN yeshi_ec_adminuser ur ON lb.lab_entry_aid=ur.id
|
WHERE <![CDATA[1>0]]>
|
<if test='key != null and key != ""'>
|
AND (lb.lab_title like '%${key}%' OR ur.id like '%${key}%' OR ur.name like '%${key}%' )
|
</if>
|
<if test='startTime != null and startTime != ""'>
|
<![CDATA[ AND lb.lab_createtime >= '${startTime}' ]]>
|
</if>
|
<if test='endTime != null and endTime != ""'>
|
<![CDATA[ AND lb.lab_createtime <= '${endTime}' ]]>
|
</if>
|
ORDER BY (lb.lab_ios_click + lb.lab_android_click)
|
<if test='orderMode == 1'> DESC </if>
|
,lb.lab_createtime DESC LIMIT ${start},${count}
|
</select>
|
|
<select id="getQueryCount" resultType="java.lang.Integer">
|
<!-- 根据条件统计所有标签数量 -->
|
SELECT count(lab_id) FROM yeshi_ec_label lb
|
LEFT JOIN yeshi_ec_adminuser ur ON lb.lab_entry_aid=ur.id
|
WHERE <![CDATA[1>0]]>
|
<if test='key != null and key != ""'>
|
AND (lb.lab_title like '%${key}%' OR ur.id like '%${key}%' OR ur.name like '%${key}%' )
|
</if>
|
<if test='startTime != null and startTime != ""'>
|
<![CDATA[ AND lb.lab_createtime >= '${startTime}' ]]>
|
</if>
|
<if test='endTime != null and endTime != ""'>
|
<![CDATA[ AND lb.lab_createtime <= '${endTime}' ]]>
|
</if>
|
</select>
|
|
<select id="getCount" resultType="java.lang.Long">
|
<!-- 统计标签总数数量 -->
|
SELECT count(lab_id) FROM yeshi_ec_label lb
|
</select>
|
|
<select id="getCountToday" resultType="java.lang.Long">
|
<!-- 统计今日各种方式录入数量 -->
|
SELECT count(lab_id) FROM yeshi_ec_label
|
WHERE lab_createtime>= CURDATE();
|
</select>
|
|
<select id="getCountByEntryMode" resultType="java.util.HashMap">
|
<!-- 统计今日各种方式录入数量 -->
|
SELECT IFNULL(count(lab_id),0) AS total,
|
IFNULL(SUM(CASE WHEN lab_entry_mode = 1 THEN 1 ELSE 0 END),0) AS totalBack,
|
IFNULL(SUM(CASE WHEN lab_entry_mode = 2 THEN 1 ELSE 0 END),0) AS totalExcel
|
FROM yeshi_ec_label
|
</select>
|
|
<delete id="deleteBatchByPrimaryKey" parameterType="int">
|
<!-- 批量删除动态信息 -->
|
delete from yeshi_ec_label where lab_id in
|
<foreach item="ids" collection="array" open="(" separator=","
|
close=")">#{ids}</foreach>
|
</delete>
|
|
<select id="selectByTitle" resultMap="ResultMap">
|
select <include refid="Base_Column_List"/> from yeshi_ec_label
|
where lab_title = #{title}
|
</select>
|
|
|
<select id="listByTitles" parameterType="java.util.List" resultMap="ResultMap">
|
select * from yeshi_ec_label
|
where lab_title in <foreach collection="list" item="item" open="(" separator="," close=")">#{item}</foreach>
|
</select>
|
|
|
<select id="getByTitle" resultMap="ResultMap">
|
select * from yeshi_ec_label
|
WHERE lab_title = #{title}
|
limit 1
|
</select>
|
|
<!-- 查询商品标 签候选项 -->
|
<select id="queryGoodsCandidate" resultMap="BaseResultMap">
|
SELECT <include refid="Base_Column_List" /> FROM `yeshi_ec_label`
|
WHERE lab_id NOT IN (SELECT L.`lg_label_id` FROM `yeshi_ec_label_goods` L WHERE L.`lg_goods_id` = #{goodsId})
|
<if test='key != null and key != ""'>
|
AND lab_title like '%#{key}%'
|
</if>
|
ORDER BY lab_createtime LIMIT #{start},#{count}
|
</select>
|
<!-- 查询商品标 签候选项统计 -->
|
<select id="getCountQueryGoodsCandidate" resultType="java.lang.Integer">
|
SELECT count(lab_id) FROM `yeshi_ec_label`
|
WHERE lab_id NOT IN (SELECT L.`lg_label_id` FROM `yeshi_ec_label_goods` L WHERE L.`lg_goods_id` = #{goodsId})
|
<if test='key != null and key != ""'>
|
AND lab_title like '%#{key}%'
|
</if>
|
</select>
|
|
|
<!-- 查询一级分类 标签候选项 -->
|
<select id="queryClassCandidate" resultMap="BaseResultMap">
|
SELECT <include refid="Base_Column_List" /> FROM `yeshi_ec_label`
|
WHERE lab_id NOT IN ( SELECT lc_label_id FROM yeshi_ec_label_class WHERE lc_class_id = ${classId})
|
<if test='key != null and key != ""'>
|
AND lab_title like '%${key}%'
|
</if>
|
ORDER BY lab_createtime LIMIT ${start},${count}
|
</select>
|
<!-- 查询一级分类 标签候选项 -->
|
<select id="getCountQueryClassCandidate" resultType="java.lang.Integer">
|
SELECT count(lab_id) FROM `yeshi_ec_label`
|
WHERE lab_id NOT IN ( SELECT lc_label_id FROM yeshi_ec_label_class WHERE lc_class_id = ${classId})
|
<if test='key != null and key != ""'>
|
AND lab_title like '%${key}%'
|
</if>
|
</select>
|
|
|
<!-- 查询子集分类 标签候选项 -->
|
<select id="querySubClassCandidate" resultMap="BaseResultMap">
|
SELECT <include refid="Base_Column_List" /> FROM `yeshi_ec_label`
|
WHERE lab_id NOT IN (SELECT lc_label_id FROM yeshi_ec_label_class WHERE lc_subclass_id = ${subClassId})
|
<if test='key != null and key != ""'>
|
AND lab_title like '%${key}%'
|
</if>
|
ORDER BY lab_createtime LIMIT ${start},${count}
|
</select>
|
<!-- 查询子集分类 标签候选项 -->
|
<select id="getCountQuerySubClassCandidate" resultType="java.lang.Integer">
|
SELECT count(lab_id) FROM `yeshi_ec_label`
|
WHERE lab_id NOT IN (SELECT lc_label_id FROM yeshi_ec_label_class WHERE lc_subclass_id = ${subClassId})
|
<if test='key != null and key != ""'>
|
AND lab_title like '%${key}%'
|
</if>
|
</select>
|
|
<!-- 查询子集分类 标签候选项 -->
|
<select id="getSecondClassLables" resultMap="BaseResultMap">
|
SELECT <include refid="Base_Column_List" /> FROM `yeshi_ec_label`
|
WHERE lab_id NOT IN (SELECT lc_label_id FROM yeshi_ec_label_class WHERE lc_subclass_id = ${subClassId})
|
ORDER BY lab_createtime
|
</select>
|
|
|
<select id="getByGoodsId" resultMap="ResultMap">
|
SELECT * FROM `yeshi_ec_label` l
|
RIGHT JOIN `yeshi_ec_label_goods` g ON g.`lg_label_id` = l.`lab_id`
|
WHERE g.`lg_goods_id` = ${goodsId}
|
</select>
|
|
|
|
</mapper>
|