@@ -312,6 +312,11 @@ public class InformationService {
typeInformation.remove(information);
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());
@@ -123,7 +123,7 @@ export default {
name: 'InformationEdit',
created() {
this.$http
- .post('information/all', { size: 1000 }, { body: 'json' })
+ .post('information/all', { size: 1000, sort: 'createdAt,desc' }, { body: 'json' })
.then(res => {
this.informations = res.content;
})
@@ -36,9 +36,9 @@ public class InformationServiceTest {
@Test
public void test2() {
- Information information = informationRepo.findById(47309L).orElse(null);
+ Information information = informationRepo.findById(32758L).orElse(null);
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());