package ink.wgink.module.activiti.controller.route;

import ink.wgink.interfaces.consts.ISystemConstant;
import ink.wgink.module.activiti.service.activiti.IActivitiModelService;
import ink.wgink.pojo.result.ErrorResult;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletResponse;

/**
 * @ClassName: ActivitiModelRouteController
 * @Description: 流程模型
 * @Author: wanggeng
 * @Date: 2022/3/28 15:57
 * @Version: 1.0
 */
@Api(tags = ISystemConstant.ROUTE_TAGS_PREFIX + "activiti模型")
@Controller
@RequestMapping(ISystemConstant.ROUTE_PREFIX + "/activiti/model")
public class ActivitiModelRouteController {

    @Autowired
    private IActivitiModelService activitiModelService;

    @GetMapping("get-process-xml")
    public ModelAndView getProcessImage() {
        ModelAndView mv = new ModelAndView("activiti/model/get-process-xml");
        return mv;
    }

    @ApiOperation(value = "查看流程图", notes = "查看流程图接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "deploymentId", value = "流程部署ID", paramType = "path")
    })
    @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
    @GetMapping("get-process-image/{deploymentId}")
    public void getProcessImage(HttpServletResponse response, @PathVariable("deploymentId") String deploymentId) {
        activitiModelService.getProcessImage(response, deploymentId);
    }

    @ApiOperation(value = "查看运行流程图", notes = "查看运行流程图接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "processInstanceId", value = "流程实例ID", paramType = "path")
    })
    @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
    @GetMapping("get-runtime-process-image/{processInstanceId}")
    public void getRuntimeProcessImage(HttpServletResponse response, @PathVariable("processInstanceId") String processInstanceId) {
        activitiModelService.getRuntimeProcessImage(response, processInstanceId);
    }

}
