package com.njcn.event.controller.majornetwork;

import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.OperateType;
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.common.utils.LogUtil;
import com.njcn.event.pojo.param.VoltageRideThroughQueryParam;
import com.njcn.event.pojo.vo.EventNewStationVo;
import com.njcn.event.pojo.vo.VoltageRideThroughVo;
import com.njcn.event.service.majornetwork.VoltageRideThroughEventService;
import com.njcn.web.controller.BaseController;
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.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;

/**
 * <p>
 * 高低电压穿越统计 前端控制器
 * </p>
 *
 * @author guofeihu
 * @since 2024-08-14
 */
@Api(tags = "高低电压穿越统计")
@Slf4j
@RestController
@RequestMapping("/voltageRideThrough")
@RequiredArgsConstructor
public class VoltageRideThroughEventController extends BaseController {

    private final VoltageRideThroughEventService voltageRideThroughEventService;

    @OperateInfo(info = LogEnum.SYSTEM_COMMON)
    @PostMapping("/view")
    @ApiOperation("查询高低电压穿越视图")
    public HttpResult<List<VoltageRideThroughVo>> voltageRideThroughView(@RequestBody @Validated VoltageRideThroughQueryParam voltageRideThroughQueryParam) {
        String methodDescribe = getMethodDescribe("voltageRideThroughView");
        LogUtil.njcnDebug(log, "{}，查询对象为：{}", methodDescribe, voltageRideThroughQueryParam);
        List<VoltageRideThroughVo> voltageRideThroughVos = voltageRideThroughEventService.voltageRideThroughView(voltageRideThroughQueryParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, voltageRideThroughVos, methodDescribe);
    }

    @OperateInfo(info = LogEnum.SYSTEM_COMMON)
    @PostMapping("/voltageRideThroughEventQueryPage")
    @ApiOperation("查询高低电压穿越暂态事件列表")
    public HttpResult<List<EventNewStationVo>> voltageRideThroughEventQueryPage(@RequestBody @Validated VoltageRideThroughQueryParam voltageRideThroughQueryParam) {
        String methodDescribe = getMethodDescribe("voltageRideThroughEventQueryPage");
        LogUtil.njcnDebug(log, "{}，查询对象为：{}", methodDescribe, voltageRideThroughQueryParam);
        List<EventNewStationVo> eventNewStationVos = voltageRideThroughEventService.voltageRideThroughEventQueryPage(voltageRideThroughQueryParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, eventNewStationVos, methodDescribe);
    }

}
