FlowManagerController.java 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are met:
  6. *
  7. * Redistributions of source code must retain the above copyright notice,
  8. * this list of conditions and the following disclaimer.
  9. * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * Neither the name of the dreamlu.net developer nor the names of its
  13. * contributors may be used to endorse or promote products derived from
  14. * this software without specific prior written permission.
  15. * Author: Chill 庄骞 (smallchill@163.com)
  16. */
  17. package org.springblade.flow.engine.controller;
  18. import com.baomidou.mybatisplus.core.metadata.IPage;
  19. import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
  20. import io.swagger.annotations.Api;
  21. import io.swagger.annotations.ApiOperation;
  22. import io.swagger.annotations.ApiParam;
  23. import lombok.AllArgsConstructor;
  24. import org.springblade.core.launch.constant.AppConstant;
  25. import org.springblade.core.mp.support.Condition;
  26. import org.springblade.core.mp.support.Query;
  27. import org.springblade.core.secure.annotation.PreAuth;
  28. import org.springblade.core.tenant.annotation.NonDS;
  29. import org.springblade.core.tool.api.R;
  30. import org.springblade.core.tool.constant.RoleConstant;
  31. import org.springblade.core.tool.support.Kv;
  32. import org.springblade.core.tool.utils.Func;
  33. import org.springblade.flow.engine.constant.FlowEngineConstant;
  34. import org.springblade.flow.engine.entity.FlowProcess;
  35. import org.springblade.flow.engine.service.FlowEngineService;
  36. import org.springframework.web.bind.annotation.*;
  37. import org.springframework.web.multipart.MultipartFile;
  38. import springfox.documentation.annotations.ApiIgnore;
  39. import java.util.List;
  40. import java.util.Objects;
  41. /**
  42. * 流程管理接口
  43. *
  44. * @author Chill
  45. */
  46. @NonDS
  47. @RestController
  48. @RequestMapping(AppConstant.APPLICATION_FLOW_NAME + "/manager")
  49. @AllArgsConstructor
  50. @Api(value = "流程管理接口", tags = "流程管理接口")
  51. @PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR)
  52. @ApiIgnore
  53. public class FlowManagerController {
  54. private final FlowEngineService flowEngineService;
  55. /**
  56. * 分页
  57. */
  58. @GetMapping("list")
  59. @ApiOperationSupport(order = 1)
  60. @ApiOperation(value = "分页", notes = "传入流程类型")
  61. public R<IPage<FlowProcess>> list(@ApiParam("流程类型") String category, Query query, @RequestParam(required = false, defaultValue = "1") Integer mode) {
  62. IPage<FlowProcess> pages = flowEngineService.selectProcessPage(Condition.getPage(query), category, mode);
  63. return R.data(pages);
  64. }
  65. /**
  66. * 变更流程状态
  67. *
  68. * @param state 状态
  69. * @param processId 流程id
  70. */
  71. @PostMapping("change-state")
  72. @ApiOperationSupport(order = 2)
  73. @ApiOperation(value = "变更流程状态", notes = "传入state,processId")
  74. public R changeState(@RequestParam String state, @RequestParam String processId) {
  75. String msg = flowEngineService.changeState(state, processId);
  76. return R.success(msg);
  77. }
  78. /**
  79. * 删除部署流程
  80. *
  81. * @param deploymentIds 部署流程id集合
  82. */
  83. @PostMapping("delete-deployment")
  84. @ApiOperationSupport(order = 3)
  85. @ApiOperation(value = "删除部署流程", notes = "部署流程id集合")
  86. public R deleteDeployment(String deploymentIds) {
  87. return R.status(flowEngineService.deleteDeployment(deploymentIds));
  88. }
  89. /**
  90. * 检查流程文件格式
  91. *
  92. * @param file 流程文件
  93. */
  94. @PostMapping("check-upload")
  95. @ApiOperationSupport(order = 4)
  96. @ApiOperation(value = "上传部署流程文件", notes = "传入文件")
  97. public R checkUpload(@RequestParam MultipartFile file) {
  98. boolean temp = Objects.requireNonNull(file.getOriginalFilename()).endsWith(FlowEngineConstant.SUFFIX);
  99. return R.data(Kv.create().set("name", file.getOriginalFilename()).set("success", temp));
  100. }
  101. /**
  102. * 上传部署流程文件
  103. *
  104. * @param files 流程文件
  105. * @param category 类型
  106. */
  107. @PostMapping("deploy-upload")
  108. @ApiOperationSupport(order = 5)
  109. @ApiOperation(value = "上传部署流程文件", notes = "传入文件")
  110. public R deployUpload(@RequestParam List<MultipartFile> files,
  111. @RequestParam String category,
  112. @RequestParam(required = false, defaultValue = "") String tenantIds) {
  113. return R.status(flowEngineService.deployUpload(files, category, Func.toStrList(tenantIds)));
  114. }
  115. }