import type { List } from '@/model';
import type { NotifyModel, NotifyQuery } from '@/model/notify.model';

import request from '@/request/alova';

// 获取通知列表
export function notifyMethod(page: number, size: number, query?: NotifyQuery) {
  return request.Post<List<NotifyModel>, List<any>>(`/fdhb-pc/noticeManage/pageNotice`, query ?? {}, {
    hitSource: /notify$/,
    params: { pageNum: page, pageSize: size },
  });
}
// 获取通知记录分页列表
export function getNotifyRecordMethod(page: number, size: number, query?: NotifyQuery) {
  return request.Post<List<NotifyModel>, List<any>>(`/fdhb-pc/noticeManage/selectNoticeSendRecord`, query ?? {}, {
    hitSource: /notify-record$/,
    params: { pageNum: page, pageSize: size },
  });
}
// 新增/修改通知
export function editNotifyMethod(data: Partial<NotifyModel>) {
  return data.id
    ? request.Post(`/fdhb-pc/noticeManage/updateNotice`, data, { name: 'edit-notify' })
    : request.Post(`/fdhb-pc/noticeManage/addNotice`, data, { name: 'add-notify' });
}
// 删除通知
export function deleteNotifyMethod(data: Partial<NotifyModel>) {
  return request.Post(`/fdhb-pc/noticeManage/deleteNotice/${data.id}`, { name: 'delete-notify' });
}
//启用-停用通知
export function updateNotifyStatusMethod(data: Partial<NotifyModel>) {
  return request.Get(`/fdhb-pc/noticeManage/updateStatus/${data.id}/${data.status}`, { name: 'update-notify-status' });
}
//根据通知ID获取通知详情
export function getNotifyDetailMethod(id: string) {
  return request.Post(`/fdhb-pc/noticeManage/detail/${id}`, { name: 'get-notify-detail' });
}
