处理请求列表空问题

This commit is contained in:
wanggeng888 2021-01-20 12:35:53 +08:00
parent 06b5fc35da
commit e15d9d810a
2 changed files with 18 additions and 0 deletions

View File

@ -3,6 +3,7 @@ package com.cm.common.result;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
@ -216,4 +217,18 @@ public class SuccessResultLayImData<T> extends SuccessResult {
this.avatar = avatar; this.avatar = avatar;
} }
} }
@ApiModel
public static class MemberData {
@ApiModelProperty(name = "list", value = "组员列表")
private List<User> list;
public List<User> getList() {
return list == null ? new ArrayList<>() : list;
}
public void setList(List<User> list) {
this.list = list;
}
}
} }

View File

@ -83,6 +83,9 @@ public class AnnotationUtil {
} }
if (fieldValue instanceof List) { if (fieldValue instanceof List) {
List fieldValueList = (List) fieldValue; List fieldValueList = (List) fieldValue;
if (fieldValueList.isEmpty()) {
throw new ParamsException(String.format("%s不能为空", checkListAnnotation.name()));
}
for (Object obj : fieldValueList) { for (Object obj : fieldValueList) {
checkField(obj); checkField(obj);
} }