<?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.SystemInfoMapper">

	   	<insert id="saveSystemInfo" parameterType="cn.pluss.platform.entity.SystemInfo">
        	insert into tb_pluss_system_info(title,content,remark,seq,createDt)VALUES(#{title},#{content},#{remark},#{seq},now())
    	</insert>

	   	<insert id="saveSystemInfoBatch">
        	insert into tb_pluss_system_info(title,content,remark,seq) VALUES 
    			<foreach collection="list" item="item" index="index" separator=",">
			(#{title},#{content},#{remark},#{seq}		)
				</foreach>
    	</insert>

		<select id="PageData" resultType="cn.pluss.platform.entity.SystemInfo">
			select id, title, content, remark, seq, createDt
			from tb_pluss_system_info
			<where>
				<if test="systemInfo.id!= null">
					and id = #{systemInfo.id}
				</if>
				<if test="systemInfo.title!= null and systemInfo.title!= ''">
					and title = #{systemInfo.title}
				</if>
				<if test="systemInfo.content!= null and systemInfo.content!= ''">
					and content = #{systemInfo.content}
				</if>
				<if test="systemInfo.remark!= null and remark!= ''">
					and remark = #{systemInfo.remark}
				</if>
				<if test="systemInfo.seq!= null and systemInfo.seq!= ''">
					and seq = #{systemInfo.seq}
				</if>
				<if test="systemInfo.startTime!= null and systemInfo.startTime!=''">
					<![CDATA[
                            and  DATE_FORMAT(createDt, '%Y-%m-%d %H:%i:%S')>=DATE_FORMAT(#{systemInfo.startTime}, '%Y-%m-%d %H:%i:%S')
                         ]]>
				</if>
				<if test="systemInfo.endTime!= null and systemInfo.endTime!=''">
					<![CDATA[
                            and  DATE_FORMAT(createDt, '%Y-%m-%d %H:%i:%S')<=DATE_FORMAT(#{systemInfo.endTime}, '%Y-%m-%d %H:%i:%S')
                         ]]>
				</if>
			</where>
			order by seq
		</select>

		<select id="querySystemInfo" parameterType="cn.pluss.platform.entity.SystemInfo" resultType="cn.pluss.platform.entity.SystemInfo">
			SELECT * from tb_pluss_system_info 
				<where> 
					<if test="id!= null"> 
					 	and id = #{id}
					 </if> 
					<if test="title!= null"> 
					 	and title = #{title}
					 </if> 
					<if test="content!= null"> 
					 	and content = #{content}
					 </if> 
					<if test="remark!= null"> 
					 	and remark = #{remark}
					 </if> 
					<if test="seq!= null"> 
					 	and seq = #{seq}
					 </if> 
					<if test="createDt!= null"> 
					 	and createDt = #{createDt}
					 </if> 
				 </where> 
		</select>

		<select id="querySystemInfoList" parameterType="cn.pluss.platform.entity.SystemInfo" resultType="cn.pluss.platform.entity.SystemInfo">
			SELECT * from tb_pluss_system_info 
				<where> 
					<if test="id!= null"> 
					 and 	id = #{id}
					 </if> 
					<if test="title!= null"> 
					 and 	title = #{title}
					 </if> 
					<if test="content!= null"> 
					 and 	content = #{content}
					 </if> 
					<if test="remark!= null"> 
					 and 	remark = #{remark}
					 </if> 
					<if test="seq!= null"> 
					 and 	seq = #{seq}
					 </if> 
					 <if test="createDt!= null"> 
                        and createDt = #{createDt}
                     </if> 
				 </where> 
		</select>

		<update id="updateSystemInfo" parameterType="cn.pluss.platform.entity.SystemInfo" >
			update tb_pluss_system_info 
				  <set> 
					<if test="title!= null"> 
					 	title = #{title},
					 </if> 
					<if test="content!= null"> 
					 	content = #{content},
					 </if> 
					<if test="remark!= null"> 
					 	remark = #{remark},
					 </if> 
					<if test="seq!= null"> 
					 	seq = #{seq}
					 </if> 
					 <if test="createDt!= null"> 
                         createDt = #{createDt}
                     </if> 
				</set>
			where id=#{id} 
		</update>

		<delete id="deleteSystemInfo" parameterType="cn.pluss.platform.entity.SystemInfo" >
			DELETE FROM tb_pluss_system_info where id=#{id}
		</delete>

		<select id="querySystemInfoPage" parameterType="java.util.Map" resultType="cn.pluss.platform.entity.SystemInfo">
			SELECT * from tb_pluss_system_info 
				<where> 
					<if test="id!= null"> 
					and id = #{id}
					 </if> 
					<if test="title!= null"> 
					and title like CONCAT("%", #{title},"%")
					 </if> 
					<if test="content!= null"> 
					and content like CONCAT("%", #{content},"%")
					 </if> 
					<if test="remark!= null"> 
					and remark = #{remark}
					 </if> 
					<if test="seq!= null"> 
					and seq = #{seq}
					 </if> 
					 <if test="createDt!= null"> 
                        and createDt = #{createDt}
                     </if> 
				 </where> 
			order by seq asc  limit #{pageSize}  offset  #{offset}  
		</select>

		<select id="querySystemInfoPageCount" parameterType="java.util.Map" resultType="java.lang.Integer">
			SELECT count(*) from tb_pluss_system_info 
					<where> 
					<if test="id!= null"> 
					 and id = #{id}
					 </if> 
					<if test="title!= null"> 
					 and title like CONCAT("%",#{title},"%")
					 </if> 
					<if test="content!= null"> 
					 and content like CONCAT("%",#{content},"%") 
					 </if> 
					<if test="remark!= null"> 
					 and remark = #{remark}
					 </if> 
					<if test="seq!= null"> 
					 and seq = #{seq}
					 </if> 
					 <if test="createDt!= null"> 
                        and createDt = #{createDt}
                     </if> 
				</where>
		</select>

</mapper>
