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

const prefix = 'file-type/';

export interface FileTypeRecord {
  id: number;
  name: string;
  icon: string;
  value: number;
  suffix: string;
  sort: number;
  status: number;
  created_at?: number;
  updated_at?: number;
}

export async function getFileTypeList() {
  return requestClient.get<FileTypeRecord[]>(`${prefix}list`);
}

export async function getFileTypeDetail(id: number) {
  return requestClient.get<FileTypeRecord>(`${prefix}detail`, { params: { id } });
}

export async function createFileType(data: Partial<FileTypeRecord>) {
  return requestClient.post<any>(`${prefix}create`, data);
}

export async function updateFileType(data: Partial<FileTypeRecord> & { id: number }) {
  return requestClient.post<any>(`${prefix}update`, data);
}

export async function deleteFileType(id: number) {
  return requestClient.post<any>(`${prefix}delete`, { id });
}
