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

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.mall.coupon.domain.entity.SeckillSkuRelation">
            <id column="id" property="id"/>
            <id column="promotion_id" property="promotionId"/>
            <id column="promotion_session_id" property="promotionSessionId"/>
            <id column="sku_id" property="skuId"/>
            <id column="seckill_price" property="seckillPrice"/>
            <id column="seckill_count" property="seckillCount"/>
            <id column="seckill_limit" property="seckillLimit"/>
            <id column="seckill_sort" property="seckillSort"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id,promotion_id,promotion_session_id,sku_id,seckill_price,seckill_count,seckill_limit,seckill_sort
    </sql>

    <!-- 分页查询秒杀活动商品关联内容 -->
    <select id="selectListByPage" resultType="com.mall.coupon.domain.vo.SeckillSkuRelationVo">
        select
        <include refid="Base_Column_List"/>
        from sms_seckill_sku_relation
        <where>
                <if test="dto.id != null and dto.id != ''">
                    and id like CONCAT('%',#{dto.id},'%')
                </if>
                <if test="dto.promotionId != null and dto.promotionId != ''">
                    and promotion_id like CONCAT('%',#{dto.promotionId},'%')
                </if>
                <if test="dto.promotionSessionId != null and dto.promotionSessionId != ''">
                    and promotion_session_id like CONCAT('%',#{dto.promotionSessionId},'%')
                </if>
                <if test="dto.skuId != null and dto.skuId != ''">
                    and sku_id like CONCAT('%',#{dto.skuId},'%')
                </if>
                <if test="dto.seckillPrice != null and dto.seckillPrice != ''">
                    and seckill_price like CONCAT('%',#{dto.seckillPrice},'%')
                </if>
                <if test="dto.seckillCount != null and dto.seckillCount != ''">
                    and seckill_count like CONCAT('%',#{dto.seckillCount},'%')
                </if>
                <if test="dto.seckillLimit != null and dto.seckillLimit != ''">
                    and seckill_limit like CONCAT('%',#{dto.seckillLimit},'%')
                </if>
                <if test="dto.seckillSort != null and dto.seckillSort != ''">
                    and seckill_sort like CONCAT('%',#{dto.seckillSort},'%')
                </if>
        </where>
    </select>

</mapper>
