package com.fuzamei.service.serviceImpl;

import java.util.HashMap;
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.Role;
import com.fuzamei.entity.User;
import com.fuzamei.mapperInterface.ReceivingClerkMapper;
import com.fuzamei.service.ReceivingClerkService;

@Service
public class ReceivingClerkServiceImpl implements  ReceivingClerkService{
	@Autowired
	private ReceivingClerkMapper receivingClerkMapper;

	
	@Override
	public List<User> queryReceivingClerk(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=receivingClerkMapper.queryReceivingClerk(map);
		}
		else if (username!=null || !username.equals("")) {
			user=receivingClerkMapper.queryReceivingClerk(map);
		}else {
			throw  new RuntimeException("账号异常1");
		}
		 return user;
	}
	

	@Override
	public String  selectRoleByUserId(int user_id) {
		
		return receivingClerkMapper.selectRoleByUserId(user_id);
	}
	
	
}
