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

interface ApiResultData {
  data: Object;
  state: number;
  message: string;
}

/**
 * 获取账号列表
 */
export async function getAccountList(params: any) {
  // 使用模拟数据进行测试
  // return Promise.resolve(mockAccountList);
  const queryString = new URLSearchParams(params);
  return requestClient.get<ApiResultData>('/user/list?' + queryString);
}

/**
 * 获取账号详情
 * @param user_id
 */
export async function getAccountInfo(user_id: string | number) {
  return requestClient.get<ApiResultData>('/user/detail?user_id=' + user_id);
}

/**
 * 更新账号信息
 * @param data
 */
export async function updateAccountInfo(data: any) {
  return requestClient.post<ApiResultData>('/user/update', data);
}

/**
 * 创建账号
 * @param data
 */
export async function createAccount(data: any) {
  return requestClient.post<ApiResultData>('/user/create_user', data);
}

/**
 * 删除账号
 * @param user_id
 */
export async function deleteAccount(data: any) {
  // 模拟删除成功
  // return Promise.resolve({ state: 1, message: '删除成功' });

  // 实际API调用（注释掉）
  return requestClient.post<ApiResultData>('/user/delete', data);
}
