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

	   	<insert id="saveNewArea" parameterType="cn.pluss.platform.entity.NewArea">
        	insert into tb_pluss_new_area(parentId,name,shortName,longitude,latitude,level,sort,status,open)VALUES(#{parentId},#{name},#{shortName},#{longitude},#{latitude},#{level},#{sort},#{status},#{open})
    	</insert>

	   	<insert id="saveNewAreaBatch">
        	insert into tb_pluss_new_area(parentId,name,shortName,longitude,latitude,level,sort,status,open) VALUES 
    			<foreach collection="list" item="item" index="index" separator=",">
			(#{parentId},#{name},#{shortName},#{longitude},#{latitude},#{level},#{sort},#{status},#{open}		)
				</foreach>
    	</insert>

		<select id="queryNewArea" parameterType="cn.pluss.platform.entity.NewArea" resultType="cn.pluss.platform.entity.NewArea">
			SELECT * from tb_pluss_new_area 
				<where> 
					<if test="id!= null"> 
					 	and id = #{id}
					 </if> 
					<if test="parentId!= null"> 
					 	and parentId = #{parentId}
					 </if> 
					<if test="name!= null"> 
					 	and name = #{name}
					 </if> 
					<if test="shortName!= null"> 
					 	and shortName = #{shortName}
					 </if> 
					<if test="longitude!= null"> 
					 	and longitude = #{longitude}
					 </if> 
					<if test="latitude!= null"> 
					 	and latitude = #{latitude}
					 </if> 
					<if test="level!= null"> 
					 	and level = #{level}
					 </if> 
					<if test="sort!= null"> 
					 	and sort = #{sort}
					 </if> 
					<if test="status!= null"> 
					 	and status = #{status}
					 </if> 
					<if test="open!= null"> 
					 	and open = #{open}
					 </if> 
				 </where> 
		</select>

		<select id="queryNewAreaList" parameterType="cn.pluss.platform.entity.NewArea" resultType="cn.pluss.platform.entity.NewArea">
			SELECT * from tb_pluss_new_area 
				<where> 
					<if test="id!= null"> 
					 and 	id = #{id}
					 </if> 
					<if test="parentId!= null"> 
					 and 	parentId = #{parentId}
					 </if> 
					<if test="name!= null"> 
					 and 	name = #{name}
					 </if> 
					<if test="shortName!= null"> 
					 and 	shortName = #{shortName}
					 </if> 
					<if test="longitude!= null"> 
					 and 	longitude = #{longitude}
					 </if> 
					<if test="latitude!= null"> 
					 and 	latitude = #{latitude}
					 </if> 
					<if test="level!= null"> 
					 and 	level = #{level}
					 </if> 
					<if test="sort!= null"> 
					 and 	sort = #{sort}
					 </if> 
					<if test="status!= null"> 
					 and 	status = #{status}
					 </if> 
					<if test="open!= null"> 
					 and 	open = #{open}
					 </if> 
				 </where> 
		</select>

		<update id="updateNewArea" parameterType="cn.pluss.platform.entity.NewArea" >
			update tb_pluss_new_area 
				  <set> 
					<if test="parentId!= null"> 
					 	parentId = #{parentId},
					 </if> 
					<if test="name!= null"> 
					 	name = #{name},
					 </if> 
					<if test="shortName!= null"> 
					 	shortName = #{shortName},
					 </if> 
					<if test="longitude!= null"> 
					 	longitude = #{longitude},
					 </if> 
					<if test="latitude!= null"> 
					 	latitude = #{latitude},
					 </if> 
					<if test="level!= null"> 
					 	level = #{level},
					 </if> 
					<if test="sort!= null"> 
					 	sort = #{sort},
					 </if> 
					<if test="status!= null"> 
					 	status = #{status},
					 </if> 
					<if test="open!= null"> 
					 	open = #{open}
					 </if> 
				</set>
			where id=#{id} 
		</update>

		<delete id="deleteNewArea" parameterType="cn.pluss.platform.entity.NewArea" >
			DELETE FROM tb_pluss_new_area where id=#{id}
		</delete>

		<select id="queryNewAreaPage" parameterType="java.util.Map" resultType="cn.pluss.platform.entity.NewArea">
			SELECT * from tb_pluss_new_area 
				<where> 
					<if test="id!= null"> 
					and id = #{id}
					 </if> 
					<if test="parentId!= null"> 
					and parentId = #{parentId}
					 </if> 
					<if test="name!= null"> 
					and name = #{name}
					 </if> 
					<if test="shortName!= null"> 
					and shortName = #{shortName}
					 </if> 
					<if test="longitude!= null"> 
					and longitude = #{longitude}
					 </if> 
					<if test="latitude!= null"> 
					and latitude = #{latitude}
					 </if> 
					<if test="level!= null"> 
					and level = #{level}
					 </if> 
					<if test="sort!= null"> 
					and sort = #{sort}
					 </if> 
					<if test="status!= null"> 
					and status = #{status}
					 </if> 
					<if test="open!= null"> 
					and open = #{open}
					 </if> 
				 </where> 
			order by id desc  limit #{pageSize}  offset  #{offset}  
		</select>

		<select id="queryNewAreaPageCount" parameterType="java.util.Map" resultType="java.lang.Integer">
			SELECT count(*) from tb_pluss_new_area 
					<where> 
					<if test="id!= null"> 
					 and id = #{id}
					 </if> 
					<if test="parentId!= null"> 
					 and parentId = #{parentId}
					 </if> 
					<if test="name!= null"> 
					 and name = #{name}
					 </if> 
					<if test="shortName!= null"> 
					 and shortName = #{shortName}
					 </if> 
					<if test="longitude!= null"> 
					 and longitude = #{longitude}
					 </if> 
					<if test="latitude!= null"> 
					 and latitude = #{latitude}
					 </if> 
					<if test="level!= null"> 
					 and level = #{level}
					 </if> 
					<if test="sort!= null"> 
					 and sort = #{sort}
					 </if> 
					<if test="status!= null"> 
					 and status = #{status}
					 </if> 
					<if test="open!= null"> 
					 and open = #{open}
					 </if> 
				</where>
		</select>

</mapper>
