package com.zcxk.rmcp.web.controller;

import com.zcxk.core.common.pojo.AjaxMessage;
import com.zcxk.core.mysql.pageing.Pagination;
import com.zcxk.rmcp.api.dto.BasePageDto;
import com.zcxk.rmcp.api.dto.alarm.DeviceAlarmQueryDto;
import com.zcxk.rmcp.api.dto.device.DeviceQueryDto;
import com.zcxk.rmcp.api.vo.DeviceAlarmVo;
import com.zcxk.rmcp.web.service.DeviceAlarmService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

/**
 * @author linqingwei
 * @date 2021-08-10 15:42
 */
@Controller
@ResponseBody
@RequestMapping("alarm")
@Api(tags  = "告警")
public class AlarmController {

    @Autowired
    private DeviceAlarmService deviceAlarmService;


    @ResponseBody
    @GetMapping("/getPage")
    @ApiOperation(value = "获取告警分页")
    public AjaxMessage<Pagination<DeviceAlarmVo>> getPage(
            @Valid DeviceAlarmQueryDto dto, BasePageDto page
    ) {
        Pagination<DeviceAlarmVo> pageInfo = deviceAlarmService.getPage(dto, page);
        return AjaxMessage.success(pageInfo);
    }


    @ResponseBody
    @GetMapping("/exportExcel")
    @ApiOperation(value = "导出excel")
    public void exportExcel(
            @Valid DeviceAlarmQueryDto dto,
            HttpServletResponse httpServletResponse
    ) {
        deviceAlarmService.exportExcel(dto, httpServletResponse);
    }
}
