<?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="cn.pluss.platform.mapper.AgreementMapper">

	   	<insert id="saveAgreement" parameterType="cn.pluss.platform.entity.Agreement">
        	insert into tb_pluss_agreement(name,content,createDt,createor,discern)VALUES(#{name},#{content},now(),#{createor},#{discern})
    	</insert>

	   	<insert id="saveAgreementBatch">
        	insert into tb_pluss_agreement(name,content,createDt,createor,discern) VALUES 
    			<foreach collection="list" item="item" index="index" separator=",">
			(#{name},#{content},now(),#{createor},#{discern}		)
				</foreach>
    	</insert>

		<select id="queryAgreement" parameterType="cn.pluss.platform.entity.Agreement" resultType="cn.pluss.platform.entity.Agreement">
			SELECT * from tb_pluss_agreement 
				<where> 
					<if test="id!= null"> 
					 	and id = #{id}
					 </if> 
					<if test="name!= null"> 
					 	and name = #{name}
					 </if> 
					<if test="content!= null"> 
					 	and content = #{content}
					 </if> 
					<if test="createDt!= null"> 
					 	and createDt = #{createDt}
					 </if> 
					<if test="createor!= null"> 
					 	and createor = #{createor}
					 </if> 
					<if test="discern!= null"> 
					 	and discern = #{discern}
					 </if> 
				 </where> 
		</select>

		<select id="queryAgreementList" parameterType="cn.pluss.platform.entity.Agreement" resultType="cn.pluss.platform.entity.Agreement">
			SELECT * from tb_pluss_agreement 
				<where> 
					<if test="id!= null"> 
					 and 	id = #{id}
					 </if> 
					<if test="name!= null"> 
					 and 	name = #{name}
					 </if> 
					<if test="content!= null"> 
					 and 	content = #{content}
					 </if> 
					<if test="createDt!= null"> 
					 and 	createDt = #{createDt}
					 </if> 
					<if test="createor!= null"> 
					 and 	createor = #{createor}
					 </if> 
					 <if test="discern!= null"> 
                        and discern = #{discern}
                     </if> 
				 </where> 
		</select>

		<update id="updateAgreement" parameterType="cn.pluss.platform.entity.Agreement" >
			update tb_pluss_agreement 
				  <set> 
					<if test="name!= null"> 
					 	name = #{name},
					 </if> 
					<if test="content!= null"> 
					 	content = #{content},
					 </if> 
					<if test="createDt!= null"> 
					 	createDt = #{createDt},
					 </if> 
					<if test="createor!= null"> 
					 	createor = #{createor},
					 </if> 
					 <if test="discern!= null"> 
                         discern = #{discern}
                     </if> 
				</set>
			where id=#{id} 
		</update>

		<delete id="deleteAgreement" parameterType="cn.pluss.platform.entity.Agreement" >
			DELETE FROM tb_pluss_agreement where id=#{id}
		</delete>

		<select id="queryAgreementPage" parameterType="java.util.Map" resultType="cn.pluss.platform.entity.Agreement">
			SELECT * from tb_pluss_agreement 
				<where> 
					<if test="id!= null"> 
					and id = #{id}
					 </if> 
					<if test="name!= null"> 
					and name like CONCAT("%",#{name},"%")
					 </if> 
					<if test="content!= null"> 
					and content = #{content}
					 </if> 
					<if test="createDt!= null"> 
					and createDt = #{createDt}
					 </if> 
					<if test="createor!= null"> 
					and createor = #{createor}
					 </if> 
					 <if test="discern!= null"> 
                        and discern = #{discern}
                     </if> 
				 </where> 
			order by id desc  limit #{pageSize}  offset  #{offset}  
		</select>

		<select id="queryAgreementPageCount" parameterType="java.util.Map" resultType="java.lang.Integer">
			SELECT count(*) from tb_pluss_agreement 
					<where> 
					<if test="id!= null"> 
					 and id = #{id}
					 </if> 
					<if test="name!= null"> 
					 and name like CONCAT("%",#{name},"%") 
					 </if> 
					<if test="content!= null"> 
					 and content = #{content}
					 </if> 
					<if test="createDt!= null"> 
					 and createDt = #{createDt}
					 </if> 
					<if test="createor!= null"> 
					 and createor = #{createor}
					 </if> 
					 <if test="discern!= null"> 
                        and discern = #{discern}
                     </if> 
				</where>
		</select>

</mapper>
