Browse Source

feat(course): 添加课程排序功能并修复视频排序逻辑- 在用户课程列表中增加多种排序方式支持- 修复用户课程视频排序逻辑,使用课程排序字段替代视频ID
- 默认排序规则更新为先按课程排序再按课程ID升序排列
- 支持通过参数控制升序和降序排列
- 优化SQL查询中的排序条件判断逻辑

xw 3 weeks ago
parent
commit
85de9e42b4

+ 11 - 1
fs-service/src/main/java/com/fs/course/mapper/FsUserCourseMapper.java

@@ -157,7 +157,17 @@ public interface FsUserCourseMapper
             "<if test ='maps.companyIdsList != null and maps.companyIdsList.length !=0 '> " +
             " and <foreach collection='maps.companyIdsList'  item='item' index='index'  open='( 1=2 ' separator='' close=')'> or find_in_set(  #{item} , REGEXP_REPLACE ( c.company_ids, '[\"\\\\[\\\\]]', '' ) )  </foreach> " +
             "</if> " +
-            " order by c.sort, c.course_id  "+
+            "<choose>" +
+            "<when test='maps.sorting != null and maps.sorting == 1'> " +
+            "order by c.sort asc " +
+            "</when>" +
+            "<when test='maps.sorting != null and maps.sorting == 2'> " +
+            "order by c.sort desc " +
+            "</when>" +
+            "<otherwise> " +
+            "order by c.sort asc, c.course_id asc " +
+            "</otherwise>" +
+            "</choose>" +
             "</script>"})
     List<FsUserCourseListPVO> selectFsUserCourseListPVO(@Param("maps") FsUserCourse param);
 

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

@@ -95,10 +95,10 @@ public interface FsUserCourseVideoMapper
             "</if>" +
             "<choose>"+
             "<when test = 'maps.sorting!=null and maps.sorting==1 '> " +
-            "order by v.video_id asc"+
+            "order by v.course_sort asc"+
             "</when>"+
             "<when test = 'maps.sorting!=null and maps.sorting==2 '> " +
-            "order by v.video_id desc"+
+            "order by v.course_sort desc"+
             "</when>"+
             "<otherwise>"+
             " order by v.course_sort  "+