import request from '@/utils/request'

// ============ 隐患台账管理 ============
export function getHazardPage(pageNum, pageSize, params) {
  return request({ url: '/api/hazard/page', method: 'get', params: { pageNum, pageSize, ...params } })
}
export function getHazardById(id) {
  return request({ url: '/api/hazard/getById/' + id, method: 'get' })
}
export function addHazard(data) {
  return request({ url: '/api/hazard/save', method: 'post', data })
}
export function updateHazard(data) {
  return request({ url: '/api/hazard/updateById', method: 'put', data })
}
export function deleteHazard(id) {
  return request({ url: '/api/hazard/deleteById', method: 'delete', params: { id } })
}
export function submitHazard(hazardId) {
  return request({ url: '/api/hazard/submit/' + hazardId, method: 'put' })
}
export function getHazardMapPoints() {
  return request({ url: '/api/hazard/map-points', method: 'get' })
}
export function getHazardStatisticsByType(params) {
  return request({ url: '/api/hazard/statistics/type', method: 'get', params })
}
export function getHazardStatisticsByStatus(params) {
  return request({ url: '/api/hazard/statistics/status', method: 'get', params })
}
export function getHazardStatisticsOverview(params) {
  return request({ url: '/api/hazard/statistics/overview', method: 'get', params })
}
export function getHazardStatisticsByLevel(params) {
  return request({ url: '/api/hazard/statistics/level', method: 'get', params })
}
export function getHazardStatisticsByRegion(params) {
  return request({ url: '/api/hazard/statistics/region', method: 'get', params })
}
export function getHazardStatisticsTypeTimeline(params) {
  return request({ url: '/api/hazard/statistics/type-timeline', method: 'get', params })
}
export function getHazardStatisticsStatusTimeline(params) {
  return request({ url: '/api/hazard/statistics/status-timeline', method: 'get', params })
}

// ============ 监测预警 ============
export function getAlarmPage(pageNum, pageSize, params) {
  return request({ url: '/api/alarm/findByPage', method: 'get', params: { pageNum, pageSize, ...params } })
}
export function getAlarmById(id) {
  return request({ url: '/api/alarm/getById/' + id, method: 'get' })
}
export function handleAlarm(alarmId, handleUser, handleRemark) {
  return request({ url: '/api/alarm/handle/' + alarmId, method: 'put', params: { handleUser, handleRemark } })
}
export function getActiveAlarmPoints() {
  return request({ url: '/api/alarm/active-points', method: 'get' })
}

// ============ 实时监测 ============
export function getPressureHistory(pointId, hours) {
  return request({ url: '/api/monitor/pressure-history', method: 'get', params: { pointId, hours } })
}
export function getFlowHistory(pointId, hours) {
  return request({ url: '/api/monitor/flow-history', method: 'get', params: { pointId, hours } })
}
export function getGasAlarmLatest() {
  return request({ url: '/api/monitor/gas-alarm-latest', method: 'get' })
}
export function getVideoList() {
  return request({ url: '/api/monitor/video-list', method: 'get' })
}
export function getPointsWithLatestData() {
  return request({ url: '/api/monitor/points-with-latest-data', method: 'get' })
}

// ============ 风险评估 ============
export function getRiskPage(pageNum, pageSize, params) {
  return request({ url: '/api/risk/findByPage', method: 'get', params: { pageNum, pageSize, ...params } })
}
export function getRiskById(riskId) {
  return request({ url: '/api/risk/' + riskId, method: 'get' })
}
export function addRisk(data) {
  return request({ url: '/api/risk/save', method: 'post', data })
}
export function updateRisk(data) {
  return request({ url: '/api/risk/updateById', method: 'put', data })
}
export function deleteRisk(id) {
  return request({ url: '/api/risk/deleteById', method: 'delete', params: { id } })
}
export function getFourColorMap() {
  return request({ url: '/api/risk/four-color-map', method: 'get' })
}
