package com.njcn.supervision.controller.user;


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.UserReportParam;
import com.njcn.supervision.pojo.po.user.UserReportRenewalPO;
import com.njcn.supervision.service.user.IUserReportRenewalService;
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.*;

import com.njcn.web.controller.BaseController;

/**
 * <p>
 * 干扰源常态化管理更新信息	 前端控制器
 * </p>
 *
 * @author wr
 * @since 2024-06-26
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/userReportRenewal")
@Api(tags = "干扰源常态化管理信息更新")
public class UserReportRenewalController extends BaseController {

    private final IUserReportRenewalService userReportRenewalService;

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getUserReportUpdateById")
    @ApiOperation("干扰源用户管理更新后信息查看")
    public HttpResult<UserReportRenewalPO> getUserReportUpdateById(@RequestParam String businessId) {
        String methodDescribe = getMethodDescribe("getUserReportUpdateById");
        UserReportRenewalPO userReportUpdateById = userReportRenewalService.getUserReportUpdateById(businessId);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, userReportUpdateById, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD)
    @PostMapping("/addEditor")
    @ApiOperation("干扰源用户管理更新信息新增功能")
    public HttpResult<String> addEditor(@RequestBody @Validated UserReportParam userReportParam) {
        String methodDescribe = getMethodDescribe("addEditor");
        String s = userReportRenewalService.addEditor(userReportParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
    }

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

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/resend")
    @ApiOperation("干扰源用户管理更新信息重新发送功能")
    public HttpResult<String> resend(@RequestBody @Validated UserReportParam userReportParam) {
        String methodDescribe = getMethodDescribe("resend");
        String s = userReportRenewalService.resend(userReportParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
    }
}

