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

	   	<insert id="saveWxCityInfo" parameterType="cn.pluss.platform.entity.WxCityInfo">
        	insert into tb_pluss_wx_city_info(cityCode,cityName)VALUES(#{cityCode},#{cityName})
    	</insert>

	   	<insert id="saveWxCityInfoBatch">
        	insert into tb_pluss_wx_city_info(cityCode,cityName) VALUES 
    			<foreach collection="list" item="item" index="index" separator=",">
			(#{cityCode},#{cityName}		)
				</foreach>
    	</insert>

		<select id="queryWxCityInfo" parameterType="cn.pluss.platform.entity.WxCityInfo" resultType="cn.pluss.platform.entity.WxCityInfo">
			SELECT * from tb_pluss_wx_city_info 
				<where> 
					<if test="id!= null"> 
					 	and id = #{id}
					 </if> 
					<if test="cityCode!= null"> 
					 	and cityCode = #{cityCode}
					 </if>
					<if test="cityName!= null"> 
					 	and cityName LIKE CONCAT(#{cityName},"%")
					 </if> 
				 </where> 
		</select>

		<select id="queryWxCityInfoList" parameterType="cn.pluss.platform.entity.WxCityInfo" resultType="cn.pluss.platform.entity.WxCityInfo">
			SELECT * from tb_pluss_wx_city_info 
				<where> 
					<if test="id!= null"> 
					 and 	id = #{id}
					 </if> 
					<if test="cityCode!= null"> 
					 and 	cityCode = #{cityCode}
					 </if> 
					<if test="cityName!= null"> 
					 and 	cityName = #{cityName}
					 </if> 
				 </where> 
		</select>

		<update id="updateWxCityInfo" parameterType="cn.pluss.platform.entity.WxCityInfo" >
			update tb_pluss_wx_city_info 
				  <set> 
					<if test="cityCode!= null"> 
					 	cityCode = #{cityCode},
					 </if> 
					<if test="cityName!= null"> 
					 	cityName = #{cityName}
					 </if> 
				</set>
			where id=#{id} 
		</update>

		<delete id="deleteWxCityInfo" parameterType="cn.pluss.platform.entity.WxCityInfo" >
			DELETE FROM tb_pluss_wx_city_info where id=#{id}
		</delete>

		<select id="queryWxCityInfoPage" parameterType="java.util.Map" resultType="cn.pluss.platform.entity.WxCityInfo">
			SELECT * from tb_pluss_wx_city_info 
				<where> 
					<if test="id!= null"> 
					and id = #{id}
					 </if> 
					<if test="cityCode!= null"> 
					and cityCode = #{cityCode}
					 </if> 
					<if test="cityName!= null"> 
					and cityName = #{cityName}
					 </if> 
				 </where> 
			order by id desc  limit #{pageSize}  offset  #{offset}  
		</select>

		<select id="queryWxCityInfoPageCount" parameterType="java.util.Map" resultType="java.lang.Integer">
			SELECT count(*) from tb_pluss_wx_city_info 
					<where> 
					<if test="id!= null"> 
					 and id = #{id}
					 </if> 
					<if test="cityCode!= null"> 
					 and cityCode = #{cityCode}
					 </if> 
					<if test="cityName!= null"> 
					 and cityName = #{cityName}
					 </if> 
				</where>
		</select>

</mapper>
