<?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 = "com.fuzamei.mapperInterface.PlannerMapper">
	<!--查询计划员列表  带条件账号查询  -->
	<select id="queryPlanner"  resultType="com.fuzamei.entity.User">
	    select user_id,username,person_name,create_time,update_time from users  where role_id = 1
	<if test="username!=null and username!='' ">
	   and username=#{username}
	</if>
	</select>
	
	<!--点击查看  根据计划员id查询所有有的供应商  --><!--已添加的供应商  -->
	<select id="queryAllSupplierByPlannerId" resultType="com.fuzamei.entity.User">
       select user_id, person_name from users   where user_id in(select supplier_id from planner_supplier where planner_id=#{plannerId})
	</select>
	
	<!--点击查看    根据计划员id查询没有得供应商  --><!--未添加的供应商  -->
	<select id="queryAllNoSupplierByPlannerId" resultType="com.fuzamei.entity.User">
		select user_id,person_name from users   where role_id=2 and user_id not in(select supplier_id from planner_supplier where planner_id=#{plannerId})
	</select>
	
	<!-- 根据计划员id  删除他原来有的，所对应得供应商。后面在得到前端传来所有得id再次做插入 -->
	<delete id="deleteBeforeSupplierByUserId">
	    delete from planner_supplier where planner_id =#{plannerId}
	</delete>
	
	<!--配置供应商  前端点提交后    获取前端传来得所有供应商Id在做插入操作）  -->
	<insert id="insertAgainSupplier">
		insert into planner_supplier(planner_id,supplier_id) values (#{plannerId},#{supplierId})
	</insert>
	

	
</mapper>