地址路径修改

This commit is contained in:
2025-10-26 13:15:04 +08:00
parent be2323074b
commit 271b88232c
77 changed files with 13254 additions and 228 deletions

147
dist/services/employeeService.js vendored Normal file
View File

@@ -0,0 +1,147 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const apiService_1 = __importDefault(require("./apiService"));
/**
* 员工管理服务类
* 提供员工信息的增删改查功能
*/
class EmployeeService {
/**
* 构造函数
*/
constructor() {
// 不再使用模拟数据
}
/**
* 获取所有员工列表
* @returns 员工信息数组
*/
async getEmployees() {
try {
return await apiService_1.default.getEmployees();
}
catch (error) {
console.error('获取员工列表失败:', error);
// API调用失败时返回空数组
return [];
}
}
/**
* 添加新员工
* @param employeeInfo 员工信息
* @returns 添加的员工信息
*/
async addEmployee(employeeInfo) {
try {
return await apiService_1.default.addEmployee(employeeInfo);
}
catch (error) {
console.error('添加员工失败:', error);
throw new Error('添加员工失败,请稍后重试');
}
}
/**
* 删除员工
* @param employeeId 员工ID
* @returns 删除结果
*/
async deleteEmployee(employeeId) {
try {
return await apiService_1.default.deleteEmployee(employeeId);
}
catch (error) {
console.error('删除员工失败:', error);
return {
success: false,
message: '删除员工失败,请稍后重试'
};
}
}
/**
* 更新员工信息
* @param employeeId 员工ID
* @param employeeInfo 员工信息
* @returns 更新后的员工信息
*/
async updateEmployee(employeeId, employeeInfo) {
try {
return await apiService_1.default.updateEmployee(employeeId, employeeInfo);
}
catch (error) {
console.error('更新员工信息失败:', error);
throw new Error('更新员工信息失败,请稍后重试');
}
}
/**
* 根据工号查找员工
* @param phone 工号
* @returns 员工信息或null
*/
async findEmployeeByPhone(phone) {
const employees = await this.getEmployees();
return employees.find(emp => emp.phone === phone) || null;
}
/**
* 验证员工信息(用于绑定时检查)
* @param name 姓名
* @param phone 工号
* @returns 验证结果
*/
async validateEmployee(name, phone) {
const employees = await this.getEmployees();
const employee = employees.find(emp => emp.name === name && emp.phone === phone);
if (employee) {
return {
success: true,
message: '员工信息验证成功',
employee
};
}
else {
return {
success: false,
message: '员工信息不存在,请联系管理员添加'
};
}
}
/**
* 上传员工头像
* @param employeeId 员工ID
* @param filePath 头像文件路径
* @returns 上传结果
*/
async uploadAvatar(employeeId, filePath) {
try {
return await apiService_1.default.uploadEmployeeAvatar(employeeId, filePath);
}
catch (error) {
console.error('上传头像失败:', error);
return {
success: false,
message: '上传头像失败,请稍后重试'
};
}
}
/**
* 获取员工头像URL
* @param employeeId 员工ID
* @returns 头像URL
*/
async getAvatarUrl(employeeId) {
try {
return await apiService_1.default.getEmployeeAvatar(employeeId);
}
catch (error) {
console.error('获取头像失败:', error);
return '';
}
}
}
/**
* 员工管理服务单例实例
* 导出供应用程序全局使用
*/
exports.default = new EmployeeService();