TRX 1 anno fa
parent
commit
53243cc085

+ 6 - 2
FullCardServer/src/main/java/com/zhongshu/card/server/core/domain/org/OrganizationUser.java

@@ -1,5 +1,6 @@
 package com.zhongshu.card.server.core.domain.org;
 
+import cn.hutool.json.JSONObject;
 import com.github.microservice.auth.security.type.AuthType;
 import com.zhongshu.card.client.type.CertificateType;
 import com.zhongshu.card.client.type.OrganizationUserType;
@@ -30,8 +31,7 @@ import java.util.List;
 @Document
 @EqualsAndHashCode(callSuper = true)
 @Builder
-@CompoundIndexes({@CompoundIndex(name = "organization_user",
-        def = "{'organization': 1, 'user': 1, 'projectOid': 1 }", unique = true)})
+@CompoundIndexes({@CompoundIndex(name = "organization_user", def = "{'organization': 1, 'user': 1, 'projectOid': 1 }", unique = true)})
 public class OrganizationUser extends SuperMain {
 
     @Schema(description = "机构信息")
@@ -99,4 +99,8 @@ public class OrganizationUser extends SuperMain {
 
     @Schema(description = "是否是机构类型,如果用户只加入项目,没加入项目的机构中,则isOrg:false")
     private Boolean isOrg = Boolean.FALSE;
+
+    @Schema(description = "扩展字段,动态字段, {'key': 'code','value: '李四', 'filedName': '学号'}")
+    private JSONObject extendData = new JSONObject();
+
 }

+ 9 - 4
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/devices/DevicePermissService.java

@@ -23,8 +23,6 @@ import com.zhongshu.card.server.core.domain.org.OrganizationUser;
 import com.zhongshu.card.server.core.domain.org.UserAccount;
 import com.zhongshu.card.server.core.event.OrgUserBindUpdateSyncEvent;
 import com.zhongshu.card.server.core.service.base.SuperService;
-import com.zhongshu.card.server.core.service.projectAbout.CardInfoServiceImpl;
-import com.zhongshu.card.server.core.service.projectAbout.OrgUserFaceService;
 import com.zhongshu.card.server.core.service.user.UserAccountServiceImpl;
 import com.zhongshu.card.server.core.util.BeanUtils;
 import com.zhongshu.card.server.core.util.CommonUtil;
@@ -179,13 +177,21 @@ public class DevicePermissService extends SuperService {
         }
     }
 
+    /**
+     * 机构用户信息发送变化
+     *
+     * @param event
+     */
     @EventListener(classes = OrgUserBindUpdateSyncEvent.class)
     @Async
     @SneakyThrows
     public void syncOrgUserChangeInfo(OrgUserBindUpdateSyncEvent event) {
         executorService.execute(() -> {
             log.info("机构用户信息发生变化 syncOrgUserChangeInfo...");
+
+            // 机构用户改变类型
             DataOperationType dataOperationType = event.getDataOperationType();
+            // 机构用户数据ID
             List<String> organizationUserIds = event.getOrganizationUserIds();
             if (dataOperationType != null) {
                 List<OrganizationUser> organizationUsers = organizationUserDao.findByIdIn(organizationUserIds);
@@ -292,8 +298,7 @@ public class DevicePermissService extends SuperService {
     public List<String> getUserAllDeviceIds(String projectOid, List<String> userIds) {
         List<String> deviceIds = Lists.newArrayList();
         if (StringUtils.isNotEmpty(projectOid) && ObjectUtils.isNotEmpty(userIds)) {
-            List<DevicePermiss> list = devicePermissDao.findByUserIdInAndProjectOidAndDataState(
-                    userIds, projectOid, DataState.Enable);
+            List<DevicePermiss> list = devicePermissDao.findByUserIdInAndProjectOidAndDataState(userIds, projectOid, DataState.Enable);
             if (ObjectUtils.isNotEmpty(list)) {
                 deviceIds = list.stream().map(it -> it.getDeviceId()).collect(Collectors.toList());
             }

+ 8 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/org/OrganizationUserServiceImpl.java

@@ -116,9 +116,13 @@ public class OrganizationUserServiceImpl extends SuperService {
 
     @Autowired
     private DevicePermissEventService devicePermissEventService;
+
     @Autowired
     private ProjectPaySettingServiceImpl projectPaySettingServiceImpl;
 
+    @Autowired
+    private UserInfoSyncService userInfoSyncService;
+
     /**
      * 添加编辑用户 添加机构用户 (包括角色 部门 职位等信息)
      * 用户可能不存在
@@ -348,10 +352,13 @@ public class OrganizationUserServiceImpl extends SuperService {
         }
         organizationUserDao.save(organizationUser);
 
+        // 发送用户信息变更事件,用以下发用户 权限关联的用户信息
+        // DevicePermissService.syncOrgUserChangeInfo
         if (isUpdate) {
             OrgUserBindUpdateSyncEvent event = new OrgUserBindUpdateSyncEvent(this, List.of(organizationUser.getId()), DataOperationType.Update);
             applicationContext.publishEvent(event);
         }
+
         // 权限中心 绑定用户
         com.github.microservice.auth.client.content.ResultContent<Void> resultContent = organizationUserService.update(organization.getOid(), new String[]{userId});
         if (resultContent.getState() == ResultState.Success) {
@@ -359,6 +366,7 @@ public class OrganizationUserServiceImpl extends SuperService {
         } else {
             log.error("权限中心:绑定机构和用户关系出错:{}", resultContent.getMsg());
         }
+        userInfoSyncService.updateProjectAboutInfoByOrgUserDataId(organizationUser.getId());
         return ResultContent.buildSuccess(organizationUser);
     }
 

+ 35 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/org/UserInfoSyncService.java

@@ -0,0 +1,35 @@
+package com.zhongshu.card.server.core.service.org;
+
+import com.zhongshu.card.server.core.dao.org.OrganizationUserDao;
+import com.zhongshu.card.server.core.domain.org.OrganizationUser;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.ObjectUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * 用户改变 后,修改其他关联的信息
+ *
+ * @author TRX
+ * @date 2024/12/13
+ */
+@Slf4j
+@Service
+public class UserInfoSyncService {
+
+    @Autowired
+    private OrganizationUserDao organizationUserDao;
+
+    /**
+     * 机构用户信息发送变化 同步其他 冗余存储的数据(主要是 用户名称、电话、角色、等信息)
+     *
+     * @param orgUserDataId
+     */
+    public void updateProjectAboutInfoByOrgUserDataId(String orgUserDataId) {
+        OrganizationUser organizationUser = organizationUserDao.findTopById(orgUserDataId);
+        if (ObjectUtils.isNotEmpty(organizationUser)) {
+
+        }
+    }
+
+}

+ 1 - 1
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/paySetting/ProjectPaySettingServiceImpl.java

@@ -592,7 +592,7 @@ public class ProjectPaySettingServiceImpl extends SuperService {
     }
 
     /**
-     * 得到支付渠道 动态参数
+     * 得到支付渠道 动态参数、动态字段
      *
      * @param paymentType
      * @return