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