| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- // 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<UserProfileData> => {
- return request<UserProfileData>({
- url: '/auth',
- method: 'GET',
- params: { officialNumber }
- });
- };
- /**
- * 修改用户信息
- * PUT /api/auth
- * @param data 需要修改的用户信息
- */
- export const updateUserProfileApi = (data: UpdateUserInfoRequest): Promise<void> => {
- return request<void>({
- url: '/auth',
- method: 'PUT',
- data
- });
- };
|