import request from '@/utils/request'

// ============ 燃气管网基础数据 ============
export function getPipeNetworkPage(pageNum, pageSize, params) {
  return request({ url: '/api/pipe-network/findByPage', method: 'get', params: { pageNum, pageSize, ...params } })
}
export function getPipeNetworkById(id) {
  return request({ url: '/api/pipe-network/getById/' + id, method: 'get' })
}
export function getPipeNetworkOptions() {
  return request({ url: '/api/pipe-network/options', method: 'get' })
}
export function addPipeNetwork(data) {
  return request({ url: '/api/pipe-network/save', method: 'post', data })
}
export function updatePipeNetwork(data) {
  return request({ url: '/api/pipe-network/updateById', method: 'put', data })
}
export function deletePipeNetwork(id) {
  return request({ url: '/api/pipe-network/deleteById', method: 'delete', params: { id } })
}
export function exportPipeNetwork(params) {
  return request({ url: '/api/pipe-network/export', method: 'get', params, responseType: 'blob' })
}

// ============ 窨井管理 ============
export function getManholePage(pageNum, pageSize, params) {
  return request({ url: '/api/manhole/findByPage', method: 'get', params: { pageNum, pageSize, ...params } })
}
export function getManholeById(id) {
  return request({ url: '/api/manhole/getById/' + id, method: 'get' })
}
export function getManholeOptions() {
  return request({ url: '/api/manhole/options', method: 'get' })
}
export function getManholeList() {
  return request({ url: '/api/manhole/list', method: 'get' })
}
export function addManhole(data) {
  return request({ url: '/api/manhole/save', method: 'post', data })
}
export function updateManhole(data) {
  return request({ url: '/api/manhole/updateById', method: 'put', data })
}
export function deleteManhole(id) {
  return request({ url: '/api/manhole/deleteById', method: 'delete', params: { id } })
}

// ============ 窨井-设备关联 ============
export function getManholeDevices(manholeId) {
  return request({ url: '/api/manhole/device/list/' + manholeId, method: 'get' })
}
export function addManholeDeviceRel(data) {
  return request({ url: '/api/manhole/device/save', method: 'post', data })
}
export function addManholeDeviceRelBatch(dataList) {
  return request({ url: '/api/manhole/device/save-batch', method: 'post', data: dataList })
}
export function deleteManholeDeviceRel(relId) {
  return request({ url: '/api/manhole/device/delete', method: 'delete', params: { relId } })
}

// ============ 维修记录 ============
export function getRepairRecordPage(pageNum, pageSize, params) {
  return request({ url: '/api/repair-record/findByPage', method: 'get', params: { pageNum, pageSize, ...params } })
}
export function getRepairRecordById(id) {
  return request({ url: '/api/repair-record/getById/' + id, method: 'get' })
}
export function getRepairRecordByNetwork(networkId) {
  return request({ url: '/api/repair-record/list-by-network/' + networkId, method: 'get' })
}
export function addRepairRecord(data) {
  return request({ url: '/api/repair-record/save', method: 'post', data })
}
export function updateRepairRecord(data) {
  return request({ url: '/api/repair-record/updateById', method: 'put', data })
}
export function deleteRepairRecord(id) {
  return request({ url: '/api/repair-record/deleteById', method: 'delete', params: { id } })
}

