<?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.ruoyi.mall.mapper.ProductCategoryMapper">

    <resultMap type="ProductCategory" id="ProductCategoryResult">
        <result property="id" column="id"/>
        <result property="parentId" column="parent_id"/>
        <result property="name" column="name"/>
        <result property="level" column="level"/>
        <result property="showStatus" column="show_status"/>
        <result property="sort" column="sort"/>
        <result property="icon" column="icon"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time" />
        <result property="storeId" column="store_id" />
    </resultMap>

    <sql id="selectProductCategoryVo">
        select id, parent_id, name, level, show_status, sort, icon, create_by, create_time, update_by, update_time   from pms_product_category
    </sql>

    <select id="selectByEntity" parameterType="ProductCategory" resultMap="ProductCategoryResult">
        <include refid="selectProductCategoryVo"/>
        <where>
            <if test="parentId != null "> and parent_id = #{parentId}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="level != null "> and level = #{level}</if>
            <if test="showStatus != null "> and show_status = #{showStatus}</if>
            <if test="sort != null "> and sort = #{sort}</if>
            <if test="icon != null  and icon != ''"> and icon = #{icon}</if>
        </where>
    </select>
</mapper>
