Commit 5eef27da6e0bb1dbe8ad2d5411dce33a00201bd2

Authored by YunaiV
1 parent cfbef058

将流程模型的权限接入

yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/BpmDefinitionController.java
... ... @@ -8,6 +8,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
8 8 import io.swagger.annotations.Api;
9 9 import io.swagger.annotations.ApiImplicitParam;
10 10 import io.swagger.annotations.ApiOperation;
  11 +import org.springframework.security.access.prepost.PreAuthorize;
11 12 import org.springframework.validation.annotation.Validated;
12 13 import org.springframework.web.bind.annotation.GetMapping;
13 14 import org.springframework.web.bind.annotation.RequestMapping;
... ... @@ -27,10 +28,9 @@ public class BpmDefinitionController {
27 28 @Resource
28 29 private BpmDefinitionService bpmDefinitionService;
29 30  
30   - // TODO 芋艿:权限
31   -
32 31 @GetMapping ("/page")
33 32 @ApiOperation(value = "获得流程定义分页")
  33 + @PreAuthorize("@ss.hasPermission('bpm:model:query')") // 暂时使用 model 的权限标识
34 34 public CommonResult<PageResult<BpmProcessDefinitionPageItemRespVO>> getDefinitionPage(BpmProcessDefinitionPageReqVO pageReqVO) {
35 35 return success(bpmDefinitionService.getDefinitionPage(pageReqVO));
36 36 }
... ... @@ -48,6 +48,7 @@ public class BpmDefinitionController {
48 48 @GetMapping ("/get-bpmn-xml")
49 49 @ApiOperation(value = "获得流程定义的 BPMN XML")
50 50 @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = String.class)
  51 + @PreAuthorize("@ss.hasPermission('bpm:model:query')") // 暂时使用 model 的权限标识
51 52 public CommonResult<String> getDefinitionBpmnXML(@RequestParam("id") String id) {
52 53 String bpmnXML = bpmDefinitionService.getDefinitionBpmnXML(id);
53 54 return success(bpmnXML);
... ...
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/model/BpmModelController.java
... ... @@ -9,10 +9,12 @@ import cn.iocoder.yudao.framework.common.util.io.IoUtils;
9 9 import io.swagger.annotations.Api;
10 10 import io.swagger.annotations.ApiImplicitParam;
11 11 import io.swagger.annotations.ApiOperation;
  12 +import org.springframework.security.access.prepost.PreAuthorize;
12 13 import org.springframework.validation.annotation.Validated;
13 14 import org.springframework.web.bind.annotation.*;
14 15  
15 16 import javax.annotation.Resource;
  17 +import javax.validation.Valid;
16 18 import java.io.IOException;
17 19  
18 20 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
... ... @@ -26,8 +28,6 @@ public class BpmModelController {
26 28 @Resource
27 29 private BpmModelService bpmModelService;
28 30  
29   - // TODO @芋艿:权限、参数校验
30   -
31 31 @GetMapping("/page")
32 32 @ApiOperation(value = "获得模型分页")
33 33 public CommonResult<PageResult<BpmModelPageItemRespVO>> getModelPage(ModelPageReqVO pageVO) {
... ... @@ -37,7 +37,7 @@ public class BpmModelController {
37 37 @GetMapping("/get")
38 38 @ApiOperation("获得模型")
39 39 @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = String.class)
40   -// @PreAuthorize("@ss.hasPermission('bpm:form:query')")
  40 + @PreAuthorize("@ss.hasPermission('bpm:model:query')")
41 41 public CommonResult<BpmModelRespVO> getModel(@RequestParam("id") String id) {
42 42 BpmModelRespVO model = bpmModelService.getModel(id);
43 43 return success(model);
... ... @@ -45,13 +45,15 @@ public class BpmModelController {
45 45  
46 46 @PostMapping("/create")
47 47 @ApiOperation(value = "新建模型")
48   - public CommonResult<String> createModel(@RequestBody BpmModelCreateReqVO createRetVO) {
  48 + @PreAuthorize("@ss.hasPermission('bpm:model:create')")
  49 + public CommonResult<String> createModel(@Valid @RequestBody BpmModelCreateReqVO createRetVO) {
49 50 return success(bpmModelService.createModel(createRetVO));
50 51 }
51 52  
52 53 @PostMapping("/import")
53 54 @ApiOperation(value = "导入模型")
54   - public CommonResult<String> importModel(BpmModeImportReqVO importReqVO) throws IOException {
  55 + @PreAuthorize("@ss.hasPermission('bpm:model:import')")
  56 + public CommonResult<String> importModel(@Valid BpmModeImportReqVO importReqVO) throws IOException {
55 57 BpmModelCreateReqVO createReqVO = BpmModelConvert.INSTANCE.convert(importReqVO);
56 58 // 读取文件
57 59 createReqVO.setBpmnXml(IoUtils.readUtf8(importReqVO.getBpmnFile().getInputStream(), false));
... ... @@ -60,7 +62,8 @@ public class BpmModelController {
60 62  
61 63 @PutMapping("/update")
62 64 @ApiOperation(value = "修改模型")
63   - public CommonResult<Boolean> updateModel(@RequestBody BpmModelUpdateReqVO modelVO) {
  65 + @PreAuthorize("@ss.hasPermission('bpm:model:update')")
  66 + public CommonResult<Boolean> updateModel(@Valid @RequestBody BpmModelUpdateReqVO modelVO) {
64 67 bpmModelService.updateModel(modelVO);
65 68 return success(true);
66 69 }
... ... @@ -68,6 +71,7 @@ public class BpmModelController {
68 71 @DeleteMapping("/delete")
69 72 @ApiOperation("删除模型")
70 73 @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = String.class)
  74 + @PreAuthorize("@ss.hasPermission('bpm:model:delete')")
71 75 public CommonResult<Boolean> deleteModel(@RequestParam("id") String id) {
72 76 bpmModelService.deleteModel(id);
73 77 return success(true);
... ... @@ -76,6 +80,7 @@ public class BpmModelController {
76 80 @PostMapping("/deploy")
77 81 @ApiOperation(value = "部署模型")
78 82 @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = String.class)
  83 + @PreAuthorize("@ss.hasPermission('bpm:model:deploy')")
79 84 public CommonResult<Boolean> deployModel(@RequestParam("id") String id) {
80 85 bpmModelService.deployModel(id);
81 86 return success(true);
... ... @@ -83,7 +88,8 @@ public class BpmModelController {
83 88  
84 89 @PutMapping("/update-state")
85 90 @ApiOperation(value = "修改模型的状态", notes = "实际更新的部署的流程定义的状态")
86   - public CommonResult<Boolean> updateModelState(@RequestBody BpmModelUpdateStateReqVO reqVO) {
  91 + @PreAuthorize("@ss.hasPermission('bpm:model:update')")
  92 + public CommonResult<Boolean> updateModelState(@Valid @RequestBody BpmModelUpdateStateReqVO reqVO) {
87 93 bpmModelService.updateModelState(reqVO.getId(), reqVO.getState());
88 94 return success(true);
89 95 }
... ...
yudao-admin-ui/src/views/bpm/model/index.vue
... ... @@ -26,11 +26,11 @@
26 26 <el-row :gutter="10" class="mb8">
27 27 <el-col :span="1.5">
28 28 <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd"
29   - v-hasPermi="['infra:config:create']">新建流程模型</el-button>
  29 + v-hasPermi="['bpm:model:create']">新建流程模型</el-button>
30 30 </el-col>
31 31 <el-col :span="1.5">
32 32 <el-button type="info" icon="el-icon-upload2" size="mini" @click="handleImport"
33   - v-hasPermi="['system:user:import']">导入流程模型</el-button>
  33 + v-hasPermi="['bpm:model:import']">导入流程模型</el-button>
34 34 </el-col>
35 35 <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
36 36 </el-row>
... ... @@ -84,10 +84,14 @@
84 84 </el-table-column>
85 85 <el-table-column label="操作" align="center" width="300">
86 86 <template slot-scope="scope">
87   - <el-button size="mini" type="text" icon="el-icon-setting" @click="handleUpdate(scope.row)">设计流程</el-button>
88   - <el-button size="mini" type="text" icon="el-icon-thumb" @click="handleDeploy(scope.row)">发布流程</el-button>
89   - <el-button size="mini" type="text" icon="el-icon-ice-cream-round" @click="handleDefinitionList(scope.row)">流程定义</el-button>
90   - <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button>
  87 + <el-button size="mini" type="text" icon="el-icon-setting" @click="handleUpdate(scope.row)"
  88 + v-hasPermi="['bpm:model:update']">设计流程</el-button>
  89 + <el-button size="mini" type="text" icon="el-icon-thumb" @click="handleDeploy(scope.row)"
  90 + v-hasPermi="['bpm:model:deploy']">发布流程</el-button>
  91 + <el-button size="mini" type="text" icon="el-icon-ice-cream-round" @click="handleDefinitionList(scope.row)"
  92 + v-hasPermi="['bpm:model:query']">流程定义</el-button>
  93 + <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
  94 + v-hasPermi="['bpm:model:delete']">删除</el-button>
91 95 </template>
92 96 </el-table-column>
93 97 </el-table>
... ...