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

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.mall.coupon.domain.entity.HomeSubject">
            <id column="id" property="id"/>
            <id column="name" property="name"/>
            <id column="title" property="title"/>
            <id column="sub_title" property="subTitle"/>
            <id column="status" property="status"/>
            <id column="url" property="url"/>
            <id column="sort" property="sort"/>
            <id column="img" property="img"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id,name,title,sub_title,status,url,sort,img
    </sql>

    <!-- 分页查询首页专题表【jd首页下面很多专题，每个专题链接新的页面，展示专题商品信息】内容 -->
    <select id="selectListByPage" resultType="com.mall.coupon.domain.vo.HomeSubjectVo">
        select
        <include refid="Base_Column_List"/>
        from sms_home_subject
        <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.title != null and dto.title != ''">
                    and title like CONCAT('%',#{dto.title},'%')
                </if>
                <if test="dto.subTitle != null and dto.subTitle != ''">
                    and sub_title like CONCAT('%',#{dto.subTitle},'%')
                </if>
                <if test="dto.status != null and dto.status != ''">
                    and status like CONCAT('%',#{dto.status},'%')
                </if>
                <if test="dto.url != null and dto.url != ''">
                    and url like CONCAT('%',#{dto.url},'%')
                </if>
                <if test="dto.sort != null and dto.sort != ''">
                    and sort like CONCAT('%',#{dto.sort},'%')
                </if>
                <if test="dto.img != null and dto.img != ''">
                    and img like CONCAT('%',#{dto.img},'%')
                </if>
        </where>
    </select>

</mapper>
