package com.njcn.gather.steady.datavie.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.LogUtil;
import com.njcn.gather.steady.datavie.pojo.param.SteadyTrendQueryParam;
import com.njcn.gather.steady.datavie.pojo.vo.SteadyTrendQueryVO;
import com.njcn.gather.steady.datavie.pojo.vo.SteadyTrendSummaryVO;
import com.njcn.gather.steady.datavie.service.SteadyDataViewTrendService;
import com.njcn.web.controller.BaseController;
import com.njcn.web.utils.HttpResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
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;

/**
 * 稳态趋势查询接口。
 */
@Slf4j
@Api(tags = "稳态趋势查询")
@RestController
@RequestMapping("/steady/data-view/trend")
@RequiredArgsConstructor
public class SteadyDataViewTrendController extends BaseController {

    private final SteadyDataViewTrendService trendService;

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("查询稳态趋势")
    @PostMapping("/query")
    public HttpResult<SteadyTrendQueryVO> queryTrend(@RequestBody SteadyTrendQueryParam param) {
        String methodDescribe = getMethodDescribe("queryTrend");
        LogUtil.njcnDebug(log, "{}，开始查询稳态趋势，param={}", methodDescribe, param);
        SteadyTrendQueryVO result = trendService.queryTrend(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("按天查询稳态趋势")
    @PostMapping("/day")
    public HttpResult<SteadyTrendQueryVO> queryTrendDay(@RequestBody SteadyTrendQueryParam param) {
        String methodDescribe = getMethodDescribe("queryTrendDay");
        LogUtil.njcnDebug(log, "{}，开始按天查询稳态趋势，param={}", methodDescribe, param);
        SteadyTrendQueryVO result = trendService.queryTrendDay(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("查询稳态趋势统计摘要")
    @PostMapping("/summary")
    public HttpResult<SteadyTrendSummaryVO> summarizeTrend(@RequestBody SteadyTrendQueryParam param) {
        String methodDescribe = getMethodDescribe("summarizeTrend");
        LogUtil.njcnDebug(log, "{}，开始查询稳态趋势统计摘要，param={}", methodDescribe, param);
        SteadyTrendSummaryVO result = trendService.summarizeTrend(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }
}
