소스 검색

调整取值config报错问题

yys 4 일 전
부모
커밋
31d4d8c5b4

+ 4 - 1
fs-company/src/main/java/com/fs/company/controller/course/FsCourseRedPacketLogController.java

@@ -11,6 +11,7 @@ import com.fs.common.core.page.TableDataInfo;
 import com.fs.common.enums.BusinessType;
 import com.fs.common.utils.ServletUtils;
 import com.fs.common.utils.poi.ExcelUtil;
+import com.fs.config.saas.ProjectConfig;
 import com.fs.course.config.CourseConfig;
 import com.fs.course.domain.FsCourseRedPacketLog;
 import com.fs.course.domain.FsUserCoursePeriod;
@@ -78,7 +79,9 @@ public class FsCourseRedPacketLogController extends BaseController
             fsCourseRedPacketLog.setCompanyId( loginUser.getCompany().getCompanyId());
         }
 
-        if("济南联志健康".equals(configService.getProjectConfig().getCloudHost().getCompanyName())){
+        ProjectConfig projectConfig = configService.getProjectConfig();
+        String companyName = (projectConfig != null && projectConfig.getCloudHost() != null) ? projectConfig.getCloudHost().getCompanyName() : null;
+        if("济南联志健康".equals(companyName)){
             fsCourseRedPacketLog.setCompanyId( loginUser.getCompany().getCompanyId());
         }
 

+ 10 - 3
fs-company/src/main/java/com/fs/company/controller/course/qw/FsQwCourseWatchLogController.java

@@ -7,6 +7,7 @@ import com.fs.common.core.page.TableDataInfo;
 import com.fs.common.enums.BusinessType;
 import com.fs.common.utils.ServletUtils;
 import com.fs.common.utils.poi.ExcelUtil;
+import com.fs.config.saas.ProjectConfig;
 import com.fs.system.service.ISysConfigService;
 import com.fs.course.domain.FsCourseWatchLog;
 import com.fs.course.param.*;
@@ -110,7 +111,9 @@ public class FsQwCourseWatchLogController extends BaseController
             return getDataTable(new ArrayList<>());
         }
         //济南联志健康 数据排除转接用户
