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

	   	<insert id="saveLevel" parameterType="cn.pluss.platform.entity.Level">
        	insert into tb_pluss_level(level,tradeMoney,authCount,levelName,rate,createDt,logo)VALUES(#{level},#{tradeMoney},#{authCount},#{levelName},#{rate},#{createDt},#{logo})
    	</insert>

	   	<insert id="saveLevelBatch">
        	insert into tb_pluss_level(level,tradeMoney,authCount,levelName,rate,createDt,logo) VALUES 
    			<foreach collection="list" item="item" index="index" separator=",">
			(#{level},#{tradeMoney},#{authCount},#{levelName},#{rate},#{createDt},#{logo}		)
				</foreach>
    	</insert>

		<select id="queryLevel" parameterType="cn.pluss.platform.entity.Level" resultType="cn.pluss.platform.entity.Level">
			SELECT * from tb_pluss_level 
				<where> 
					<if test="id!= null"> 
					 	and id = #{id}
					 </if> 
					<if test="level!= null"> 
					 	and level = #{level}
					 </if> 
					<if test="tradeMoney!= null"> 
					 	and tradeMoney = #{tradeMoney}
					 </if> 
					<if test="authCount!= null"> 
					 	and authCount = #{authCount}
					 </if> 
					<if test="levelName!= null"> 
					 	and levelName = #{levelName}
					 </if> 
					<if test="rate!= null"> 
					 	and rate = #{rate}
					 </if> 
					<if test="createDt!= null"> 
					 	and createDt = #{createDt}
					 </if> 
					<if test="logo!= null"> 
					 	and logo = #{logo}
					 </if> 
				 </where> 
		</select>

		<select id="queryLevelList" parameterType="cn.pluss.platform.entity.Level" resultType="cn.pluss.platform.entity.Level">
			SELECT * from tb_pluss_level 
				<where> 
					<if test="id!= null"> 
					 and 	id = #{id}
					 </if> 
					<if test="level!= null"> 
					 and 	level = #{level}
					 </if> 
					<if test="tradeMoney!= null"> 
					 and 	tradeMoney = #{tradeMoney}
					 </if> 
					<if test="authCount!= null"> 
					 and 	authCount = #{authCount}
					 </if> 
					<if test="levelName!= null"> 
					 and 	levelName = #{levelName}
					 </if> 
					<if test="rate!= null"> 
					 and 	rate = #{rate}
					 </if> 
					<if test="createDt!= null"> 
					 and 	createDt = #{createDt}
					 </if> 
					<if test="logo!= null"> 
					 and 	logo = #{logo}
					 </if> 
				 </where> 
		</select>

		<update id="updateLevel" parameterType="cn.pluss.platform.entity.Level" >
			update tb_pluss_level 
				  <set> 
					<if test="level!= null"> 
					 	level = #{level},
					 </if> 
					<if test="tradeMoney!= null"> 
					 	tradeMoney = #{tradeMoney},
					 </if> 
					<if test="authCount!= null"> 
					 	authCount = #{authCount},
					 </if> 
					<if test="levelName!= null"> 
					 	levelName = #{levelName},
					 </if> 
					<if test="rate!= null"> 
					 	rate = #{rate},
					 </if> 
					<if test="createDt!= null"> 
					 	createDt = #{createDt},
					 </if> 
					<if test="logo!= null"> 
					 	logo = #{logo}
					 </if> 
				</set>
			where id=#{id} 
		</update>

		<delete id="deleteLevel" parameterType="cn.pluss.platform.entity.Level" >
			DELETE FROM tb_pluss_level where id=#{id}
		</delete>

		<select id="queryLevelPage" parameterType="java.util.Map" resultType="cn.pluss.platform.entity.Level">
			SELECT * from tb_pluss_level 
				<where> 
					<if test="id!= null"> 
					and id = #{id}
					 </if> 
					<if test="level!= null"> 
					and level = #{level}
					 </if> 
					<if test="tradeMoney!= null"> 
					and tradeMoney = #{tradeMoney}
					 </if> 
					<if test="authCount!= null"> 
					and authCount = #{authCount}
					 </if> 
					<if test="levelName!= null"> 
					and levelName = #{levelName}
					 </if> 
					<if test="rate!= null"> 
					and rate = #{rate}
					 </if> 
					<if test="createDt!= null"> 
					and createDt = #{createDt}
					 </if> 
					<if test="logo!= null"> 
					and logo = #{logo}
					 </if> 
				 </where> 
			order by id desc  limit #{pageSize}  offset  #{offset}  
		</select>

		<select id="queryLevelPageCount" parameterType="java.util.Map" resultType="java.lang.Integer">
			SELECT count(*) from tb_pluss_level 
					<where> 
					<if test="id!= null"> 
					 and id = #{id}
					 </if> 
					<if test="level!= null"> 
					 and level = #{level}
					 </if> 
					<if test="tradeMoney!= null"> 
					 and tradeMoney = #{tradeMoney}
					 </if> 
					<if test="authCount!= null"> 
					 and authCount = #{authCount}
					 </if> 
					<if test="levelName!= null"> 
					 and levelName = #{levelName}
					 </if> 
					<if test="rate!= null"> 
					 and rate = #{rate}
					 </if> 
					<if test="createDt!= null"> 
					 and createDt = #{createDt}
					 </if> 
					<if test="logo!= null"> 
					 and logo = #{logo}
					 </if> 
				</where>
		</select>

</mapper>
