<?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.platform.dao.GoodsCustomDao">

    <select id="getGoodsCategory" resultType="java.util.Map">
        select
         goods.category_id , category.name
        from nideshop_goods goods
        LEFT JOIN nideshop_category category
        ON goods.category_id = category.id
        ${ew.customSqlSegment}
        group by goods.category_id
    </select>


    <select id="queryGoodsByBrandId" resultType="java.util.Map">
        select
        goods.id,
        goods.category_id categoryId,
        goods.name,
        goods.goods_number goodsNumber,
        goods.goods_desc goodsDesc,
        goods.is_on_sale isOnSale,
        goods.add_time addTime,
        goods.update_time updateTime,
        goods.primary_pic_url primaryPicUrl,
        goods.list_pic_url listPicUrl,
        goods.retail_price retailPrice,
        goods.is_hot isHot,
        goods.market_price marketPrice,
        category.name categoryName,
        attribute.name attributeCategoryName,
        brand.id brandId,
        brand.name brandName
        from nideshop_goods goods
        LEFT JOIN nideshop_category category
        ON goods.category_id = category.id
        LEFT JOIN nideshop_attribute_category attribute ON goods.attribute_category = attribute.id
        LEFT JOIN nideshop_brand brand ON brand.id = goods.brand_id
        WHERE 1=1
        <if test="goodsName != null and goodsName.trim() != ''">
            AND goods.name LIKE concat('%',#{goodsName},'%')
        </if>
        <if test="brandId != null">
            AND goods.brand_id = #{brandId}
        </if>
        <if test="categoryId != null">
            AND goods.category_id = #{categoryId}
        </if>
        AND goods.is_Delete = 0

       order by goods.id desc
        <!--${ew.customSqlSegment}-->
    </select>
</mapper>