1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
@Mapper
public interface OrderMapper extends BaseMapStruct<ItemDTO, Item> {
OrderMapper INSTANCE = Mappers.getMapper(OrderMapper.class);
@Mappings({
@Mapping(source = "birthday", target = "birth"),
@Mapping(source = "birthday", target = "birthDateFormat", dateFormat = "yyyy-MM-dd HH:mm:ss"),
@Mapping(target = "birthExpressionFormat", expression = "java(org.apache.commons.lang3.time.DateFormatUtils.format(person.getBirthday(),\"yyyy-MM-dd HH:mm:ss\"))"),
@Mapping(target = "birthValue", expression = "java(person.getBirthday().getTime())"),
@Mapping(target = "id", ignore = true) // 忽略id,不进行映射
})
ItemDTO domain(Item person);
}
@Data
@Accessors(chain = true)
public class Item {
private String itemName;
private Long price;
private Date birthday;
private Integer id;
}
@Data
@Accessors(chain = true)
public class ItemDTO {
private String itemName;
private Long price;
private String birthDateFormat;
private Date birth;
private String birthExpressionFormat;
private Long birthValue;
private Integer id;
}
|