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

        <resultMap type="cn.pluss.platform.leshua.LeshuaArea" id="area">
              <result property="code" column="f_area_no" ></result>
              <result property="name" column="f_area_name" jdbcType="VARCHAR"></result>
        </resultMap>

	   	<insert id="saveArea" parameterType="cn.pluss.platform.entity.Area">
        	insert into tb_pluss_area(f_area_no,f_area_name,f_aliasa,f_area_cups_no,f_city_no,f_x,f_y)VALUES(#{f_area_no},#{f_area_name},#{f_aliasa},#{f_area_cups_no},#{f_city_no},#{f_x},#{f_y})
    	</insert>

	   	<insert id="saveAreaBatch">
        	insert into tb_pluss_area(f_area_no,f_area_name,f_aliasa,f_area_cups_no,f_city_no,f_x,f_y) VALUES 
    			<foreach collection="list" item="item" index="index" separator=",">
			(#{f_area_no},#{f_area_name},#{f_aliasa},#{f_area_cups_no},#{f_city_no},#{f_x},#{f_y}		)
				</foreach>
    	</insert>

		<select id="queryArea" parameterType="cn.pluss.platform.entity.Area" resultMap="area">
			SELECT * from tb_pluss_area 
				<where> 
					<if test="f_area_no!= null"> 
					 	and f_area_no = #{f_area_no}
					 </if> 
					<if test="f_area_name!= null"> 
					 	and f_area_name = #{f_area_name}
					 </if> 
					<if test="f_aliasa!= null"> 
					 	and f_aliasa = #{f_aliasa}
					 </if> 
					<if test="f_area_cups_no!= null"> 
					 	and f_area_cups_no = #{f_area_cups_no}
					 </if> 
					<if test="f_city_no!= null"> 
					 	and f_city_no = #{f_city_no}
					 </if> 
					<if test="f_x!= null"> 
					 	and f_x = #{f_x}
					 </if> 
					<if test="f_y!= null"> 
					 	and f_y = #{f_y}
					 </if> 
				 </where> 
		</select>

		<select id="queryAreaList" parameterType="cn.pluss.platform.entity.Area" resultMap="area">
			SELECT * from tb_pluss_area 
				<where> 
					<if test="f_area_no!= null"> 
					 and 	f_area_no = #{f_area_no}
					 </if> 
					<if test="f_area_name!= null"> 
					 and 	f_area_name = #{f_area_name}
					 </if> 
					<if test="f_aliasa!= null"> 
					 and 	f_aliasa = #{f_aliasa}
					 </if> 
					<if test="f_area_cups_no!= null"> 
					 and 	f_area_cups_no = #{f_area_cups_no}
					 </if> 
					<if test="f_city_no!= null"> 
					 and 	f_city_no = #{f_city_no}
					 </if> 
					<if test="f_x!= null"> 
					 and 	f_x = #{f_x}
					 </if> 
					<if test="f_y!= null"> 
					 and 	f_y = #{f_y}
					 </if> 
				 </where> 
		</select>

		<update id="updateArea" parameterType="cn.pluss.platform.entity.Area" >
			update tb_pluss_area 
				  <set> 
					<if test="f_area_no!= null"> 
					 	f_area_no = #{f_area_no},
					 </if> 
					<if test="f_area_name!= null"> 
					 	f_area_name = #{f_area_name},
					 </if> 
					<if test="f_aliasa!= null"> 
					 	f_aliasa = #{f_aliasa},
					 </if> 
					<if test="f_area_cups_no!= null"> 
					 	f_area_cups_no = #{f_area_cups_no},
					 </if> 
					<if test="f_city_no!= null"> 
					 	f_city_no = #{f_city_no},
					 </if> 
					<if test="f_x!= null"> 
					 	f_x = #{f_x},
					 </if> 
					<if test="f_y!= null"> 
					 	f_y = #{f_y}
					 </if> 
				</set>
			where id=#{id} 
		</update>

		<delete id="deleteArea" parameterType="cn.pluss.platform.entity.Area" >
			DELETE FROM tb_pluss_area where id=#{id}
		</delete>

		<select id="queryAreaPage" parameterType="java.util.Map" resultMap="area">
			SELECT * from tb_pluss_area 
				<where> 
					<if test="f_area_no!= null"> 
					and f_area_no = #{f_area_no}
					 </if> 
					<if test="f_area_name!= null"> 
					and f_area_name = #{f_area_name}
					 </if> 
					<if test="f_aliasa!= null"> 
					and f_aliasa = #{f_aliasa}
					 </if> 
					<if test="f_area_cups_no!= null"> 
					and f_area_cups_no = #{f_area_cups_no}
					 </if> 
					<if test="f_city_no!= null"> 
					and f_city_no = #{f_city_no}
					 </if> 
					<if test="f_x!= null"> 
					and f_x = #{f_x}
					 </if> 
					<if test="f_y!= null"> 
					and f_y = #{f_y}
					 </if> 
				 </where> 
			order by id desc  limit #{pageSize}  offset  #{offset}  
		</select>

		<select id="queryAreaPageCount" parameterType="java.util.Map" resultType="java.lang.Integer">
			SELECT count(*) from tb_pluss_area 
					<where> 
					<if test="f_area_no!= null"> 
					 and f_area_no = #{f_area_no}
					 </if> 
					<if test="f_area_name!= null"> 
					 and f_area_name = #{f_area_name}
					 </if> 
					<if test="f_aliasa!= null"> 
					 and f_aliasa = #{f_aliasa}
					 </if> 
					<if test="f_area_cups_no!= null"> 
					 and f_area_cups_no = #{f_area_cups_no}
					 </if> 
					<if test="f_city_no!= null"> 
					 and f_city_no = #{f_city_no}
					 </if> 
					<if test="f_x!= null"> 
					 and f_x = #{f_x}
					 </if> 
					<if test="f_y!= null"> 
					 and f_y = #{f_y}
					 </if> 
				</where>
		</select>

</mapper>
