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.
 
 

108 lines
5.1 KiB

<?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="cc.hiver.mall.dao.mapper.GoodsMapper">
<resultMap id="BaseResultMap" type="cc.hiver.mall.pojo.vo.GoodsPageVO">
<id property="id" column="id" jdbcType="VARCHAR"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="categoryId" column="category_id" jdbcType="BIGINT"/>
<result property="brandId" column="brand_id" jdbcType="BIGINT"/>
<result property="purchasePrice" column="purchase_price" jdbcType="BIGINT"/>
<result property="price" column="price" jdbcType="BIGINT"/>
<result property="wholesalePrice" column="wholesale_price" jdbcType="BIGINT"/>
<result property="sales" column="sales" jdbcType="INTEGER"/>
<result property="picUrl" column="pic_url" jdbcType="VARCHAR"/>
<result property="album" column="album" jdbcType="VARCHAR"/>
<result property="unit" column="unit" jdbcType="VARCHAR"/>
<result property="description" column="description" jdbcType="VARCHAR"/>
<result property="detail" column="detail" jdbcType="VARCHAR"/>
<result property="status" column="status" jdbcType="TINYINT"/>
<result property="categoryName" column="categoryName" jdbcType="VARCHAR"/>
<result property="brandName" column="brandName" jdbcType="VARCHAR"/>
<collection property="goodsStockList" column="id" select="cc.hiver.mall.dao.mapper.GoodsStockMapper.listGoodsByGoodsId">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="sn" column="sn" jdbcType="VARCHAR"/>
<result property="picUrl" column="pic_url" jdbcType="VARCHAR"/>
<result property="specIds" column="spec_ids" jdbcType="VARCHAR"/>
<result property="purchasePrice" column="purchase_price" jdbcType="BIGINT"/>
<result property="price" column="price" jdbcType="BIGINT"/>
<result property="wholesalePrice" column="wholesale_price" jdbcType="BIGINT"/>
<result property="stock" column="stock" jdbcType="INTEGER"/>
<result property="lockedStock" column="locked_stock" jdbcType="INTEGER"/>
</collection>
</resultMap>
<!--管理商品分页列表-->
<select id="listGoodsPages" resultMap="BaseResultMap">
SELECT
t1.id,
t1.name,
t1.pic_url,
t1.purchase_price,
t1.price,
t1.wholesale_price,
t1.sales,
t1.unit,
t1.detail,
t1.description,
t3.NAME categoryName,
t4.NAME brandName
FROM t_goods t1
LEFT JOIN t_goods_category t3 ON t1.category_id = t3.id
LEFT JOIN t_goods_brand t4 ON t1.brand_id = t4.id
<where>
<if test='queryParams.keywords!=null and queryParams.keywords.trim() neq ""'>
AND t1.name like concat('%',#{queryParams.keywords},'%')
</if>
<if test='queryParams.categoryId!=null and queryParams.categoryId.trim() neq ""'>
AND t1.category_id =#{queryParams.categoryId}
</if>
<if test='queryParams.brandId!=null and queryParams.brandId.trim() neq ""'>
AND t1.brand_id = #{queryParams.brandId}
</if>
<if test='queryParams.shopId!=null and queryParams.shopId.trim() neq ""'>
AND t1.shop_id = #{queryParams.shopId}
</if>
</where>
ORDER BY
<if test='queryParams.sortField!=null and queryParams.sortField.trim() neq "" and queryParams.sortField !=null and queryParams.sort.trim() neq ""'>
#{queryParams.sortField} #{queryParams.sort} ,
</if>
t1.create_time desc
</select>
<select id="listMallGoodsPages" resultType="cc.hiver.mall.pojo.vo.MallGoodsPageVO">
SELECT
id,
name,
pic_url,
purchase_price,
price,
wholesale_price,
sales
FROM
`t_goods`
<where>
<if test='queryParams.keywords!=null and queryParams.keywords.trim() neq ""'>
AND name like concat('%',#{queryParams.keywords},'%')
</if>
<if test='queryParams.categoryId!=null and queryParams.categoryId.trim() neq ""'>
AND category_id =#{queryParams.categoryId}
</if>
<if test='queryParams.brandId!=null and queryParams.brandId.trim() neq ""'>
AND brand_id = #{queryParams.brandId}
</if>
<if test='queryParams.shopId!=null and queryParams.shopId.trim() neq ""'>
AND shop_id = #{queryParams.shopId}
</if>
</where>
ORDER BY
<if test='queryParams.sortField!=null and queryParams.sortField.trim() neq "" and queryParams.sortField !=null and queryParams.sort.trim() neq ""'>
#{queryParams.sortField} #{queryParams.sort} ,
</if>
create_time desc
</select>
</mapper>