Complete team user code

This commit is contained in:
JiaJu Zhuang
2023-08-13 14:57:24 +08:00
parent 697e7bc024
commit af6fcc2baf
56 changed files with 1288 additions and 266 deletions

View File

@ -272,6 +272,25 @@ public class PageResult<T> implements Serializable, Result<List<T>> {
return pageResult;
}
/**
* 将当前的类型转换成另外一个类型
*
* @param mapper 转换的方法
* @param <R> 返回的类型
* @return 分页返回对象
*/
public <R> ListResult<R> mapToList(Function<T, R> mapper) {
List<R> returnData = hasData(this) ? getData().stream().map(mapper).collect(Collectors.toList())
: Collections.emptyList();
ListResult<R> result = new ListResult<>();
result.setSuccess(getSuccess());
result.setErrorCode(getErrorCode());
result.setErrorMessage(getErrorMessage());
result.setTraceId(getTraceId());
result.setData(returnData);
return result;
}
/**
* 将当前的类型转换成另外一个类型
* 并且转换成web的类型