Skip to content

Commit

Permalink
fix: 修复一个 bug
Browse files Browse the repository at this point in the history
  • Loading branch information
CarefreeState committed Sep 22, 2024
1 parent be895ec commit 554927a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
15 changes: 7 additions & 8 deletions src/main/java/com/achobeta/common/base/BasePageQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;

Expand All @@ -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 <T> IPage<T> toMpPage(OrderItem... orders){
Expand All @@ -47,16 +48,14 @@ public <T> IPage<T> toMpPage(OrderItem... orders){
page.addOrder(new OrderItem(sortBy, isAsc));
// 2.排序条件
List<OrderItem> 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 <T> IPage<T> toMpPage(OrderItem order){
return toMpPage(order);
}

public <T> IPage<T> toMpPage(String sortBy, boolean isAsc){
return toMpPage(new OrderItem(sortBy, isAsc));
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/achobeta/common/base/BasePageResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static <P> BasePageResult<P> of(IPage<P> p) {
public static <V, P> BasePageResult<V> of(IPage<P> p, Class<V> voClass) {
// 1.非空校验
List<P> records = p.getRecords();
if (records == null || records.size() <= 0) {
if (CollectionUtils.isEmpty(records)) {
// 无数据,返回空结果
return empty(p);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
public interface MyBatisPageConstants {

Integer DEFAULT_PAGE_NO = 1;
Integer DEFAULT_CURRENT = 1;

Integer DEFAULT_PAGE_SIZE = 10;

Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -16,8 +16,9 @@
*/
@Data
public class StuResumeDTO implements Serializable {
@Valid

@NotNull
@Valid
private StuSimpleResumeDTO stuSimpleResumeDTO;

// 附件列表可以为 null 但是不为 null 的时候进行循环检测
Expand Down

0 comments on commit 554927a

Please sign in to comment.