Selaa lähdekoodia

相关新闻倒叙

licailing 4 vuotta sitten
vanhempi
commit
efa0aef9f9

+ 6 - 1
src/main/java/com/izouma/imt/service/InformationService.java

@@ -312,6 +312,11 @@ public class InformationService {
             typeInformation.remove(information);
             typeInformation.remove(information);
             informationList.addAll(typeInformation);
             informationList.addAll(typeInformation);
         }
         }
-        return informationList.stream().distinct().limit(5).collect(Collectors.toList());
+
+        return informationList.stream()
+                .distinct()
+                .limit(5)
+                .sorted((a, b) -> b.getCreatedAt().compareTo(a.getCreatedAt()))
+                .collect(Collectors.toList());
     }
     }
 }
 }

+ 1 - 1
src/main/vue/src/views/InformationEdit.vue

@@ -123,7 +123,7 @@ export default {
     name: 'InformationEdit',
     name: 'InformationEdit',
     created() {
     created() {
         this.$http
         this.$http
-            .post('information/all', { size: 1000 }, { body: 'json' })
+            .post('information/all', { size: 1000, sort: 'createdAt,desc' }, { body: 'json' })
             .then(res => {
             .then(res => {
                 this.informations = res.content;
                 this.informations = res.content;
             })
             })

+ 2 - 2
src/test/java/com/izouma/imt/service/InformationServiceTest.java

@@ -36,9 +36,9 @@ public class InformationServiceTest {
 
 
     @Test
     @Test
     public void test2() {
     public void test2() {
-        Information information = informationRepo.findById(47309L).orElse(null);
+        Information information = informationRepo.findById(32758L).orElse(null);
         List<Information> related = informationService.related(information);
         List<Information> related = informationService.related(information);
-        related.forEach(re -> System.out.println(re.getId()));
+        related.forEach(re -> System.out.println(re.getCreatedAt()));
         System.out.println(related.size());
         System.out.println(related.size());
     }
     }
 }
 }