<?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.goafanti.common.dao.ActivityMapper">
	<select id="findActivityListByPage" parameterType="String" resultType="com.goafanti.activity.bo.ActivityListBo">
		select
			id,
			start_time as startTime,
			end_time as endTime, 
			name,
			host,
			type,
			form,
			enroll_deadline as enrollDeadline
		from activity
		where 1=1
		<if test="sTime != null">
			and start_time <![CDATA[ >= ]]> #{sTime,jdbcType=TIMESTAMP}
		</if>
		<if test="eTime != null">
			and start_time <![CDATA[ < ]]> #{eTime,jdbcType=TIMESTAMP}
		</if>
		<if test="name != null">
			and name like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
		</if>
		<if test="host != null">
			and host like CONCAT('%',#{host,jdbcType=VARCHAR},'%')
		</if>
		<if test="type != null">
			and type = #{type,jdbcType=INTEGER}
		</if>
		<if test="form != null">
			and form = #{form,jdbcType=INTEGER}
		</if>
		order by start_time desc
		<if test="page_sql!=null">
			${page_sql}
		</if>
	</select>
	
	<select id="findActivityCount" parameterType="String" resultType="java.lang.Integer">
		select
			count(1)
		from activity
		where 1=1
		<if test="sTime != null">
			and start_time <![CDATA[ >= ]]> #{sTime,jdbcType=TIMESTAMP}
		</if>
		<if test="eTime != null">
			and start_time <![CDATA[ < ]]> #{eTime,jdbcType=TIMESTAMP}
		</if>
		<if test="name != null">
			and name like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
		</if>
		<if test="host != null">
			and host like CONCAT('%',#{host,jdbcType=VARCHAR},'%')
		</if>
		<if test="type != null">
			and type = #{type,jdbcType=INTEGER}
		</if>
		<if test="form != null">
			and form = #{form,jdbcType=INTEGER}
		</if>
	</select>
	
  <delete id="batchDeleteByPrimaryKey" parameterType="java.util.List">
  	delete
  		from activity
  	where id in
  	<foreach item="item" index="index" collection="list" open="("
			separator="," close=")">
			#{item}
	</foreach>
  </delete>
  
  <select id="findPortalList" resultMap="BaseResultMap">
	select
		<include refid="Base_Column_List" />
	from activity
	where 1=1
	<if test="form != null">
		and form = #{form,jdbcType=INTEGER}
	</if>
	order by start_time desc
	limit #{pageNo,jdbcType=INTEGER}, #{pageSize,jdbcType=INTEGER}
</select>
</mapper>