三七 2 nedēļas atpakaļ
vecāks
revīzija
6f472426d3

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

@@ -549,6 +549,7 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
             param.setQwExternalId(UnionEXt.getId());
             FsCourseWatchLog log = courseWatchLogMapper.getWatchCourseVideoByExt(UnionEXt.getId(), param.getVideoId(),param.getQwUserId());
             if (log==null){
+                param.setUserId(user.getUserId());
                 createWatchLog(param);
             }
             return R.error(567,"群聊通用链接").put("qwExternalId", UnionEXt.getId());
@@ -572,6 +573,7 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
         log.setQwUserId(Long.valueOf(param.getQwUserId()));
         log.setCreateTime(new Date());
         log.setLogType(3);
+
         logger.info("【群聊生成看课记录】:{}",param);
         courseWatchLogMapper.insertFsCourseWatchLog(log);
     }

+ 50 - 11
fs-user-app/src/main/java/com/fs/app/controller/course/CourseQwController.java

@@ -124,20 +124,46 @@ public class CourseQwController extends AppBaseController {
         param.setUserId(Long.parseLong(getUserId()));
         String json = configService.selectConfigByKey("course.config");
         CourseConfig config = JSONUtil.toBean(json, CourseConfig.class);
-        FsUserCourseVideoH5DVO course = courseService.selectFsUserCourseVideoH5DVOByVideoId(param.getVideoId());
-        List<FsUserCourseVideoQuestionVO> questionVOList = new ArrayList<>();
-        if (StringUtils.isNotEmpty(course.getQuestionBankId())){
-            String[] questionIds = course.getQuestionBankId().split(",");
-            for (String questionId : questionIds){
-                FsUserCourseVideoQuestionVO vo = new FsUserCourseVideoQuestionVO();
-                FsCourseQuestionBank questionBank = questionBankService.selectFsCourseQuestionBankById(Long.parseLong(questionId));
-                if (questionBank!=null&&questionBank.getStatus()!=0){
-                    BeanUtils.copyProperties(questionBank,vo);
-                    questionVOList.add(vo);
+
+        FsUserCourseVideoH5DVO course = null;
+        try
+        {
+            course=redisCache.getCacheObject("cache:video1:"+param.getVideoId());
+            if(course==null){
+                course = courseService.selectFsUserCourseVideoH5DVOByVideoId(param.getVideoId());
+                redisCache.setCacheObject("cache:video1:"+param.getVideoId(),course, 10, TimeUnit.MINUTES);
+            }
+        }
+        catch (Exception e){
+
+        }
+        if(course==null){
+            course = courseService.selectFsUserCourseVideoH5DVOByVideoId(param.getVideoId());
+        }
+        //获取题库
+        List<FsUserCourseVideoQuestionVO> questionVOList = null;
+        try
+        {
+            questionVOList=redisCache.getCacheObject("cache:question:"+param.getVideoId());
+            if(questionVOList==null||questionVOList.size()==0){
+                questionVOList = new ArrayList<>();
+                if (StringUtils.isNotEmpty(course.getQuestionBankId())){
+                    String[] questionIds = course.getQuestionBankId().split(",");
+                    for (String questionId : questionIds){
+                        FsUserCourseVideoQuestionVO vo = new FsUserCourseVideoQuestionVO();
+                        FsCourseQuestionBank questionBank = questionBankService.selectFsCourseQuestionBankById(Long.parseLong(questionId));
+                        if (questionBank!=null&&questionBank.getStatus()!=0){
+                            BeanUtils.copyProperties(questionBank,vo);
+                            questionVOList.add(vo);
+                        }
+                    }
                 }
+                redisCache.setCacheObject("cache:question:"+param.getVideoId(),questionVOList, 10,TimeUnit.MINUTES);
             }
         }
+        catch (Exception e){
 
+        }
         if(param.getIsOpen() == null || param.getIsOpen() == 0){
             Long duration = 0L;
             long tipsTime = 0L;
@@ -306,7 +332,20 @@ public class CourseQwController extends AppBaseController {
         }
         return r;
     }
-
+    @Login
+    @ApiOperation("获取缓冲流量")
+    @GetMapping("/getInternetTraffic")
+    public R getInternetTrafficGet(@RequestBody FsUserCourseVideoFinishUParam param) {
+        R r = null;
+        Long userId = Long.parseLong(getUserId());
+        param.setUserId(userId);
+        if(param.getIsOpen() == null || param.getIsOpen() == 0){
+            r = courseVideoService.getInternetTraffic(param);
+        }else{
+            r = courseVideoService.getInternetTrafficIsOpen(param);
+        }
+        return r;
+    }
 
 //    @Login
 //    @ApiOperation("H5看课绑定手机号")