Explorar o código

1、调整分享链接问题处理

yys hai 1 semana
pai
achega
6b05bc2182

+ 4 - 3
fs-company-app/src/main/java/com/fs/app/controller/FsUserCourseVideoController.java

@@ -575,12 +575,13 @@ public class FsUserCourseVideoController extends AppBaseController {
             param.setPeriodId(periodId);
             param.setProjectId(projectId);
             param.setId(id);
-            String link = feiShuService.getFeishuRegisterLink(param);
+            // 客户在微信打开,飞书云文档微信内无法预览;直接返回授权H5
+            String link = feiShuService.getFeishuRegisterH5Link(param);
             log.info("链接{}", link);
             return R.ok().put("data", link);
         }
-        // 默认使用老方法
-        String oldLink = feiShuService.getFeishuCourseLink(companyUserId, videoId, periodId);
+        // 客户在微信打开,直接返回看课H5(不包飞书文档)
+        String oldLink = feiShuService.getFeishuCourseH5Link(companyUserId, videoId, periodId);
         log.info("老链接{}", oldLink);
         return R.ok().put("data", oldLink);
     }

+ 7 - 0
fs-service/src/main/java/com/fs/course/service/impl/FsCourseLinkServiceImpl.java

@@ -955,6 +955,13 @@ public class FsCourseLinkServiceImpl implements IFsCourseLinkService
                 if (pageUrl.startsWith("/")) {
                     pageUrl = pageUrl.substring(1);
                 }
+                // 销售端常传 H5 路径 videovip,微信小程序正式页是 video,否则打开会失败
+                if (pageUrl.endsWith("videovip") || pageUrl.contains("videovip.")) {
+                    pageUrl = pageUrl.replace("videovip", "video");
+                }
+                if (pageUrl.endsWith(".html")) {
+                    pageUrl = pageUrl.substring(0, pageUrl.length() - 5);
+                }
                 //处理参数
                 String query = split[1];
                 query = key + "=" + URLEncoder.encode(query, StandardCharsets.UTF_8.toString());

+ 34 - 0
fs-service/src/main/java/com/fs/feishu/service/FeiShuService.java

@@ -82,6 +82,20 @@ public class FeiShuService {
         }
     }
 
+    /**
+     * 直接返回看课H5(供微信内打开,不包飞书文档)
+     */
+    public String getFeishuCourseH5Link(Long companyUserId, Long videoId, Long periodId) {
+        if (companyUserId == null || videoId == null) {
+            throw new CustomException("用户ID和视频ID不能为空");
+        }
+        FsUserCourseVideo userCourseVideo = videoMapper.selectFsUserCourseVideoByVideoId(videoId);
+        if (userCourseVideo == null) {
+            throw new CustomException("视频不存在: " + videoId);
+        }
+        return buildCourseLink(companyUserId, videoId, periodId);
+    }
+
     /**
      * 复制飞书看课新链接
      */
@@ -148,6 +162,26 @@ public class FeiShuService {
         }
     }
 
+    /**
+     * 直接返回授权H5(供微信内打开,不包飞书文档)
+     */
+    public String getFeishuRegisterH5Link(FeishuLinkParam param) {
+        if (param == null || param.getCompanyUserId() == null || param.getCompanyId() == null) {
+            throw new CustomException("参数不能为空");
+        }
+        FsUserCourseVideo userCourseVideo = videoMapper.selectFsUserCourseVideoByVideoId(param.getVideoId());
+        if (userCourseVideo == null) {
+            throw new CustomException("视频不存在: " + param.getVideoId());
+        }
+        try {
+            String authUrl = buildAuthLink(param.getCompanyId(), param.getCompanyUserId(),
+                    param.getCourseId(), param.getVideoId(), param.getPeriodId(), param.getProjectId(), param.getId());
+            return java.net.URLDecoder.decode(authUrl, "UTF-8");
+        } catch (UnsupportedEncodingException e) {
+            throw new CustomException("授权URL解析失败", e);
+        }
+    }
+
 
     /**
      * 创建云文档