MapStruct学习(一)

NuoYI 2021年02月10日 358次浏览

1、默认隐式映射

@Mapping(target = "actived", constant = "true")
@Mapping(target = "deleted", constant = "false")
InsureCity vmToDomain(InsureCityCreateVM insureCityCreateVM);

示例

图片1.png

2、BeanMapping显示映射

@BeanMapping(ignoreByDefault = true)

示例

图片2.png

3、实现自定义的映射方法

@Mapping(target = "insureRule", target= "insureRuleDto")
@Mapping(target = "actived", constant = "true")
@Mapping(target = "deleted", constant = "false")
InsureCity vmToDomain(InsureCityCreateVM insureCityCreateVM);

图片3.png