// ============ 监测设备管理 ============
export function getEquipmentList() {
  return request({ url: '/EquipmentBase/getList', method: 'get' })
}
export function getEquipmentPage(pageNum, pageSize, params) {
  return request({ url: '/EquipmentBase/findByPage', method: 'get', params: { pageNum, pageSize, ...params } })
}
export function getEquipmentFullPage(pageNum, pageSize, params) {
  return request({ url: '/api/equipment/findFullByPage', method: 'get', params: { pageNum, pageSize, ...params } })
}
export function getEquipmentById(id) {
  return request({ url: '/EquipmentBase/getById/' + id, method: 'get' })
}
export function addEquipment(data) {
  return request({ url: '/api/equipment/save', method: 'post', data })
}
export function updateEquipment(data) {
  return request({ url: '/api/equipment/updateById', method: 'put', data })
}
export function deleteEquipment(id) {
  return request({ url: '/api/equipment/deleteById', method: 'delete', params: { id } })
}
export function getEquipmentTypeList() {
  return request({ url: '/EquipmentType/getList', method: 'get' })
}
export function getEquipmentByTopLevelType(typeName) {
  return request({ url: '/EquipmentBase/findByTopLevelType', method: 'get', params: { typeName } })
}
export function getGasDashboardSummary() {
  return request({ url: '/api/gas-dashboard/summary', method: 'get' })
}
export function getEquipmentStatus(equipmentId) {
  return request({ url: '/api/equipment/status/' + equipmentId, method: 'get' })
}
export function getEquipmentAbnormalList() {
  return request({ url: '/api/equipment/abnormal', method: 'get' })
}
export function getPointRelByEquipment(equipmentId) {
  return request({ url: '/api/equipment/point-rel/' + equipmentId, method: 'get' })
}
export function getEquipmentByPoint(pointId) {
  return request({ url: '/api/equipment/point-rel/by-point/' + pointId, method: 'get' })
}
// ============ 管点-设备关联 ============
export function getPipePointDevices(pointId) {
  return request({ url: '/api/gas-pipe-point/device/list/' + pointId, method: 'get' })
}
export function addPipePointDeviceRel(data) {
  return request({ url: '/api/gas-pipe-point/device/save', method: 'post', data })
}
export function saveEquipmentDeviceRel(data) {
  return request({ url: '/api/equipment/device-rel/save', method: 'post', data })
}
export function addPipePointDeviceRelBatch(dataList) {
  return request({ url: '/api/gas-pipe-point/device/save-batch', method: 'post', dataList })
}
export function deletePipePointDeviceRel(relId) {
  return request({ url: '/api/gas-pipe-point/device/delete', method: 'delete', params: { relId } })
}
export function savePointRel(data) {
  return request({ url: '/api/equipment/point-rel/save', method: 'post', data })
}
export function deletePointRel(relId) {
  return request({ url: '/api/equipment/point-rel/delete', method: 'delete', params: { relId } })
}

// ============ 测点管理 ============
export function getPointPage(pageNum, pageSize, params) {
  return request({ url: '/api/monitor-point/findByPage', method: 'get', params: { pageNum, pageSize, ...params } })
}
export function getPointById(id) {
  return request({ url: '/api/monitor-point/getById/' + id, method: 'get' })
}
export function addPoint(data) {
  return request({ url: '/api/monitor-point/save', method: 'post', data })
}
export function updatePoint(data) {
  return request({ url: '/api/monitor-point/updateById', method: 'put', data })
}
export function deletePoint(id) {
  return request({ url: '/api/monitor-point/deleteById', method: 'delete', params: { id } })
}

// ============ 燃气管点管理 ============
export function getGasPipePointPage(pageNum, pageSize, params) {
  return request({ url: '/api/gas-pipe-point/findByPage', method: 'get', params: { pageNum, pageSize, ...params } })
}
export function getGasPipePointById(id) {
  return request({ url: '/api/gas-pipe-point/getById/' + id, method: 'get' })
}
export function getGasPipePointByNetwork(networkId) {
  return request({ url: '/api/gas-pipe-point/list-by-network/' + networkId, method: 'get' })
}
export function getGasPipePointOptions() {
  return request({ url: '/api/gas-pipe-point/options', method: 'get' })
}
export function addGasPipePoint(data) {
  return request({ url: '/api/gas-pipe-point/save', method: 'post', data })
}
export function updateGasPipePoint(data) {
  return request({ url: '/api/gas-pipe-point/updateById', method: 'put', data })
}
export function deleteGasPipePoint(id) {
  return request({ url: '/api/gas-pipe-point/deleteById', method: 'delete', params: { id } })
}

// ============ GIS一张图 ============
export function getGisPipeLines(params) {
  return request({ url: '/api/gis/pipe-lines', method: 'get', params })
}
export function getGisManholes() {
  return request({ url: '/api/gis/manholes', method: 'get' })
}
export function getGisEquipments(params) {
  return request({ url: '/api/gis/equipments', method: 'get', params })
}
