|
@@ -3,16 +3,23 @@ package cn.com.qmth.examcloud.core.basic.service.impl;
|
|
|
import cn.com.qmth.examcloud.commons.logging.ExamCloudLog;
|
|
|
import cn.com.qmth.examcloud.commons.logging.ExamCloudLogFactory;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.LoginRuleRepo;
|
|
|
+import cn.com.qmth.examcloud.core.basic.dao.entity.LoginRuleEntity;
|
|
|
import cn.com.qmth.examcloud.core.basic.service.LoginRuleService;
|
|
|
+import cn.com.qmth.examcloud.core.basic.service.cache.LoginRuleCacheBean;
|
|
|
import cn.com.qmth.examcloud.web.redis.RedisClient;
|
|
|
+import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
@Service
|
|
|
public class LoginRuleServiceImpl implements LoginRuleService {
|
|
|
|
|
|
private static final ExamCloudLog log = ExamCloudLogFactory.getLog("INTERFACE_LOGGER");
|
|
|
|
|
|
+ private static final String CACHE_KEY_LOGIN_RULE = "B_LOGIN_RULE";// “登录规则”缓存KEY
|
|
|
+
|
|
|
@Autowired
|
|
|
private LoginRuleRepo loginRuleRepo;
|
|
|
|
|
@@ -21,7 +28,23 @@ public class LoginRuleServiceImpl implements LoginRuleService {
|
|
|
|
|
|
@Override
|
|
|
public void refreshLoginRule() {
|
|
|
+ log.info("refreshLoginRule start...");
|
|
|
+
|
|
|
+ List<LoginRuleEntity> entities = loginRuleRepo.findAll();
|
|
|
+ redisClient.delete(CACHE_KEY_LOGIN_RULE);
|
|
|
+
|
|
|
+ if (CollectionUtils.isNotEmpty(entities)) {
|
|
|
+ for (LoginRuleEntity entity : entities) {
|
|
|
+ LoginRuleCacheBean cacheBean = new LoginRuleCacheBean();
|
|
|
+ cacheBean.setRootOrgId(entity.getRootOrgId());
|
|
|
+ cacheBean.setWhite(entity.getWhite());
|
|
|
+
|
|
|
+ final String subKey = cacheBean.getRootOrgId().toString();
|
|
|
+ redisClient.set(CACHE_KEY_LOGIN_RULE, subKey, cacheBean);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ log.info("refreshLoginRule end...");
|
|
|
}
|
|
|
|
|
|
-}
|
|
|
+}
|