import request from '@/config/axios'

export interface DangerReportVO {
  id: number
  discoverer: string
  discoverTime: string
  location: string
  description: string
  safetyOfficer: string
  status: string
  images: DangerImageVO[]
  createTime: string
}

export interface DangerImageVO {
  url: string
  name: string
}

export interface DangerReportPageReqVO extends PageParam {
  discoverer?: string
  safetyOfficer?: string
  status?: string
  discoverTime?: string[]
}

export interface DangerReportExportReqVO {
  discoverer?: string
  safetyOfficer?: string
  status?: string
  discoverTime?: string[]
}

export interface DangerReportCreateReqVO {
  discoverer: string
  discoverTime: string
  location: string
  description: string
  safetyOfficer: string
  status: string
  images?: DangerImageVO[]
}

export interface DangerReportUpdateReqVO extends DangerReportCreateReqVO {
  id: number
}

// 查询隐患上报分页
export const getDangerReportPage = (params: DangerReportPageReqVO) => {
  return request.get({ url: '/safe/danger-report/page', params })
}

// 查询隐患上报详情
export const getDangerReport = (id: number) => {
  return request.get({ url: `/safe/danger-report/get?id=${id}` })
}

// 新增隐患上报
export const createDangerReport = (data: DangerReportCreateReqVO) => {
  return request.post({ url: '/safe/danger-report/create', data })
}

// 修改隐患上报
export const updateDangerReport = (data: DangerReportUpdateReqVO) => {
  return request.put({ url: '/safe/danger-report/update', data })
}

// 删除隐患上报
export const deleteDangerReport = (id: number) => {
  return request.delete({ url: `/safe/danger-report/delete?id=${id}` })
}

// 导出隐患上报 Excel
export const exportDangerReport = (params: DangerReportExportReqVO) => {
  return request.download({ url: '/safe/danger-report/export-excel', params })
}

// 根据状态统计隐患数量
export const getDangerReportCountByStatus = (status: string) => {
  return request.get({ url: `/safe/danger-report/count-by-status?status=${status}` })
}

// 根据安全员统计隐患数量
export const getDangerReportCountBySafetyOfficer = (safetyOfficer: string) => {
  return request.get({ url: `/safe/danger-report/count-by-safety-officer?safetyOfficer=${safetyOfficer}` })
} 