<?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="cn.xluobo.business.stock.goods.repo.mapper.StockGoodsMapper">

    <select id="selectByCondition" resultType="cn.xluobo.business.stock.goods.repo.model.StockGoods">
        select a.*,sc.category_name from stock_goods a left join stock_category sc on a.category_id = sc.category_id
        where a.delete_flag='0'
        <if test="reqSearchStockGoods.categoryId != null and reqSearchStockGoods.categoryId != ''">
            and a.category_id=#{reqSearchStockGoods.categoryId}
        </if>
        <if test="reqSearchStockGoods.goodsName != null and reqSearchStockGoods.goodsName != ''">
            and a.goods_name like concat('%', #{reqSearchStockGoods.goodsName}, '%')
        </if>
        <if test="reqSearchStockGoods.sale != null and reqSearchStockGoods.sale != ''">
            and a.sale = #{reqSearchStockGoods.sale}
        </if>
        order by create_time desc
    </select>
</mapper>
