// src/api/user.ts import { request } from '@/utils/request'; // 获取用户信息的响应数据接口 interface UserProfileData { birthday: string | null; contactEmail: string | null; createTime: string; englishName: string | null; gender: number | null; // 【修正】后端返回的是 number id: number; lastLoginTime: string | null; name: string; officialEmail: string; officialNumber: string; password: string; phone: string; pid: string | null; // 【修正】pid 是 string role: number; // 【修正】后端返回的是 number userAvatar: string; } export interface UserProfileResponse { code: number; data: UserProfileData; msg: string; } // 更新用户信息的请求体接口 interface UpdateUserInfoRequest { name?: string; officialEmail?: string | null; officialNumber?: string | null; role?: 'STUDENT' | 'TEACHER' | null; userAvatar?: string | null; englishName?: string | null; gender?: number | string | null; birthday?: string | null; contentEmail?: string | null; } /** * 获取当前用户个人信息 * GET /api/auth * @param officialNumber 学生的学号/工号,用于查询 */ export const getUserProfileApi = (officialNumber: string | number): Promise => { return request({ url: '/auth', method: 'GET', params: { officialNumber } }); }; /** * 修改用户信息 * PUT /api/auth * @param data 需要修改的用户信息 */ export const updateUserProfileApi = (data: UpdateUserInfoRequest): Promise => { return request({ url: '/auth', method: 'PUT', data }); };