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

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.mall.product.domain.entity.SkuInfo">
            <id column="sku_id" property="skuId"/>
            <id column="spu_id" property="spuId"/>
            <id column="sku_name" property="skuName"/>
            <id column="sku_desc" property="skuDesc"/>
            <id column="catalog_id" property="catalogId"/>
            <id column="brand_id" property="brandId"/>
            <id column="sku_default_img" property="skuDefaultImg"/>
            <id column="sku_title" property="skuTitle"/>
            <id column="sku_subtitle" property="skuSubtitle"/>
            <id column="price" property="price"/>
            <id column="sale_count" property="saleCount"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        sku_id,spu_id,sku_name,sku_desc,catalog_id,brand_id,sku_default_img,sku_title,sku_subtitle,price,sale_count
    </sql>

    <!-- 分页查询sku信息内容 -->
    <select id="selectListByPage" resultType="com.mall.product.domain.vo.SkuInfoVo">
        select
        <include refid="Base_Column_List"/>
        from pms_sku_info
        <where>
                <if test="dto.skuId != null and dto.skuId != ''">
                    and sku_id like CONCAT('%',#{dto.skuId},'%')
                </if>
                <if test="dto.spuId != null and dto.spuId != ''">
                    and spu_id like CONCAT('%',#{dto.spuId},'%')
                </if>
                <if test="dto.skuName != null and dto.skuName != ''">
                    and sku_name like CONCAT('%',#{dto.skuName},'%')
                </if>
                <if test="dto.skuDesc != null and dto.skuDesc != ''">
                    and sku_desc like CONCAT('%',#{dto.skuDesc},'%')
                </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.skuDefaultImg != null and dto.skuDefaultImg != ''">
                    and sku_default_img like CONCAT('%',#{dto.skuDefaultImg},'%')
                </if>
                <if test="dto.skuTitle != null and dto.skuTitle != ''">
                    and sku_title like CONCAT('%',#{dto.skuTitle},'%')
                </if>
                <if test="dto.skuSubtitle != null and dto.skuSubtitle != ''">
                    and sku_subtitle like CONCAT('%',#{dto.skuSubtitle},'%')
                </if>
                <if test="dto.price != null and dto.price != ''">
                    and price like CONCAT('%',#{dto.price},'%')
                </if>
                <if test="dto.saleCount != null and dto.saleCount != ''">
                    and sale_count like CONCAT('%',#{dto.saleCount},'%')
                </if>
        </where>
    </select>

</mapper>
