<?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.mall.product.mapper.CategoryMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.mall.product.domain.entity.CategoryEntity">
        <id column="cat_id" property="catId"/>
        <id column="name" property="name"/>
        <id column="parent_cid" property="parentCid"/>
        <id column="cat_level" property="catLevel"/>
        <id column="show_status" property="showStatus"/>
        <id column="sort" property="sort"/>
        <id column="icon" property="icon"/>
        <id column="product_unit" property="productUnit"/>
        <id column="product_count" property="productCount"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        cat_id,name,parent_cid,cat_level,show_status,sort,icon,product_unit,product_count
    </sql>

    <!-- 分页查询商品三级分类内容 -->
    <select id="selectListByPage" resultType="com.mall.product.domain.vo.CategoryVo">
        select
        <include refid="Base_Column_List"/>
        from pms_category
        <where>
            <if test="dto.catId != null and dto.catId != ''">
                and cat_id like CONCAT('%',#{dto.catId},'%')
            </if>
            <if test="dto.name != null and dto.name != ''">
                and name like CONCAT('%',#{dto.name},'%')
            </if>
            <if test="dto.parentCid != null and dto.parentCid != ''">
                and parent_cid like CONCAT('%',#{dto.parentCid},'%')
            </if>
            <if test="dto.catLevel != null and dto.catLevel != ''">
                and cat_level like CONCAT('%',#{dto.catLevel},'%')
            </if>
            <if test="dto.showStatus != null and dto.showStatus != ''">
                and show_status like CONCAT('%',#{dto.showStatus},'%')
            </if>
            <if test="dto.sort != null and dto.sort != ''">
                and sort like CONCAT('%',#{dto.sort},'%')
            </if>
            <if test="dto.icon != null and dto.icon != ''">
                and icon like CONCAT('%',#{dto.icon},'%')
            </if>
            <if test="dto.productUnit != null and dto.productUnit != ''">
                and product_unit like CONCAT('%',#{dto.productUnit},'%')
            </if>
            <if test="dto.productCount != null and dto.productCount != ''">
                and product_count like CONCAT('%',#{dto.productCount},'%')
            </if>
        </where>
    </select>

</mapper>
