import http from '@/utils/http'

const { request } = http

export interface InsuranceType {
  id?: string
  description: string
  insuranceTypeName: string
  coverage?: string
}

export interface InsuranceTypeListParams {
  insuranceTypeName?: string
  description?: string
  current?: number
  size?: number
}

export interface InsuranceTypeListResponse {
  records: InsuranceType[]
  total: number
  current: number
  size: number
}

// 新增保险类型
export function createInsuranceType(data: InsuranceType) {
  return request({
    url: '/insurance-type',
    method: 'post',
    data
  })
}

// 查询保险类型列表
export function getInsuranceTypeList(params?: InsuranceTypeListParams) {
  return request<InsuranceTypeListResponse>({
    url: '/insurance-type/list',
    method: 'get',
    params
  })
}

// 查询保险类型详情
export function getInsuranceTypeDetail(insuranceTypeId: string) {
  return request<InsuranceType>({
    url: `/insurance-type/detail/${insuranceTypeId}`,
    method: 'get'
  })
}

// 编辑保险类型
export function updateInsuranceType(id: string, data: InsuranceType) {
  return request({
    url: `/insurance-type/${id}`,
    method: 'put',
    data
  })
}

// 删除保险类型
export function deleteInsuranceType(id: string) {
  return request({
    url: `/insurance-type/${id}`,
    method: 'delete'
  })
}

// 批量删除保险类型
export function batchDeleteInsuranceType(ids: string[]) {
  return request({
    url: '/insurance-type/batch',
    method: 'delete',
    data: { ids }
  })
}
