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

	   	<insert id="saveProvince" parameterType="cn.pluss.platform.entity.Province">
        	insert into tb_pluss_province(f_province_no,f_province_name,f_aliasp,f_province_cups_no)VALUES(#{f_province_no},#{f_province_name},#{f_aliasp},#{f_province_cups_no})
    	</insert>

	   	<insert id="saveProvinceBatch">
        	insert into tb_pluss_province(f_province_no,f_province_name,f_aliasp,f_province_cups_no) VALUES 
    			<foreach collection="list" item="item" index="index" separator=",">
			(#{f_province_no},#{f_province_name},#{f_aliasp},#{f_province_cups_no}		)
				</foreach>
    	</insert>

		<select id="queryProvince" parameterType="cn.pluss.platform.entity.Province" resultMap="province">
			SELECT * from tb_pluss_province 
				<where> 
					<if test="f_province_no!= null"> 
					 	and f_province_no = #{f_province_no}
					 </if> 
					<if test="f_province_name!= null"> 
					 	and f_province_name = #{f_province_name}
					 </if> 
					<if test="f_aliasp!= null"> 
					 	and f_aliasp = #{f_aliasp}
					 </if> 
					<if test="f_province_cups_no!= null"> 
					 	and f_province_cups_no = #{f_province_cups_no}
					 </if> 
				 </where> 
		</select>
		
		<resultMap type="cn.pluss.platform.leshua.LeshuaProvince" id="province">
              <result property="code" column="F_province_no" ></result>
              <result property="name" column="F_province_name" jdbcType="VARCHAR"></result>
        </resultMap>

		<select id="queryProvinceList" parameterType="cn.pluss.platform.entity.Province" resultMap="province">
			SELECT * from tb_pluss_province
				<where> 
					<if test="f_province_no!= null"> 
					 and 	f_province_no = #{f_province_no}
					 </if> 
					<if test="f_province_name!= null"> 
					 and 	f_province_name = #{f_province_name}
					 </if> 
					<if test="f_aliasp!= null"> 
					 and 	f_aliasp = #{f_aliasp}
					 </if> 
					<if test="f_province_cups_no!= null"> 
					 and 	f_province_cups_no = #{f_province_cups_no}
					 </if> 
				 </where> 
		</select>

		<update id="updateProvince" parameterType="cn.pluss.platform.entity.Province" >
			update tb_pluss_province 
				  <set> 
					<if test="f_province_no!= null"> 
					 	f_province_no = #{f_province_no},
					 </if> 
					<if test="f_province_name!= null"> 
					 	f_province_name = #{f_province_name},
					 </if> 
					<if test="f_aliasp!= null"> 
					 	f_aliasp = #{f_aliasp},
					 </if> 
					<if test="f_province_cups_no!= null"> 
					 	f_province_cups_no = #{f_province_cups_no}
					 </if> 
				</set>
			where id=#{id} 
		</update>

		<delete id="deleteProvince" parameterType="cn.pluss.platform.entity.Province" >
			DELETE FROM tb_pluss_province where id=#{id}
		</delete>

		<select id="queryProvincePage" parameterType="java.util.Map" resultMap="province">
			SELECT * from tb_pluss_province 
				<where> 
					<if test="f_province_no!= null"> 
					and f_province_no = #{f_province_no}
					 </if> 
					<if test="f_province_name!= null"> 
					and f_province_name = #{f_province_name}
					 </if> 
					<if test="f_aliasp!= null"> 
					and f_aliasp = #{f_aliasp}
					 </if> 
					<if test="f_province_cups_no!= null"> 
					and f_province_cups_no = #{f_province_cups_no}
					 </if> 
				 </where> 
			order by id desc  limit #{pageSize}  offset  #{offset}  
		</select>

		<select id="queryProvincePageCount" parameterType="java.util.Map" resultType="java.lang.Integer">
			SELECT count(*) from tb_pluss_province 
					<where> 
					<if test="f_province_no!= null"> 
					 and f_province_no = #{f_province_no}
					 </if> 
					<if test="f_province_name!= null"> 
					 and f_province_name = #{f_province_name}
					 </if> 
					<if test="f_aliasp!= null"> 
					 and f_aliasp = #{f_aliasp}
					 </if> 
					<if test="f_province_cups_no!= null"> 
					 and f_province_cups_no = #{f_province_cups_no}
					 </if> 
				</where>
		</select>

</mapper>
