<?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.coupon.mapper.HomeSubjectSpuMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.mall.coupon.domain.entity.HomeSubjectSpu">
            <id column="id" property="id"/>
            <id column="name" property="name"/>
            <id column="subject_id" property="subjectId"/>
            <id column="spu_id" property="spuId"/>
            <id column="sort" property="sort"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id,name,subject_id,spu_id,sort
    </sql>

    <!-- 分页查询专题商品内容 -->
    <select id="selectListByPage" resultType="com.mall.coupon.domain.vo.HomeSubjectSpuVo">
        select
        <include refid="Base_Column_List"/>
        from sms_home_subject_spu
        <where>
                <if test="dto.id != null and dto.id != ''">
                    and id like CONCAT('%',#{dto.id},'%')
                </if>
                <if test="dto.name != null and dto.name != ''">
                    and name like CONCAT('%',#{dto.name},'%')
                </if>
                <if test="dto.subjectId != null and dto.subjectId != ''">
                    and subject_id like CONCAT('%',#{dto.subjectId},'%')
                </if>
                <if test="dto.spuId != null and dto.spuId != ''">
                    and spu_id like CONCAT('%',#{dto.spuId},'%')
                </if>
                <if test="dto.sort != null and dto.sort != ''">
                    and sort like CONCAT('%',#{dto.sort},'%')
                </if>
        </where>
    </select>

</mapper>
