zjk
2026-09-30 9c47cdc8175e8efcdf64a1b56d9c825ae255fce5
fix(study): 添加id二级排序固定study查询顺序

修复studySort字段重复时排序结果不确定的问题,保证返回顺序与提交数组一致。
1个文件已修改
11 ■■■■■ 已修改文件
ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TStudyController.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TStudyController.java
@@ -764,7 +764,8 @@
        // 听音选图
        List<TStudyListen> list = studyListenService.list(new QueryWrapper<TStudyListen>()
                .eq("week", week)
                .eq("day", day).orderByAsc("studySort"));
                // studySort 会有重复值,追加 id 升序作为二级排序,保证与提交数组顺序一致
                .eq("day", day).orderByAsc("studySort").orderByAsc("id"));
        List<TSubject> list9 = subjectService.list();
        for (TStudyListen tStudyListen : list) {
@@ -793,7 +794,7 @@
        // 看音选图
        List<TStudyLook> list1 = studyLookService.list(new QueryWrapper<TStudyLook>()
                .eq("week", week)
                .eq("day", day).orderByAsc("studySort")
                .eq("day", day).orderByAsc("studySort").orderByAsc("id")
        );
        for (TStudyLook tStudyLook : list1) {
            int index = 0;
@@ -828,7 +829,7 @@
        // 归纳排除
        List<TStudyInduction> list2 = studyInductionService.list(new QueryWrapper<TStudyInduction>()
                .eq("week", week)
                .eq("day", day).orderByAsc("studySort")
                .eq("day", day).orderByAsc("studySort").orderByAsc("id")
        );
        for (TStudyInduction tStudyInduction : list2) {
            StringBuilder names = new StringBuilder();
@@ -856,7 +857,7 @@
        // 有问有答
        List<TStudyAnswer> list3 = studyAnswerService.list(new QueryWrapper<TStudyAnswer>()
                .eq("week", week)
                .eq("day", day).orderByAsc("studySort"));
                .eq("day", day).orderByAsc("studySort").orderByAsc("id"));
        for (TStudyAnswer tStudyAnswer : list3) {
            StringBuilder names = new StringBuilder();
            StudyAnswerVO studyAnswerVO = new StudyAnswerVO();
@@ -909,7 +910,7 @@
        // 音图相配
        List<TStudyPair> list4 = studyPairService.list(new QueryWrapper<TStudyPair>()
                .eq("week", week)
                .eq("day", day).orderByAsc("studySort")
                .eq("day", day).orderByAsc("studySort").orderByAsc("id")
        );
        for (TStudyPair tStudyPair : list4) {
            StringBuilder names = new StringBuilder();