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

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.mall.coupon.domain.entity.CouponSpuCategoryRelation">
            <id column="id" property="id"/>
            <id column="coupon_id" property="couponId"/>
            <id column="category_id" property="categoryId"/>
            <id column="category_name" property="categoryName"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id,coupon_id,category_id,category_name
    </sql>

    <!-- 分页查询优惠券分类关联内容 -->
    <select id="selectListByPage" resultType="com.mall.coupon.domain.vo.CouponSpuCategoryRelationVo">
        select
        <include refid="Base_Column_List"/>
        from sms_coupon_spu_category_relation
        <where>
                <if test="dto.id != null and dto.id != ''">
                    and id like CONCAT('%',#{dto.id},'%')
                </if>
                <if test="dto.couponId != null and dto.couponId != ''">
                    and coupon_id like CONCAT('%',#{dto.couponId},'%')
                </if>
                <if test="dto.categoryId != null and dto.categoryId != ''">
                    and category_id like CONCAT('%',#{dto.categoryId},'%')
                </if>
                <if test="dto.categoryName != null and dto.categoryName != ''">
                    and category_name like CONCAT('%',#{dto.categoryName},'%')
                </if>
        </where>
    </select>

</mapper>
