import http from '@/utils/http'
import type { CertificationInfo, CertificationListParams, CertificationListResponse, SimpleUserInfo,CertificationPageResponse, CertificationReq } from './type'

const { request } = http

// 导出类型定义
export type { CertificationInfo, CertificationListParams, CertificationListResponse, SimpleUserInfo }

// 新增人员资质
export function createCertification(data: CertificationReq) {
  return request({
    url: '/certification',
    method: 'post',
    data
  })
}

// 查询人员资质信息列表
export function getCertificationList(params: CertificationListParams) {
  return request<CertificationListResponse>({
    url: '/certification/list',
    method: 'get',
    params
  })
}

// 查询人员资质详情
export function getCertificationDetail(certificationId: string) {
  return request<CertificationInfo>({
    url: `/certification/detail/${certificationId}`,
    method: 'get'
  })
}

// 修改人员资质信息
export function updateCertification(certificationId: string, data: CertificationInfo) {
  return request({
    url: `/certification/${certificationId}`,
    method: 'put',
    data
  })
}

// 删除人员资质
export function deleteCertification(certificationId: string) {
  return request({
    url: `/certification/${certificationId}`,
    method: 'delete'
  })
}

// 批量删除人员资质
export function batchDeleteCertification(ids: string[]) {
  return request({
    url: '/certification/batch',
    method: 'delete',
    data: { ids }
  })
}

// 导出人员资质
export function exportCertification(params: CertificationListParams) {
  return request({
    url: '/certification/export',
    method: 'get',
    params,
    responseType: 'blob'
  })
}

// 获取用户列表（用于下拉选择）
export function getUserList() {
  return request<SimpleUserInfo[]>({
    url: '/user/list',
    method: 'get'
  })
} 
// 查询人员资质信息分页列表（新接口）
export function getCertificationPage(params: CertificationListParams) {
  return request<CertificationPageResponse>({
    url: '/certification/page',
    method: 'get',
    params
  })
}