-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request !65 from 芋道源码/feature/vo-optimize
- Loading branch information
Showing
242 changed files
with
13,657 additions
and
1,713 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...k/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/object/BeanUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package cn.iocoder.yudao.framework.common.util.object; | ||
|
||
import cn.hutool.core.bean.BeanUtil; | ||
import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Bean 工具类 | ||
* | ||
* 1. 默认使用 {@link cn.hutool.core.bean.BeanUtil} 作为实现类,虽然不同 bean 工具的性能有差别,但是对绝大多数同学的项目,不用在意这点性能 | ||
* 2. 针对复杂的对象转换,可以搜参考 AuthConvert 实现,通过 mapstruct + default 配合实现 | ||
* | ||
* @author 芋道源码 | ||
*/ | ||
public class BeanUtils { | ||
|
||
public static <T> T toBean(Object source, Class<T> targetClass) { | ||
return BeanUtil.toBean(source, targetClass); | ||
} | ||
|
||
public static <S, T> List<T> toBean(List<S> source, Class<T> targetType) { | ||
if (source == null) { | ||
return null; | ||
} | ||
return CollectionUtils.convertList(source, s -> toBean(s, targetType)); | ||
} | ||
|
||
public static <S, T> PageResult<T> toBean(PageResult<S> source, Class<T> targetType) { | ||
if (source == null) { | ||
return null; | ||
} | ||
return new PageResult<>(toBean(source.getList(), targetType), source.getTotal()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,4 @@ public class CodegenDetailRespVO { | |
@Schema(description = "字段定义") | ||
private List<CodegenColumnRespVO> columns; | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.