diff --git a/luoo_music/src/main/java/com/luoo/music/dto/response/AlbumSearchDTO.java b/luoo_music/src/main/java/com/luoo/music/dto/response/AlbumSearchDTO.java index 6309548..89ae885 100644 --- a/luoo_music/src/main/java/com/luoo/music/dto/response/AlbumSearchDTO.java +++ b/luoo_music/src/main/java/com/luoo/music/dto/response/AlbumSearchDTO.java @@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.Serializable; +import java.time.LocalDate; /** * @Author: yawei.huang @@ -16,10 +17,21 @@ import java.io.Serializable; @Data public class AlbumSearchDTO implements Serializable { + @ApiModelProperty("音乐人id") private String artistId; + @ApiModelProperty("专辑状态") private Integer state; @ApiModelProperty("时间查询条件 null-全部时间,1-今年,2-最近一月,3-最近一周,4-最近24小时") private Integer timeQuery; + + @ApiModelProperty("专辑名称") + private String name; + + @ApiModelProperty("时间范围-开始时间") + private LocalDate startTime; + + @ApiModelProperty("时间范围-结束时间") + private LocalDate endTime; } diff --git a/luoo_music/src/main/java/com/luoo/music/service/AlbumService.java b/luoo_music/src/main/java/com/luoo/music/service/AlbumService.java index d7ec630..9087fa8 100644 --- a/luoo_music/src/main/java/com/luoo/music/service/AlbumService.java +++ b/luoo_music/src/main/java/com/luoo/music/service/AlbumService.java @@ -101,14 +101,17 @@ public class AlbumService { return (Root root, CriteriaQuery query, CriteriaBuilder builder) -> { List predicateList = new ArrayList(); if (StringUtils.isNotBlank(param.getArtistId())) { + // 音乐人id predicateList.add(builder.equal(root.get("artistId"), param.getArtistId())); } if (param.getState() != null) { + // 专辑状态 predicateList.add(builder.equal(root.get("state"), param.getState())); } if (param.getTimeQuery() != null) { + // 时间范围,系统定义 switch (param.getTimeQuery()) { case 1: // 今年 @@ -134,6 +137,21 @@ public class AlbumService { } } + if(StringUtils.isNotBlank(param.getName())) { + // 专辑名称 + String likeExpression = "%" + param.getName() + "%"; + predicateList.add(builder.and(builder.like(root.get("name"), likeExpression))); + } + + if(param.getStartTime() != null) { + predicateList.add(builder.greaterThanOrEqualTo(root.get("createTime"), param.getStartTime())); + } + + if(param.getEndTime() != null) { + predicateList.add(builder.lessThanOrEqualTo(root.get("createTime"), param.getEndTime())); + + } + return builder.and(predicateList.toArray(new Predicate[predicateList.size()])); }; }