import { requestClient } from '#/api/request';
import type { UserInfo,AdminLog } from '#/model/admin.user';

export interface UserParam {
  uid: string;
}
export interface AdminLogParam {
  username?: string;
  page?: number;
  pageSize?: number;
  opration?: string;
}

export interface AdminConfig {
  id ?: number;
  key: string;
  value: string;
  remark?: string;
}

export interface AdminConfigListParam{
    page?: number;
  pageSize?: number;
}

export async function getAdminInfoApi(param: UserParam) {
  return requestClient.post<UserInfo>('/admin/info', param);
}

export async function getAdminListApi() {
  return requestClient.post<UserInfo[]>('/admin/list');
}

export async function getAdminLogListApi(param:AdminLogParam) {
  return requestClient.post<AdminLog[]>('/admin/log/list', param);
}


export async function addAdminApi(param: UserInfo) {
  return requestClient.post<UserInfo>('/admin/add', param);
}

export async function editAdminApi(param: UserInfo) {
  return requestClient.post('/admin/edit', param);
}

export async function deleteAdminApi(id: number) {
  return requestClient.post('/admin/delete', { id });
}

export async function getAdminConfigList(param:AdminConfigListParam) {
  return requestClient.post<AdminConfig>('/admin/config/list', param);
}

export async function addAdminConfig(param:AdminConfig) {
  return requestClient.post('/admin/config/add', param);
}

export async function editAdminConfig(param:AdminConfig) {
  return requestClient.post('/admin/config/edit', param);
}
