<?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.njzscloud.supervisory.goods.mapper.GoodsCategoryMapper">

    <select id="pagingWithStationName" resultType="com.njzscloud.supervisory.goods.pojo.entity.GoodsCategoryEntity">
        SELECT 
            gc.id,
            gc.category_name,
            gc.picture,
            gc.sort,
            gc.creator_id,
            gc.modifier_id,
            gc.create_time,
            gc.modify_time,
            gc.deleted,
            gc.enable,
            gc.inventory_type,
            gc.business_type,
            gc.weight,
            gc.station_id,
            bc.company_name as station_name
        FROM goods_category gc
        LEFT JOIN biz_company bc ON gc.station_id = bc.id AND bc.station = 1 AND bc.deleted = 0
        WHERE gc.deleted = 0
        <if test="entity.categoryName != null and entity.categoryName != ''">
            AND gc.category_name LIKE CONCAT('%', #{entity.categoryName}, '%')
        </if>
        <if test="entity.enable != null">
            AND gc.enable = #{entity.enable}
        </if>
        <if test="entity.inventoryType != null">
            AND gc.inventory_type = #{entity.inventoryType}
        </if>
        <if test="entity.businessType != null">
            AND gc.business_type = #{entity.businessType}
        </if>
        ORDER BY gc.sort ASC, gc.create_time DESC
    </select>

</mapper>