stream 的排序模式
This commit is contained in:
parent
5b63e648e2
commit
a8cd7f8436
|
@ -525,16 +525,17 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
||||||
resultPage.setRecords(resourceDTOS.stream().sorted(Comparator.comparing(x -> {
|
resultPage.setRecords(resourceDTOS.stream().sorted(Comparator.comparing(x -> {
|
||||||
ResourceDTO index = (ResourceDTO) x;
|
ResourceDTO index = (ResourceDTO) x;
|
||||||
return index.getPinTop() == null ? 0 : index.getPinTop();
|
return index.getPinTop() == null ? 0 : index.getPinTop();
|
||||||
}, Comparator.reverseOrder())
|
}).reversed()
|
||||||
.thenComparing(x -> {
|
.thenComparing(x -> {
|
||||||
ResourceDTO index = (ResourceDTO) x;
|
ResourceDTO index = (ResourceDTO) x;
|
||||||
int pinTop = index.getPinTop() == null ? 0 : index.getPinTop();
|
int pinTop = index.getPinTop() == null ? 0 : index.getPinTop();
|
||||||
if (pinTop > 0) {
|
if (pinTop > 0) {
|
||||||
return index.getPinTopTime() == null ? new Date(0).getTime() : index.getPinTopTime().getTime();
|
return index.getPinTopTime() == null ? new Date(0).getTime() + pinTop : index.getPinTopTime().getTime() + pinTop;
|
||||||
} else {
|
} else {
|
||||||
return new Date(0).getTime();
|
return new Date(0).getTime() + pinTop;
|
||||||
}
|
}
|
||||||
}, Comparator.reverseOrder()).thenComparing(x -> {
|
}).reversed()
|
||||||
|
.thenComparing(x -> {
|
||||||
ResourceDTO index = (ResourceDTO) x;
|
ResourceDTO index = (ResourceDTO) x;
|
||||||
return index.getTotal() == null ? 0L : index.getTotal();
|
return index.getTotal() == null ? 0L : index.getTotal();
|
||||||
}, Comparator.reverseOrder())
|
}, Comparator.reverseOrder())
|
||||||
|
@ -543,7 +544,8 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
||||||
resultPage.setRecords(resourceDTOS.stream().sorted(Comparator.comparing(x -> {
|
resultPage.setRecords(resourceDTOS.stream().sorted(Comparator.comparing(x -> {
|
||||||
ResourceDTO index = (ResourceDTO) x;
|
ResourceDTO index = (ResourceDTO) x;
|
||||||
return index.getPinTop() == null ? 0 : index.getPinTop();
|
return index.getPinTop() == null ? 0 : index.getPinTop();
|
||||||
}, Comparator.reverseOrder()).thenComparing(x -> {
|
}).reversed()
|
||||||
|
.thenComparing(x -> {
|
||||||
ResourceDTO index = (ResourceDTO) x;
|
ResourceDTO index = (ResourceDTO) x;
|
||||||
int pinTop = index.getPinTop() == null ? 0 : index.getPinTop();
|
int pinTop = index.getPinTop() == null ? 0 : index.getPinTop();
|
||||||
if (pinTop > 0) {
|
if (pinTop > 0) {
|
||||||
|
@ -551,7 +553,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
||||||
} else {
|
} else {
|
||||||
return new Date(0).getTime();
|
return new Date(0).getTime();
|
||||||
}
|
}
|
||||||
}, Comparator.reverseOrder())
|
}).reversed()
|
||||||
.thenComparing(x -> {
|
.thenComparing(x -> {
|
||||||
ResourceDTO index = (ResourceDTO) x;
|
ResourceDTO index = (ResourceDTO) x;
|
||||||
return index.getTotal() == null ? 0L : index.getTotal();
|
return index.getTotal() == null ? 0L : index.getTotal();
|
||||||
|
|
Loading…
Reference in New Issue