package com.njcn.supervision.controller.problem;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.supervision.pojo.param.device.SupervisionTempLineDebugParam;
import com.njcn.supervision.pojo.param.leaflet.WarningAddParam;
import com.njcn.supervision.pojo.vo.device.SupervisionTempLineDebugVO;
import com.njcn.supervision.service.leaflet.ILineRunTestProblemService;
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;

/**
 * @author wr
 * @date 2024/7/3 9:02
 */
@Slf4j
@RestController
@RequestMapping("/lineRunTestProblem")
@Api(tags = "试运行评估问题")
@AllArgsConstructor
public class LineRunTestProblemController extends BaseController {

    private final ILineRunTestProblemService lineRunTestProblemService;

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/pageProblem")
    @ApiOperation("查询问题列表")
    @ApiImplicitParam(name = "supervisionTempLineDebugQuery", value = "参数", required = true)
    public HttpResult<Page<SupervisionTempLineDebugVO>> pageProblem(@RequestBody @Validated SupervisionTempLineDebugParam.SupervisionTempLineDebugQuery supervisionTempLineDebugQuery) {
        String methodDescribe = getMethodDescribe("pageProblem");
        Page<SupervisionTempLineDebugVO> out = lineRunTestProblemService.pageProblem(supervisionTempLineDebugQuery);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, out, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/initiateWarningLeaflet")
    @ApiOperation("针对试运行发起告警单")
    public HttpResult<Boolean> initiateWarningLeaflet(@RequestBody WarningAddParam.Extend warningAddParam){
        String methodDescribe = getMethodDescribe("initiateWarningLeaflet");
        lineRunTestProblemService.initiateWarningLeaflet(warningAddParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, Boolean.TRUE, methodDescribe);
    }

}
