|
|
@@ -1,11 +1,22 @@
|
|
|
package com.zhongshu.card.server.core.service.sync;
|
|
|
|
|
|
+import com.github.microservice.auth.security.type.AuthType;
|
|
|
+import com.zhongshu.card.client.ret.ResultContent;
|
|
|
import com.zhongshu.card.server.core.dao.org.OrganizationDao;
|
|
|
import com.zhongshu.card.server.core.domain.org.Organization;
|
|
|
+import com.zhongshu.card.server.core.event.ProjectSyncEvent;
|
|
|
+import lombok.SneakyThrows;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.context.ApplicationContext;
|
|
|
+import org.springframework.context.event.EventListener;
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
/**
|
|
|
* @author TRX
|
|
|
* @date 2024/6/27
|
|
|
@@ -17,4 +28,31 @@ public class ProjectSyncIotCenterService {
|
|
|
@Autowired
|
|
|
OrganizationDao organizationDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ ApplicationContext applicationContext;
|
|
|
+
|
|
|
+ public ResultContent noticeSyncProjects(List<Organization> list) {
|
|
|
+ if (ObjectUtils.isNotEmpty(list)) {
|
|
|
+ List<String> projectIds = list.stream().map(it -> it.getOid()).collect(Collectors.toList());
|
|
|
+ ProjectSyncEvent event = new ProjectSyncEvent(this, projectIds);
|
|
|
+ applicationContext.publishEvent(event);
|
|
|
+ }
|
|
|
+ return ResultContent.buildSuccess();
|
|
|
+ }
|
|
|
+
|
|
|
+ public ResultContent noticeSyncProject(Organization organization) {
|
|
|
+ if (ObjectUtils.isNotEmpty(organization) && organization.getAuthType() == AuthType.Project) {
|
|
|
+ List<String> projectIds = List.of(organization.getOid());
|
|
|
+ ProjectSyncEvent event = new ProjectSyncEvent(this, projectIds);
|
|
|
+ applicationContext.publishEvent(event);
|
|
|
+ }
|
|
|
+ return ResultContent.buildSuccess();
|
|
|
+ }
|
|
|
+
|
|
|
+ @EventListener(classes = ProjectSyncEvent.class)
|
|
|
+ @Async
|
|
|
+ @SneakyThrows
|
|
|
+ public void syncProjectInfo(ProjectSyncEvent event) {
|
|
|
+
|
|
|
+ }
|
|
|
}
|