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

	   	<insert id="saveMerchantImage" parameterType="cn.pluss.platform.entity.MerchantImage">
        	insert into tb_pluss_merchant_image(merchantCode,photoType,photoUrl,picUrl,createDt,updateDt,aisleSwitch)VALUES(#{merchantCode},#{photoType},#{photoUrl},#{picUrl},#{createDt},#{updateDt},#{aisleSwitch})
    	</insert>

	   	<insert id="saveMerchantImageBatch">
        	insert into tb_pluss_merchant_image(merchantCode,photoType,photoUrl,picUrl,createDt,updateDt) VALUES 
    			<foreach collection="list" item="item" index="index" separator=",">
			(#{merchantCode},#{photoType},#{photoUrl},#{picUrl},#{createDt},#{updateDt}		)
				</foreach>
    	</insert>

		<select id="queryMerchantImage" parameterType="cn.pluss.platform.entity.MerchantImage" resultType="cn.pluss.platform.entity.MerchantImage">
			SELECT * from tb_pluss_merchant_image 
				<where> 
					<if test="id!= null"> 
					 	and id = #{id}
					 </if> 
					<if test="merchantCode!= null"> 
					 	and merchantCode = #{merchantCode}
					 </if> 
					<if test="photoType!= null"> 
					 	and photoType = #{photoType}
					 </if> 
					<if test="photoUrl!= null"> 
					 	and photoUrl = #{photoUrl}
					 </if> 
					<if test="picUrl!= null"> 
					 	and picUrl = #{picUrl}
					 </if> 
					<if test="createDt!= null"> 
					 	and createDt = #{createDt}
					 </if> 
					<if test="updateDt!= null"> 
					 	and updateDt = #{updateDt}
					 </if> 
					<if test="aisleSwitch!= null"> 
					 	and aisleSwitch = #{aisleSwitch}
					 </if> 
				 </where> 
		</select>

		<select id="queryMerchantImageList" parameterType="cn.pluss.platform.entity.MerchantImage" resultType="cn.pluss.platform.entity.MerchantImage">
			SELECT * from tb_pluss_merchant_image 
				<where> 
					<if test="id!= null"> 
					 and 	id = #{id}
					 </if> 
					<if test="merchantCode!= null"> 
					 and 	merchantCode = #{merchantCode}
					 </if> 
					<if test="photoType!= null"> 
					 and 	photoType = #{photoType}
					 </if> 
					<if test="photoUrl!= null"> 
					 and 	photoUrl = #{photoUrl}
					 </if> 
					<if test="picUrl!= null"> 
					 and 	picUrl = #{picUrl}
					 </if> 
					<if test="createDt!= null"> 
					 and 	createDt = #{createDt}
					 </if> 
					<if test="updateDt!= null"> 
					 and 	updateDt = #{updateDt}
					 </if> 
					 <if test="aisleSwitch!= null"> 
                        and aisleSwitch = #{aisleSwitch}
                     </if> 
				 </where> 
		</select>

		<update id="updateMerchantImage" parameterType="cn.pluss.platform.entity.MerchantImage" >
			update tb_pluss_merchant_image 
				  <set> 
					<if test="merchantCode!= null"> 
					 	merchantCode = #{merchantCode},
					 </if> 
					<if test="photoType!= null"> 
					 	photoType = #{photoType},
					 </if> 
					<if test="photoUrl!= null"> 
					 	photoUrl = #{photoUrl},
					 </if> 
					<if test="picUrl!= null"> 
					 	picUrl = #{picUrl},
					 </if> 
					<if test="createDt!= null"> 
					 	createDt = #{createDt},
					 </if> 
					<if test="updateDt!= null"> 
					 	updateDt = #{updateDt},
					 </if> 
					 <if test="aisleSwitch!= null"> 
                         aisleSwitch = #{aisleSwitch}
                     </if> 
				</set>
			where id=#{id} 
		</update>

		<delete id="deleteMerchantImage" parameterType="cn.pluss.platform.entity.MerchantImage" >
			DELETE FROM tb_pluss_merchant_image where id=#{id}
		</delete>
		
		<delete id="deleteMerchantImageByMerchantCode" parameterType="cn.pluss.platform.entity.MerchantImage" >
			DELETE FROM tb_pluss_merchant_image where merchantCode=#{merchantCode}
		</delete>

		<select id="queryMerchantImagePage" parameterType="java.util.Map" resultType="cn.pluss.platform.entity.MerchantImage">
			SELECT * from tb_pluss_merchant_image 
				<where> 
					<if test="id!= null"> 
					and id = #{id}
					 </if> 
					<if test="merchantCode!= null"> 
					and merchantCode = #{merchantCode}
					 </if> 
					<if test="photoType!= null"> 
					and photoType = #{photoType}
					 </if> 
					<if test="photoUrl!= null"> 
					and photoUrl = #{photoUrl}
					 </if> 
					<if test="picUrl!= null"> 
					and picUrl = #{picUrl}
					 </if> 
					<if test="createDt!= null"> 
					and createDt = #{createDt}
					 </if> 
					<if test="updateDt!= null"> 
					and updateDt = #{updateDt}
					 </if> 
					 <if test="aisleSwitch!= null"> 
                        and aisleSwitch = #{aisleSwitch}
                     </if> 
				 </where> 
			order by id desc  limit #{pageSize}  offset  #{offset}  
		</select>

		<select id="queryMerchantImagePageCount" parameterType="java.util.Map" resultType="java.lang.Integer">
			SELECT count(*) from tb_pluss_merchant_image 
					<where> 
					<if test="id!= null"> 
					 and id = #{id}
					 </if> 
					<if test="merchantCode!= null"> 
					 and merchantCode = #{merchantCode}
					 </if> 
					<if test="photoType!= null"> 
					 and photoType = #{photoType}
					 </if> 
					<if test="photoUrl!= null"> 
					 and photoUrl = #{photoUrl}
					 </if> 
					<if test="picUrl!= null"> 
					 and picUrl = #{picUrl}
					 </if> 
					<if test="createDt!= null"> 
					 and createDt = #{createDt}
					 </if> 
					<if test="updateDt!= null"> 
					 and updateDt = #{updateDt}
					 </if> 
					 <if test="aisleSwitch!= null"> 
                        and aisleSwitch = #{aisleSwitch}
                     </if> 
				</where>
		</select>

</mapper>
