Bläddra i källkod

Merge branch '84-wb' into '84-integrate'

84 wb



See merge request !26

wangbo 2 år sedan
förälder
incheckning
c5e4aff3fd

+ 14 - 0
smsb-customer-manager-app/src/main/java/com/inspur/customer/service/keycloak/KeycloakServiceImpl.java

@@ -16,11 +16,14 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.dubbo.config.annotation.DubboService;
 import org.keycloak.admin.client.resource.*;
 import org.keycloak.representations.idm.*;
+import org.springframework.cache.annotation.CacheEvict;
 import org.springframework.cache.annotation.Cacheable;
+import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.StringUtils;
 
 import javax.annotation.Resource;
+import java.time.LocalDateTime;
 import java.util.*;
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.stream.Collectors;
@@ -46,6 +49,17 @@ public class KeycloakServiceImpl implements KeycloakService {
         return userMap;
     }
 
+    @CacheEvict(value = "smsb:users" , allEntries = true)
+    public void clearUserMapCache(){
+        log.info("users map cache clear:{}",LocalDateTime.now() );
+    }
+
+    @Scheduled(cron = "* * 0/10 * * ?")
+    public void expiredCache(){
+        // 每隔10小时,清除缓存数据初始化一次
+        this.clearUserMapCache();
+    }
+
     /**
      * get users in role (xuzhou environment)
      * @param role role

+ 2 - 0
smsb-customer-manager-app/src/main/java/com/inspur/customer/service/org/SmsbDepartmentUserServiceImpl.java

@@ -23,6 +23,7 @@ import org.apache.dubbo.config.annotation.DubboService;
 import org.springframework.beans.BeanUtils;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.time.LocalDateTime;
 import java.util.List;
 import java.util.Objects;
 
@@ -91,6 +92,7 @@ public class SmsbDepartmentUserServiceImpl extends ServiceImpl<SmsbDepartmentUse
         }
         SmsbDepartmentUserDO smsbDepartmentUserDO = new SmsbDepartmentUserDO();
         BeanUtils.copyProperties(userMigration , smsbDepartmentUserDO);
+        smsbDepartmentUserDO.setCreateTime(LocalDateTime.now());
         super.save(smsbDepartmentUserDO);
         return SingleResponse.of(smsbDepartmentUserDO);
     }