businessListenerItemList) {
+ CONTEXT.put(businessCode, businessListenerItemList);
+ }
+
+}
diff --git a/kernel-d-event/event-sdk/src/main/java/cn/stylefeng/roses/kernel/event/sdk/pojo/BusinessListenerDetail.java b/kernel-d-event/event-sdk/src/main/java/cn/stylefeng/roses/kernel/event/sdk/pojo/BusinessListenerDetail.java
new file mode 100644
index 000000000..51cbabeb2
--- /dev/null
+++ b/kernel-d-event/event-sdk/src/main/java/cn/stylefeng/roses/kernel/event/sdk/pojo/BusinessListenerDetail.java
@@ -0,0 +1,33 @@
+package cn.stylefeng.roses.kernel.event.sdk.pojo;
+
+import lombok.Data;
+
+import java.lang.reflect.Method;
+
+/**
+ * 业务事件监听的详情封装
+ *
+ * @author fengshuonan
+ * @since 2023/7/14 15:18
+ */
+@Data
+public class BusinessListenerDetail {
+
+ /**
+ * Spring的Bean名称
+ */
+ private String beanName;
+
+ /**
+ * 业务监听器对应注解的类方法
+ */
+ private Method listenerMethod;
+
+ /**
+ * 方法参数的类型,如果方法有多个参数,这里只获取第一个参数的类型
+ *
+ * 如果方法没参数,则这里为null
+ */
+ private Class> parameterClassType;
+
+}
diff --git a/kernel-d-event/event-sdk/src/main/java/cn/stylefeng/roses/kernel/event/sdk/publish/BusinessEventPublisher.java b/kernel-d-event/event-sdk/src/main/java/cn/stylefeng/roses/kernel/event/sdk/publish/BusinessEventPublisher.java
new file mode 100644
index 000000000..e4749a0b7
--- /dev/null
+++ b/kernel-d-event/event-sdk/src/main/java/cn/stylefeng/roses/kernel/event/sdk/publish/BusinessEventPublisher.java
@@ -0,0 +1,76 @@
+package cn.stylefeng.roses.kernel.event.sdk.publish;
+
+import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.extra.spring.SpringUtil;
+import cn.stylefeng.roses.kernel.event.sdk.container.EventContainer;
+import cn.stylefeng.roses.kernel.event.sdk.pojo.BusinessListenerDetail;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.List;
+
+/**
+ * 业务事件发布工具
+ *
+ * @author fengshuonan
+ * @since 2023/7/14 16:21
+ */
+public class BusinessEventPublisher {
+
+ /**
+ * 发布一个业务事件
+ *
+ * 如果有方法上加了@BusinessListener,则会自动回调那些方法
+ *
+ * @author fengshuonan
+ * @since 2023/7/14 15:37
+ */
+ public static void publishEvent(String businessCode, T businessObject) {
+
+ // 获取该业务是否有监听器
+ List listener = EventContainer.getListener(businessCode);
+
+ // 没有监听器则直接返回
+ if (ObjectUtil.isEmpty(listener)) {
+ return;
+ }
+
+ // 依次调用监听器方法,进行回调调用
+ for (BusinessListenerDetail businessListenerDetail : listener) {
+
+ // 监听器的Spring Bean
+ String beanName = businessListenerDetail.getBeanName();
+ Object bean = SpringUtil.getBean(beanName);
+
+ // 监听器的具体方法
+ Method listenerMethod = businessListenerDetail.getListenerMethod();
+ Class> parameterClassType = businessListenerDetail.getParameterClassType();
+
+ // 如果发布事件的时候参数是空的,则直接调用无参的方法
+ if (ObjectUtil.isEmpty(businessObject)) {
+
+ // 如果方法的参数数量为0,则直接调用,如果不为0,则跳过执行下个
+ if (parameterClassType == null) {
+ try {
+ listenerMethod.invoke(businessObject);
+ } catch (IllegalAccessException | InvocationTargetException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ }
+
+ // 如果发布事件的时候,包含参数,则判断method的第一个参数是否和businessObject的class一样,不一样则不调用
+ else {
+ if (parameterClassType != null && parameterClassType.equals(businessObject.getClass())) {
+ try {
+ listenerMethod.invoke(bean, businessObject);
+ } catch (IllegalAccessException | InvocationTargetException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+ }
+ }
+
+}
diff --git a/kernel-d-event/event-spring-boot-starter/README.md b/kernel-d-event/event-spring-boot-starter/README.md
new file mode 100644
index 000000000..ab408c724
--- /dev/null
+++ b/kernel-d-event/event-spring-boot-starter/README.md
@@ -0,0 +1,2 @@
+# Spring Boot自动装配
+
diff --git a/kernel-d-event/event-spring-boot-starter/pom.xml b/kernel-d-event/event-spring-boot-starter/pom.xml
new file mode 100644
index 000000000..942c5d531
--- /dev/null
+++ b/kernel-d-event/event-spring-boot-starter/pom.xml
@@ -0,0 +1,29 @@
+
+
+ 4.0.0
+
+
+ cn.stylefeng.roses
+ kernel-d-event
+ 8.0.0
+ ../pom.xml
+
+
+ event-spring-boot-starter
+
+ jar
+
+
+
+
+
+ cn.stylefeng.roses
+ event-sdk
+ ${roses.version}
+
+
+
+
+
diff --git a/kernel-d-event/event-spring-boot-starter/src/main/java/cn/stylefeng/roses/kernel/event/starter/EventAutoConfiguration.java b/kernel-d-event/event-spring-boot-starter/src/main/java/cn/stylefeng/roses/kernel/event/starter/EventAutoConfiguration.java
new file mode 100644
index 000000000..b3094bf70
--- /dev/null
+++ b/kernel-d-event/event-spring-boot-starter/src/main/java/cn/stylefeng/roses/kernel/event/starter/EventAutoConfiguration.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright [2020-2030] [https://www.stylefeng.cn]
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
+ *
+ * 1.请不要删除和修改根目录下的LICENSE文件。
+ * 2.请不要删除和修改Guns源码头部的版权声明。
+ * 3.请保留源码和相关描述文件的项目出处,作者声明等。
+ * 4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns
+ * 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
+ * 6.若您的项目无法满足以上几点,可申请商业授权
+ */
+package cn.stylefeng.roses.kernel.event.starter;
+
+import cn.stylefeng.roses.kernel.event.sdk.EventAnnotationScanner;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * 业务事件自动装配
+ *
+ * @author fengshuonan
+ * @date 2023-07-14 15:05:54
+ */
+@Configuration
+public class EventAutoConfiguration {
+
+ /**
+ * 创建事件的扫描
+ *
+ * @author fengshuonan
+ * @since 2023/7/14 16:00
+ */
+ @Bean
+ public EventAnnotationScanner eventAnnotationScanner() {
+ return new EventAnnotationScanner();
+ }
+
+}
diff --git a/kernel-d-event/event-spring-boot-starter/src/main/resources/META-INF/spring.factories b/kernel-d-event/event-spring-boot-starter/src/main/resources/META-INF/spring.factories
new file mode 100644
index 000000000..8ad7fffea
--- /dev/null
+++ b/kernel-d-event/event-spring-boot-starter/src/main/resources/META-INF/spring.factories
@@ -0,0 +1,2 @@
+org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
+ cn.stylefeng.roses.kernel.event.starter.EventAutoConfiguration
diff --git a/kernel-d-event/pom.xml b/kernel-d-event/pom.xml
new file mode 100644
index 000000000..d6bcf8d34
--- /dev/null
+++ b/kernel-d-event/pom.xml
@@ -0,0 +1,35 @@
+
+
+ 4.0.0
+
+
+ cn.stylefeng.roses
+ roses-kernel
+ 8.0.0
+ ../pom.xml
+
+
+ kernel-d-event
+
+ pom
+
+
+ event-api
+ event-sdk
+ event-spring-boot-starter
+
+
+
+
+
+
+ cn.stylefeng.roses
+ kernel-a-rule
+ ${roses.version}
+
+
+
+
+
diff --git a/kernel-s-system/system-business-hr/pom.xml b/kernel-s-system/system-business-hr/pom.xml
index bfaf89bdc..1a0ae59a8 100644
--- a/kernel-s-system/system-business-hr/pom.xml
+++ b/kernel-s-system/system-business-hr/pom.xml
@@ -17,6 +17,13 @@
+
+
+ cn.stylefeng.roses
+ event-spring-boot-starter
+ ${roses.version}
+
+
cn.stylefeng.roses
diff --git a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/constants/OrgConstants.java b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/constants/OrgConstants.java
index b295ac22c..bd24783d3 100644
--- a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/constants/OrgConstants.java
+++ b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/constants/OrgConstants.java
@@ -37,4 +37,9 @@ public interface OrgConstants {
*/
String NONE_PARENT_ORG = "无上级机构";
+ /**
+ * 添加组织机构的事件监听
+ */
+ String ADD_ORG_EVENT = "ADD_ORG_EVENT";
+
}
diff --git a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/listener/OrgOperateListener.java b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/listener/OrgOperateListener.java
new file mode 100644
index 000000000..7a374692d
--- /dev/null
+++ b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/listener/OrgOperateListener.java
@@ -0,0 +1,43 @@
+package cn.stylefeng.roses.kernel.sys.modular.org.listener;
+
+import cn.hutool.core.util.ObjectUtil;
+import cn.stylefeng.roses.kernel.cache.api.CacheOperatorApi;
+import cn.stylefeng.roses.kernel.event.api.annotation.BusinessListener;
+import cn.stylefeng.roses.kernel.sys.modular.org.constants.OrgConstants;
+import cn.stylefeng.roses.kernel.sys.modular.org.entity.HrOrganization;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+
+/**
+ * 添加组织机构的事件监听器
+ *
+ * @author fengshuonan
+ * @since 2023/7/14 14:19
+ */
+@Service
+public class OrgOperateListener {
+
+ @Resource(name = "sysOrgSubFlagCache")
+ private CacheOperatorApi sysOrgSubFlagCache;
+
+ /**
+ * 监听新增组织机构,删除相关的缓存
+ *
+ * @author fengshuonan
+ * @since 2023/7/14 16:22
+ */
+ @BusinessListener(businessCode = OrgConstants.ADD_ORG_EVENT)
+ public void addOrgCallback(HrOrganization businessObject) {
+
+ if (ObjectUtil.isNotEmpty(businessObject.getOrgId())) {
+ sysOrgSubFlagCache.remove(String.valueOf(businessObject.getOrgId()));
+ }
+
+ if (ObjectUtil.isNotEmpty(businessObject.getOrgParentId())) {
+ sysOrgSubFlagCache.remove(String.valueOf(businessObject.getOrgParentId()));
+ }
+
+ }
+
+}
diff --git a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/service/impl/HrOrganizationServiceImpl.java b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/service/impl/HrOrganizationServiceImpl.java
index 1a9f928fb..fb7c5e7b2 100644
--- a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/service/impl/HrOrganizationServiceImpl.java
+++ b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/service/impl/HrOrganizationServiceImpl.java
@@ -12,6 +12,7 @@ import cn.stylefeng.roses.kernel.db.api.factory.PageFactory;
import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory;
import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseEntity;
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
+import cn.stylefeng.roses.kernel.event.sdk.publish.BusinessEventPublisher;
import cn.stylefeng.roses.kernel.rule.constants.TreeConstants;
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
import cn.stylefeng.roses.kernel.rule.tree.factory.DefaultTreeBuildFactory;
@@ -76,6 +77,9 @@ public class HrOrganizationServiceImpl extends ServiceImpl
kernel-d-email
+
+ kernel-d-event
+
kernel-d-file