<?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.business.dao.CameraPurchaserDAO">
	<resultMap id="CameraPurchaserMap" type="com.jpsoft.shinestar.modules.business.entity.CameraPurchaser">
		<id property="id" column="id_" />
			<result property="personId" column="person_id" />
			<result property="endTime" column="end_time" />
			<result property="createTime" column="create_time" />
			<result property="createBy" column="create_by" />
			<result property="updateTime" column="update_time" />
			<result property="updateBy" column="update_by" />
			<result property="delFlag" column="del_flag" />
			<result property="studentId" column="student_id" />

	</resultMap>
	<insert id="insert" parameterType="com.jpsoft.shinestar.modules.business.entity.CameraPurchaser">
	<!--
	<selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
		select sys_guid() from dual
	</selectKey>
	-->
	<![CDATA[
		insert into business_camera_purchaser
	    (id_,person_id,end_time,create_time,create_by,update_time,update_by,del_flag,student_id)
		values
		(
#{id,jdbcType=VARCHAR}
,#{personId,jdbcType= NUMERIC }
,#{endTime,jdbcType= TIMESTAMP }
,#{createTime,jdbcType= TIMESTAMP }
,#{createBy,jdbcType=VARCHAR}
,#{updateTime,jdbcType= TIMESTAMP }
,#{updateBy,jdbcType=VARCHAR}
,#{delFlag,jdbcType= NUMERIC }
,#{studentId,jdbcType= NUMERIC }
		)
	]]>
	</insert>
	<delete id="delete" parameterType="string">
		delete from business_camera_purchaser where id_=#{id,jdbcType=VARCHAR}
	</delete>
	<update id="update" parameterType="com.jpsoft.shinestar.modules.business.entity.CameraPurchaser">
		update business_camera_purchaser
		<set>
				<if test="personId!=null">
		person_id=#{personId,jdbcType= NUMERIC },
		</if>
				<if test="endTime!=null">
		end_time=#{endTime,jdbcType= TIMESTAMP },
		</if>
				<if test="createTime!=null">
		create_time=#{createTime,jdbcType= TIMESTAMP },
		</if>
				<if test="createBy!=null">
		create_by=#{createBy,jdbcType=VARCHAR},
		</if>
				<if test="updateTime!=null">
		update_time=#{updateTime,jdbcType= TIMESTAMP },
		</if>
				<if test="updateBy!=null">
		update_by=#{updateBy,jdbcType=VARCHAR},
		</if>
				<if test="delFlag!=null">
		del_flag=#{delFlag,jdbcType= NUMERIC },
		</if>
			<if test="studentId!=null">
				student_id=#{studentId,jdbcType= NUMERIC },
			</if>
		</set>
	where id_=#{id}
	</update>
	<select id="get" parameterType="string" resultMap="CameraPurchaserMap">
		select 
id_,person_id,end_time,create_time,create_by,update_time,update_by,del_flag	,student_id	from business_camera_purchaser where id_=#{0}
	</select>
	<select id="getByPersonId"   resultMap="CameraPurchaserMap">
		select
			id_,person_id,end_time,create_time,create_by,update_time,update_by,del_flag	,student_id	from business_camera_purchaser
			where person_id=#{personId}   and  del_flag=0

	</select>
	<select id="exist" parameterType="string" resultType="int">
		select count(*) from business_camera_purchaser where id_=#{0}
	</select>
	<select id="list" resultMap="CameraPurchaserMap">
		select * from business_camera_purchaser
	</select>
	<select id="search" parameterType="hashmap" resultMap="CameraPurchaserMap">
		<![CDATA[
			select * from business_camera_purchaser
		]]>
		<where>
			<if test="searchParams.id != null">
				and ID_ like #{searchParams.id}
			</if>
		</where>
		<foreach item="sort" collection="sortList"  open="order by" separator=",">
	        ${sort.name} ${sort.order}
	 	</foreach>
	</select>
</mapper>