Przeglądaj źródła

课程评论 关联到小节

yuhongqi 3 tygodni temu
rodzic
commit
e5a5f71483

+ 4 - 2
fs-admin/src/main/java/com/fs/course/controller/FsUserCourseCommentController.java

@@ -209,7 +209,7 @@ public class FsUserCourseCommentController extends BaseController
     @PreAuthorize("@ss.hasPermi('course:userCourseComment:add')")
     @Log(title = "精选留言导入", businessType = BusinessType.IMPORT)
     @PostMapping("/importComments/{courseId}")
-    public AjaxResult importComments(@PathVariable Long courseId, @RequestParam("file") MultipartFile file) throws IOException {
+    public AjaxResult importComments(@PathVariable Long courseId, @RequestParam(value = "videoId", required = false) Long videoId, @RequestParam("file") MultipartFile file) throws IOException {
         if (file.isEmpty()) {
             return AjaxResult.error("请选择要导入的文件");
         }
@@ -254,6 +254,7 @@ public class FsUserCourseCommentController extends BaseController
 
                 FsUserCourseComment comment = new FsUserCourseComment();
                 comment.setCourseId(courseId);
+                comment.setVideoId(videoId);
                 comment.setType(3L); // 精选留言
                 comment.setParentId(0L);
                 comment.setNickName(nickName != null ? nickName.trim() : "");
@@ -274,10 +275,11 @@ public class FsUserCourseCommentController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('course:userCourseComment:list')")
     @GetMapping("/featuredComments/{courseId}")
-    public TableDataInfo featuredComments(@PathVariable Long courseId) {
+    public TableDataInfo featuredComments(@PathVariable Long courseId, @RequestParam(value = "videoId", required = false) Long videoId) {
         startPage();
         FsUserCourseComment param = new FsUserCourseComment();
         param.setCourseId(courseId);
+        param.setVideoId(videoId);
         param.setType(3L);
         param.setIsDel(0);
         List<FsUserCourseComment> list = fsUserCourseCommentService.selectFsUserCourseCommentList(param);

+ 3 - 0
fs-service/src/main/java/com/fs/course/domain/FsUserCourseComment.java

@@ -58,4 +58,7 @@ public class FsUserCourseComment extends BaseEntity
     /** 昵称(精选留言导入时使用) */
     private String nickName;
 
+    /** 视频ID */
+    private Long videoId;
+
 }

+ 8 - 0
fs-service/src/main/java/com/fs/course/mapper/FsUserCourseCommentMapper.java

@@ -94,6 +94,7 @@ public interface FsUserCourseCommentMapper
             "LEFT JOIN fs_user_course_comment_like l ON c.comment_id=l.comment_id and #{userId}=l.user_id "+
             "where c.is_del = 0 and  c.type = 1  \n" +
             "<if test=\"courseId != null \"> and c.course_id = #{courseId}</if>\n" +
+            "<if test=\"videoId != null \"> and c.video_id = #{videoId}</if>\n" +
             "<if test=\"sortType != null and sortType == 1\"> order by c.likes desc </if>" +
             "<if test=\"sortType != null and sortType == 2\"> order by c.comment_id desc </if>" +
             "</script>"})
@@ -102,6 +103,7 @@ public interface FsUserCourseCommentMapper
             "select c.*,u.nick_name,u.avatar,tu.nick_name to_nick_name from fs_user_course_comment c LEFT JOIN fs_user u ON c.user_id=u.user_id LEFT  JOIN fs_user tu ON tu.user_id =c.to_user_id " +
             "where c.user_id=#{userId} " +
             "<if test='courseId != null'> and c.course_id = #{courseId}</if>" +
+            "<if test='videoId != null'> and c.video_id = #{videoId}</if>" +
             " order by c.create_time desc" +
             "</script>"})
     List<FsUserCourseCommentListUVO> selectFsUserCourseCommentMyListUVO(FsUserCourseCommentUParam param);
@@ -146,6 +148,7 @@ public interface FsUserCourseCommentMapper
             "LEFT  JOIN fs_user tu ON tu.user_id =c.to_user_id " +
             "where c.is_del = 0 and  c.type = 1  \n" +
             "<if test=\"courseId != null \"> and c.course_id = #{courseId}</if>\n" +
+            "<if test=\"videoId != null \"> and c.video_id = #{videoId}</if>\n" +
             "<if test=\"sortType != null and sortType == 1\"> order by c.likes desc </if>" +
             "<if test=\"sortType != null and sortType == 2\"> order by c.comment_id desc </if>" +
             "</script>"})
