import { http } from '@/utils/http/axios';
import type { QueryPageRequest, QueryPageResponse } from '@/types/basic-query';

import {
  TableSearchQuery,
  CreateRegulationQuery,
  RegulationDetailResponse,
  NoticeDetailResponse,
  UpdateNoticeQuery,
  CreateNoticeQuery,
} from '@/views/security-confidentiality/confidentiality-regulation-notice/types';

export const getRegulationList = (params: QueryPageRequest<TableSearchQuery>) => {
  return http.request<QueryPageResponse<RegulationDetailResponse>>({
    url: '/defenseRuleNotice/queryDefenseRuleNoticePage',
    method: 'post',
    params,
  });
};

export const createRegulation = (data: CreateRegulationQuery) => {
  return http.request({
    url: '/defenseRuleNotice/saveDefenseRuleNotice',
    method: 'post',
    data,
  });
};

export const updateRegulation = (data: CreateRegulationQuery) => {
  return http.request({
    url: '/defenseRuleNotice/updateDefenseRuleNotice',
    method: 'post',
    data,
  });
};

export const getRegulationDetail = (id: number) => {
  return http.request<RegulationDetailResponse>({
    url: `/defenseRuleNotice/queryDefenseRuleNotice?id=${id}`,
    method: 'post',
  });
};

export const deleteRegulation = (id: number) => {
  return http.request({
    url: `/defenseRuleNotice/deleteDefenseRuleNotice?id=${id}`,
    method: 'post',
  });
};

export const getNoticeList = (params: QueryPageRequest<TableSearchQuery>) => {
  return getRegulationList(params);
};

export const createNotice = (data: CreateNoticeQuery) => {
  return http.request({
    url: '/defenseRuleNotice/saveDefenseRuleNotice',
    method: 'post',
    data,
  });
};

export const updateNotice = (data: UpdateNoticeQuery) => {
  return http.request({
    url: '/defenseRuleNotice/updateDefenseRuleNotice',
    method: 'post',
    data,
  });
};

export const getNoticeDetail = (id: number) => {
  return http.request<NoticeDetailResponse>({
    url: `/defenseRuleNotice/queryDefenseRuleNotice?id=${id}`,
    method: 'post',
  });
};
export const deleteNotice = (id: number) => {
  return deleteRegulation(id);
};
