<?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.MeetingInfoDAO">
	<resultMap id="MeetingInfoMap" type="com.jpsoft.shinestar.modules.base.entity.MeetingInfo">
		<id property="id" column="id_" />
			<result property="number" column="number_" />
			<result property="name" column="name_" />
			<result property="addressId" column="address_id" />
			<result property="content" column="content_" />
			<result property="remark" column="remark_" />
			<result property="status" column="status_" />
			<result property="pushStatus" column="push_status" />
			<result property="pushTime" column="push_time" />
			<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="delFlag" column="del_flag" />
			<result property="searchCompanyId" column="search_company_id" />

			</resultMap>
	<insert id="insert" parameterType="com.jpsoft.shinestar.modules.base.entity.MeetingInfo">
	<!--
	<selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
		select sys_guid() from dual
	</selectKey>
	-->
	<![CDATA[
		insert into base_meeting_info
	    (id_,number_,name_,address_id,content_,remark_,status_,push_status,push_time,create_by,create_time,update_by,update_time,del_flag,search_company_id)
		values
		(
#{id,jdbcType=VARCHAR}
,#{number,jdbcType=VARCHAR}
,#{name,jdbcType=VARCHAR}
,#{addressId,jdbcType=VARCHAR}
,#{content,jdbcType=VARCHAR}
,#{remark,jdbcType=VARCHAR}
,#{status,jdbcType=VARCHAR}
,#{pushStatus,jdbcType=VARCHAR}
,#{pushTime,jdbcType= TIMESTAMP }
,#{createBy,jdbcType=VARCHAR}
,#{createTime,jdbcType= TIMESTAMP }
,#{updateBy,jdbcType=VARCHAR}
,#{updateTime,jdbcType= TIMESTAMP }
,#{delFlag,jdbcType= NUMERIC }
,#{searchCompanyId,jdbcType=VARCHAR}
		)
	]]>
	</insert>
	<delete id="delete" parameterType="string">
		delete from base_meeting_info where id_=#{id,jdbcType=VARCHAR}
	</delete>
	<update id="update" parameterType="com.jpsoft.shinestar.modules.base.entity.MeetingInfo">
		update base_meeting_info
		<set>
				<if test="number!=null">
		number_=#{number,jdbcType=VARCHAR},
		</if>
				<if test="name!=null">
		name_=#{name,jdbcType=VARCHAR},
		</if>
				<if test="addressId!=null">
		address_id=#{addressId,jdbcType=VARCHAR},
		</if>
				<if test="content!=null">
		content_=#{content,jdbcType=VARCHAR},
		</if>
				<if test="remark!=null">
		remark_=#{remark,jdbcType=VARCHAR},
		</if>
				<if test="status!=null">
		status_=#{status,jdbcType=VARCHAR},
		</if>
				<if test="pushStatus!=null">
		push_status=#{pushStatus,jdbcType=VARCHAR},
		</if>
				<if test="pushTime!=null">
		push_time=#{pushTime,jdbcType= TIMESTAMP },
		</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="delFlag!=null">
			del_flag=#{delFlag,jdbcType= NUMERIC },
		</if>
			<if test="searchCompanyId!=null">
				search_company_id=#{searchCompanyId,jdbcType= VARCHAR },
			</if>
		</set>
	where id_=#{id}
	</update>
	<select id="get" parameterType="string" resultMap="MeetingInfoMap">
		select * from base_meeting_info where id_=#{0}
	</select>
	<select id="exist" parameterType="string" resultType="int">
		select count(*) from base_meeting_info where id_=#{0}
	</select>
	<select id="list" resultMap="MeetingInfoMap">
		select * from base_meeting_info where del_flag=false
	</select>
	<select id="notEndList" resultMap="MeetingInfoMap">
		<![CDATA[
			select * from base_meeting_info where del_flag=false and (status_="1" or  status_="2")
		]]>
	</select>

	<select id="search" parameterType="hashmap" resultMap="MeetingInfoMap">
		<![CDATA[
			select DISTINCT a.* from base_meeting_info a left join base_meeting_time b on a.id_=b.meeting_id
		]]>
		<where>
			a.del_flag=false and b.del_flag = false
			<if test="searchParams.name != null">
				and a.name_ like #{searchParams.name}
			</if>
			<if test="searchParams.pushStatus != null">
				and a.push_status = #{searchParams.pushStatus}
			</if>
			<if test="searchParams.beginTime != null">
				<![CDATA[
                  and b.meeting_date >= #{searchParams.beginTime}
                ]]>
			</if>
			<if test="searchParams.endTime != null">
				<![CDATA[
                  and b.meeting_date <= #{searchParams.endTime}
                ]]>
			</if>
		</where>
		<foreach item="sort" collection="sortList"  open="order by" separator=",">
	        ${sort.name} ${sort.order}
	 	</foreach>
	</select>
</mapper>