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.device.pq.pojo.param.DeviceInfoParam;
import com.njcn.harmonic.pojo.vo.TerminalCensusVO;
import com.njcn.harmonic.pojo.vo.TerminalVO;
import com.njcn.harmonic.service.TerminalService;
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
 * @date 2022/03/01 21:57
 * @Description: <描述>
 */
@Validated
@Slf4j
@RestController
@RequestMapping("/terminal")
@Api(tags = "终端状态")
@AllArgsConstructor
public class TerminalController extends BaseController {

    private final TerminalService terminalService;

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getTerminalData")
    @ApiOperation("终端状态列表")
    @ApiImplicitParam(name = "terminalParam", value = "终端状态参数", required = true)
    public HttpResult<List<TerminalVO>> getTerminalData (@RequestBody @Validated DeviceInfoParam.BusinessParam terminalParam){
        String methodDescribe = getMethodDescribe("getTerminalData");
        List<TerminalVO> list = terminalService.getTerminalData(terminalParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getTerminalDataCensus")
    @ApiOperation("终端状态统计")
    @ApiImplicitParam(name = "terminalCensusParam", value = "终端状态参数", required = true)
    public HttpResult<TerminalCensusVO> getTerminalDataCensus (@RequestBody @Validated DeviceInfoParam.BusinessParam terminalCensusParam){
        String methodDescribe = getMethodDescribe("getTerminalDataCensus");
        TerminalCensusVO censusVO = terminalService.getTerminalDataCensus(terminalCensusParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, censusVO, methodDescribe);
    }

}
