package com.njcn.harmonic.controller;

import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
import com.njcn.harmonic.pojo.vo.OnlineRateCensusVO;
import com.njcn.harmonic.pojo.vo.OnlineRateVO;
import com.njcn.harmonic.service.OnlineRateDataService;
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 chenchao
 * @createTime 2022/2/16 11:17
 */
@Validated
@Slf4j
@RestController
@RequestMapping("/onlineRateData")
@Api(tags = "终端在线率")
@AllArgsConstructor
public class OnlineRateDataController extends BaseController {

    private final OnlineRateDataService onlineRateDataService;

    @OperateInfo
    @PostMapping("/getOnlineRateData")
    @ApiOperation("终端在线率列表")
    @ApiImplicitParam(name = "onlineRateParam", value = "终端在线率参数", required = true)
    public HttpResult<List<OnlineRateVO>> getOnlineRateData(@RequestBody @Validated DeviceInfoParam.BusinessParam onlineRateParam) {
        String methodDescribe = getMethodDescribe("getOnlineRateData");
        List<OnlineRateVO> list = onlineRateDataService.getOnlineRateData(onlineRateParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
    }

    @OperateInfo
    @PostMapping("/getOnlineRateDataCensus")
    @ApiOperation("终端在线率图表")
    @ApiImplicitParam(name = "onlineRateCensusParam", value = "终端在线率参数", required = true)
    public HttpResult<OnlineRateCensusVO> getOnlineRateDataCensus(@RequestBody @Validated DeviceInfoParam.CompareBusinessParam onlineRateCensusParam){
        String methodDescribe = getMethodDescribe("getOnlineRateDataCensus");
        OnlineRateCensusVO onlineRateCensusVO = onlineRateDataService.getOnlineRateDataCensus(onlineRateCensusParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,onlineRateCensusVO,methodDescribe);
    }

}

