瀏覽代碼

红德堂-V1.2 新增看课链接复制相关接口

Long 1 周之前
父節點
當前提交
a8f39c4504

+ 42 - 0
fs-company-app/src/main/java/com/fs/app/controller/CourseController.java

@@ -0,0 +1,42 @@
+package com.fs.app.controller;
+
+import com.fs.app.annotation.Login;
+import com.fs.common.core.domain.R;
+import com.fs.course.domain.FsUserCoursePeriodDays;
+import com.fs.course.param.FsCourseLinkCreateParam;
+import com.fs.course.service.IFsUserCoursePeriodDaysService;
+import com.fs.course.service.IFsUserCourseService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+@Api("课程接口")
+@RestController
+@RequestMapping("/app/course")
+public class CourseController extends AppBaseController {
+
+    @Autowired
+    private IFsUserCourseService fsUserCourseService;
+    @Autowired
+    private IFsUserCoursePeriodDaysService fsUserCoursePeriodDaysService;
+
+    @Login
+    @ApiOperation("生成看课短链接")
+    @GetMapping("/createLinkV2")
+    public R createLinkV2(@RequestParam Long id) {
+        FsUserCoursePeriodDays fsUserCoursePeriodDays = fsUserCoursePeriodDaysService.selectFsUserCoursePeriodDaysById(id);
+        if (fsUserCoursePeriodDays == null) {
+            return R.error("课程不存在");
+        }
+
+        FsCourseLinkCreateParam param = new FsCourseLinkCreateParam();
+        param.setCourseId(fsUserCoursePeriodDays.getCourseId());
+        param.setVideoId(fsUserCoursePeriodDays.getVideoId());
+        param.setPeriodId(fsUserCoursePeriodDays.getPeriodId());
+        param.setCompanyUserId(getCompanyUserId());
+        param.setCompanyId(getCompanyId());
+        param.setId(fsUserCoursePeriodDays.getId());
+        return fsUserCourseService.createAppCourseSortLink(param);
+    }
+}

+ 2 - 0
fs-service/src/main/java/com/fs/course/service/IFsCourseLinkService.java

@@ -72,6 +72,8 @@ public interface IFsCourseLinkService
 
     R getRealLink(String link);
 
+    R getRealLinkV2(String link);
+
     void delCourseExpireLink();
 
     void updateLinks();

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

@@ -503,6 +503,40 @@ public class FsCourseLinkServiceImpl implements IFsCourseLinkService
     }
 
 
+    @Override
+    public R getRealLinkV2(String link) {
+        try {
+            String sLink = URLDecoder.decode(link, "UTF-8");
+
+            FsCourseLink courseLink = fsCourseLinkMapper.selectFsCourseLinkByLink(sLink);
+            if (courseLink != null) {
+                if (courseLink.getRealLink() == null) {
+                    log.error("真实链接不存在, link: {}", sLink);
+                    return R.error("真实链接不存在").put("realLink", sLink);
+                }
+                log.info("链接有效: {}", sLink);
+                String json = configService.selectConfigByKey("course.config");
+                CourseConfig config = JSONUtil.toBean(json, CourseConfig.class);
+                String domainName = companyUserMapper.selectDomainByUserId(courseLink.getCompanyUserId());
+                if (StringUtils.isEmpty(domainName)){
+                    domainName = config.getRealLinkDomainName();
+                }
+                String realLink = domainName + courseLink.getRealLink();
+                return R.ok().put("realLink", realLink).put("config", config).put("headerImg", cloudHostProper.getHeaderImg());
+            } else {
+                log.warn("URL解析错误或链接不存在: {}", sLink);
+                return R.error("URL 解析错误或链接不存在").put("realLink", sLink);
+            }
+
+        } catch (UnsupportedEncodingException e) {
+            log.error("URL 解码失败: {}", e.getMessage(), e);
+            return R.error("URL 解码失败").put("realLink", link);
+        } catch (Exception e) {
+            log.error("发生未知错误: {}", e.getMessage(), e);
+            return R.error("发生未知错误,请稍后再试").put("realLink", link);
+        }
+    }
+
     @Override
     public void delCourseExpireLink() {
         List<Long> linkIds  = fsCourseLinkMapper.selectExpireLink();

+ 9 - 0
fs-user-app/src/main/java/com/fs/app/controller/CourseController.java

@@ -50,6 +50,8 @@ public class CourseController extends  AppBaseController{
     private IFsCourseSopAppLinkService courseSopAppLinkService;
     @Autowired
     ITencentCloudCosService tencentCloudCosService;
+    @Autowired
+    private IFsCourseLinkService courseLinkService;
 
 //    @Cacheable(value="getCourseCate" )
     @ApiOperation("获取分类")
@@ -355,4 +357,11 @@ public class CourseController extends  AppBaseController{
         log.info("zyp \n【发放APP奖励】:{}",param);
         return courseVideoService.sendAppReward(param);
     }
+
+    @ApiOperation("获取真实链接V2(不判断过期时间)")
+    @GetMapping("/getRealLinkV2")
+    public R getRealLinkV2(@RequestParam("link")String link)
+    {
+        return courseLinkService.getRealLinkV2(link);
+    }
 }