fuzhengwei/vo2dto

能否新加一种生成方式?obj.setField(this.field)

Lizecongs opened this issue · 0 comments

目前我们的实体转换都是在实体对象本身去做的 如下:

public class TeacherDto implements ObjectConvert {

private String id;

private String createBy;

private LocalDateTime createTime;

private String updateBy;

private LocalDateTime updateTime;

private String sysOrgCode;

private String name;

private String introduce;

private String bgImage;

private String headImage;

private Integer enable;

private Integer fakeAttentionNum;

private Integer pageNum;

private Integer pageSize;

@Override
public Teacher objectConvert() {
    Teacher eo = new Teacher();
    eo.setId(this.id);
    eo.setCreateBy(this.createBy);
    eo.setCreateTime(this.createTime);
    eo.setUpdateBy(this.updateBy);
    eo.setUpdateTime(this.updateTime);
    eo.setSysOrgCode(this.sysOrgCode);
    eo.setName(this.name);
    eo.setIntroduce(this.introduce);
    eo.setBgImage(this.bgImage);
    eo.setHeadImage(this.headImage);
    eo.setEnable(this.enable);
    eo.setFakeAttentionNum(this.fakeAttentionNum);
    return eo;
}

}

vo dto的实体对象都继承了 ObjectConvert接口 我只需要在objectConvert()方法中定义他们的转换关系即可

x.set(y.get) 的方式对我来说并不适用