| 123456789101112131415161718192021222324252627282930313233 |
- // 认证API端点
- import type { AxiosInstance } from 'axios';
- import type { LoginRequest, LoginResponse, User, SystemUser, ChangePasswordRequest } from '@smartcut/types';
- import type { ApiResponse } from '@smartcut/types';
- export class AuthApi {
- constructor(private client: AxiosInstance) {}
- /**
- * 用户登录
- * 新增factory_id参数(Query参数传递)
- */
- async login(data: LoginRequest): Promise<LoginResponse> {
- const response = await this.client.post<ApiResponse<LoginResponse>>('/auth/login', data);
- return response.data.data;
- }
- /**
- * 获取当前用户信息
- */
- async getProfile(): Promise<User | SystemUser> {
- const response = await this.client.get<ApiResponse<User | SystemUser>>('/auth/profile');
- return response.data.data;
- }
- /**
- * 修改密码
- */
- async changePassword(data: ChangePasswordRequest): Promise<void> {
- await this.client.put<ApiResponse>('/auth/password', data);
- }
- }
|