package com.zksy.web.controller.gasbasic;

import com.zksy.base.service.EquipmentAbnormalService;
import com.zksy.common.annotation.Anonymous;
import com.zksy.common.core.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 设备异常 — 终端故障关联设备信息
 */
@Api(tags = "燃气监测-设备异常")
@RestController
@RequestMapping("/api/equipment-abnormal")
@Anonymous
public class EquipmentAbnormalController {

    @Autowired
    private EquipmentAbnormalService equipmentAbnormalService;

    @GetMapping("/list")
    @ApiOperation("分页查询燃气设备故障列表(关联设备名称/类型/地址)")
    public AjaxResult getList(@RequestParam(defaultValue = "1") int pageNum,
                              @RequestParam(defaultValue = "10") int pageSize,
                              @RequestParam(required = false) String searchKey,
                              @RequestParam(required = false) String level,
                              @RequestParam(required = false) String type,
                              @RequestParam(required = false) String status) {
        return AjaxResult.success(equipmentAbnormalService.getList(pageNum, pageSize, searchKey, level, type, status));
    }

    @GetMapping("/stats")
    @ApiOperation("燃气设备故障统计数据")
    public AjaxResult getStats() {
        return AjaxResult.success(equipmentAbnormalService.getStats());
    }
}
