Plugin-DataBulid-Core-1.0.2

DataBulid

License

License

Categories

Categories

Data
GroupId

GroupId

com.github.link-kou
ArtifactId

ArtifactId

databulid-core
Last Version

Last Version

1.0.2
Release Date

Release Date

Type

Type

jar
Description

Description

Plugin-DataBulid-Core-1.0.2
DataBulid
Project Organization

Project Organization

Link-Kou

Download databulid-core

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.link-kou/databulid-core/ -->
<dependency>
    <groupId>com.github.link-kou</groupId>
    <artifactId>databulid-core</artifactId>
    <version>1.0.2</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.link-kou/databulid-core/
implementation 'com.github.link-kou:databulid-core:1.0.2'
// https://jarcasting.com/artifacts/com.github.link-kou/databulid-core/
implementation ("com.github.link-kou:databulid-core:1.0.2")
'com.github.link-kou:databulid-core:jar:1.0.2'
<dependency org="com.github.link-kou" name="databulid-core" rev="1.0.2">
  <artifact name="databulid-core" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.link-kou', module='databulid-core', version='1.0.2')
)
libraryDependencies += "com.github.link-kou" % "databulid-core" % "1.0.2"
[com.github.link-kou/databulid-core "1.0.2"]

Dependencies

compile (3)

Group / Artifact Type Version
org.reflections : reflections jar 0.9.12
org.springframework : spring-context-support Optional jar 4.3.7.RELEASE
com.squareup : javawriter jar 2.5.0

test (1)

Group / Artifact Type Version
org.springframework : spring-test jar 4.3.7.RELEASE

system (1)

Group / Artifact Type Version
com.sun » tools Optional jar 1.8

Project Modules

There are no modules declared in this project.

DataBulid

Plugin-DataBulid 能做什么?

基于注解,进行Bean to Bean 的转换 基于注解,对所有转换进行归类


使用环境

JAVA1.8以上

在线安装

<dependency>
  <groupId>com.github.link-kou</groupId>
  <artifactId>databulid-all</artifactId>
  <version>1.0.2</version>
</dependency>

###BUG

1.接口 default 支持 void类型 2.添加方法排除注解

手动安装

为什么重新造轮子

1、使用场景中大多情况下是一对一的转换。 2、少数情况下是不同字段转换为不同字段(字段名称、字段类型) 3、因为历史习惯的遗留数据库字段有前缀 4、因为DTO、VO需要排除某一些特点字段 5、基于方法进行匹配 6、扩展性

一、案例说明示列

/**
 * 菜单管理(OrgMenus)实体类
 *
 * @author lk
 * @since 2020-05-28 18:22:11
 */
@Data
@Accessors(chain = true)
public class MenusVO {

    private String id;
    /**
     * 菜单名称
     */
    private String title;
    /**
     * key
     */
    private String keyId;
    /**
     * 父id
     */
    private String parentId;
    /**
     * 上一个节点id
     */
    private String preId;
    /**
     * 类型
     */
    private Integer type;
    /**
     * 参数
     */
    private String param;

    private BoolTypeEnum deleted;
    /**
     * 创建时间
     */
    private Date createtime;
    private Date updatedtime;
}
/**
 * 菜单管理(OrgMenus)实体类
 *
 * @author lk
 * @since 2020-05-28 18:22:11
 */
@Data
@Accessors(chain = true)
public class OrgMenusDomain {

    private Integer frows;
    private String fId;
    /**
     * 菜单名称
     */
    private String fTitle;
    /**
     * key
     */
    private String fKey;
    /**
     * 父id
     */
    private String fParent;
    /**
     * 上一个节点id
     */
    private String fPreid;
    /**
     * 参数
     */
    private String fParam;
    /**
     * 类型
     */
    private Integer fType;

    /**
     * 1 表示删除,0 表示未删除。
     */
    private BoolTypeEnum isDeleted;
    /**
     * 创建时间
     */
    private Date createtime;
    private Date updatedtime;
}
    /**
     * @author lk
     * @version 1.0
     * @date 2020/5/11 19:15
     */
    @Mappers
    public interface ToFromMenuMapping {
    
        @MappersField
        MenusVO fromToMenusVO(
                @Regexs(replaceFirstMap = {
                        @Regexs.Regex(methodsName = "getFParent", regex = {""}, rename = "ParentId"),
                        @Regexs.Regex(methodsName = "getFKey", regex = {""}, rename = "KeyId"),
                        @Regexs.Regex(methodsName = "getFPreid", regex = {""}, rename = "PreId"),
                        @Regexs.Regex(methodsName = "getIsDeleted", regex = {""}, rename = "Deleted")
                }) OrgMenusDomain orgMenusDomain);
        
        @MappersField
        MenusVO fromToMenusVO(MenusDTO menusdto);
    
    
    }
@Component
public class ToFromMenuMappingImpl implements ToFromMenuMapping {
    public MenusVO fromToMenusVO(OrgMenusDomain orgMenusDomain) {
        MenusVO returnlocalvar = new MenusVO();
        returnlocalvar.setId(orgMenusDomain.getFId());
        returnlocalvar.setTitle(orgMenusDomain.getFTitle());
        returnlocalvar.setKeyId(orgMenusDomain.getFKey());
        returnlocalvar.setParentId(orgMenusDomain.getFParent());
        returnlocalvar.setPreId(orgMenusDomain.getFPreid());
        returnlocalvar.setType(orgMenusDomain.getFType());
        returnlocalvar.setParam(orgMenusDomain.getFParam());
        returnlocalvar.setDeleted(orgMenusDomain.getIsDeleted());
        returnlocalvar.setCreatetime(orgMenusDomain.getCreatetime());
        returnlocalvar.setUpdatedtime(orgMenusDomain.getUpdatedtime());
        return returnlocalvar;
    }
}

二、说明

说明文档:
待补充

开源推荐

Versions

Version
1.0.2
1.0.1
1.0.0