<?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.liquidnet.service.kylin.mapper.KylinRecommendActiveMapper">
    <resultMap id="BaseResultMap" type="com.liquidnet.service.kylin.entity.KylinRecommendActive">
        <id column="mid" jdbcType="BIGINT" property="mid" />
        <result column="recommend_id" jdbcType="VARCHAR" property="recommendId" />
        <result column="start_time" jdbcType="TIMESTAMP" property="startTime" />
        <result column="end_time" jdbcType="TIMESTAMP" property="endTime" />
        <result column="active_type" jdbcType="INTEGER" property="activeType" />
        <result column="active_bind_id" jdbcType="VARCHAR" property="activeBindId" />
        <result column="del_tag" jdbcType="INTEGER" property="delTag" />
        <result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
        <result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
        <result column="status" jdbcType="INTEGER" property="status" />
    </resultMap>
    <!-- getBannersRelationsId  -->
    <select id="validateTime" parameterType="com.liquidnet.service.kylin.entity.KylinRecommendActive" resultType="int">
    select count(1) from  kylin_recommend_active
    where (#{startTime} BETWEEN start_time and end_time
    or #{endTime} BETWEEN start_time and end_time) and active_type=#{activeType} and active_bind_id=#{activeBindId}
    <if test="recommendId !=null">
        and recommend_id != #{recommendId}
    </if>
    </select>

    <select id="getBybindId"  resultMap="BaseResultMap">
    select * from kylin_recommend_active where active_type=#{type} and active_bind_id=#{bindId} and del_tag=0 and `status`=0 and end_time>=NOW()
     ORDER BY start_time asc
    </select>

</mapper>
