Browse Source

系统参数修改

wangliang 2 years ago
parent
commit
d18ae35b5d

+ 7 - 1
themis-admin/src/main/java/com/qmth/themis/admin/api/SysConfigController.java

@@ -8,6 +8,7 @@ import com.qmth.themis.business.dto.response.SysConfigBean;
 import com.qmth.themis.business.entity.SysConfig;
 import com.qmth.themis.business.enums.UploadFileEnum;
 import com.qmth.themis.business.service.SysConfigService;
+import com.qmth.themis.business.service.ThemisCacheService;
 import com.qmth.themis.business.util.OssUtil;
 import com.qmth.themis.common.exception.BusinessException;
 import com.qmth.themis.common.util.GsonUtil;
@@ -51,6 +52,9 @@ public class SysConfigController {
     @Resource
     SysConfigService sysConfigService;
 
+    @Resource
+    ThemisCacheService themisCacheService;
+
     @Resource
     OssUtil ossUtil;
 
@@ -72,6 +76,7 @@ public class SysConfigController {
         }
         SysConfig sysConfig = GsonUtil.fromJson(GsonUtil.toJson(sysConfigBean), SysConfig.class);
         sysConfig.setEditor(1);
+        sysConfig.setEnable(true);
         sysConfigService.saveOrUpdate(sysConfig);
         updateSysconfig(sysConfig);
         return ResultUtil.ok(true);
@@ -98,6 +103,7 @@ public class SysConfigController {
     public void updateSysconfig(SysConfig sysConfig) {
         File file = null;
         try {
+            themisCacheService.updateSysConfigCache(sysConfig.getConfigKey());
             file = SystemConstant.getFileTempVar(SystemConstant.JSON_PREFIX);
             JSONObject jsonObject = JSONObject
                     .parseObject(new String(ossUtil.download(true, UploadFileEnum.client.name() + "/" + SystemConstant.EXAM_CONFIG_FILE_NAME), StandardCharsets.UTF_8));
@@ -113,7 +119,7 @@ public class SysConfigController {
             }
             SysConfigBean sysConfigBean = GsonUtil.fromJson(GsonUtil.toJson(sysConfig), SysConfigBean.class);
             sysConfigBeanList.removeIf(e -> Objects.equals(e.getConfigKey(), sysConfigBean.getConfigKey()));
-            if (sysConfigBean.getEnable()) {
+            if (Objects.nonNull(sysConfigBean.getEnable()) && sysConfigBean.getEnable()) {
                 sysConfigBeanList.add(sysConfigBean);
             }
             jsonObject.put(SystemConstant.SYS_CONFIG_LIST, sysConfigBeanList);