Browse Source

feat: 参数修改

xdd 4 weeks ago
parent
commit
ffaac7afe5

+ 6 - 1
fs-service/src/main/java/com/fs/core/config/WxMaConfiguration.java

@@ -14,6 +14,7 @@ import com.fs.system.mapper.SysConfigMapper;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import jodd.util.StringUtil;
+import lombok.extern.slf4j.Slf4j;
 import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
 import me.chanjar.weixin.common.error.WxErrorException;
 import me.chanjar.weixin.common.error.WxRuntimeException;
@@ -30,7 +31,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
 
-
+@Slf4j
 @Configuration
 @ComponentScan("com.fs.system.mapper")
 public class WxMaConfiguration {
@@ -77,11 +78,15 @@ public class WxMaConfiguration {
     }
 
     public static WxMaService getMaService(String appid) {
+        log.info("开始获取微信小程序服务,appid=[{}]", appid);
+
         WxMaService wxService = maServices.get(appid);
         if (wxService == null) {
+            log.error("未找到对应appid=[{}]的配置", appid);
             throw new IllegalArgumentException(String.format("未找到对应appid=[%s]的配置,请核实!", appid));
         }
 
+        log.info("成功获取微信小程序服务,appid=[{}]", appid);
         return wxService;
     }
 

+ 26 - 3
fs-service/src/main/java/com/fs/his/utils/ConfigUtil.java

@@ -7,10 +7,12 @@ import com.fs.his.config.FsSysConfig;
 import com.fs.hisStore.config.FsErpConfig;
 import com.fs.system.domain.SysConfig;
 import com.fs.system.mapper.SysConfigMapper;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 
+@Slf4j
 @Service
 public class ConfigUtil {
     FsSysConfig fsSysConfig;
@@ -57,17 +59,38 @@ public class ConfigUtil {
     }
 
     public JSONObject generateConfigByKey(String key){
+        log.info("开始根据配置键[{}]获取配置信息", key);
+
         SysConfig sysConfig = sysConfigMapper.selectConfigByConfigKey(key);
+
+        if (sysConfig == null) {
+            log.info("未找到配置键[{}]对应的配置信息", key);
+            return new JSONObject();
+        }
+
         String configValue = sysConfig.getConfigValue();
+        log.info("配置键[{}]对应的配置值为: {}", key, configValue);
+
+        JSONObject result;
         if(configValue != null && configValue.trim().startsWith("[")){
+            log.info("配置键[{}]的值为JSON数组格式", key);
             JSONArray array = JSON.parseArray(configValue);
             if (array.size() > 0) {
-                return array.getJSONObject(0); // 取第一个元素
+                log.info("配置键[{}]的JSON数组长度为{},返回第一个元素", key, array.size());
+                result = array.getJSONObject(0); // 取第一个元素
+            } else {
+                log.info("配置键[{}]的JSON数组为空", key);
+                result = new JSONObject();
             }
-            return new JSONObject();
+        } else {
+            log.info("配置键[{}]的值为JSON对象格式", key);
+            result = JSONObject.parseObject(configValue);
         }
-        return JSONObject.parseObject(configValue);
+
+        log.info("配置键[{}]生成配置对象完成", key);
+        return result;
     }
 
 
+
 }

+ 16 - 16
fs-service/src/main/resources/application-config-dev.yml

@@ -10,23 +10,23 @@ logging:
 wx:
   miniapp:
     configs:
-      - appid: wx4115995705bb0ea0   #中康智慧
-        secret: 58910ae743005c396012b029c7def579
-        token: Ncbnd7lJvkripVOpyTFAna6NAWCxCrvC
-        aesKey: HlEiBB55eaWUaeBVAQO3cWKWPYv1vOVQSq7nFNICw4E
-        msgDataFormat: JSON
-      - appid: wxedde588767b358b1   #中康未来智慧药房
-        secret: 928d2961c81610d8f64b019597212fcd
-        token: Ncbnd7lJvkripVOpyTFAna6NAWCxCrvC
-        aesKey: HlEiBB55eaWUaeBVAQO3cWKWPYv1vOVQSq7nFNICw4E
-        msgDataFormat: JSON
-      - appid: wxa73f0d48f1f2f66c   #金康健
-        secret: 93d342d00b2d7126a044408fb7082798
-        token: Ncbnd7lJvkripVOpyTFAna6NAWCxCrvC
-        aesKey: HlEiBB55eaWUaeBVAQO3cWKWPYv1vOVQSq7nFNICw4E
-        msgDataFormat: JSON
+#      - appid: wx4115995705bb0ea0   #中康智慧
+#        secret: 58910ae743005c396012b029c7def579
+#        token: Ncbnd7lJvkripVOpyTFAna6NAWCxCrvC
+#        aesKey: HlEiBB55eaWUaeBVAQO3cWKWPYv1vOVQSq7nFNICw4E
+#        msgDataFormat: JSON
+#      - appid: wxedde588767b358b1   #中康未来智慧药房
+#        secret: 928d2961c81610d8f64b019597212fcd
+#        token: Ncbnd7lJvkripVOpyTFAna6NAWCxCrvC
+#        aesKey: HlEiBB55eaWUaeBVAQO3cWKWPYv1vOVQSq7nFNICw4E
+#        msgDataFormat: JSON
+#      - appid: wxa73f0d48f1f2f66c   #金康健
+#        secret: 93d342d00b2d7126a044408fb7082798
+#        token: Ncbnd7lJvkripVOpyTFAna6NAWCxCrvC
+#        aesKey: HlEiBB55eaWUaeBVAQO3cWKWPYv1vOVQSq7nFNICw4E
+#        msgDataFormat: JSON
       - appid: wx29d26f63f836be7f  #中康智慧商城APP
-        secret: a85bfaf0d8e243817f265a321684f6ec
+        secret: a1bcf6dbcf6745e97e11590dd923facc
         token: Ncbnd7lJvkripVOpyTFAna6NAWCxCrvC
         aesKey: HlEiBB55eaWUaeBVAQO3cWKWPYv1vOVQSq7nFNICw4E
         msgDataFormat: JSON

+ 4 - 3
fs-user-app/src/main/java/com/fs/app/controller/store/WxUserScrmController.java

@@ -257,12 +257,13 @@ public class WxUserScrmController extends AppBaseController {
     @PostMapping("/loginByMiniApp")
     @Synchronized
     public R loginByMiniApp( @RequestBody LoginMpWxParam param) {
+        logger.info("小程序登录 参数 {}",param);
+
         if (StringUtils.isBlank(param.getCode())) {
             return R.error("code不存在");
         }
-        final WxMaService wxService = WxMaConfiguration.getMaService(
-                configUtil.generateConfigByKey(SysConfigEnum.COURSE_MA_CONFIG.getKey()).getString("appid")
-        );
+        WxMaService wxService = WxMaConfiguration.getMaService(maProperties.getConfigs().get(0).getAppid());
+
         try {
             WxMaJscode2SessionResult session = wxService.getUserService().getSessionInfo(param.getCode());
             // 解密