import type { CertificateSettingModel } from './model';

import type { BaseResult } from '#/api/base-result';

import { commonExport } from '#/api/helper';
import { requestClient } from '#/api/request';

// API路径常量枚举
enum Api {
  // 导出
  export = '/sysLicenseRule/rule/export',
  // 列表查询
  list = '/sysLicenseRule/rule/list',
  // 基础路径
  root = '/sysLicenseRule/rule',
}

/**
 * 查询证照规则列表
 * @param params 查询参数
 * @returns 分页结果
 */
export function certificateSettingList(params: any) {
  return requestClient.get<BaseResult<CertificateSettingModel[]>>(Api.list, {
    params,
  });
}

/**
 * 获取证照规则详细信息
 * @param id 证照规则ID
 * @returns 证照规则详情
 */
export function getCertificateSettingDetail(id: number) {
  return requestClient.get<CertificateSettingModel>(`${Api.root}/${id}`);
}

/**
 * 新增证照规则
 * @param data 证照规则数据
 * @returns 操作结果
 */
export function addCertificateSetting(data: CertificateSettingModel) {
  return requestClient.post(Api.root, data, {
    successMessageMode: 'message',
  });
}

/**
 * 修改证照规则
 * @param data 证照规则数据
 * @returns 操作结果
 */
export function updateCertificateSetting(data: CertificateSettingModel) {
  return requestClient.put(Api.root, data, {
    successMessageMode: 'message',
  });
}

/**
 * 删除证照规则
 * @param ids 证照规则ID数组
 * @returns 操作结果
 */
export function deleteCertificateSetting(ids: number[]) {
  return requestClient.delete(`${Api.root}/${ids.join(',')}`, {
    successMessageMode: 'message',
  });
}

/**
 * 导出证照规则列表
 * @param data 导出参数
 * @returns 导出结果
 */
export function exportCertificateSetting(data: Partial<CertificateSettingModel>) {
  return commonExport(Api.export, data);
}