@@ -157,4 +160,9 @@ public interface FsUserCourseCommentMapper
      * 按课程ID和用户ID列表批量查询评论(type=1,未删除)
      */
     List<FsUserCourseComment> selectCommentsByCourseIdAndUserIds(@Param("courseId") Long courseId, @Param("userIds") List<Long> userIds);
+
+    /**
+     * 按视频ID和用户ID列表批量查询评论(type=1,未删除)
+     */
+    List<FsUserCourseComment> selectCommentsByVideoIdAndUserIds(@Param("videoId") Long videoId, @Param("userIds") List<Long> userIds);
 }

+ 3 - 0
fs-service/src/main/java/com/fs/course/param/FsUserCourseCommentAddParam.java

@@ -25,4 +25,7 @@ public class FsUserCourseCommentAddParam {
 
 
     private Long toUserId;
+
+    /** 视频ID */
+    private Long videoId;
 }

+ 3 - 0
fs-service/src/main/java/com/fs/course/param/FsUserCourseCommentUParam.java

@@ -15,4 +15,7 @@ public class FsUserCourseCommentUParam extends BaseParam {
     /** 排序类型 1 热度 2 时间 **/
     private Integer sortType ;
 
+    /** 视频ID */
+    private Long videoId;
+
 }

+ 3 - 6
fs-service/src/main/java/com/fs/course/service/impl/FsCourseWatchLogServiceImpl.java

@@ -1949,12 +1949,9 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
         if (CollectionUtils.isEmpty(list)) {
             return;
         }
-        // 通过videoId获取courseId
-        FsUserCourseVideo video = fsUserCourseVideoMapper.selectFsUserCourseVideoByVideoId(videoId);
-        if (video == null || video.getCourseId() == null) {
+        if (videoId == null) {
             return;
         }
-        Long courseId = video.getCourseId();
 
         // 收集所有userId
         List<Long> userIds = list.stream()
@@ -1966,8 +1963,8 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
             return;
         }
 
-        // 批量查询评论(type=1 评论,is_del=0 未删除)
-        List<FsUserCourseComment> comments = fsUserCourseCommentMapper.selectCommentsByCourseIdAndUserIds(courseId, userIds);
+        // 按videoId批量查询评论(type=1 评论,is_del=0 未删除)
+        List<FsUserCourseComment> comments = fsUserCourseCommentMapper.selectCommentsByVideoIdAndUserIds(videoId, userIds);
         if (CollectionUtils.isEmpty(comments)) {
             return;
         }

+ 17 - 2
fs-service/src/main/resources/mapper/course/FsUserCourseCommentMapper.xml

@@ -18,10 +18,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="toUserId"    column="to_user_id"    />
         <result property="isDel"    column="is_del"    />
         <result property="nickName"    column="nick_name"    />
+        <result property="videoId"    column="video_id"    />
     </resultMap>
 
     <sql id="selectFsUserCourseCommentVo">
-        select comment_id,to_user_id, user_id,is_del, course_id, type, parent_id, content, reply_count, create_time, update_time, likes, nick_name from fs_user_course_comment
+        select comment_id,to_user_id, user_id,is_del, course_id, type, parent_id, content, reply_count, create_time, update_time, likes, nick_name, video_id from fs_user_course_comment
     </sql>
 
     <select id="selectFsUserCourseCommentList" parameterType="FsUserCourseComment" resultMap="FsUserCourseCommentResult">
@@ -34,7 +35,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="content != null  and content != ''"> and content = #{content}</if>
             <if test="replyCount != null "> and reply_count = #{replyCount}</if>
             <if test="likes != null "> and likes = #{likes}</if>
-            <if test="isDel != null "> and is_del = #{isDel}</if>
+            <if test="isDel != null"> and is_del = #{isDel}</if>
+            <if test="videoId != null"> and video_id = #{videoId}</if>
         </where>
     </select>
 
@@ -58,6 +60,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="toUserId != null">to_user_id,</if>
             <if test="isDel != null">is_del,</if>
             <if test="nickName != null">nick_name,</if>
+            <if test="videoId != null">video_id,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="userId != null">#{userId},</if>
@@ -72,6 +75,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="toUserId != null">#{toUserId},</if>
             <if test="isDel != null">#{isDel},</if>
             <if test="nickName != null">#{nickName},</if>
+            <if test="videoId != null">#{videoId},</if>
          </trim>
     </insert>
 
