package com.fuzamei.service.serviceImpl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.fuzamei.constant.Roles;
import com.fuzamei.entity.User;
import com.fuzamei.mapperInterface.PlannerMapper;
import com.fuzamei.mapperInterface.ReceivingClerkMapper;
import com.fuzamei.service.PlannerService;
@Service
public class PlannerServiceImpl implements  PlannerService{
  @Autowired
  private PlannerMapper  plannerMapper;
  @Autowired
  private ReceivingClerkMapper receivingClerkMapper;


	@Override
	public List<User> queryPlanner(Map<String, Object> map) {
	    List<User>  user= null; 
		//Map<String, Object> account = new LinkedHashMap<String, Object>(); 
	    int user_id=(int) map.get("user_id");
		String username=(String) map.get("username");
		System.out.println(username+"kkkkk");
		String role=receivingClerkMapper.selectRoleByUserId(user_id);//通过用户id查询角色   如果角色是管理员就可以看查看收货员列表
	    System.out.println(role+"lllllll");
		if (role.equals(Roles.ADMIN)) {
			user=plannerMapper.queryPlanner(map);
		}
		else if (username!=null || !username.equals("")) {
			user=plannerMapper.queryPlanner(map);
		}else {
			throw  new RuntimeException("账号异常5");
		}
		 return user;
		
    }


	@Override
	public List<User> queryAllSupplierByPlannerId(int plannerId) {//根据计划员id查询已经有的供应商
		return plannerMapper.queryAllSupplierByPlannerId(plannerId);
	}


	@Override
	public List<User> queryAllNoSupplierByPlannerId(int plannerId) {////根据计划员id查询未添加的供应商
		return plannerMapper.queryAllNoSupplierByPlannerId(plannerId);
	}
	
}
