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

	   	<insert id="saveBanner" parameterType="cn.pluss.platform.entity.Banner">
        	insert into tb_pluss_banner(picUrl,seq,jumpUrl,type)VALUES(#{picUrl},#{seq},#{jumpUrl},#{type})
    	</insert>

	   	<insert id="saveBannerBatch">
        	insert into tb_pluss_banner(picUrl,seq,jumpUrl,type) VALUES 
    			<foreach collection="list" item="item" index="index" separator=",">
			(#{picUrl},#{seq},#{jumpUrl},#{type}		)
				</foreach>
    	</insert>

		<select id="queryBanner" parameterType="cn.pluss.platform.entity.Banner" resultType="cn.pluss.platform.entity.Banner">
			SELECT * from tb_pluss_banner 
				<where> 
					<if test="id!= null"> 
					 	and id = #{id}
					 </if> 
					<if test="picUrl!= null"> 
					 	and picUrl = #{picUrl}
					 </if> 
					<if test="seq!= null"> 
					 	and seq = #{seq}
					 </if> 
					<if test="jumpUrl!= null"> 
					 	and jumpUrl = #{jumpUrl}
					 </if> 
					 <if test="type!= null"> 
					 	and type = #{type}
					 </if> 
				 </where> 
		</select>

		<select id="queryBannerList" parameterType="cn.pluss.platform.entity.Banner" resultType="cn.pluss.platform.entity.Banner">
			SELECT * from tb_pluss_banner
				<where>
					(`status` != '0' OR `status` IS NULL)
					<if test="id!= null"> 
					 and id = #{id}
					 </if> 
					<if test="picUrl!= null"> 
					 and 	picUrl = #{picUrl}
					 </if> 
					<if test="seq!= null"> 
					 and 	seq = #{seq}
					 </if> 
					<if test="jumpUrl!= null"> 
					 and 	jumpUrl = #{jumpUrl}
					 </if> 
					 <if test="type!= null"> 
					 and 	type = #{type}
					 </if> 
				 </where> 
		</select>

		<update id="updateBanner" parameterType="cn.pluss.platform.entity.Banner" >
			update tb_pluss_banner 
				  <set> 
					<if test="picUrl!= null"> 
					 	picUrl = #{picUrl},
					 </if> 
					<if test="seq!= null"> 
					 	seq = #{seq},
					 </if> 
					<if test="jumpUrl!= null"> 
					 	jumpUrl = #{jumpUrl},
					 </if> 
					 <if test="type!= null"> 
					 	type = #{type}
					 </if> 
				</set>
			where id=#{id} 
		</update>

		<delete id="deleteBanner" parameterType="cn.pluss.platform.entity.Banner" >
			DELETE FROM tb_pluss_banner where id=#{id}
		</delete>

		<select id="queryBannerPage" parameterType="java.util.Map" resultType="cn.pluss.platform.entity.Banner">
			SELECT * from tb_pluss_banner 
				<where> 
					<if test="id!= null"> 
					and id = #{id}
					 </if> 
					<if test="picUrl!= null"> 
					and picUrl = #{picUrl}
					 </if> 
					<if test="seq!= null"> 
					and seq = #{seq}
					 </if> 
					<if test="jumpUrl!= null"> 
					and jumpUrl = #{jumpUrl}
					 </if> 
					 <if test="type!= null"> 
					and type = #{type}
					 </if> 
				 </where> 
			order by id desc  limit #{pageSize}  offset  #{offset}  
		</select>

		<select id="queryBannerPageCount" parameterType="java.util.Map" resultType="java.lang.Integer">
			SELECT count(*) from tb_pluss_banner 
					<where> 
					<if test="id!= null"> 
					 and id = #{id}
					 </if> 
					<if test="picUrl!= null"> 
					 and picUrl = #{picUrl}
					 </if> 
					<if test="seq!= null"> 
					 and seq = #{seq}
					 </if> 
					<if test="jumpUrl!= null"> 
					 and jumpUrl = #{jumpUrl}
					 </if> 
					 <if test="type!= null"> 
					 and type = #{type}
					 </if> 
				</where>
		</select>

</mapper>
