package com.njcn.event.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.dto.wave.WaveDataDTO;
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.event.pojo.param.TransientParam;
import com.njcn.event.pojo.vo.TransientVO;
import com.njcn.event.service.TransientService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
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.*;

/**
 * @author: chenchao
 * @date: 2022/03/29 10:19
 * @Description: <描述>
 */
@Validated
@Slf4j
@RestController
@RequestMapping("/transient")
@Api(tags = "暂态事件列表")
@AllArgsConstructor
public class TransientController extends BaseController {

    private final TransientService transientService;

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getTransientData")
    @ApiOperation("暂态事件信息列表")
    @ApiImplicitParam(name = "transientParam", value = "暂态列表参数", required = true)
    public HttpResult<Page<TransientVO>> getTransientData(@RequestBody @Validated TransientParam transientParam){
        String methodDescribe = getMethodDescribe("getTransientData");
        Page<TransientVO> list = transientService.getTransientData(transientParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getTransientAnalyseWave")
    @ApiOperation("暂态事件波形分析")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "timeId", value = "暂态时刻", required = true),
            @ApiImplicitParam(name = "lineId", value = "暂态监测点Id", required = true)
    })
    public HttpResult<WaveDataDTO> getTransientAnalyseWave(@RequestParam("timeId") String timeId, @RequestParam("lineId") String lineId){
        String methodDescribe = getMethodDescribe("getTransientAnalyseWave");
        WaveDataDTO wave = transientService.getTransientAnalyseWave(timeId, lineId);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, wave, methodDescribe);
    }

}
