<?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.xintong.visualinspection.dao.master.CheckTaskPeriodDao">
	<resultMap id="BaseResultMap"
		type="com.xintong.visualinspection.bean.CheckTaskPeriod">
		<id column="id" property="id" jdbcType="INTEGER" />
		<result column="starttime" jdbcType="TIMESTAMP" property="starttime" javaType="java.sql.Timestamp" />  
		<result column="endtime" jdbcType="TIMESTAMP" property="endtime" javaType="java.sql.Timestamp" />  
		<result column="currentday" property="currentday" jdbcType="INTEGER" />
		<result column="name" property="name" jdbcType="VARCHAR" />
	</resultMap>

	<select id="select" parameterType="com.xintong.visualinspection.bean.CheckTaskPeriod"
		resultMap="BaseResultMap">
		select * from check_task_period where 	1=1  
		<if test="name != null">and name = #{name} </if>
		<if test="id != null">and id = #{id} </if>
	
	</select>

	<select id="selectbytime" parameterType="com.xintong.visualinspection.bean.CheckTaskPeriod"
		resultMap="BaseResultMap">
     <![CDATA[
      select * from  check_task_period where 
       #{starttime} = starttime
      and 
      1=1 
      ]]>
	</select>

	<select id="selectbydatetime" parameterType="com.xintong.visualinspection.bean.CheckTaskPeriod"
			resultMap="BaseResultMap">
		<![CDATA[
      select * from  check_task_period where
       #{starttime} >= starttime and  #{starttime} <= endtime
      and
      1=1
      ]]>
	</select>


	<insert id="insert" parameterType="com.xintong.visualinspection.bean.CheckTaskPeriod">
		INSERT INTO
		check_task_period
		(name,starttime,endtime,currentday)
		VALUES
		(#{name},#{starttime},#{endtime},#{currentday})
	</insert>

	<update id="update" parameterType="com.xintong.visualinspection.bean.CheckTaskPeriod">
		UPDATE
		check_task_period
		SET
		<if test="name != null">name = #{name},</if>
		<if test="starttime != null">starttime = #{starttime},</if>
		<if test="endtime != null">endtime = #{endtime},</if>
		<if test="currentday != null">currentday = #{currentday},</if>
		id = #{id}
		WHERE
		id = #{id}
	</update>

	<delete id="delete" parameterType="java.lang.Long">
		DELETE FROM
		check_task_period
		WHERE
		id =#{id}
	</delete>



</mapper>