package com.njcn.supervision.controller.user;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.bpm.pojo.param.instance.BpmProcessInstanceCancelParam;
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.supervision.pojo.param.user.UserReportNormalParam;
import com.njcn.supervision.pojo.vo.user.UserReportVO;
import com.njcn.supervision.service.user.IUserReportNormalService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 干扰源用户常态化管理 前端控制器
 * </p>
 *
 * @author hongawen
 * @since 2024-05-17
 */
@RestController
@RequestMapping("userReportNormal")
@Api("干扰源常态化管理")
@RequiredArgsConstructor
public class UserReportNormalController extends BaseController {

    private final IUserReportNormalService iUserReportNormalService;


    @OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType= OperateType.ADD)
    @PostMapping("/addUserReportNormal")
    @ApiOperation("新增干扰源常态化管理")
    @ApiImplicitParam(name = "userReportNormalParam", value = "实体参数", required = true)
    public HttpResult<String> addUserReport(@RequestBody @Validated UserReportNormalParam userReportNormalParam){
        String methodDescribe = getMethodDescribe("addUserReport");
        String userReportId = iUserReportNormalService.addUserNormal(userReportNormalParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, userReportId, methodDescribe);
    }


    @PostMapping("/update")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType= OperateType.UPDATE)
    @Operation(summary = "重新发起")
    @ApiImplicitParam(name = "userReportParam", value = "实体参数", required = true)
    public HttpResult<Object> updateUserReport(@RequestBody @Validated UserReportNormalParam userReportParam) {
        String methodDescribe = getMethodDescribe("updateUserReport");
        String userReportId = iUserReportNormalService.updateUserNormal(userReportParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, userReportId, methodDescribe);
    }


    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/userReportGoNetPage")
    @ApiOperation("分页查询干扰源常态化页面")
    @ApiImplicitParam(name = "userReportNormalParam", value = "实体参数", required = true)
    public HttpResult<Page<UserReportVO.UserReportGoNetVO>> userReportGoNetPage(@RequestBody @Validated UserReportNormalParam userReportNormalParam){
        String methodDescribe = getMethodDescribe("userReportGoNetPage");
        Page<UserReportVO.UserReportGoNetVO> userReportId = iUserReportNormalService.userReportGoNetPage(userReportNormalParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, userReportId, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @GetMapping("/userReportGoNetById")
    @ApiOperation("查询干扰源常态化详情")
    public HttpResult<UserReportVO.UserReportGoNetVO> userReportGoNetById(@RequestParam("id")String id){
        String methodDescribe = getMethodDescribe("userReportGoNetById");
        UserReportVO.UserReportGoNetVO userReport = iUserReportNormalService.userReportGoNetById(id);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, userReport, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.UPDATE)
    @GetMapping("/updateUserReportNormalStatus")
    @ApiOperation("修改业务审核状态")
    public HttpResult<Object> updateUserReportNormalStatus(@RequestParam("businessKey") String businessKey, @RequestParam("status")Integer status){
        String methodDescribe = getMethodDescribe("updateUserReportNormalStatus");
        iUserReportNormalService.updateProcessStatus(businessKey,status);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD)
    @PostMapping("/cancel")
    @ApiOperation("取消")
    @ApiImplicitParam(name = "cancelReqVO", value = "取消原因", required = true)
    public HttpResult<String> cancelUserReport(@Validated @RequestBody BpmProcessInstanceCancelParam cancelReqVO) {
        String methodDescribe = getMethodDescribe("cancelUserReport");
        String userReportId = iUserReportNormalService.cancelUserReport(cancelReqVO);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, userReportId, methodDescribe);
    }
}

