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

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.mall.product.domain.entity.SpuInfo">
            <id column="id" property="id"/>
            <id column="spu_name" property="spuName"/>
            <id column="spu_description" property="spuDescription"/>
            <id column="catalog_id" property="catalogId"/>
            <id column="brand_id" property="brandId"/>
            <id column="weight" property="weight"/>
            <id column="publish_status" property="publishStatus"/>
            <id column="create_time" property="createTime"/>
            <id column="update_time" property="updateTime"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id,spu_name,spu_description,catalog_id,brand_id,weight,publish_status,create_time,update_time
    </sql>

    <!-- 分页查询spu信息内容 -->
    <select id="selectListByPage" resultType="com.mall.product.domain.vo.SpuInfoVo">
        select
        <include refid="Base_Column_List"/>
        from pms_spu_info
        <where>
                <if test="dto.id != null and dto.id != ''">
                    and id like CONCAT('%',#{dto.id},'%')
                </if>
                <if test="dto.spuName != null and dto.spuName != ''">
                    and spu_name like CONCAT('%',#{dto.spuName},'%')
                </if>
                <if test="dto.spuDescription != null and dto.spuDescription != ''">
                    and spu_description like CONCAT('%',#{dto.spuDescription},'%')
                </if>
                <if test="dto.catalogId != null and dto.catalogId != ''">
                    and catalog_id like CONCAT('%',#{dto.catalogId},'%')
                </if>
                <if test="dto.brandId != null and dto.brandId != ''">
                    and brand_id like CONCAT('%',#{dto.brandId},'%')
                </if>
                <if test="dto.weight != null and dto.weight != ''">
                    and weight like CONCAT('%',#{dto.weight},'%')
                </if>
                <if test="dto.publishStatus != null and dto.publishStatus != ''">
                    and publish_status like CONCAT('%',#{dto.publishStatus},'%')
                </if>
                <if test="dto.createTime != null and dto.createTime != ''">
                    and create_time like CONCAT('%',#{dto.createTime},'%')
                </if>
                <if test="dto.updateTime != null and dto.updateTime != ''">
                    and update_time like CONCAT('%',#{dto.updateTime},'%')
                </if>
        </where>
    </select>

</mapper>
