package com.prolog.rdc.tms.controller;

import com.prolog.framework.common.message.RestMessage;
import com.prolog.framework.log.aop.annotation.UserLog;
import com.prolog.rdc.tms.model.dto.ApprovalInfoDTO;
import com.prolog.rdc.tms.model.vo.ApprovalVO;
import com.prolog.rdc.tms.service.ShipbillEventFeedbackService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
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 hongbo.pan
 * @date 2023/1/31
 */
@RestController
@Api(tags = "事件上报控制层")
@RequestMapping("/shipbillEventback")
public class ShipbillEventbackController {

    @Autowired
    private ShipbillEventFeedbackService service;

    @UserLog("审核信息查询")
    @ApiOperation(value = "审核信息查询", notes = "审核信息查询")
    @PostMapping("/getApprovalInfo")
    public RestMessage<ApprovalInfoDTO> getApprovalInfo(@RequestBody ApprovalVO vo) {
        return RestMessage.newInstance(true, "查询成功！", service.getApprovalInfo(vo));
    }

    @UserLog("审批作废")
    @ApiOperation(value = "审批作废", notes = "审批作废")
    @PostMapping("/invalidApproval")
    public RestMessage invalidApproval(@RequestBody ApprovalVO vo) {
        service.invalidApproval(vo);
        return RestMessage.newInstance(true, "操作成功！", null);
    }

    @UserLog("审批流撤回")
    @ApiOperation(value = "审批流撤回", notes = "审批流撤回")
    @PostMapping("/retractApproval")
    public RestMessage retractApproval(@RequestBody ApprovalVO vo) {
        service.retractApproval(vo);
        return RestMessage.newInstance(true, "操作成功！", null);
    }

    @UserLog("审批流提交")
    @ApiOperation(value = "审批流提交", notes = "审批流提交")
    @PostMapping("/submitApproval")
    public RestMessage submitApproval(@RequestBody ApprovalVO vo) {
        service.submitApproval(vo);
        return RestMessage.newInstance(true, "操作成功！", null);
    }

    @UserLog("审批流审核")
    @ApiOperation(value = "审批流审核", notes = "审批流审核")
    @PostMapping("/reviewApproval")
    public RestMessage reviewApproval(@RequestBody ApprovalVO vo) {
        service.reviewApproval(vo);
        return RestMessage.newInstance(true, "操作成功！", null);
    }
}

