Sfoglia il codice sorgente

同名排序有问题

chen 5 anni fa
parent
commit
4e7b86399e

+ 7 - 2
ssj-mybatis-service-impl/src/main/java/com/ssj/service/kmt/exercise/KmtExerciseMapperServiceImpl.java

@@ -1069,11 +1069,16 @@ public class KmtExerciseMapperServiceImpl implements KmtExerciseMapperService {
     private List<ExerciseBookDto> sortByBookName (List<ExerciseBookDto> list){
         if (list != null){
             Map<String, List<ExerciseBookDto>> temp = new HashMap<>();
+            List<ExerciseBookDto> tempMapList;
             for (ExerciseBookDto item : list){
                 if (temp.containsKey(item.getName())){
-                    temp.get(item.getName()).add(item);
+                    tempMapList = temp.get(item.getName());
+                    tempMapList.add(item);
+                    temp.put(item.getName(), tempMapList);
                 } else {
-                    temp.put(item.getName(), Collections.singletonList(item));
+                    tempMapList = new ArrayList<>();
+                    tempMapList.add(item);
+                    temp.put(item.getName(), tempMapList);
                 }
             }
             ArrayList tempList = new ArrayList(temp.keySet());