-
Notifications
You must be signed in to change notification settings - Fork 9
嵌套转换
罗战 edited this page Oct 14, 2022
·
6 revisions
类似于Spring @Valid的嵌套校验功能,@Transform也支持嵌套转换
如学生信息中包含同桌(deskmate)和小组成员列表(team):
public class StudentVO{
private Long id;
private Integer sex;
@TransformDict(group = "sex")
private String sexName;
// 小组成员
private List<StudentVO> team;
// 同桌
private StudentVO deskmate;
}
如果想要小组成员属性和同桌属性里的性别也使用转换,很简单,只需要在属性上用@Transform
标识即可:
...
// 小组成员
@Transform
private List<StudentVO> team;
// 同桌
@Transform
private StudentVO deskmate;
}
支持嵌套转换的属性类型有集合和Bean
By @Robot