From 32610bf1f69a722936608dcabd121339ba54d42d Mon Sep 17 00:00:00 2001 From: pikaqiudeshujia Date: Mon, 29 Apr 2024 08:46:36 +0800 Subject: [PATCH] =?UTF-8?q?release-=E4=B8=93=E8=BE=91=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=9F=A5=E8=AF=A2=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../music/dto/response/AlbumSearchDTO.java | 12 ++++++++++++ .../com/luoo/music/service/AlbumService.java | 18 ++++++++++++++++++ 2 files changed, 30 insertions(+) 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()])); }; }