@@ -90,6 +94,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="toUserId != null">to_user_id = #{toUserId},</if>
             <if test="isDel != null">is_del = #{isDel},</if>
             <if test="nickName != null">nick_name = #{nickName},</if>
+            <if test="videoId != null">video_id = #{videoId},</if>
         </trim>
         where comment_id = #{commentId}
     </update>
@@ -118,4 +123,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </foreach>
         ORDER BY user_id, create_time ASC
     </select>
+
+    <select id="selectCommentsByVideoIdAndUserIds" resultMap="FsUserCourseCommentResult">
+        <include refid="selectFsUserCourseCommentVo"/>
+        WHERE video_id = #{videoId} AND type = 1 AND is_del = 0
+        AND user_id IN
+        <foreach item="userId" collection="userIds" open="(" separator="," close=")">
+            #{userId}
+        </foreach>
+        ORDER BY user_id, create_time ASC
+    </select>
 </mapper>

+ 4 - 1
fs-user-app/src/main/java/com/fs/app/controller/CourseCommentController.java

@@ -174,6 +174,7 @@ public class CourseCommentController extends AppBaseController
             fsUserCourseComment.setParentId(param.getParentId());
         }
         fsUserCourseComment.setToUserId(param.getToUserId());
+        fsUserCourseComment.setVideoId(param.getVideoId());
         fsUserCourseComment.setCreateTime(new Date());
         fsUserCourseCommentService.insertFsUserCourseComment(fsUserCourseComment);
         if (param.getType()==2){
@@ -197,7 +198,8 @@ public class CourseCommentController extends AppBaseController
             @RequestParam(value = "content", required = false) String content,
             @RequestParam(value = "toUserId", required = false) Long toUserId,
             @RequestParam(value = "imageFiles", required = false) MultipartFile[] imageFiles,
-            @RequestParam(value = "videoFiles", required = false) MultipartFile[] videoFiles
+            @RequestParam(value = "videoFiles", required = false) MultipartFile[] videoFiles,
+            @RequestParam(value = "videoId", required = false) Long videoId
     ) throws Exception {
         boolean b = redisCache.setIfAbsent("comment_" + courseId + "_" + getUserId(), 1, 10, TimeUnit.MINUTES);
         if (!b) {
@@ -275,6 +277,7 @@ public class CourseCommentController extends AppBaseController
                 fsUserCourseComment.setParentId(parentId);
             }
             fsUserCourseComment.setToUserId(toUserId);
+            fsUserCourseComment.setVideoId(videoId);
             fsUserCourseComment.setCreateTime(new Date());
             fsUserCourseCommentService.insertFsUserCourseComment(fsUserCourseComment);
             if (type == 2) {

+ 4 - 1
fs-user-app/src/main/java/com/fs/app/controller/store/CourseCommentScrmController.java

@@ -153,6 +153,7 @@ public class CourseCommentScrmController extends AppBaseController
             fsUserCourseComment.setParentId(param.getParentId());
         }
         fsUserCourseComment.setToUserId(param.getToUserId());
+        fsUserCourseComment.setVideoId(param.getVideoId());
         fsUserCourseComment.setCreateTime(new Date());
         fsUserCourseCommentService.insertFsUserCourseComment(fsUserCourseComment);
         if (param.getType()==2){
@@ -176,7 +177,8 @@ public class CourseCommentScrmController extends AppBaseController
             @RequestParam(value = "content", required = false) String content,
             @RequestParam(value = "toUserId", required = false) Long toUserId,
             @RequestParam(value = "imageFiles", required = false) MultipartFile[] imageFiles,
-            @RequestParam(value = "videoFiles", required = false) MultipartFile[] videoFiles
+            @RequestParam(value = "videoFiles", required = false) MultipartFile[] videoFiles,
+            @RequestParam(value = "videoId", required = false) Long videoId
     ) throws Exception {
         boolean b = redisCache.setIfAbsent("comment_" + courseId + "_" + getUserId(), 1, 10, TimeUnit.MINUTES);
         if (!b) {
@@ -254,6 +256,7 @@ public class CourseCommentScrmController extends AppBaseController
                 fsUserCourseComment.setParentId(parentId);
             }
             fsUserCourseComment.setToUserId(toUserId);
+            fsUserCourseComment.setVideoId(videoId);
             fsUserCourseComment.setCreateTime(new Date());
 
             fsUserCourseCommentService.insertFsUserCourseComment(fsUserCourseComment);