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.CarrierMapper;
import com.fuzamei.mapperInterface.ReceivingClerkMapper;
import com.fuzamei.service.CarrierService;
@Service
public class CarrierServiceImpl implements  CarrierService{
	@Autowired
	private CarrierMapper  carrierMapper;
	@Autowired
	private ReceivingClerkMapper receivingClerkMapper;
	
	@Override
	public List<User> queryCarriers(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");
			String role=receivingClerkMapper.selectRoleByUserId(user_id);//通过用户id查询角色   如果角色是管理员就可以看查看承运商列表
			if (role.equals(Roles.ADMIN)) {
				user=carrierMapper.queryCarriers(map);
			}
			else if (username!=null || !username.equals("")) {
				user=carrierMapper.queryCarriers(map);
			}else {
				throw  new RuntimeException("账号异常");
			}
			 return user;
	}

}
