|
|
|
@ -74,7 +74,7 @@ public class AlbumService {
|
|
|
|
|
|
|
|
|
|
public PageResult<ArtistAlbum> getList(AlbumSearchDTO albumSearchDTO, Integer page, Integer size) {
|
|
|
|
|
List<ArtistAlbum> result = new ArrayList<>();
|
|
|
|
|
Sort sort = new Sort(Sort.Direction.DESC, "create_time");
|
|
|
|
|
Sort sort = new Sort(Sort.Direction.DESC, "createTime");
|
|
|
|
|
PageRequest pageRequest = PageRequest.of(page - 1, size, sort);
|
|
|
|
|
Page<ArtistAlbum> albumPage;
|
|
|
|
|
if (!Objects.isNull(albumSearchDTO)) {
|
|
|
|
@ -84,6 +84,8 @@ public class AlbumService {
|
|
|
|
|
albumPage = artistAlbumDao.findAll(pageRequest);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result = albumPage.getContent();
|
|
|
|
|
|
|
|
|
|
long totalElements = albumPage.getTotalElements();
|
|
|
|
|
|
|
|
|
|
return new PageResult<>(totalElements, result);
|
|
|
|
@ -106,28 +108,30 @@ public class AlbumService {
|
|
|
|
|
predicateList.add(builder.equal(root.get("state"), param.getState()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (param.getTimeQuery()) {
|
|
|
|
|
case 1:
|
|
|
|
|
// 今年
|
|
|
|
|
LocalDate now = LocalDate.now();
|
|
|
|
|
int currentYear = now.getYear();
|
|
|
|
|
predicateList.add(builder.equal(builder.function("YEAR", Integer.class, root.get("createTime")), currentYear));
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
// 最近一月
|
|
|
|
|
LocalDate oneMonthAgo = LocalDate.now().minusMonths(1);
|
|
|
|
|
predicateList.add(builder.greaterThanOrEqualTo(root.get("createTime"), oneMonthAgo.atStartOfDay()));
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
// 最近一周
|
|
|
|
|
LocalDate oneWeekAgo = LocalDate.now().minusWeeks(1);
|
|
|
|
|
predicateList.add(builder.greaterThanOrEqualTo(root.get("createTime"), oneWeekAgo.atStartOfDay()));
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
// 24小时内
|
|
|
|
|
LocalDate oneDayAge = LocalDate.now().minusDays(1);
|
|
|
|
|
predicateList.add(builder.greaterThanOrEqualTo(root.get("createTime"), oneDayAge.atStartOfDay()));
|
|
|
|
|
break;
|
|
|
|
|
if (param.getTimeQuery() != null) {
|
|
|
|
|
switch (param.getTimeQuery()) {
|
|
|
|
|
case 1:
|
|
|
|
|
// 今年
|
|
|
|
|
LocalDate now = LocalDate.now();
|
|
|
|
|
int currentYear = now.getYear();
|
|
|
|
|
predicateList.add(builder.equal(builder.function("YEAR", Integer.class, root.get("createTime")), currentYear));
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
// 最近一月
|
|
|
|
|
LocalDate oneMonthAgo = LocalDate.now().minusMonths(1);
|
|
|
|
|
predicateList.add(builder.greaterThanOrEqualTo(root.get("createTime"), oneMonthAgo.atStartOfDay()));
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
// 最近一周
|
|
|
|
|
LocalDate oneWeekAgo = LocalDate.now().minusWeeks(1);
|
|
|
|
|
predicateList.add(builder.greaterThanOrEqualTo(root.get("createTime"), oneWeekAgo.atStartOfDay()));
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
// 24小时内
|
|
|
|
|
LocalDate oneDayAge = LocalDate.now().minusDays(1);
|
|
|
|
|
predicateList.add(builder.greaterThanOrEqualTo(root.get("createTime"), oneDayAge.atStartOfDay()));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return builder.and(predicateList.toArray(new Predicate[predicateList.size()]));
|
|
|
|
|