22 Star 275 Fork 48

easii/mapstruct-plus

 / 详情

AutoMappings能否支持ElementType.METHOD?

Done
Opened this issue  
2024-02-27 10:17

已知类(大致代码):
public abstract class BaseDomain {
private Long id;
}

@AutoMappers({ @AutoMapper(target = TestDoaminDTO.class) })
public class TestDoamin extends BaseDomain {
@加贝
// 不支持下面这种
// @AutoMappings({ @AutoMapping(targetClass = TestDoaminDTO.class, target = "testDomainId") })
@AutoMapping(targetClass = TestDoaminDTO.class, target = "testDomainId")
public Long getId() {
return super.getId();
}
}

public class TestDoaminDTO {
private Long testDomainId;
}

public class TestDoaminDTO2 {
private Long testDomain2Id;
}

背景:BaseDomain 在别人的 jar 包,改不了源码的。另外BaseDomain的子类会很多,所以只能考虑在子类中,针对父类属性的方法上打@AutoMapping。但是 TestDoamin 对应的 子类 DTO 会有不同,所以 @AutoMappings 注解能否支持打在方法上呢?

Comments (5)

Vincen created任务

伪代码中 @加贝 是 @Override,gitee错误认为是要 @ 加贝 这个人

@AutoMapping 是支持在方法上面标注的

是的,@AutoMapping 是支持的,但是 @AutoMappings 不支持呢 :scream:

后面可以考虑改下

大佬牛批, :+1: :+1:

easii changed issue state from 待办的 to 进行中
easii set assignee to easii
easii set priority to Secondary
easii set branch to cycle_avoiding
easii througheasii/mapstruct-plus Pull Request !6 changed issue state from 进行中 to 已完成

Sign in to comment

Status
Assignees
Milestones
Pull Requests
Successfully merging a pull request will close this issue.
Branches
Planed to start   -   Planed to end
-
Top level
Priority
参与者(2)
1006745 gzvincen 1578938108 1374229 easii 1710989212
Java
1
https://gitee.com/easii/mapstruct-plus.git
git@gitee.com:easii/mapstruct-plus.git
easii
mapstruct-plus
mapstruct-plus

Search