diff --git a/blade-ops/blade-flowdesign/src/main/java/org/springblade/flowable/FlowDesignApplication.java b/blade-ops/blade-flowdesign/src/main/java/org/springblade/flowable/FlowDesignApplication.java index f92cd37a..0a2a2b51 100644 --- a/blade-ops/blade-flowdesign/src/main/java/org/springblade/flowable/FlowDesignApplication.java +++ b/blade-ops/blade-flowdesign/src/main/java/org/springblade/flowable/FlowDesignApplication.java @@ -20,6 +20,7 @@ import org.flowable.ui.common.conf.DevelopmentConfiguration; import org.flowable.ui.common.rest.idm.remote.RemoteAccountResource; import org.springblade.core.launch.BladeApplication; import org.springblade.core.launch.constant.AppConstant; +import org.springblade.flowable.constant.FlowableConstant; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration; import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration; @@ -27,9 +28,6 @@ import org.springframework.boot.autoconfigure.security.servlet.UserDetailsServic import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.FilterType; -import static org.springblade.flowable.constant.FlowableConstant.BASE_PACHAGE; -import static org.springblade.flowable.constant.FlowableConstant.FLOWABLE_BASE_PACKAGE; - /** * FlowDesign启动器 * @@ -37,14 +35,13 @@ import static org.springblade.flowable.constant.FlowableConstant.FLOWABLE_BASE_P */ @SpringBootApplication( exclude = { - SecurityAutoConfiguration.class, SecurityAutoConfiguration.class, UserDetailsServiceAutoConfiguration.class, LiquibaseAutoConfiguration.class } ) @ComponentScan( - basePackages = {BASE_PACHAGE, FLOWABLE_BASE_PACKAGE}, + basePackages = {AppConstant.BASE_PACKAGES, FlowableConstant.FLOWABLE_BASE_PACKAGES}, excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {RemoteAccountResource.class, DevelopmentConfiguration.class}) ) public class FlowDesignApplication { diff --git a/blade-ops/blade-flowdesign/src/main/java/org/springblade/flowable/constant/FlowableConstant.java b/blade-ops/blade-flowdesign/src/main/java/org/springblade/flowable/constant/FlowableConstant.java index 0c1d5834..246774b8 100644 --- a/blade-ops/blade-flowdesign/src/main/java/org/springblade/flowable/constant/FlowableConstant.java +++ b/blade-ops/blade-flowdesign/src/main/java/org/springblade/flowable/constant/FlowableConstant.java @@ -22,8 +22,7 @@ package org.springblade.flowable.constant; * @author Chill */ public interface FlowableConstant { - String BASE_PACHAGE = "org.springblade"; - String FLOWABLE_BASE_PACKAGE = "org.flowable.ui"; + String FLOWABLE_BASE_PACKAGES = "org.flowable.ui"; String css = ".css"; String js = ".js"; diff --git a/blade-service/blade-flow/pom.xml b/blade-service/blade-flow/pom.xml index d451e71e..197bd3c3 100644 --- a/blade-service/blade-flow/pom.xml +++ b/blade-service/blade-flow/pom.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <parent> - <artifactId>blade-ops</artifactId> + <artifactId>blade-service</artifactId> <groupId>org.springblade</groupId> <version>2.0.0.RC8</version> </parent> @@ -37,12 +37,36 @@ <version>${bladex.tool.version}</version> <scope>provided</scope> </dependency> + <dependency> + <groupId>org.mybatis</groupId> + <artifactId>mybatis-spring</artifactId> + <version>2.0.0</version> + </dependency> <!-- 工作流 --> <dependency> <groupId>org.flowable</groupId> <artifactId>flowable-spring-boot-starter</artifactId> <version>${flowable.version}</version> </dependency> + <dependency> + <groupId>org.flowable</groupId> + <artifactId>flowable-ui-modeler-rest</artifactId> + <version>${flowable.version}</version> + <exclusions> + <exclusion> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-slf4j-impl</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-core</artifactId> + </exclusion> + <exclusion> + <groupId>org.slf4j</groupId> + <artifactId>jul-to-slf4j</artifactId> + </exclusion> + </exclusions> + </dependency> </dependencies> </project> diff --git a/blade-service/blade-flow/src/main/java/org/springblade/flowable/FlowApplication.java b/blade-service/blade-flow/src/main/java/org/springblade/flowable/FlowApplication.java index cbb79dd2..163509c7 100644 --- a/blade-service/blade-flow/src/main/java/org/springblade/flowable/FlowApplication.java +++ b/blade-service/blade-flow/src/main/java/org/springblade/flowable/FlowApplication.java @@ -16,10 +16,20 @@ */ package org.springblade.flowable; +import org.flowable.ui.common.conf.DevelopmentConfiguration; import org.springblade.core.cloud.feign.EnableBladeFeign; import org.springblade.core.launch.BladeApplication; import org.springblade.core.launch.constant.AppConstant; -import org.springframework.cloud.client.SpringCloudApplication; +import org.springblade.flowable.engine.constant.FlowableConstant; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration; +import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration; +import org.springframework.boot.autoconfigure.security.servlet.UserDetailsServiceAutoConfiguration; +import org.springframework.boot.autoconfigure.web.servlet.MultipartAutoConfiguration; +import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.FilterType; /** * Flowable启动器 @@ -27,7 +37,20 @@ import org.springframework.cloud.client.SpringCloudApplication; * @author Chill */ @EnableBladeFeign -@SpringCloudApplication +@EnableDiscoveryClient +@EnableCircuitBreaker +@SpringBootApplication( + exclude = { + SecurityAutoConfiguration.class, + UserDetailsServiceAutoConfiguration.class, + LiquibaseAutoConfiguration.class, + MultipartAutoConfiguration.class + } +) +@ComponentScan( + basePackages = {AppConstant.BASE_PACKAGES, FlowableConstant.FLOWABLE_BASE_PACKAGES}, + excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {DevelopmentConfiguration.class}) +) public class FlowApplication { public static void main(String[] args) { diff --git a/blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/config/FlowableConfiguration.java b/blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/config/FlowableConfiguration.java index fa453234..4460a672 100644 --- a/blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/config/FlowableConfiguration.java +++ b/blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/config/FlowableConfiguration.java @@ -20,7 +20,9 @@ import lombok.AllArgsConstructor; import org.flowable.spring.SpringProcessEngineConfiguration; import org.flowable.spring.boot.EngineConfigurationConfigurer; import org.flowable.spring.boot.FlowableProperties; +import org.flowable.ui.modeler.properties.FlowableModelerAppProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; /** @@ -34,6 +36,11 @@ import org.springframework.context.annotation.Configuration; public class FlowableConfiguration implements EngineConfigurationConfigurer<SpringProcessEngineConfiguration> { private FlowableProperties flowableProperties; + @Bean + public FlowableModelerAppProperties flowableModelerAppProperties() { + return new FlowableModelerAppProperties(); + } + @Override public void configure(SpringProcessEngineConfiguration engineConfiguration) { engineConfiguration.setActivityFontName(flowableProperties.getActivityFontName()); diff --git a/blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/constant/FlowableConstant.java b/blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/constant/FlowableConstant.java new file mode 100644 index 00000000..85bd6b93 --- /dev/null +++ b/blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/constant/FlowableConstant.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 庄骞 (smallchill@163.com) + */ +package org.springblade.flowable.engine.constant; + +/** + * 流程常量. + * + * @author zhuangqian + */ +public interface FlowableConstant { + + String FLOWABLE_BASE_PACKAGES = "org.flowable.ui"; + + String suffix = ".bpmn20.xml"; + + +} diff --git a/blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/controller/FlowModelController.java b/blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/controller/FlowModelController.java index 51bc9274..371c37c0 100644 --- a/blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/controller/FlowModelController.java +++ b/blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/controller/FlowModelController.java @@ -74,7 +74,7 @@ public class FlowModelController { */ @PostMapping("/deploy") @ApiOperation(value = "部署", notes = "传入模型id和分类", position = 7) - public R deploy(@ApiParam(value = "模型id") @RequestParam String modelId, @ApiParam(value = "分类") @RequestParam String category) { + public R deploy(@ApiParam(value = "模型id") @RequestParam String modelId, @ApiParam(value = "工作流分类") @RequestParam String category) { boolean temp = flowService.deploy(modelId, category); return R.status(temp); } diff --git a/blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/service/impl/FlowServiceImpl.java b/blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/service/impl/FlowServiceImpl.java index aadd168a..3ac1d901 100644 --- a/blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/service/impl/FlowServiceImpl.java +++ b/blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/service/impl/FlowServiceImpl.java @@ -18,18 +18,37 @@ package org.springblade.flowable.engine.service.impl; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.flowable.engine.RepositoryService; +import org.flowable.engine.repository.Deployment; +import org.flowable.engine.repository.ProcessDefinition; +import org.flowable.ui.modeler.domain.Model; +import org.flowable.ui.modeler.serviceapi.ModelService; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.tool.utils.StringUtil; +import org.springblade.flowable.engine.constant.FlowableConstant; import org.springblade.flowable.engine.entity.FlowModel; import org.springblade.flowable.engine.mapper.FlowMapper; import org.springblade.flowable.engine.service.FlowService; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.List; + /** - * FlowServiceImpl + * 工作流服务实现类 * * @author Chill */ +@Slf4j @Service +@AllArgsConstructor public class FlowServiceImpl extends ServiceImpl<FlowMapper, FlowModel> implements FlowService { + + private RepositoryService repositoryService; + private ModelService modelService; + @Override public IPage<FlowModel> selectFlowPage(IPage<FlowModel> page, FlowModel flowModel) { return page.setRecords(baseMapper.selectFlowPage(page, flowModel)); @@ -37,6 +56,40 @@ public class FlowServiceImpl extends ServiceImpl<FlowMapper, FlowModel> implemen @Override public boolean deploy(String modelId, String category) { - return false; + Model model = modelService.getModel(modelId); + byte[] bytes = modelService.getBpmnXML(model); + + String processName = model.getName(); + if (!StringUtil.endsWithIgnoreCase(processName, FlowableConstant.suffix)) { + processName += FlowableConstant.suffix; + } + + Deployment deployment = repositoryService.createDeployment() + .addBytes(processName, bytes) + .name(model.getName()) + .key(model.getKey()) + .deploy(); + + log.debug("流程部署--------deploy:" + deployment + " 分类---------->" + category); + + List<ProcessDefinition> list = repositoryService.createProcessDefinitionQuery().deploymentId(deployment.getId()).list(); + + StringBuilder logBuilder = new StringBuilder(500); + List<Object> logArgs = new ArrayList<>(); + // 设置流程分类 + for (ProcessDefinition processDefinition : list) { + if (StringUtil.isNotBlank(category)) { + repositoryService.setProcessDefinitionCategory(processDefinition.getId(), category); + } + logBuilder.append("部署成功,流程ID={} \n"); + logArgs.add(processDefinition.getId()); + } + + if (list.size() == 0) { + throw new ServiceException("部署失败,未找到流程"); + } else { + log.info(logBuilder.toString(), logArgs.toArray()); + return true; + } } } diff --git a/blade-service/blade-flow/src/main/resources/application.yml b/blade-service/blade-flow/src/main/resources/application.yml index 5af24db9..4fb24594 100644 --- a/blade-service/blade-flow/src/main/resources/application.yml +++ b/blade-service/blade-flow/src/main/resources/application.yml @@ -1,6 +1,11 @@ flowable: - async-executor-activate: false activity-font-name: \u5B8B\u4F53 label-font-name: \u5B8B\u4F53 annotation-font-name: \u5B8B\u4F53 check-process-definitions: false + common: + app: + idm-url: http://localhost:9999 + idm-admin: + user: admin + password: test diff --git a/blade-service/blade-flow/src/main/resources/processes/ExpenseProcess.bpmn20.xml b/blade-service/blade-flow/src/main/resources/processes/ExpenseProcess.bpmn20.xml deleted file mode 100644 index a779d37b..00000000 --- a/blade-service/blade-flow/src/main/resources/processes/ExpenseProcess.bpmn20.xml +++ /dev/null @@ -1,108 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:flowable="http://flowable.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" - xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" - typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" - targetNamespace="http://www.flowable.org/processdef"> - <process id="Expense" name="ExpenseProcess" isExecutable="true"> - <documentation>报销流程</documentation> - <startEvent id="start" name="开始"></startEvent> - <userTask id="fillTask" name="出差报销" flowable:assignee="${taskUser}"> - <extensionElements> - <modeler:initiator-can-complete xmlns:modeler="http://flowable.org/modeler"> - <![CDATA[false]]></modeler:initiator-can-complete> - </extensionElements> - </userTask> - <exclusiveGateway id="judgeTask"></exclusiveGateway> - <userTask id="directorTak" name="经理审批"> - <extensionElements> - <flowable:taskListener event="create" - class="org.springblade.flowable.business.handler.ManagerTaskHandler"></flowable:taskListener> - </extensionElements> - </userTask> - <userTask id="bossTask" name="老板审批"> - <extensionElements> - <flowable:taskListener event="create" - class="org.springblade.flowable.business.handler.BossTaskHandler"></flowable:taskListener> - </extensionElements> - </userTask> - <endEvent id="end" name="结束"></endEvent> - <sequenceFlow id="directorNotPassFlow" name="驳回" sourceRef="directorTak" targetRef="fillTask"> - <conditionExpression xsi:type="tFormalExpression"><![CDATA[${outcome=='驳回'}]]></conditionExpression> - </sequenceFlow> - <sequenceFlow id="bossNotPassFlow" name="驳回" sourceRef="bossTask" targetRef="fillTask"> - <conditionExpression xsi:type="tFormalExpression"><![CDATA[${outcome=='驳回'}]]></conditionExpression> - </sequenceFlow> - <sequenceFlow id="flow1" sourceRef="start" targetRef="fillTask"></sequenceFlow> - <sequenceFlow id="flow2" sourceRef="fillTask" targetRef="judgeTask"></sequenceFlow> - <sequenceFlow id="judgeMore" name="大于500元" sourceRef="judgeTask" targetRef="bossTask"> - <conditionExpression xsi:type="tFormalExpression"><![CDATA[${money > 500}]]></conditionExpression> - </sequenceFlow> - <sequenceFlow id="bossPassFlow" name="通过" sourceRef="bossTask" targetRef="end"> - <conditionExpression xsi:type="tFormalExpression"><![CDATA[${outcome=='通过'}]]></conditionExpression> - </sequenceFlow> - <sequenceFlow id="directorPassFlow" name="通过" sourceRef="directorTak" targetRef="end"> - <conditionExpression xsi:type="tFormalExpression"><![CDATA[${outcome=='通过'}]]></conditionExpression> - </sequenceFlow> - <sequenceFlow id="judgeLess" name="小于500元" sourceRef="judgeTask" targetRef="directorTak"> - <conditionExpression xsi:type="tFormalExpression"><![CDATA[${money <= 500}]]></conditionExpression> - </sequenceFlow> - </process> - <bpmndi:BPMNDiagram id="BPMNDiagram_Expense"> - <bpmndi:BPMNPlane bpmnElement="Expense" id="BPMNPlane_Expense"> - <bpmndi:BPMNShape bpmnElement="start" id="BPMNShape_start"> - <omgdc:Bounds height="30.0" width="30.0" x="285.0" y="135.0"></omgdc:Bounds> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape bpmnElement="fillTask" id="BPMNShape_fillTask"> - <omgdc:Bounds height="80.0" width="100.0" x="405.0" y="110.0"></omgdc:Bounds> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape bpmnElement="judgeTask" id="BPMNShape_judgeTask"> - <omgdc:Bounds height="40.0" width="40.0" x="585.0" y="130.0"></omgdc:Bounds> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape bpmnElement="directorTak" id="BPMNShape_directorTak"> - <omgdc:Bounds height="80.0" width="100.0" x="735.0" y="110.0"></omgdc:Bounds> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape bpmnElement="bossTask" id="BPMNShape_bossTask"> - <omgdc:Bounds height="80.0" width="100.0" x="555.0" y="255.0"></omgdc:Bounds> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape bpmnElement="end" id="BPMNShape_end"> - <omgdc:Bounds height="28.0" width="28.0" x="771.0" y="281.0"></omgdc:Bounds> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1"> - <omgdi:waypoint x="315.0" y="150.0"></omgdi:waypoint> - <omgdi:waypoint x="405.0" y="150.0"></omgdi:waypoint> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2"> - <omgdi:waypoint x="505.0" y="150.16611295681062"></omgdi:waypoint> - <omgdi:waypoint x="585.4333333333333" y="150.43333333333334"></omgdi:waypoint> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge bpmnElement="judgeLess" id="BPMNEdge_judgeLess"> - <omgdi:waypoint x="624.5530726256983" y="150.44692737430168"></omgdi:waypoint> - <omgdi:waypoint x="735.0" y="150.1392757660167"></omgdi:waypoint> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge bpmnElement="directorNotPassFlow" id="BPMNEdge_directorNotPassFlow"> - <omgdi:waypoint x="785.0" y="110.0"></omgdi:waypoint> - <omgdi:waypoint x="785.0" y="37.0"></omgdi:waypoint> - <omgdi:waypoint x="455.0" y="37.0"></omgdi:waypoint> - <omgdi:waypoint x="455.0" y="110.0"></omgdi:waypoint> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge bpmnElement="bossPassFlow" id="BPMNEdge_bossPassFlow"> - <omgdi:waypoint x="655.0" y="295.0"></omgdi:waypoint> - <omgdi:waypoint x="771.0" y="295.0"></omgdi:waypoint> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge bpmnElement="judgeMore" id="BPMNEdge_judgeMore"> - <omgdi:waypoint x="605.4340277777778" y="169.56597222222223"></omgdi:waypoint> - <omgdi:waypoint x="605.1384083044983" y="255.0"></omgdi:waypoint> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge bpmnElement="directorPassFlow" id="BPMNEdge_directorPassFlow"> - <omgdi:waypoint x="785.0" y="190.0"></omgdi:waypoint> - <omgdi:waypoint x="785.0" y="281.0"></omgdi:waypoint> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge bpmnElement="bossNotPassFlow" id="BPMNEdge_bossNotPassFlow"> - <omgdi:waypoint x="555.0" y="295.0"></omgdi:waypoint> - <omgdi:waypoint x="455.0" y="295.0"></omgdi:waypoint> - <omgdi:waypoint x="455.0" y="190.0"></omgdi:waypoint> - </bpmndi:BPMNEdge> - </bpmndi:BPMNPlane> - </bpmndi:BPMNDiagram> -</definitions> diff --git a/blade-service/blade-flow/src/main/resources/processes/LeaveProcess.bpmn20.xml b/blade-service/blade-flow/src/main/resources/processes/LeaveProcess.bpmn20.xml new file mode 100644 index 00000000..f9f2444e --- /dev/null +++ b/blade-service/blade-flow/src/main/resources/processes/LeaveProcess.bpmn20.xml @@ -0,0 +1,101 @@ +<?xml version="1.0" encoding="UTF-8"?> +<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:flowable="http://flowable.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.flowable.org/processdef"> + <process id="Leave" name="LeaveProcess" isExecutable="true"> + <documentation>请假流程</documentation> + <startEvent id="start" name="开始"></startEvent> + <userTask id="fillTask" name="事假申请" flowable:assignee="${taskUser}"> + <extensionElements> + <modeler:initiator-can-complete xmlns:modeler="http://flowable.org/modeler"><![CDATA[false]]></modeler:initiator-can-complete> + </extensionElements> + </userTask> + <exclusiveGateway id="judgeTask"></exclusiveGateway> + <userTask id="directorTak" name="经理审批"> + <extensionElements> + <flowable:taskListener event="create" class="org.springblade.flowable.business.handler.ManagerTaskHandler"></flowable:taskListener> + </extensionElements> + </userTask> + <userTask id="bossTask" name="老板审批"> + <extensionElements> + <flowable:taskListener event="create" class="org.springblade.flowable.business.handler.BossTaskHandler"></flowable:taskListener> + </extensionElements> + </userTask> + <endEvent id="end" name="结束"></endEvent> + <sequenceFlow id="flow1" sourceRef="start" targetRef="fillTask"></sequenceFlow> + <sequenceFlow id="flow2" sourceRef="fillTask" targetRef="judgeTask"></sequenceFlow> + <sequenceFlow id="judgeLess" name="小于3天" sourceRef="judgeTask" targetRef="directorTak"> + <conditionExpression xsi:type="tFormalExpression"><![CDATA[${days <= 3}]]></conditionExpression> + </sequenceFlow> + <sequenceFlow id="judgeMore" name="大于3天" sourceRef="judgeTask" targetRef="bossTask"> + <conditionExpression xsi:type="tFormalExpression"><![CDATA[${days > 3}]]></conditionExpression> + </sequenceFlow> + <sequenceFlow id="bossNotPassFlow" name="驳回" sourceRef="bossTask" targetRef="fillTask"> + <conditionExpression xsi:type="tFormalExpression"><![CDATA[${outcome=='驳回'}]]></conditionExpression> + </sequenceFlow> + <sequenceFlow id="bossPassFlow" name="通过" sourceRef="bossTask" targetRef="end"> + <conditionExpression xsi:type="tFormalExpression"><![CDATA[${outcome=='通过'}]]></conditionExpression> + </sequenceFlow> + <sequenceFlow id="directorPassFlow" name="通过" sourceRef="directorTak" targetRef="end"> + <conditionExpression xsi:type="tFormalExpression"><![CDATA[${outcome=='通过'}]]></conditionExpression> + </sequenceFlow> + <sequenceFlow id="directorNotPassFlow" name="驳回" sourceRef="directorTak" targetRef="fillTask"> + <conditionExpression xsi:type="tFormalExpression"><![CDATA[${outcome=='驳回'}]]></conditionExpression> + </sequenceFlow> + </process> + <bpmndi:BPMNDiagram id="BPMNDiagram_Leave"> + <bpmndi:BPMNPlane bpmnElement="Leave" id="BPMNPlane_Leave"> + <bpmndi:BPMNShape bpmnElement="start" id="BPMNShape_start"> + <omgdc:Bounds height="30.0" width="30.0" x="285.0" y="135.0"></omgdc:Bounds> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape bpmnElement="fillTask" id="BPMNShape_fillTask"> + <omgdc:Bounds height="80.0" width="100.0" x="405.0" y="110.0"></omgdc:Bounds> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape bpmnElement="judgeTask" id="BPMNShape_judgeTask"> + <omgdc:Bounds height="40.0" width="40.0" x="585.0" y="130.0"></omgdc:Bounds> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape bpmnElement="directorTak" id="BPMNShape_directorTak"> + <omgdc:Bounds height="80.0" width="100.0" x="735.0" y="110.0"></omgdc:Bounds> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape bpmnElement="bossTask" id="BPMNShape_bossTask"> + <omgdc:Bounds height="80.0" width="100.0" x="555.0" y="255.0"></omgdc:Bounds> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape bpmnElement="end" id="BPMNShape_end"> + <omgdc:Bounds height="28.0" width="28.0" x="771.0" y="281.0"></omgdc:Bounds> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1"> + <omgdi:waypoint x="314.9499992392744" y="150.0"></omgdi:waypoint> + <omgdi:waypoint x="404.9999999999684" y="150.0"></omgdi:waypoint> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2"> + <omgdi:waypoint x="504.95000000000005" y="150.0"></omgdi:waypoint> + <omgdi:waypoint x="585.0" y="150.0"></omgdi:waypoint> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge bpmnElement="judgeLess" id="BPMNEdge_judgeLess"> + <omgdi:waypoint x="624.9444614102993" y="150.0"></omgdi:waypoint> + <omgdi:waypoint x="734.9999999999723" y="150.0"></omgdi:waypoint> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge bpmnElement="directorNotPassFlow" id="BPMNEdge_directorNotPassFlow"> + <omgdi:waypoint x="785.0" y="110.0"></omgdi:waypoint> + <omgdi:waypoint x="785.0" y="37.0"></omgdi:waypoint> + <omgdi:waypoint x="455.0" y="37.0"></omgdi:waypoint> + <omgdi:waypoint x="455.0" y="110.0"></omgdi:waypoint> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge bpmnElement="bossPassFlow" id="BPMNEdge_bossPassFlow"> + <omgdi:waypoint x="654.9499999999431" y="295.0"></omgdi:waypoint> + <omgdi:waypoint x="771.0" y="295.0"></omgdi:waypoint> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge bpmnElement="judgeMore" id="BPMNEdge_judgeMore"> + <omgdi:waypoint x="605.0" y="169.94312543073747"></omgdi:waypoint> + <omgdi:waypoint x="605.0" y="255.0"></omgdi:waypoint> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge bpmnElement="directorPassFlow" id="BPMNEdge_directorPassFlow"> + <omgdi:waypoint x="785.0" y="189.95"></omgdi:waypoint> + <omgdi:waypoint x="785.0" y="281.0"></omgdi:waypoint> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge bpmnElement="bossNotPassFlow" id="BPMNEdge_bossNotPassFlow"> + <omgdi:waypoint x="555.0" y="295.0"></omgdi:waypoint> + <omgdi:waypoint x="455.0" y="295.0"></omgdi:waypoint> + <omgdi:waypoint x="455.0" y="189.95"></omgdi:waypoint> + </bpmndi:BPMNEdge> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</definitions> \ No newline at end of file diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/controller/MenuController.java b/blade-service/blade-system/src/main/java/org/springblade/system/controller/MenuController.java index 1f8f42bb..cadfe1b2 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/controller/MenuController.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/controller/MenuController.java @@ -50,7 +50,6 @@ import static org.springblade.common.cache.CacheNames.AUTH_ROUTES; @AllArgsConstructor @RequestMapping("/menu") @Api(value = "菜单", tags = "菜单") -@PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR) public class MenuController extends BladeController { private IMenuService menuService; @@ -61,6 +60,7 @@ public class MenuController extends BladeController { * 详情 */ @GetMapping("/detail") + @PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR) @ApiOperation(value = "详情", notes = "传入menu", position = 1) public R<MenuVO> detail(Menu menu) { Menu detail = menuService.getOne(Condition.getQueryWrapper(menu)); @@ -76,6 +76,7 @@ public class MenuController extends BladeController { @ApiImplicitParam(name = "code", value = "菜单编号", paramType = "query", dataType = "string"), @ApiImplicitParam(name = "name", value = "菜单名称", paramType = "query", dataType = "string") }) + @PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR) @ApiOperation(value = "列表", notes = "传入menu", position = 2) public R<List<MenuVO>> list(@ApiIgnore @RequestParam Map<String, Object> menu) { @SuppressWarnings("unchecked") @@ -88,6 +89,7 @@ public class MenuController extends BladeController { * 前端菜单数据 */ @GetMapping("/routes") + @PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR) @ApiOperation(value = "前端菜单数据", notes = "前端菜单数据", position = 3) public R<List<MenuVO>> routes(BladeUser user) { List<MenuVO> list = menuService.routes(user.getRoleId()); @@ -98,6 +100,7 @@ public class MenuController extends BladeController { * 前端按钮数据 */ @GetMapping("/buttons") + @PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR) @ApiOperation(value = "前端按钮数据", notes = "前端按钮数据", position = 4) public R<List<MenuVO>> buttons(BladeUser user) { List<MenuVO> list = menuService.buttons(user.getRoleId()); @@ -108,6 +111,7 @@ public class MenuController extends BladeController { * 获取菜单树形结构 */ @GetMapping("/tree") + @PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR) @ApiOperation(value = "树形结构", notes = "树形结构", position = 5) public R<List<MenuVO>> tree() { List<MenuVO> tree = menuService.tree(); @@ -118,6 +122,7 @@ public class MenuController extends BladeController { * 获取权限分配树形结构 */ @GetMapping("/grant-tree") + @PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR) @ApiOperation(value = "权限分配树形结构", notes = "权限分配树形结构", position = 6) public R<List<MenuVO>> grantTree(BladeUser user) { return R.data(menuService.grantTree(user)); @@ -127,6 +132,7 @@ public class MenuController extends BladeController { * 获取权限分配树形结构 */ @GetMapping("/role-tree-keys") + @PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR) @ApiOperation(value = "角色所分配的树", notes = "角色所分配的树", position = 7) public R<List<String>> roleTreeKeys(String roleIds) { return R.data(menuService.roleTreeKeys(roleIds)); @@ -137,6 +143,7 @@ public class MenuController extends BladeController { */ @PostMapping("/submit") @CacheEvict(cacheNames = {AUTH_ROUTES}) + @PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR) @ApiOperation(value = "新增或修改", notes = "传入menu", position = 8) public R submit(@Valid @RequestBody Menu menu) { return R.status(menuService.saveOrUpdate(menu)); @@ -148,6 +155,7 @@ public class MenuController extends BladeController { */ @PostMapping("/remove") @CacheEvict(cacheNames = {AUTH_ROUTES}) + @PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR) @ApiOperation(value = "删除", notes = "传入ids", position = 9) public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { return R.status(menuService.removeByIds(Func.toIntList(ids)));