<?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.AttrMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.mall.product.domain.entity.Attr">
            <id column="attr_id" property="attrId"/>
            <id column="attr_name" property="attrName"/>
            <id column="search_type" property="searchType"/>
            <id column="value_type" property="valueType"/>
            <id column="icon" property="icon"/>
            <id column="value_select" property="valueSelect"/>
            <id column="attr_type" property="attrType"/>
            <id column="enable" property="enable"/>
            <id column="catelog_id" property="catelogId"/>
            <id column="show_desc" property="showDesc"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        attr_id,attr_name,search_type,value_type,icon,value_select,attr_type,enable,catelog_id,show_desc
    </sql>

    <!-- 分页查询商品属性内容 -->
    <select id="selectListByPage" resultType="com.mall.product.domain.vo.AttrVo">
        select
        <include refid="Base_Column_List"/>
        from pms_attr
        <where>
                <if test="dto.attrId != null and dto.attrId != ''">
                    and attr_id like CONCAT('%',#{dto.attrId},'%')
                </if>
                <if test="dto.attrName != null and dto.attrName != ''">
                    and attr_name like CONCAT('%',#{dto.attrName},'%')
                </if>
                <if test="dto.searchType != null and dto.searchType != ''">
                    and search_type like CONCAT('%',#{dto.searchType},'%')
                </if>
                <if test="dto.valueType != null and dto.valueType != ''">
                    and value_type like CONCAT('%',#{dto.valueType},'%')
                </if>
                <if test="dto.icon != null and dto.icon != ''">
                    and icon like CONCAT('%',#{dto.icon},'%')
                </if>
                <if test="dto.valueSelect != null and dto.valueSelect != ''">
                    and value_select like CONCAT('%',#{dto.valueSelect},'%')
                </if>
                <if test="dto.attrType != null and dto.attrType != ''">
                    and attr_type like CONCAT('%',#{dto.attrType},'%')
                </if>
                <if test="dto.enable != null and dto.enable != ''">
                    and enable like CONCAT('%',#{dto.enable},'%')
                </if>
                <if test="dto.catelogId != null and dto.catelogId != ''">
                    and catelog_id like CONCAT('%',#{dto.catelogId},'%')
                </if>
                <if test="dto.showDesc != null and dto.showDesc != ''">
                    and show_desc like CONCAT('%',#{dto.showDesc},'%')
                </if>
        </where>
    </select>

</mapper>
