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

const prefix = 'announcement/';
/**
 * 分页查询公告列表
 * @param data
 */
export async function getNoticeList(data: any) {
  return requestClient.get<any>(`${prefix}list`, { params: data });
}

/**
 * 获取最新公告（用于工作台）
 * @param limit
 */
export async function getLatestNotice(limit: number = 10) {
  return requestClient.get<any>(`${prefix}latest`, { params: { limit } });
}

/**
 * 获取详情
 * @param id
 */
export async function getNoticeInfo(id: number) {
  return requestClient.get<any>(`${prefix}detail`, { params: { id } });
}

/**
 * 新增公告
 * @param data
 */
export async function createNotice(data: Record<string, any>) {
  return requestClient.post<any>(`${prefix}create`, data);
}

/**
 * 编辑公告
 * @param data
 */
export async function updateNotice(data: Record<string, any>) {
  return requestClient.post<any>(`${prefix}update`, data);
}

/**
 * 删除公告
 * @param data
 */
export async function deleteNotice(data: Record<string, any>) {
  return requestClient.post<any>(`${prefix}delete`, data);
}
