This commit is contained in:
wangliwen 2022-08-15 15:47:06 +08:00
parent 9565b4fe82
commit bda6596caa
1 changed files with 27 additions and 22 deletions

View File

@ -470,7 +470,30 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
switch (orderType.toUpperCase()) {
case "DESC": // total 倒序
ids = customThreadPool.submit(() -> {
List<Long> temp = selectDTOPageSpecilTotal.parallelStream().map(Map.class::cast).sorted(Comparator.comparing(x -> {
List<Long> temp = selectDTOPageSpecilTotal.parallelStream().map(Map.class::cast)
.sorted(Comparator.comparing(x -> {
Map index = (Map) x;
int pingTOp = (index.get("pin_top") == null) ? 0 : Integer.parseInt(index.get("pin_top").toString());
return pingTOp;
}, Comparator.reverseOrder())
.thenComparing(x -> {
Map index = (Map) x;
long pingTOp = (index.get("pin_top_time") == null) ? 0 : Long.parseLong(index.get("pin_top_time").toString());
return pingTOp;
}, Comparator.reverseOrder())
.thenComparing(x -> {
Map index = (Map) x;
String string = (index.get("total") == null) ? "0" : index.get("total").toString();
return Long.valueOf(string);
}, Comparator.reverseOrder())
).skip((long) (pageNum - 1) * pageSize).limit(pageSize).map(x -> Long.valueOf(x.get("id").toString())).limit(pageSize).collect(Collectors.toList());
return temp;
}).get();
break;
case "ASC": // total 升序
ids = customThreadPool.submit(() -> {
List<Long> temp = selectDTOPageSpecilTotal.parallelStream().map(Map.class::cast)
.sorted(Comparator.comparing(x -> {
Map index = (Map) x;
int pingTOp = (index.get("pin_top") == null) ? 0 : Integer.parseInt(index.get("pin_top").toString());
return pingTOp;
@ -479,30 +502,12 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
Map index = (Map) x;
long pingTOp = (index.get("pin_top_time") == null) ? 0 : Long.parseLong(index.get("pin_top_time").toString());
return pingTOp;
}, Comparator.reverseOrder()).thenComparing(x -> {
}, Comparator.reverseOrder())
.thenComparing(x -> {
Map index = (Map) x;
String string = (index.get("total") == null) ? "0" : index.get("total").toString();
return Long.valueOf(string);
}, Comparator.reverseOrder())
).skip((long) (pageNum - 1) * pageSize).limit(pageSize).map(x -> Long.valueOf(x.get("id").toString())).limit(pageSize).collect(Collectors.toList());
return temp;
}).get();
break;
case "ASC": // total 升序
ids = customThreadPool.submit(() -> {
List<Long> temp = selectDTOPageSpecilTotal.parallelStream().map(Map.class::cast).sorted(Comparator.comparing(x -> {
Map index = (Map) x;
int pingTOp = (index.get("pin_top") == null) ? 0 : Integer.parseInt(index.get("pin_top").toString());
return pingTOp;
}, Comparator.reverseOrder()).thenComparing(x -> {
Map index = (Map) x;
long pingTOp = (index.get("pin_top_time") == null) ? 0 : Long.parseLong(index.get("pin_top_time").toString());
return pingTOp;
}, Comparator.reverseOrder()).thenComparing(x -> {
Map index = (Map) x;
String string = (index.get("total") == null) ? "0" : index.get("total").toString();
return Long.valueOf(string);
})).skip((pageNum - 1) * pageSize).limit(pageSize).map(x -> Long.valueOf(x.get("id").toString())).limit(pageSize).collect(Collectors.toList());
})).skip((pageNum - 1) * pageSize).limit(pageSize).map(x -> Long.valueOf(x.get("id").toString())).limit(pageSize).collect(Collectors.toList());
return temp;
}).get();
break;