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

import type {
  BreakTableQuery,
  BreakTableData,
  VisitorTableQuery,
  VisitorTableData,
  BreakPushConfig,
} from '@/views/security-confidentiality/person-management/outer-person/types';

export function getBreakTableList(data: QueryPageRequest<BreakTableQuery>) {
  return http.request<QueryPageResponse<BreakTableData>>({
    url: '/personnelManagement/queryPersonnelIntrudeRecordPage',
    method: 'post',
    data,
  });
}

export function exportBreakTableList(data: BreakTableQuery) {
  return http.request(
    {
      url: '/personnelManagement/exportPersonnelIntrudeRecordList',
      method: 'post',
      data,
      responseType: 'blob',
    },
    {
      isTransformResponse: false,
    },
  );
}

export function getVisitorList(data: QueryPageRequest<VisitorTableQuery>) {
  return http.request<QueryPageResponse<VisitorTableData>>({
    url: '/personnelManagement/queryVisitorAccessRecordPage',
    method: 'post',
    data,
  });
}

export function exportVisitorList(data: VisitorTableQuery) {
  return http.request(
    {
      url: '/personnelManagement/exportVisitorAccessRecordList',
      method: 'post',
      data,
      responseType: 'blob',
    },
    {
      isTransformResponse: false,
    },
  );
}

export function updateBreakPushConfig(data: BreakPushConfig) {
  return http.request({
    url: '/personnelManagement/updateIntrudeAlertPushConfigRes',
    method: 'post',
    data,
  });
}

export function queryBreakPushConfig() {
  return http.request<BreakPushConfig>({
    url: '/personnelManagement/queryIntrudeAlertPushConfig',
    method: 'get',
  });
}
