wangliang преди 2 години
родител
ревизия
228da3c61e

+ 5 - 0
themis-admin/src/main/java/com/qmth/themis/admin/start/StartRunning.java

@@ -2,6 +2,7 @@ package com.qmth.themis.admin.start;
 
 import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.service.AuthInfoService;
+import com.qmth.themis.business.service.SysConfigService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Value;
@@ -28,11 +29,15 @@ public class StartRunning implements CommandLineRunner {
     @Resource
     AuthInfoService authInfoService;
 
+    @Resource
+    SysConfigService sysConfigService;
+
     @Override
     public void run(String... args) throws Exception {
         log.info("服务器启动时执行 start");
         SystemConstant.initTempFiles();
         SystemConstant.getSearcher(SystemConstant.TEMP_FILES_DIR + File.separator + applicationName);
+        sysConfigService.selectAll();
         authInfoService.appInfoInit();
         log.info("服务器启动时执行 end");
     }

+ 3 - 2
themis-admin/src/main/resources/application.properties

@@ -209,8 +209,9 @@ mq.config.map.TENCENT_VIDEO_GROUP=themis-group-exam-tencentVideo
 
 #monitor.config.prefix=oe_test
 
-com.qmth.solar.access-key=8134f6aae0134770b8618913705d3667
-com.qmth.solar.access-secret=s1NENpvc8Jq5evcE0B7GfLmoQOvwmlCy
+#com.qmth.solar.access-key=8134f6aae0134770b8618913705d3667
+#com.qmth.solar.access-secret=s1NENpvc8Jq5evcE0B7GfLmoQOvwmlCy
+com.qmth.solar.license=/Volumes/extend/\u542F\u660E/\u77E5\u5B66\u77E5\u8003/\u897F\u4EA4\u5927\u6FC0\u6D3B\u6587\u4EF6/tc-xjtu.lic
 
 #\u65E0\u9700\u9274\u6743\u7684url
 #no.auth.urls=/webjars/**,/druid/**,/swagger-ui.html,/doc.html,/swagger-resources/**,/v2/api-docs,/webjars/springfox-swagger-ui/**,/api/admin/user/login/account,/api/admin/sys/org/queryByOrgCode,/file/**,/upload/**,/client/**,/base_photo/**,/frontend/**,/api/admin/client/save,/api/admin/client/upload,/api/admin/client/query,/api/admin/app/save,/api/admin/app/query,/api/notify/monitor/record/tencent,/api/notify/monitor/status/tencent,/api/admin/exam/http/test/send,/api/admin/exam/http/test/save,/api/admin/exam/http/test/student/score,/api/admin/exam/http/test/subject/save,/api/admin/exam/http/test/student/save,/api/admin/exam/http/test/file/{type}/upload,/api/admin/invigilateUser/login/query

+ 0 - 1
themis-business/src/main/java/com/qmth/themis/business/constant/SystemConstant.java

@@ -87,7 +87,6 @@ public class SystemConstant {
     public static final String CLOUD_MARK_URL = "cloud.mark.url";
     public static final String MONITOR_CONFIG_PREFIX = "monitor.config.prefix";
     public static final String WXAPP_UPLOAD_URL = "wxapp.upload.url";
-//    public static final String CLIENT_CONFIG_URL = "client.config.url";
 
     public static final String DATE_TIME_FORMAT = "%02d";
 

+ 8 - 0
themis-business/src/main/java/com/qmth/themis/business/service/CacheService.java

@@ -237,4 +237,12 @@ public interface CacheService {
      * @param id
      */
     public void removeAttachmentCache(Long id);
+
+    /**
+     * 更新系统参数缓存
+     *
+     * @param key
+     * @param sysConfig
+     */
+    public void updateSysConfigCacheForDb(String key, SysConfig sysConfig);
 }

+ 8 - 0
themis-business/src/main/java/com/qmth/themis/business/service/SysConfigService.java

@@ -3,6 +3,8 @@ package com.qmth.themis.business.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.qmth.themis.business.entity.SysConfig;
 
+import java.util.List;
+
 /**
  * @Description: 系统参数 服务类
  * @Param:
@@ -12,4 +14,10 @@ import com.qmth.themis.business.entity.SysConfig;
  */
 public interface SysConfigService extends IService<SysConfig> {
 
+    /**
+     * 查询所有系统配置项
+     *
+     * @return
+     */
+    List<SysConfig> selectAll();
 }

+ 15 - 3
themis-business/src/main/java/com/qmth/themis/business/service/impl/CacheServiceImpl.java

@@ -17,6 +17,7 @@ import com.qmth.themis.common.exception.BusinessException;
 import com.qmth.themis.common.util.GsonUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.cache.CacheManager;
 import org.springframework.cache.annotation.CacheEvict;
 import org.springframework.cache.annotation.CachePut;
 import org.springframework.cache.annotation.Cacheable;
@@ -61,15 +62,15 @@ public class CacheServiceImpl implements CacheService {
     @Resource
     SysConfigService sysConfigService;
 
-    @Resource
-    SolarService solarService;
-
     @Resource
     TEAudioService teAudioService;
 
     @Resource
     TBAttachmentService tbAttachmentService;
 
+    @Resource
+    CacheManager cacheManager;
+
     /**
      * 添加机构缓存
      *
@@ -471,4 +472,15 @@ public class CacheServiceImpl implements CacheService {
     public void removeAttachmentCache(Long id) {
 
     }
+
+    /**
+     * 更新系统参数缓存
+     *
+     * @param key
+     * @return
+     */
+    @Override
+    public void updateSysConfigCacheForDb(String key, SysConfig sysConfig) {
+        cacheManager.getCache(SystemConstant.sysConfigCache).put(key, sysConfig);
+    }
 }

+ 32 - 0
themis-business/src/main/java/com/qmth/themis/business/service/impl/SysConfigServiceImpl.java

@@ -1,10 +1,17 @@
 package com.qmth.themis.business.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.dao.SysConfigMapper;
 import com.qmth.themis.business.entity.SysConfig;
+import com.qmth.themis.business.service.CacheService;
 import com.qmth.themis.business.service.SysConfigService;
 import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+import javax.annotation.Resource;
+import java.util.List;
 
 /**
  * @Description: 系统参数 服务实现类
@@ -16,4 +23,29 @@ import org.springframework.stereotype.Service;
 @Service
 public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig> implements SysConfigService {
 
+    @Resource
+    CacheService cacheService;
+
+    /**
+     * 查询所有系统配置项
+     *
+     * @return
+     */
+    @Override
+    public List<SysConfig> selectAll() {
+        List<SysConfig> sysConfigList = null;
+        try {
+            QueryWrapper<SysConfig> sysConfigQueryWrapper = new QueryWrapper<>();
+            sysConfigQueryWrapper.lambda().isNull(SysConfig::getOrgId);
+            sysConfigList = this.list(sysConfigQueryWrapper);
+            if (!CollectionUtils.isEmpty(sysConfigList)) {
+                for (SysConfig s : sysConfigList) {
+                    cacheService.updateSysConfigCacheForDb(s.getConfigKey(), s);
+                }
+            }
+        } catch (Exception e) {
+            log.error(SystemConstant.LOG_ERROR, e);
+        }
+        return sysConfigList;
+    }
 }