// 货运人员服务 - 处理货运人员相关的数据操作 import { DeliveryPerson } from '../types'; import apiService from './apiService'; /** * 货运人员服务类 * 提供货运人员信息管理、状态管理等功能 */ class DeliveryPersonService { /** * 构造函数 */ constructor() { // 不再使用模拟数据 } /** * 获取所有货运人员 * @returns 货运人员列表 */ async getDeliveryPersons(): Promise { return apiService.getDeliveryPersons(); } /** * 根据ID获取货运人员 * @param id 货运人员ID * @returns 货运人员信息或null */ async getDeliveryPersonById(id: number): Promise { try { const result = await apiService.getDeliveryPersonById(id); return result; } catch (error) { console.error('获取货运人员失败:', error); return null; } } /** * 获取空闲的货运人员 * @returns 空闲货运人员列表 */ async getIdleDeliveryPersons(): Promise { return apiService.getIdleDeliveryPersons(); } /** * 获取忙碌的货运人员 * @returns 忙碌货运人员列表 */ async getBusyDeliveryPersons(): Promise { return apiService.getBusyDeliveryPersons(); } /** * 获取货运人员当前订单 * @param deliveryPersonId 货运人员ID * @returns 订单列表 */ async getDeliveryPersonOrders(deliveryPersonId: number): Promise> { return apiService.getDeliveryPersonOrders(deliveryPersonId); } } /** * 货运人员服务单例实例 * 导出供应用程序全局使用 */ export default new DeliveryPersonService();