ソースを参照

优化生成链接缓存逻辑

yjwang 1 ヶ月 前
コミット
6535d6f0c7

+ 18 - 4
fs-service/src/main/java/com/fs/course/service/impl/FsCourseLinkServiceImpl.java

@@ -136,6 +136,8 @@ public class FsCourseLinkServiceImpl implements IFsCourseLinkService
 
     private static final String WX_URL_REDIS_PREFIX = "wx:link:";
 
+    private static final String WX_URL_REDIS_PREFIX_MEMBER = "wx:member:link:";
+
 
     /**
      * 查询短链
@@ -779,10 +781,22 @@ public class FsCourseLinkServiceImpl implements IFsCourseLinkService
     public String getGotoWxAppLink(String linkStr,String appId) {
         log.info("appid:{}", appId);
         log.info("linkStr:{}", linkStr);
-        String key = "course=";
-        String linkStrJson = linkStr.substring(linkStr.indexOf(key) + key.length());
-        JSONObject json = JSON.parseObject(linkStrJson);
-        String wxAppLinkKey = String.format("%s%s%s%s%s%s%s",WX_URL_REDIS_PREFIX,json.get("companyId"),json.get("companyUserId"),json.get("projectId"),json.get("courseId"),json.get("videoId"),appId);
+        String wxAppLinkKey = null;
+        String key;
+        String linkStrJson;
+        JSONObject json;
+        if(linkStr.contains("becomeVip=")){
+             key = "becomeVip=";
+            linkStrJson = linkStr.substring(linkStr.indexOf(key) + key.length());
+            json = JSON.parseObject(linkStrJson);
+            wxAppLinkKey = String.format("%s%s%s%s%s",WX_URL_REDIS_PREFIX_MEMBER,json.get("companyId"),json.get("companyUserId"),json.get("projectId"),appId);
+        }else {
+             key = "course=";
+            linkStrJson = linkStr.substring(linkStr.indexOf(key) + key.length());
+            json = JSON.parseObject(linkStrJson);
+            wxAppLinkKey = String.format("%s%s%s%s%s%s%s",WX_URL_REDIS_PREFIX,json.get("companyId"),json.get("companyUserId"),json.get("projectId"),json.get("courseId"),json.get("videoId"),appId);
+        }
+
         String linkCache = redisCache.getCacheObject(wxAppLinkKey);
         if (StringUtils.isNotBlank(linkCache)) {
             return linkCache;