<?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.fzm.mall.server.front.goods.mapper.SpuMapper">

    <select id="getByCategoryId" resultType="com.fzm.mall.server.front.goods.model.vo.GoodsVo">
        select a.*,c.shop_name as merchantName,c.* from goods_spu a left join goods_count b on a.goods_id = b.goods_id left join  shop c on a.merchant_id = c.merchant_id
        left join goods_category_spu d on d.goods_id = a.goods_id where d.category_id = #{categoryId}  and a.status = 1 order by a.default_price ${price},b.sales ${sale},a.create_time desc limit ${start},${end};
    </select>

    <select id="getSearch" resultType="com.fzm.mall.server.front.goods.model.vo.GoodsVo">
        select a.*,c.shop_name as merchantName,c.* from goods_spu a left join goods_count b on a.goods_id = b.goods_id left join  shop c on a.merchant_id = c.merchant_id
        where a.name like  #{searchKey} and a.status = 1 order by a.default_price ${price},b.sales ${sale},a.create_time desc limit ${start},${end};
    </select>

    <select id="getByGoodsId" resultType="com.fzm.mall.server.front.goods.model.vo.GoodsVo">
        select a.*,c.shop_name as merchantName,c.* from goods_spu a left join goods_count b on a.goods_id = b.goods_id left join  shop c on a.merchant_id = c.merchant_id
        where a.goods_id = #{goodsId}  and a.status = 1;
    </select>
</mapper>
