3 Commits

Author SHA1 Message Date
疯狂的狮子Li
74e3d232f5 update 优化 工作流任务创建监听器 传递流程参数 2025-07-09 10:43:22 +08:00
疯狂的狮子Li
03fca40c7d update 优化 监控使用springSecurity新语法 2025-07-09 09:56:32 +08:00
疯狂的狮子Li
b2ad257bd8 fix 修复 代码生成 setIsRequired 标志写反 2025-07-09 09:35:35 +08:00
6 changed files with 24 additions and 9 deletions

View File

@@ -4,6 +4,7 @@ import lombok.Data;
import java.io.Serial; import java.io.Serial;
import java.io.Serializable; import java.io.Serializable;
import java.util.Map;
/** /**
* 流程任务监听 * 流程任务监听
@@ -56,4 +57,9 @@ public class ProcessTaskEvent implements Serializable {
*/ */
private String status; private String status;
/**
* 办理参数
*/
private Map<String, Object> params;
} }

View File

@@ -3,6 +3,7 @@ package org.dromara.monitor.admin.config;
import de.codecentric.boot.admin.server.config.AdminServerProperties; import de.codecentric.boot.admin.server.config.AdminServerProperties;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
import org.springframework.security.config.Customizer; import org.springframework.security.config.Customizer;
import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
@@ -10,7 +11,8 @@ import org.springframework.security.config.annotation.web.configurers.AbstractHt
import org.springframework.security.config.annotation.web.configurers.HeadersConfigurer; import org.springframework.security.config.annotation.web.configurers.HeadersConfigurer;
import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler; import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher; import org.springframework.security.web.servlet.util.matcher.MvcRequestMatcher;
import org.springframework.web.servlet.handler.HandlerMappingIntrospector;
/** /**
* admin 监控 安全配置 * admin 监控 安全配置
@@ -28,7 +30,7 @@ public class SecurityConfig {
} }
@Bean @Bean
public SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception { public SecurityFilterChain filterChain(HttpSecurity httpSecurity, MvcRequestMatcher.Builder mvc) throws Exception {
SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler(); SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler();
successHandler.setTargetUrlParameter("redirectTo"); successHandler.setTargetUrlParameter("redirectTo");
successHandler.setDefaultTargetUrl(adminContextPath + "/"); successHandler.setDefaultTargetUrl(adminContextPath + "/");
@@ -38,8 +40,8 @@ public class SecurityConfig {
header.frameOptions(HeadersConfigurer.FrameOptionsConfig::disable)) header.frameOptions(HeadersConfigurer.FrameOptionsConfig::disable))
.authorizeHttpRequests((authorize) -> .authorizeHttpRequests((authorize) ->
authorize.requestMatchers( authorize.requestMatchers(
new AntPathRequestMatcher(adminContextPath + "/assets/**"), mvc.pattern(adminContextPath + "/assets/**"),
new AntPathRequestMatcher(adminContextPath + "/login") mvc.pattern(adminContextPath + "/login")
).permitAll() ).permitAll()
.anyRequest().authenticated()) .anyRequest().authenticated())
.formLogin((formLogin) -> .formLogin((formLogin) ->
@@ -51,4 +53,10 @@ public class SecurityConfig {
.build(); .build();
} }
@Scope("prototype")
@Bean
public MvcRequestMatcher.Builder mvc(HandlerMappingIntrospector introspector) {
return new MvcRequestMatcher.Builder(introspector);
}
} }

View File

@@ -302,7 +302,7 @@ public class GenTableServiceImpl implements IGenTableService {
tableColumn.setColumnComment(column.getComment()); tableColumn.setColumnComment(column.getComment());
tableColumn.setColumnType(column.getOriginType().toLowerCase()); tableColumn.setColumnType(column.getOriginType().toLowerCase());
tableColumn.setSort(column.getPosition()); tableColumn.setSort(column.getPosition());
tableColumn.setIsRequired(column.isNullable() ? "1" : "0"); tableColumn.setIsRequired(column.isNullable() ? "0" : "1");
tableColumn.setIsIncrement(column.isAutoIncrement() ? "1" : "0"); tableColumn.setIsIncrement(column.isAutoIncrement() ? "1" : "0");
tableColumns.add(tableColumn); tableColumns.add(tableColumn);
}); });

View File

@@ -56,7 +56,7 @@ public class FlowProcessEventHandler {
* @param instance 实例数据 * @param instance 实例数据
* @param taskId 任务id * @param taskId 任务id
*/ */
public void processTaskHandler(String flowCode, Instance instance, Long taskId) { public void processTaskHandler(String flowCode, Instance instance, Long taskId, Map<String, Object> params) {
String tenantId = TenantHelper.getTenantId(); String tenantId = TenantHelper.getTenantId();
log.info("【流程任务事件发布】租户ID: {}, 流程编码: {}, 业务ID: {}, 节点类型: {}, 节点编码: {}, 节点名称: {}, 任务ID: {}", log.info("【流程任务事件发布】租户ID: {}, 流程编码: {}, 业务ID: {}, 节点类型: {}, 节点编码: {}, 节点名称: {}, 任务ID: {}",
tenantId, flowCode, instance.getBusinessId(), instance.getNodeType(), instance.getNodeCode(), instance.getNodeName(), taskId); tenantId, flowCode, instance.getBusinessId(), instance.getNodeType(), instance.getNodeCode(), instance.getNodeName(), taskId);
@@ -69,6 +69,7 @@ public class FlowProcessEventHandler {
processTaskEvent.setNodeName(instance.getNodeName()); processTaskEvent.setNodeName(instance.getNodeName());
processTaskEvent.setTaskId(taskId); processTaskEvent.setTaskId(taskId);
processTaskEvent.setStatus(instance.getFlowStatus()); processTaskEvent.setStatus(instance.getFlowStatus());
processTaskEvent.setParams(params);
SpringUtils.context().publishEvent(processTaskEvent); SpringUtils.context().publishEvent(processTaskEvent);
} }

View File

@@ -130,7 +130,7 @@ public class WorkflowGlobalListener implements GlobalListener {
} }
//发布任务事件 //发布任务事件
if (task != null) { if (task != null) {
flowProcessEventHandler.processTaskHandler(definition.getFlowCode(), instance, task.getId()); flowProcessEventHandler.processTaskHandler(definition.getFlowCode(), instance, task.getId(), params);
} }
if (ObjectUtil.isNull(flowParams)) { if (ObjectUtil.isNull(flowParams)) {
return; return;

View File

@@ -136,7 +136,7 @@ public class TestLeaveServiceImpl implements ITestLeaveService {
} }
/** /**
* 总体流程监听(例如: 草稿,撤销,退回,作废,终止,已完成,单任务完成等) * 总体流程监听(例如: 草稿,撤销,退回,作废,终止,已完成等)
* 正常使用只需#processEvent.flowCode=='leave1' * 正常使用只需#processEvent.flowCode=='leave1'
* 示例为了方便则使用startsWith匹配了全部示例key * 示例为了方便则使用startsWith匹配了全部示例key
* *
@@ -164,7 +164,7 @@ public class TestLeaveServiceImpl implements ITestLeaveService {
} }
/** /**
* 执行任务创建监听 * 执行任务创建监听(也代表上一条任务完成事件)
* 示例:也可通过 @EventListener(condition = "#processTaskEvent.flowCode=='leave1'")进行判断 * 示例:也可通过 @EventListener(condition = "#processTaskEvent.flowCode=='leave1'")进行判断
* 在方法中判断流程节点key * 在方法中判断流程节点key
* if ("xxx".equals(processTaskEvent.getNodeCode())) { * if ("xxx".equals(processTaskEvent.getNodeCode())) {