|
@@ -0,0 +1,52 @@
|
|
|
+package cn.com.qmth.examcloud.core.basic.service.cache;
|
|
|
+
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
|
+import cn.com.qmth.examcloud.core.basic.dao.ThirdPartyAccessRepo;
|
|
|
+import cn.com.qmth.examcloud.core.basic.dao.entity.ThirdPartyAccessEntity;
|
|
|
+import cn.com.qmth.examcloud.core.basic.dao.entity.ThirdPartyAccessPK;
|
|
|
+import cn.com.qmth.examcloud.support.cache.bean.ThirdPartyAccessCacheBean;
|
|
|
+import cn.com.qmth.examcloud.web.cache.RandomObjectRedisCache;
|
|
|
+import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
|
|
|
+
|
|
|
+@Service
|
|
|
+public class ThirdPartyAccessCache extends RandomObjectRedisCache<ThirdPartyAccessCacheBean> {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ThirdPartyAccessRepo thirdPartyAccessRepo;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ThirdPartyAccessCacheBean loadFromResource(Object... keys) {
|
|
|
+ Long rootOrgId = (Long) keys[0];
|
|
|
+ String appId = (String) keys[1];
|
|
|
+
|
|
|
+ ThirdPartyAccessEntity entity = GlobalHelper.getEntity(thirdPartyAccessRepo,
|
|
|
+ new ThirdPartyAccessPK(rootOrgId, appId), ThirdPartyAccessEntity.class);
|
|
|
+
|
|
|
+ if (null == entity) {
|
|
|
+ throw new StatusException("001001", "第三方接入信息不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ ThirdPartyAccessCacheBean bean = new ThirdPartyAccessCacheBean();
|
|
|
+ bean.setAppId(entity.getAppId());
|
|
|
+ bean.setRootOrgId(entity.getRootOrgId());
|
|
|
+ bean.setSecretKey(entity.getSecretKey());
|
|
|
+ bean.setTimeRange(entity.getTimeRange());
|
|
|
+
|
|
|
+ return bean;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected String getKeyPrefix() {
|
|
|
+ return "B_THIRD_PARTY_ACCESS:";
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected int getTimeout() {
|
|
|
+
|
|
|
+ return 60 * 5;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|