import request from '/@/utils/request';
import type { CompanyPolicyAddReq, CompanyPolicyPageReq } from './types';

/**
 * 分页查询制度文件
 * POST /admin/companyPolicies/page
 */
export function fetchCompanyPoliciesPage(query?: CompanyPolicyPageReq) {
  if (query) {
    query.page = (query as any).current
  }
  return request({
    url: '/admin/companyPolicies/page',
    method: 'post',
    data: query,
  });
}

/**
 * 添加制度文件
 * POST /admin/companyPolicies/add
 */
export function addCompanyPolicy(obj?: CompanyPolicyAddReq) {
  return request({
    url: '/admin/companyPolicies/add',
    method: 'post',
    data: obj,
  });
}

/**
 * 下载次数统计（或登记下载）
 * PUT /admin/companyPolicies/downloadNum
 */
export function downloadCompanyPolicyCount(id?: string | number) {
  return request({
    url: '/admin/companyPolicies/downloadNum?id=' + id,
    method: 'put',
  });
}

/**
 * 删除制度文件
 * DELETE /admin/companyPolicies/delete
 */
export function deleteCompanyPolicies(id?: string) {
  return request({
    url: '/admin/companyPolicies/delete?id=' + id,
    method: 'delete'
  });
}
