<?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.RolePersonCheckOnDAO">
	<resultMap id="RolePersonCheckOnMap" type="com.jpsoft.shinestar.modules.base.entity.RolePersonCheckOn">
		<id property="id" column="id_" />
			<result property="rolePersonId" column="role_person_id" />
			<result property="rolePerson" column="role_person" />
			<result property="checkOnCountFlag" column="check_on_count_flag" />
			<result property="checkOnCount" column="check_on_count" />
			<result property="checkOnTimeFlag" column="check_on_time_flag" />
			<result property="checkStartTime" column="check_start_time" />
			<result property="checkEndTime" column="check_end_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" />
			</resultMap>
	<insert id="insert" parameterType="com.jpsoft.shinestar.modules.base.entity.RolePersonCheckOn">
	<!--
	<selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
		select sys_guid() from dual
	</selectKey>
	-->
	<![CDATA[
		insert into base_role_person_check_on
	    (id_,role_person_id,role_person,check_on_count_flag,check_on_count,check_on_time_flag,check_start_time,check_end_time,create_by,create_time,update_by,update_time,del_flag)
		values
		(
			#{id,jdbcType=VARCHAR}
			,#{rolePersonId,jdbcType=VARCHAR}
			,#{rolePerson,jdbcType= NUMERIC }
			,#{checkOnCountFlag,jdbcType= NUMERIC }
			,#{checkOnCount,jdbcType=VARCHAR}
			,#{checkOnTimeFlag,jdbcType= NUMERIC }
			,#{checkStartTime,jdbcType=VARCHAR}
			,#{checkEndTime,jdbcType=VARCHAR}
			,#{createBy,jdbcType=VARCHAR}
			,#{createTime,jdbcType= TIMESTAMP }
			,#{updateBy,jdbcType=VARCHAR}
			,#{updateTime,jdbcType= TIMESTAMP }
			,#{delFlag,jdbcType= NUMERIC }
		)
	]]>
	</insert>
	<delete id="delete" parameterType="string">
		delete from base_role_person_check_on where id_=#{id,jdbcType=VARCHAR}
	</delete>
	<update id="update" parameterType="com.jpsoft.shinestar.modules.base.entity.RolePersonCheckOn">
		update base_role_person_check_on
		<set>
				<if test="rolePersonId!=null">
		role_person_id=#{rolePersonId,jdbcType=VARCHAR},
		</if>
				<if test="rolePerson!=null">
		role_person=#{rolePerson,jdbcType= NUMERIC },
		</if>
				<if test="checkOnCountFlag!=null">
		check_on_count_flag=#{checkOnCountFlag,jdbcType= NUMERIC },
		</if>
				<if test="checkOnCount!=null">
		check_on_count=#{checkOnCount,jdbcType=VARCHAR},
		</if>
				<if test="checkOnTimeFlag!=null">
		check_on_time_flag=#{checkOnTimeFlag,jdbcType= NUMERIC },
		</if>
				<if test="checkStartTime!=null">
		check_start_time=#{checkStartTime,jdbcType=VARCHAR},
		</if>
				<if test="checkEndTime!=null">
		check_end_time=#{checkEndTime,jdbcType=VARCHAR},
		</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>
		</set>
	where id_=#{id}
	</update>
	<select id="get" parameterType="string" resultMap="RolePersonCheckOnMap">
		select 
id_,role_person_id,role_person,check_on_count_flag,check_on_count,check_on_time_flag,check_start_time,check_end_time,create_by,create_time,update_by,update_time,del_flag		from base_role_person_check_on where id_=#{0}
	</select>
	<select id="exist" parameterType="string" resultType="int">
		select count(*) from base_role_person_check_on where id_=#{0}
	</select>
	<select id="list" resultMap="RolePersonCheckOnMap">
		select * from base_role_person_check_on
	</select>
	<select id="findByPersonId" resultMap="RolePersonCheckOnMap">
		select * from base_role_person_check_on
		where del_flag = 0
		and role_person = 1
		and role_person_id = #{0}
		limit 1
	</select>
	<select id="search" parameterType="hashmap" resultMap="RolePersonCheckOnMap">
		<![CDATA[
			select * from base_role_person_check_on
		]]>
		<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>
    <select id="findByRoleId" resultMap="RolePersonCheckOnMap">
		select * from base_role_person_check_on
		where del_flag = 0
		and role_person = 0
		and role_person_id = #{0}
		limit 1
	</select>
</mapper>