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.SteadyDataViewDetailParam;
import com.njcn.gather.steady.datavie.pojo.vo.SteadyDataViewTemplateVO;
import com.njcn.gather.steady.datavie.pojo.vo.SteadyDataViewVO;
import com.njcn.gather.steady.datavie.service.SteadyDataViewService;
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.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
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;

/**
 * 稳态数据查看接口。
 */
@Validated
@Slf4j
@Api(tags = "稳态数据查看")
@RestController
@RequestMapping("/steady/data-view")
@RequiredArgsConstructor
public class SteadyDataViewController extends BaseController {

    /** 稳态数据查看服务。 */
    private final SteadyDataViewService steadyDataViewService;

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("查询稳态数据详情")
    @PostMapping("/detail")
    public HttpResult<SteadyDataViewVO> getSteadyDataDetail(@RequestBody SteadyDataViewDetailParam param) {
        String methodDescribe = getMethodDescribe("getSteadyDataDetail");
        LogUtil.njcnDebug(log, "{}，开始查询稳态数据详情，param={}", methodDescribe, param);
        SteadyDataViewVO result = steadyDataViewService.getSteadyDataDetail(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("查询稳态数据模板")
    @GetMapping("/templates")
    public HttpResult<List<SteadyDataViewTemplateVO>> listTemplates() {
        String methodDescribe = getMethodDescribe("listTemplates");
        LogUtil.njcnDebug(log, "{}，开始查询稳态数据模板", methodDescribe);
        List<SteadyDataViewTemplateVO> result = steadyDataViewService.listTemplates();
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }
}
