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

	   	<insert id="saveRoleMenuInfo" parameterType="cn.pluss.platform.entity.RoleMenuInfo">
        	insert into tb_pluss_role_menu_info(roleId,menuId)VALUES(#{roleId},#{menuId})
    	</insert>

	   	<insert id="saveRoleMenuInfoBatch">
        	insert into tb_pluss_role_menu_info(roleId,menuId) VALUES 
    			<foreach collection="list" item="item" index="index" separator=",">
			(#{roleId},#{menuId}		)
				</foreach>
    	</insert>

		<select id="queryRoleMenuInfo" parameterType="cn.pluss.platform.entity.RoleMenuInfo" resultType="cn.pluss.platform.entity.RoleMenuInfo">
			SELECT * from tb_pluss_role_menu_info 
				<where> 
					<if test="id!= null"> 
					 and	id = #{id}
					 </if> 
					<if test="roleId!= null"> 
					 and	roleId = #{roleId}
					 </if> 
					<if test="menuId!= null"> 
					 and	menuId = #{menuId}
					 </if> 
				 </where> 
		</select>

		<select id="queryRoleMenuInfoList" parameterType="cn.pluss.platform.entity.RoleMenuInfo" resultType="cn.pluss.platform.entity.RoleMenuInfo">
			SELECT * from tb_pluss_role_menu_info 
				<where> 
					<if test="id!= null"> 
					 and	id = #{id}
					 </if> 
					<if test="roleId!= null"> 
					 and	roleId = #{roleId}
					 </if> 
					<if test="menuId!= null"> 
					 and	menuId = #{menuId}
					 </if> 
				 </where> 
		</select>

		<update id="updateRoleMenuInfo" parameterType="cn.pluss.platform.entity.RoleMenuInfo" >
			update tb_pluss_role_menu_info 
				  <set> 
					<if test="roleId!= null"> 
					 roleId = #{roleId},
					 </if> 
					<if test="menuId!= null"> 
					 menuId = #{menuId}
					 </if> 
				</set>
			where id=#{id} 
		</update>

		<delete id="deleteRoleMenuInfo" parameterType="cn.pluss.platform.entity.RoleMenuInfo" >
			DELETE FROM tb_pluss_role_menu_info where roleId=#{roleId}
		</delete>

		<select id="queryRoleMenuInfoPage" parameterType="java.util.Map" resultType="cn.pluss.platform.entity.RoleMenuInfo">
			SELECT * from tb_pluss_role_menu_info 
				<where> 
					<if test="id!= null"> 
					 and	id = #{id}
					 </if> 
					<if test="roleId!= null"> 
					 and	roleId = #{roleId}
					 </if> 
					<if test="menuId!= null"> 
					 and	menuId = #{menuId}
					 </if> 
				 </where> 
			order by id desc  limit #{pageSize}  offset  #{offset}  
		</select>

		<select id="queryRoleMenuInfoPageCount" parameterType="java.util.Map" resultType="java.lang.Integer">
			SELECT count(*) from tb_pluss_role_menu_info 
					<where> 
					<if test="id!= null"> 
					 and	id = #{id}
					 </if> 
					<if test="roleId!= null"> 
					 and	roleId = #{roleId}
					 </if> 
					<if test="menuId!= null"> 
					 and	menuId = #{menuId}
					 </if> 
				</where>
		</select>

</mapper>
