import http from '@/utils/http'

const { request } = http

export interface InsuranceCompany {
  id?: string
  contact: string
  contactPhone: string
  insuranceCompanyName: string
  status: string
  email?: string
  address?: string
  startDate?: string
}

export interface InsuranceCompanyListParams {
  contact?: string
  contactPhone?: string
  insuranceCompanyName?: string
  status?: string
  current?: number
  size?: number
}

export interface InsuranceCompanyListResponse {
  records: InsuranceCompany[]
  total: number
  current: number
  size: number
}

// 新增保险公司信息
export function createInsuranceCompany(data: InsuranceCompany) {
  return request({
    url: '/insurance-company',
    method: 'post',
    data
  })
}

// 查询保险公司信息列表
export function getInsuranceCompanyList(params: InsuranceCompanyListParams) {
  return request<InsuranceCompanyListResponse>({
    url: '/insurance-company/list',
    method: 'get',
    params
  })
}

// 查询保险公司详情
export function getInsuranceCompanyDetail(id: string) {
  return request<InsuranceCompany>({
    url: `/insurance-company/detail/${id}`,
    method: 'get'
  })
}

// 编辑保险公司信息
export function updateInsuranceCompany(id: string, data: InsuranceCompany) {
  return request({
    url: `/insurance-company/${id}`,
    method: 'put',
    data
  })
}

// 删除保险公司
export function deleteInsuranceCompany(id: string) {
  return request({
    url: `/insurance-company/${id}`,
    method: 'delete'
  })
}

// 终止合作
export function terminateCooperation(id: string) {
  return request({
    url: `/insurance-company/terminate/${id}`,
    method: 'post'
  })
}

// 恢复合作
export function resumeCooperation(id: string) {
  return request({
    url: `/insurance-company/resume/${id}`,
    method: 'post'
  })
}

// 获取所有有效保险公司（用于下拉选择）
