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

// 参数接口
export interface QueryParams {
  id?: number;
  name?: string;
  description?: string;
  createTime?: Record<string, unknown>;
  modifyTime?: Record<string, unknown>;
  createUid?: number;
  disabled?: string;
}

// 响应接口
export interface Res {
  status: boolean;
  msg: string;
  data: Record<string, unknown>;
  total: number;
}

export function search(
  pageNum: number,
  pageSize: number,
  params: QueryParams
): Promise<Service.RequestResult<QueryParams[]>> {
  return request.post(`/category/query?pageNum=${pageNum}&pageSize=${pageSize}`, params);
}

export function add(params: QueryParams): Promise<Service.RequestResult<Res>> {
  return request.post(`/category/add`, params);
}

export function edit(params: QueryParams): Promise<Service.RequestResult<Res>> {
  return request.put(`/category/update`, params);
}

export function del(id: number): Promise<Service.RequestResult<Res>> {
  return request.delete(`/category/delete?id=${id}`);
}
