package com.njcn.harmonic.controller;

import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.harmonic.pojo.param.HistoryHarmOverLimitParam;
import com.njcn.harmonic.pojo.vo.HistoryHarmOverLimitVO;
import com.njcn.harmonic.service.NormLimitService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 异常数据统计
 * @author denghuajun
 * @version 1.0.0
 * @date 2022/3/18
 */
@Slf4j
@RestController
@RequestMapping("/normLimit")
@Api(tags = "异常数据统计")
@AllArgsConstructor
public class NormLimitController extends BaseController {

    private final NormLimitService normLimitService;

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getHistoryTableData")
    @ApiOperation("异常数据统计")
    @ApiImplicitParam(name = "historyHarmOverLimitParam", value = "异常数据统计参数", required = true)
    public HttpResult<List<HistoryHarmOverLimitVO>> getHistoryTableData(@RequestBody @Validated HistoryHarmOverLimitParam historyHarmOverLimitParam) {
        String methodDescribe = getMethodDescribe("getHistoryTableData");
        List<HistoryHarmOverLimitVO> list = normLimitService.getHistoryData(historyHarmOverLimitParam,0);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getHistoryData")
    @ApiOperation("告警数据统计")
    @ApiImplicitParam(name = "historyHarmOverLimitParam", value = "异常数据统计参数", required = true)
    public HttpResult<List<HistoryHarmOverLimitVO>> getHistoryData(@RequestBody @Validated HistoryHarmOverLimitParam historyHarmOverLimitParam) {
        String methodDescribe = getMethodDescribe("getHistoryData");
        List<HistoryHarmOverLimitVO> list = normLimitService.getHistoryData(historyHarmOverLimitParam,1);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
    }
}
