import { requestClient } from '#/api/request';

export namespace UserApi {
  export interface DeptResult {
    id: number;
    name: string;
  }
  export interface RoleResult {
    id: number;
    name: string;
  }
  export interface CsrfTokenResult {
    token: string;
    headerName: string;
    parameterName: string;
  }

  export interface UserInfo {
    id?: number;
    username: string;
    dept: DeptResult;
    role: RoleResult;
    permissions: string[];
  }
  export interface UserResult {
    user: string | UserInfo;
    csrf: CsrfTokenResult;
  }
}

/**
 * 获取用户信息
 */
export async function getUserInfoApi() {
  return requestClient.get<UserApi.UserResult>('/rest/user/me');
}
