// 系统管理员认证API端点(系统级,路径前缀 /sys) import type { AxiosInstance } from 'axios'; import type { LoginResponse, SystemUser, ChangePasswordRequest } from '@smartcut/types'; import type { ApiResponse } from '@smartcut/types'; export class SystemAuthApi { constructor(private client: AxiosInstance) {} /** * 系统管理员登录(无需 factory_id) */ async login(data: { username: string; password: string }): Promise { const response = await this.client.post>('/sys/auth/login', data); if (!response.data.data) { throw new Error(response.data.msg || '登录失败'); } return response.data.data; } /** * 获取当前系统管理员信息 */ async getProfile(): Promise { const response = await this.client.get>('/sys/auth/profile'); return response.data.data; } /** * 修改密码 */ async changePassword(data: ChangePasswordRequest): Promise { await this.client.put('/sys/auth/password', data); } /** * 登出(撤销后端 jti) */ async logout(): Promise { await this.client.post('/sys/auth/logout'); } }