package com.njcn.device.pms.controller.ledgerManger;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.device.pms.pojo.param.MonitorAuditParam;
import com.njcn.device.pms.pojo.param.MonitorStatus;
import com.njcn.device.pms.pojo.po.MonitorAudit;
import com.njcn.device.pms.service.majornetwork.IMonitorAuditService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
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 com.njcn.web.controller.BaseController;

import java.util.List;
import java.util.Objects;

/**
 * <p>
 * 台账审核 前端控制器
 * </p>
 *
 * @author wr
 * @since 2023-02-20
 */
@RestController
@RequestMapping("/pms/monitorAudit")
@Api(tags = "台账审核")
@RequiredArgsConstructor
public class MonitorAuditController extends BaseController {

    private final IMonitorAuditService monitorAuditService;


    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getAllMonitorAuditList")
    @ApiOperation("分页获取台账审核")
    @ApiImplicitParam(name = "baseParam", required = true)
    public HttpResult<List<MonitorAudit>> getAllMonitorAuditList(@RequestBody MonitorAuditParam baseParam) {
        String methodDescribe = getMethodDescribe("getAllMonitorAuditList");
        List<MonitorAudit> monitor = monitorAuditService.getAllMonitorAuditList(baseParam);
        if (Objects.isNull(monitor)) {
            return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.NO_DATA, null, methodDescribe);
        } else {
            return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, monitor, methodDescribe);
        }
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE)
    @PostMapping("/updateStatus")
    @ApiOperation("修改台账审核数据状态")
    @ApiImplicitParam(name = "monitorParam", value = "修改台账审核数据状态", required = true)
    public HttpResult<Boolean> updateStatus(@RequestBody @Validated MonitorStatus.Status monitorParam) {
        String methodDescribe = getMethodDescribe("updateStatus");
        boolean result = monitorAuditService.updateStatus(monitorParam);
        if (result) {
            return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
        }
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);

    }
}

