import request from '@/utils/request';

// 获取通知列表
export async function getNoticeList(params: API.NoticeSearchParams & { pageNo?: number; pageSize?: number }) {
  return request('/notices', {
    method: 'GET',
    params,
  });
}

// 获取通知详情
export async function getNoticeDetail(id: string) {
  return request(`/notices/${id}`, {
    method: 'GET',
  });
}

// 新增通知
export async function addNotice(params: API.NoticeRequest) {
  return request('/notices', {
    method: 'POST',
    data: params,
  });
}

// 更新通知
export async function updateNotice(id: string, params: API.NoticeRequest) {
  return request(`/notices/${id}`, {
    method: 'PUT',
    data: params,
  });
}

// 删除通知
export async function deleteNotice(id: string) {
  return request(`/notices/${id}`, {
    method: 'DELETE',
  });
}

// 批量删除通知
export async function batchDeleteNotice(ids: string[]) {
  return request('/notices/batch', {
    method: 'DELETE',
    data: { ids },
  });
}

// 发布/下架通知
export async function updateNoticeStatus(id: string, status: string) {
  return request(`/notices/${id}/status`, {
    method: 'PUT',
    data: { status },
  });
}

// 置顶/取消置顶通知
export async function updateNoticeTopStatus(id: string, isTop: string) {
  return request(`/notices/${id}/top`, {
    method: 'PUT',
    data: { isTop },
  });
}
