|
@@ -1,8 +1,5 @@
|
|
|
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.commons.helpers.DynamicEnum;
|
|
|
import cn.com.qmth.examcloud.commons.helpers.DynamicEnumManager;
|
|
@@ -11,61 +8,64 @@ import cn.com.qmth.examcloud.core.basic.dao.OrgRepo;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.entity.OrgEntity;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.entity.OrgPropertyEntity;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.enums.OrgProperty;
|
|
|
+import cn.com.qmth.examcloud.support.CacheConstants;
|
|
|
import cn.com.qmth.examcloud.support.cache.bean.OrgPropertyCacheBean;
|
|
|
import cn.com.qmth.examcloud.web.cache.RandomObjectRedisCache;
|
|
|
import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
|
|
@Service
|
|
|
public class OrgPropertyCache extends RandomObjectRedisCache<OrgPropertyCacheBean> {
|
|
|
|
|
|
- @Autowired
|
|
|
- OrgRepo orgRepo;
|
|
|
+ @Autowired
|
|
|
+ OrgRepo orgRepo;
|
|
|
|
|
|
- @Autowired
|
|
|
- OrgPropertyRepo orgPropertyRepo;
|
|
|
+ @Autowired
|
|
|
+ OrgPropertyRepo orgPropertyRepo;
|
|
|
|
|
|
- @Override
|
|
|
- public OrgPropertyCacheBean loadFromResource(Object... keys) {
|
|
|
- Long orgId = (Long) keys[0];
|
|
|
- String key = (String) keys[1];
|
|
|
+ @Override
|
|
|
+ public OrgPropertyCacheBean loadFromResource(Object... keys) {
|
|
|
+ Long orgId = (Long) keys[0];
|
|
|
+ String key = (String) keys[1];
|
|
|
|
|
|
- OrgEntity orgEntity = null;
|
|
|
- if (null != orgId) {
|
|
|
- orgEntity = GlobalHelper.getEntity(orgRepo, orgId, OrgEntity.class);
|
|
|
- if (null == orgEntity) {
|
|
|
- throw new StatusException("001250", "orgId is wrong");
|
|
|
- }
|
|
|
- } else {
|
|
|
- throw new StatusException("001253", "orgId and domainName are all null");
|
|
|
- }
|
|
|
+ OrgEntity orgEntity = null;
|
|
|
+ if (null != orgId) {
|
|
|
+ orgEntity = GlobalHelper.getEntity(orgRepo, orgId, OrgEntity.class);
|
|
|
+ if (null == orgEntity) {
|
|
|
+ throw new StatusException("001250", "orgId is wrong");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new StatusException("001253", "orgId and domainName are all null");
|
|
|
+ }
|
|
|
|
|
|
- DynamicEnumManager manager = OrgProperty.getDynamicEnumManager();
|
|
|
- DynamicEnum de = manager.getByName(key);
|
|
|
- OrgPropertyEntity one = orgPropertyRepo.findByOrgIdAndKeyId(orgEntity.getId(), de.getId());
|
|
|
+ DynamicEnumManager manager = OrgProperty.getDynamicEnumManager();
|
|
|
+ DynamicEnum de = manager.getByName(key);
|
|
|
+ OrgPropertyEntity one = orgPropertyRepo.findByOrgIdAndKeyId(orgEntity.getId(), de.getId());
|
|
|
|
|
|
- OrgPropertyCacheBean b = new OrgPropertyCacheBean();
|
|
|
- b.setOrgId(orgId);
|
|
|
- b.setKey(key);
|
|
|
+ OrgPropertyCacheBean b = new OrgPropertyCacheBean();
|
|
|
+ b.setOrgId(orgId);
|
|
|
+ b.setKey(key);
|
|
|
|
|
|
- if (null == one) {
|
|
|
- b.setHasValue(false);
|
|
|
- return b;
|
|
|
- }
|
|
|
+ if (null == one) {
|
|
|
+ b.setHasValue(false);
|
|
|
+ return b;
|
|
|
+ }
|
|
|
|
|
|
- b.setValue(one.getValue());
|
|
|
+ b.setValue(one.getValue());
|
|
|
|
|
|
- return b;
|
|
|
- }
|
|
|
+ return b;
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- protected String getKeyPrefix() {
|
|
|
- return "B_ORG_PROP:";
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ protected String getKeyPrefix() {
|
|
|
+ return CacheConstants.CACHE_B_ORG_PROP;
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- protected int getTimeout() {
|
|
|
- // 60分钟
|
|
|
- return 60 * 60;
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ protected int getTimeout() {
|
|
|
+ // 60分钟
|
|
|
+ return 60 * 60;
|
|
|
+ }
|
|
|
|
|
|
}
|