You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
5.5 KiB

3 years ago
<?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.qs.serve.modules.goods.mapper.GoodsSpuMapper">
<resultMap id="goodsSpuMap" type="com.qs.serve.modules.goods.entity.GoodsSpu" >
<result property="id" column="id"/>
<result property="spuCode" column="spu_code"/>
<result property="name" column="name"/>
<result property="categoryFirst" column="category_first"/>
<result property="categorySecond" column="category_second"/>
<result property="categoryThird" column="category_third"/>
<result property="categoryLast" column="category_last"/>
<result property="picUrls" column="pic_urls" typeHandler="com.qs.serve.common.framework.mybatis.handler.meta.SplitStringTypeHandler" />
<result property="shelf" column="shelf"/>
<result property="sort" column="sort"/>
<result property="saleNum" column="sale_num"/>
<result property="tasteValue" column="taste_value"/>
<result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/>
<result property="createBy" column="create_by"/>
<result property="updateBy" column="update_by"/>
<result property="tenantId" column="tenant_id"/>
<result property="delFlag" column="del_flag"/>
<result property="costFlag" column="cost_flag"/>
3 years ago
<result property="cateFirstLabel" column="cate_first_label"/>
<result property="cateSecondLabel" column="cate_second_label"/>
<result property="cateThirdLabel" column="cate_third_label"/>
3 years ago
</resultMap>
<sql id="goodsSpuSql">
goods_spu.`id`,
goods_spu.`spu_code`,
goods_spu.`name`,
goods_spu.`category_first`,
goods_spu.`category_second`,
goods_spu.`category_third`,
goods_spu.`category_last`,
goods_spu.`pic_urls`,
goods_spu.`shelf`,
goods_spu.`sort`,
goods_spu.`sale_num`,
goods_spu.`spec_type`,
goods_spu.`taste_value`,
goods_spu.`create_time`,
goods_spu.`update_time`,
goods_spu.`create_by`,
goods_spu.`update_by`,
goods_spu.`tenant_id`,
goods_spu.`cost_flag`,
3 years ago
goods_spu.`del_flag` </sql>
3 years ago
<select id="selectSpuList" parameterType="com.qs.serve.modules.goods.entity.GoodsSpu" resultMap="goodsSpuMap">
3 years ago
SELECT
3 years ago
`cate1`.`name` AS `cate_first_label`,
`cate2`.`name` AS `cate_second_label`,
`cate3`.`name` AS `cate_third_label`,
3 years ago
<include refid="goodsSpuSql"/>
FROM `goods_spu` `goods_spu`
3 years ago
LEFT JOIN `goods_category` `cate1` ON `cate1`.`id` = `goods_spu`.`category_first`
LEFT JOIN `goods_category` `cate2` ON `cate2`.`id` = `goods_spu`.`category_second`
LEFT JOIN `goods_category` `cate3` ON `cate3`.`id` = `goods_spu`.`category_third`
3 years ago
<where>
2 years ago
and `goods_spu`.`del_flag` = 0
3 years ago
<if test="query.id != null"> and `goods_spu`.`id` = #{query.id}</if>
2 years ago
<if test="query.spuCode != null and query.spuCode != ''"> and `goods_spu`.`spu_code` like concat('%', #{query.spuCode},'%')</if>
<if test="query.name != null and query.name != ''"> and `goods_spu`.`name` like concat('%', #{query.name},'%') </if>
3 years ago
<if test="query.categoryFirst != null"> and `goods_spu`.`category_first` = #{query.categoryFirst}</if>
<if test="query.categorySecond != null"> and `goods_spu`.`category_second` = #{query.categorySecond}</if>
<if test="query.categoryThird != null"> and `goods_spu`.`category_third` = #{query.categoryThird}</if>
<if test="query.categoryLast != null"> and `goods_spu`.`category_last` = #{query.categoryLast}</if>
<if test="query.shelf != null and query.shelf != ''"> and `goods_spu`.`shelf` = #{query.shelf}</if>
<if test="query.sort != null"> and `goods_spu`.`sort` = #{query.sort}</if>
<if test="query.saleNum != null"> and `goods_spu`.`sale_num` = #{query.saleNum}</if>
<if test="query.tasteValue != null and query.tasteValue != ''"> and `goods_spu`.`taste_value` = #{query.tasteValue}</if>
<if test="query.createTime != null"> and `goods_spu`.`create_time` = #{query.createTime}</if>
<if test="query.updateTime != null"> and `goods_spu`.`update_time` = #{query.updateTime}</if>
<if test="query.createBy != null and query.createBy != ''"> and `goods_spu`.`create_by` = #{query.createBy}</if>
<if test="query.updateBy != null and query.updateBy != ''"> and `goods_spu`.`update_by` = #{query.updateBy}</if>
<if test="query.tenantId != null and query.tenantId != ''"> and `goods_spu`.`tenant_id` = #{query.tenantId}</if>
<if test="query.delFlag != null and query.delFlag != ''"> and `goods_spu`.`del_flag` = #{query.delFlag}</if>
3 years ago
<if test="query.searchValue != null and query.searchValue != ''"> and (`goods_spu`.`name` like concat('%',#{query.searchValue},'%') or `goods_spu`.`goods_spu` like concat('%',#{query.searchValue},'%')) </if>
<if test="query.selectIds!=null and query.selectIds.size > 0">
and `goods_spu`.`id` in
<foreach collection="query.selectIds" item ="selectId" index="i" open="(" close=")" separator=",">
#{selectId}
</foreach>
</if>
3 years ago
</where>
</select>
</mapper>