<?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="org.springblade.activity.mapper.BladeActivityMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="org.springblade.activity.entity.BladeActivity">
        <id column="id" property="id" />
        <result column="title" property="title" />
        <result column="type" property="type" />
        <result column="activity_uuid" property="activityUuid" />
        <result column="activity_start_time" property="activityStartTime" />
        <result column="activity_end_time" property="activityEndTime" />
        <result column="cash_deadline" property="cashDeadline" />
        <result column="activity_province" property="activityProvince" />
        <result column="activity_city" property="activityCity" />
        <result column="activity_region" property="activityRegion" />
        <result column="activity_totalfee" property="activityTotalfee" />
        <result column="create_time" property="createTime" />
        <result column="update_time" property="updateTime" />
        <result column="status" property="status" />
        <result column="is_third" property="isThird" />
        <result column="is_deleted" property="isDeleted" />
        <result column="responsible_ids" property="responsibleIds" />
        <result column="channel_ids" property="channelIds" />
        <result column="product_ids" property="productIds" />
        <result column="prize_ids" property="prizeIds" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, title, type, activity_time,activity_id, activity_end_time,activity_province, activity_city, activity_region, activity_totalfee,  create_time, update_time, status, is_deleted
    </sql>


    <select id="getPageByQuery" resultType="org.springblade.activity.dto.vo.BladeActivityPageVo">
        SELECT
        *
        FROM
        blade_activity
        where is_deleted = 0
        <if test="query.activityName != null and query.activityName != ''">
            and title LIKE CONCAT('%',#{query.activityName},'%')
        </if>
        <if test="query.activityType != null and query.activityType != ''">
            and type = #{query.activityType}
        </if>
        <if test="query.productId != null and query.productId != ''">
            and FIND_IN_SET(#{query.productId},product_ids)
        </if>
        <if test="query.responsibleId != null and query.responsibleId != ''">
            and FIND_IN_SET(#{query.responsibleId},responsible_ids)
        </if>
        <if test="query.channelId != null and query.channelId != ''">
            and FIND_IN_SET(#{query.channelId},channel_ids)
        </if>
        ORDER BY
        create_time DESC
    </select>

  <!--  <select id="ssss">
        SELECT
            *
        FROM
            blade_activity ba
        JOIN blade_responsible br ON FIND_IN_SET(br.id, ba.responsible_ids)
        WHERE
            br.`name` LIKE '%李%'
        JOIN blade_channel bc ON FIND_IN_SET(bc.id, ba.channel_ids)
        JOIN blade_product bp ON FIND_IN_SET(bp.id, ba.product_ids)
        JOIN blade_prize bpi ON FIND_IN_SET(bpi.id, ba.prize_ids)
    </select>-->

</mapper>
