<?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">
<!-- namespace必须指向DAO接口 -->
<mapper namespace="com.jpsoft.shinestar.modules.base.dao.ActivityInfoDAO">
	<resultMap id="ActivityInfoMap" type="com.jpsoft.shinestar.modules.base.entity.ActivityInfo">
		<id property="id" column="id_" />
			<result property="title" column="title_" />
			<result property="content" column="content_" />
			<result property="frontCover" column="front_cover" />
			<result property="startTime" column="start_time" />
			<result property="endTime" column="end_time" />
			<result property="applicant" column="applicant_" />
			<result property="roomNumber" column="room_number" />
			<result property="applicationTime" column="application_time" />
			<result property="verify" column="verify_" />
			<result property="delFlag" column="del_flag" />
			<result property="createBy" column="create_by" />
			<result property="createTime" column="create_time" />
			<result property="updateBy" column="update_by" />
			<result property="updateTime" column="update_time" />
			<result property="verifyTime" column="verify_time" />
			<result property="verifyMsg" column="verify_msg" />
			</resultMap>
	<insert id="insert" parameterType="com.jpsoft.shinestar.modules.base.entity.ActivityInfo">
	<!--
	<selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
		select sys_guid() from dual
	</selectKey>
	-->
	<![CDATA[
		insert into base_activity_info
	    (id_,title_,content_,front_cover,start_time,end_time,applicant_,room_number,application_time,verify_,del_flag,create_by,create_time,update_by,update_time,verify_time,verify_msg)
		values
		(
#{id,jdbcType=VARCHAR}
,#{title,jdbcType=VARCHAR}
,#{content,jdbcType=VARCHAR}
,#{frontCover,jdbcType=VARCHAR}
,#{startTime,jdbcType= TIMESTAMP }
,#{endTime,jdbcType= TIMESTAMP }
,#{applicant,jdbcType=VARCHAR}
,#{roomNumber,jdbcType=VARCHAR}
,#{applicationTime,jdbcType= TIMESTAMP }
,#{verify,jdbcType= NUMERIC }
,#{delFlag,jdbcType= NUMERIC }
,#{createBy,jdbcType=VARCHAR}
,#{createTime,jdbcType= TIMESTAMP }
,#{updateBy,jdbcType=VARCHAR}
,#{updateTime,jdbcType= TIMESTAMP }
,#{verifyTime,jdbcType= TIMESTAMP }
,#{verifyMsg,jdbcType=VARCHAR}
		)
	]]>
	</insert>
	<delete id="delete" parameterType="string">
		delete from base_activity_info where id_=#{id,jdbcType=VARCHAR}
	</delete>
	<update id="update" parameterType="com.jpsoft.shinestar.modules.base.entity.ActivityInfo">
		update base_activity_info
		<set>
				<if test="title!=null">
		title_=#{title,jdbcType=VARCHAR},
		</if>
				<if test="content!=null">
		content_=#{content,jdbcType=VARCHAR},
		</if>
				<if test="frontCover!=null">
		front_cover=#{frontCover,jdbcType=VARCHAR},
		</if>
				<if test="startTime!=null">
		start_time=#{startTime,jdbcType= TIMESTAMP },
		</if>
				<if test="endTime!=null">
		end_time=#{endTime,jdbcType= TIMESTAMP },
		</if>
				<if test="applicant!=null">
		applicant_=#{applicant,jdbcType=VARCHAR},
		</if>
				<if test="roomNumber!=null">
		room_number=#{roomNumber,jdbcType=VARCHAR},
		</if>
				<if test="applicationTime!=null">
		application_time=#{applicationTime,jdbcType= TIMESTAMP },
		</if>
				<if test="verify!=null">
		verify_=#{verify,jdbcType= NUMERIC },
		</if>
				<if test="delFlag!=null">
		del_flag=#{delFlag,jdbcType= NUMERIC },
		</if>
				<if test="createBy!=null">
		create_by=#{createBy,jdbcType=VARCHAR},
		</if>
				<if test="createTime!=null">
		create_time=#{createTime,jdbcType= TIMESTAMP },
		</if>
				<if test="updateBy!=null">
		update_by=#{updateBy,jdbcType=VARCHAR},
		</if>
				<if test="updateTime!=null">
		update_time=#{updateTime,jdbcType= TIMESTAMP },
		</if>
		<if test="verifyTime!=null">
			verify_time=#{verifyTime,jdbcType= TIMESTAMP },
		</if>
			<if test="verifyMsg!=null">
				verify_msg=#{verifyMsg,jdbcType=VARCHAR},
			</if>
		</set>
	where id_=#{id}
	</update>
	<select id="get" parameterType="string" resultMap="ActivityInfoMap">
		select * from base_activity_info where id_=#{0}
	</select>
	<select id="exist" parameterType="string" resultType="int">
		select count(*) from base_activity_info where id_=#{0}
	</select>
	<select id="list" resultMap="ActivityInfoMap">
		select * from base_activity_info
	</select>
	<select id="search" parameterType="hashmap" resultMap="ActivityInfoMap">
		<![CDATA[
			select * from base_activity_info
		]]>
		<where>
			del_flag = 0 and verify_ IS NOT NULL
			<if test="searchParams.title != null">
				and title_ like #{searchParams.title}
			</if>
			<if test="searchParams.applicant != null">
				and applicant_ like #{searchParams.applicant}
			</if>
			<if test="searchParams.createBy != null">
				and create_by = #{searchParams.createBy}
			</if>
			<if test="searchParams.endTime != null">
				<![CDATA[
				and end_time >= #{searchParams.endTime}
				]]>
			</if>
			<if test="searchParams.verify != null">
				and verify_ = #{searchParams.verify}
			</if>
			<if test="searchParams.isVerify == 0">
				and verify_ = 0
			</if>
			<if test="searchParams.isVerify == 1">
				and (verify_ = 1 or verify_ = 2)
			</if>
		</where>
		<foreach item="sort" collection="sortList"  open="order by" separator=",">
	        ${sort.name} ${sort.order}
	 	</foreach>
	</select>
</mapper>