-        if ("济南联志健康".equals(sysConfigService.getProjectConfig().getCloudHost().getCompanyName())) {
+        ProjectConfig projectConfig = sysConfigService.getProjectConfig();
+        String companyName = (projectConfig != null && projectConfig.getCloudHost() != null) ? projectConfig.getCloudHost().getCompanyName() : null;
+        if ("济南联志健康".equals(companyName)) {
             return qwWatchLogService.selectQwWatchLogStatisticsListVOExcludeTransfer(param);
         } else {
             return qwWatchLogService.selectQwWatchLogStatisticsListVO(param);
@@ -126,7 +129,9 @@ public class FsQwCourseWatchLogController extends BaseController
             return getDataTable(new ArrayList<>());
         }
         //济南联志健康 数据排除转接用户
-        if ("济南联志健康".equals(sysConfigService.getProjectConfig().getCloudHost().getCompanyName())) {
+        ProjectConfig projectConfig2 = sysConfigService.getProjectConfig();
+        String companyName2 = (projectConfig2 != null && projectConfig2.getCloudHost() != null) ? projectConfig2.getCloudHost().getCompanyName() : null;
+        if ("济南联志健康".equals(companyName2)) {
             return qwWatchLogService.selectQwWatchLogStatisticsListVOExcludeTransfer(param);
         } else {
             return qwWatchLogService.selectQwWatchLogStatisticsListVO(param);
@@ -227,7 +232,9 @@ public class FsQwCourseWatchLogController extends BaseController
         param.setCompanyId( loginUser.getCompany().getCompanyId());
         List<QwWatchLogStatisticsListVO> list = new ArrayList<>();
 
-        if ("济南联志健康".equals(sysConfigService.getProjectConfig().getCloudHost().getCompanyName())) {
+        ProjectConfig projectConfig3 = sysConfigService.getProjectConfig();
+        String companyName3 = (projectConfig3 != null && projectConfig3.getCloudHost() != null) ? projectConfig3.getCloudHost().getCompanyName() : null;
+        if ("济南联志健康".equals(companyName3)) {
             list = qwWatchLogService.selectQwWatchLogStatisticsListVOExportExcludeTransfer(param);
         }else{
             list = qwWatchLogService.selectQwWatchLogStatisticsListVOExport(param);

+ 15 - 12
fs-service/src/main/java/com/fs/config/saas/ProjectConfig.java

@@ -452,18 +452,21 @@ public class ProjectConfig {
         List<ProjectConfig.Wx.Mp.Config> mpConfigs = new ArrayList<>();
 
         if (tenantCfg != null) {
-            JSONObject mp = tenantCfg.getJSONObject("wx").getJSONObject("mp");
-            if (mp != null) {
-                JSONArray arr = mp.getJSONArray("configs");
-                if (arr != null) {
-                    for (int i = 0; i < arr.size(); i++) {
-                        JSONObject cfgJson = arr.getJSONObject(i);
-                        ProjectConfig.Wx.Mp.Config cfg = new ProjectConfig.Wx.Mp.Config();
-                        cfg.setAppId(cfgJson.getString("appId"));
-                        cfg.setSecret(cfgJson.getString("secret"));
-                        cfg.setToken(cfgJson.getString("token"));
-                        cfg.setAesKey(cfgJson.getString("aesKey"));
-                        mpConfigs.add(cfg);
+            JSONObject wx = tenantCfg.getJSONObject("wx");
+            if (wx != null) {
+                JSONObject mp = wx.getJSONObject("mp");
+                if (mp != null) {
+                    JSONArray arr = mp.getJSONArray("configs");
+                    if (arr != null) {
+                        for (int i = 0; i < arr.size(); i++) {
+                            JSONObject cfgJson = arr.getJSONObject(i);
+                            ProjectConfig.Wx.Mp.Config cfg = new ProjectConfig.Wx.Mp.Config();
+                            cfg.setAppId(cfgJson.getString("appId"));
+                            cfg.setSecret(cfgJson.getString("secret"));
+                            cfg.setToken(cfgJson.getString("token"));
+                            cfg.setAesKey(cfgJson.getString("aesKey"));
+                            mpConfigs.add(cfg);
+                        }
                     }
                 }
             }

+ 4 - 2
fs-service/src/main/java/com/fs/core/config/WxMpProperties.java

@@ -47,7 +47,9 @@ public class WxMpProperties {
             ProjectConfig cachedConfig = getConfigFromCache();
             if (cachedConfig != null) {
                 log.debug("从Redis缓存中获取ProjectConfig配置");
-                return cachedConfig.getWx().getMp();
+                if (cachedConfig.getWx() != null) {
+                    return cachedConfig.getWx().getMp();
+                }
             }
             ProjectConfig projectConfig = ProjectConfig.getFromDB(sysConfigMapper);
             if (projectConfig == null) {
@@ -55,7 +57,7 @@ public class WxMpProperties {
                 return null;
             }
 
-            if (projectConfig == null || projectConfig.getWx() == null) {
+            if (projectConfig.getWx() == null) {
                 log.warn("配置中未找到wx节点");
                 return null;
             }

+ 4 - 2
fs-service/src/main/java/com/fs/core/config/WxPayProperties.java

@@ -38,7 +38,9 @@ public class WxPayProperties {
       ProjectConfig cachedConfig = getConfigFromCache();
       if (cachedConfig != null) {
         log.debug("从Redis缓存中获取ProjectConfig配置");
-        return cachedConfig.getWx().getPay();
+        if (cachedConfig.getWx() != null) {
+          return cachedConfig.getWx().getPay();
+        }
       }
 
       ProjectConfig projectConfig = ProjectConfig.getFromDB(sysConfigMapper);
@@ -47,7 +49,7 @@ public class WxPayProperties {
         return null;
       }
 
-      if (projectConfig == null || projectConfig.getWx() == null) {
+      if (projectConfig.getWx() == null) {
         log.warn("配置中未找到wx节点");
         return null;
       }

+ 4 - 2
fs-service/src/main/java/com/fs/wx/cp/config/WxCpProperties.java

@@ -42,7 +42,9 @@ public class WxCpProperties {
             ProjectConfig cachedConfig = getConfigFromCache();
             if (cachedConfig != null) {
                 log.debug("从Redis缓存中获取ProjectConfig配置");
-                return cachedConfig.getWx().getCp();
+                if (cachedConfig.getWx() != null) {
+                    return cachedConfig.getWx().getCp();
+                }
             }
             ProjectConfig projectConfig = ProjectConfig.getFromDB(sysConfigMapper);
             if (projectConfig == null) {
@@ -50,7 +52,7 @@ public class WxCpProperties {
                 return null;
             }
 
-            if (projectConfig == null || projectConfig.getWx() == null) {
+            if (projectConfig.getWx() == null) {
                 log.warn("配置中未找到wx节点");
                 return null;
             }

+ 6 - 2
fs-service/src/main/java/com/fs/wx/miniapp/config/WxMaProperties.java

@@ -41,7 +41,11 @@ public class WxMaProperties {
             // 1. 先从Redis缓存中获取
             ProjectConfig cachedConfig = getConfigFromCache();
             if (cachedConfig != null) {
-                return cachedConfig.getWx().getMiniapp().getConfigs();
+                if (cachedConfig.getWx() != null && cachedConfig.getWx().getMiniapp() != null) {
+                    List<ProjectConfig.Wx.Miniapp.Config> configs = cachedConfig.getWx().getMiniapp().getConfigs();
+                    return configs != null ? configs : new ArrayList<>();
+                }
+                return new ArrayList<>();
             }
 
             ProjectConfig projectConfig = ProjectConfig.getFromDB(sysConfigMapper);
@@ -49,7 +53,7 @@ public class WxMaProperties {
                 return new ArrayList<>();
             }
 
-            if (projectConfig == null || projectConfig.getWx() == null ||
+            if (projectConfig.getWx() == null ||
                     projectConfig.getWx().getMiniapp() == null) {
                 return new ArrayList<>();
             }