فهرست منبع

feat:获取弹幕接口调整

caoliqin 1 هفته پیش
والد
کامیت
9071481555

+ 6 - 0
fs-service/src/main/java/com/fs/course/mapper/FsCourseWatchCommentMapper.java

@@ -77,4 +77,10 @@ public interface FsCourseWatchCommentMapper extends BaseMapper<FsCourseWatchComm
      */
     List<FsCourseWatchCommentVO> selectH5CourseWatchComments(FsCourseWatchCommentListParam param);
 
+    /**
+     * 随机获取200条弹幕
+     * @param param 入参
+     * @return list
+     */
+    List<FsCourseWatchCommentVO> selectH5CourseWatchCommentsRound(FsCourseWatchCommentListParam param);
 }

+ 5 - 2
fs-service/src/main/java/com/fs/course/param/FsCourseWatchCommentListParam.java

@@ -14,8 +14,8 @@ public class FsCourseWatchCommentListParam{
     @ApiModelProperty(value = "页大小,默认为10", required = true)
     private Integer pageSize = 10;
 
-//    @ApiModelProperty(value = "不传,通过配置获取")
-//    private Integer listNum;
+    @ApiModelProperty(value = "不传,通过配置获取")
+    private Integer listNum;
 
     @ApiModelProperty(value = "课程id")
     private Long courseId;
@@ -23,4 +23,7 @@ public class FsCourseWatchCommentListParam{
     @ApiModelProperty(value = "视频id")
     private Long videoId;
 
+    @ApiModelProperty(value = "1-评论/2-弹幕")
+    private Integer openCommentStatus;
+
 }

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

@@ -64,7 +64,7 @@ public interface IFsCourseWatchCommentService extends IService<FsCourseWatchComm
     int deleteFsCourseWatchCommentByCommentId(Long commentId);
 
     /**
-     * 保存h5的评论数据
+     * 保存评论/弹幕数据
      * @param param 入参
      * @return
      */
@@ -78,7 +78,7 @@ public interface IFsCourseWatchCommentService extends IService<FsCourseWatchComm
     R revokeH5CourseWatchComment(Long commentId);
 
     /**
-     * h5查询评论列表
+     * 查询评论列表
      * @param param 入参
      * @return list
      */

+ 5 - 1
fs-service/src/main/java/com/fs/course/service/impl/FsCourseWatchCommentServiceImpl.java

@@ -161,7 +161,11 @@ public class FsCourseWatchCommentServiceImpl extends ServiceImpl<FsCourseWatchCo
 
     @Override
     public List<FsCourseWatchCommentVO> selectH5CourseWatchComments(FsCourseWatchCommentListParam param) {
-        return baseMapper.selectH5CourseWatchComments(param);
+        if(param.getOpenCommentStatus() != null && 2 == param.getOpenCommentStatus()){
+            return baseMapper.selectH5CourseWatchCommentsRound(param);
+        } else {
+            return baseMapper.selectH5CourseWatchComments(param);
+        }
     }
 
 }

+ 18 - 0
fs-service/src/main/resources/mapper/course/FsCourseWatchCommentMapper.xml

@@ -130,4 +130,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         order by cwc.create_time desc
     </select>
 
+    <select id="selectH5CourseWatchCommentsRound" resultType="com.fs.course.vo.FsCourseWatchCommentVO">
+        select * from (
+        select cwc.comment_id, cwc.user_id, cwc.user_type, cwc.course_id, cwc.video_id, cwc.type, cwc.content,
+        cwc.create_time,
+        fs_user.nick_name,cwc.time,cwc.font_size, cwc.mode, cwc.color from fs_course_watch_comment cwc
+        left join fs_user on fs_user.user_id = cwc.user_id
+        <where>
+            and cwc.is_revoke = 0
+            <if test="courseId != null">
+                and cwc.course_id = #{courseId}
+            </if>
+            <if test="videoId != null">
+                and cwc.video_id = #{videoId}
+            </if>
+        </where>
+        ORDER BY RAND() LIMIT #{listNum}
+        ) a
+    </select>
 </mapper>

+ 5 - 14
fs-user-app/src/main/java/com/fs/app/controller/CourseController.java

@@ -562,23 +562,14 @@ public class CourseController extends  AppBaseController{
 
     @ApiOperation("获取历史评论数据")
     @GetMapping("/getComments")
-    public ResponseResult<PageInfo<FsCourseWatchCommentVO>> getCourseWatchComments(@ApiParam(value = "页码", required = true) @RequestParam Integer pageNum,
-            @ApiParam(value = "每页大小", required = true) @RequestParam Integer pageSize,
-            @ApiParam(value = "课程id", required = true) @RequestParam Long courseId,
-            @ApiParam(value = "视频id", required = true) @RequestParam Long videoId)
+    public ResponseResult<PageInfo<FsCourseWatchCommentVO>> getCourseWatchComments(FsCourseWatchCommentListParam param)
     {
         //获取配置信息中需要查询的数据条数
-//        String json = configService.selectConfigByKey("course.config");
-//        CourseConfig config = JSONUtil.toBean(json, CourseConfig.class);
-
-        FsCourseWatchCommentListParam param = new FsCourseWatchCommentListParam();
-        param.setPageNum(pageNum);
-        param.setPageSize(pageSize);
-        param.setCourseId(courseId);
-        param.setVideoId(videoId);
-//        param.setListNum(config.getViewCommentNum() != null &&  config.getViewCommentNum() != 0 ? config.getViewCommentNum() : 200);
+        String json = configService.selectConfigByKey("course.config");
+        CourseConfig config = JSONUtil.toBean(json, CourseConfig.class);
+        param.setListNum(config.getViewCommentNum() != null &&  config.getViewCommentNum() != 0 ? config.getViewCommentNum() : 200);
 
-        PageHelper.startPage(pageNum, pageSize);
+        PageHelper.startPage(param.getPageNum(), param.getPageSize());
         List<FsCourseWatchCommentVO> list = courseWatchCommentService.selectH5CourseWatchComments(param);
         PageInfo<FsCourseWatchCommentVO> pageInfo = new PageInfo<>(list);
         return ResponseResult.ok(pageInfo);