From 554927a4496e8ee38db9884e950dde8a89e54160 Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Sun, 22 Sep 2024 16:14:37 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=B8=AA=20b?= =?UTF-8?q?ug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/achobeta/common/base/BasePageQuery.java | 15 +++++++-------- .../com/achobeta/common/base/BasePageResult.java | 2 +- .../common/constants/MyBatisPageConstants.java | 2 +- .../domain/student/model/dto/StuResumeDTO.java | 7 ++++--- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/achobeta/common/base/BasePageQuery.java b/src/main/java/com/achobeta/common/base/BasePageQuery.java index 966d3218..aa99728c 100644 --- a/src/main/java/com/achobeta/common/base/BasePageQuery.java +++ b/src/main/java/com/achobeta/common/base/BasePageQuery.java @@ -10,6 +10,7 @@ import java.util.Arrays; import java.util.List; import java.util.Objects; +import java.util.Optional; import static com.achobeta.common.constants.MyBatisPageConstants.*; @@ -33,10 +34,10 @@ public class BasePageQuery { private Boolean isAsc; private void init() { - current = Objects.isNull(current) ? DEFAULT_PAGE_NO : current; - pageSize = Objects.isNull(pageSize) ? DEFAULT_PAGE_SIZE : pageSize; - sortBy = Objects.isNull(sortBy) ? DEFAULT_SORT_BY : sortBy; - isAsc = Objects.isNull(isAsc) ? DEFAULT_IS_ASC : isAsc; + current = Optional.ofNullable(current).orElse(DEFAULT_CURRENT); + pageSize = Optional.ofNullable(pageSize).orElse(DEFAULT_PAGE_SIZE); + sortBy = Optional.ofNullable(sortBy).orElse(DEFAULT_SORT_BY); + isAsc = Optional.ofNullable(isAsc).orElse(DEFAULT_IS_ASC); } public IPage toMpPage(OrderItem... orders){ @@ -47,16 +48,14 @@ public IPage toMpPage(OrderItem... orders){ page.addOrder(new OrderItem(sortBy, isAsc)); // 2.排序条件 List orderItemList = Arrays.stream(orders) - .filter(order -> Objects.nonNull(order) && Objects.nonNull(order.getColumn())) + .filter(Objects::nonNull) + .filter(order -> Objects.nonNull(order.getColumn())) .toList(); if(!CollectionUtils.isEmpty(orderItemList)) { page.addOrder(orderItemList); } return page; } - public IPage toMpPage(OrderItem order){ - return toMpPage(order); - } public IPage toMpPage(String sortBy, boolean isAsc){ return toMpPage(new OrderItem(sortBy, isAsc)); diff --git a/src/main/java/com/achobeta/common/base/BasePageResult.java b/src/main/java/com/achobeta/common/base/BasePageResult.java index aaedd6c5..8db07dfb 100644 --- a/src/main/java/com/achobeta/common/base/BasePageResult.java +++ b/src/main/java/com/achobeta/common/base/BasePageResult.java @@ -63,7 +63,7 @@ public static

BasePageResult

of(IPage

p) { public static BasePageResult of(IPage

p, Class voClass) { // 1.非空校验 List

records = p.getRecords(); - if (records == null || records.size() <= 0) { + if (CollectionUtils.isEmpty(records)) { // 无数据,返回空结果 return empty(p); } diff --git a/src/main/java/com/achobeta/common/constants/MyBatisPageConstants.java b/src/main/java/com/achobeta/common/constants/MyBatisPageConstants.java index 78478f6b..945412fa 100644 --- a/src/main/java/com/achobeta/common/constants/MyBatisPageConstants.java +++ b/src/main/java/com/achobeta/common/constants/MyBatisPageConstants.java @@ -9,7 +9,7 @@ */ public interface MyBatisPageConstants { - Integer DEFAULT_PAGE_NO = 1; + Integer DEFAULT_CURRENT = 1; Integer DEFAULT_PAGE_SIZE = 10; diff --git a/src/main/java/com/achobeta/domain/student/model/dto/StuResumeDTO.java b/src/main/java/com/achobeta/domain/student/model/dto/StuResumeDTO.java index 6c18e5c8..42b7925d 100644 --- a/src/main/java/com/achobeta/domain/student/model/dto/StuResumeDTO.java +++ b/src/main/java/com/achobeta/domain/student/model/dto/StuResumeDTO.java @@ -1,9 +1,9 @@ package com.achobeta.domain.student.model.dto; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; import lombok.Data; -import javax.validation.Valid; -import javax.validation.constraints.NotNull; import java.io.Serializable; import java.util.List; @@ -16,8 +16,9 @@ */ @Data public class StuResumeDTO implements Serializable { - @Valid + @NotNull + @Valid private StuSimpleResumeDTO stuSimpleResumeDTO; // 附件列表可以为 null 但是不为 null 的时候进行循环检测