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/querySecrecyRuleNoticePage',
    method: 'post',
    params,
  });
};

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

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

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

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

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

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

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

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