import type { ApiResponse } from '@/types/api';
import type { LoginParams, LoginResult, User } from '@/types/auth';

import { request } from '@/utils/request';

/**
 * 登录
 */
export function login(data: LoginParams): Promise<ApiResponse<LoginResult>> {
  return request.post('/auth/login', data);
}

/**
 * 登出
 */
export function logout(): Promise<ApiResponse<null>> {
  return request.post('/auth/logout');
}

/**
 * 获取当前用户信息
 */
export function getUserInfo(): Promise<ApiResponse<User>> {
  return request.get('/auth/user_info');
}
