xiaoyong931011
2022-08-09 485f0621ee2ce413526dab06853a229a87abc203
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
35
36
37
38
39
40
41
42
43
44
45
46
package com.xcong.farmer.cms.mapper;
 
import org.mapstruct.*;
import org.mapstruct.factory.Mappers;
 
import java.util.List;
 
/**
 * @author wzy
 * @date 2020-05-05 11:00
 **/
@Mapper
public abstract class CarMapper {
    public static final CarMapper INSTANCE = Mappers.getMapper(CarMapper.class);
 
    @Mapping(source = "createTime", target = "createTime", dateFormat = "yyyy-MM-dd HH:mm:ss")
    public abstract CarDto carToCarDto(Car car);
 
    @InheritInverseConfiguration
    @Mapping(target = "name", ignore = true)
    public abstract Car carDtoToCar(CarDto carDto);
 
    @Named("useMe1")
    @Mapping(source = "name", target = "userName")
    @Mapping(source = "color", target = "userColor")
    @Mapping(source = "createTime", target = "time", dateFormat = "yyyy-MM-dd HH:mm:ss")
    public abstract CarEntity carToCarEntity(Car car);
 
    @Mapping(source = "name", target = "userName")
    @Mapping(source = "color", target = "userColor")
    public abstract CarEntity carToCarEntityList(Car car);
 
    @InheritInverseConfiguration(name = "carToCarEntity")
    public abstract Car carEntityToCar(CarEntity carEntity);
 
 
    @Named("useMe")
    @InheritInverseConfiguration(name = "carToCarEntityList")
    public abstract Car carEntityToCar1(CarEntity carEntity);
 
    @IterableMapping(qualifiedByName = "useMe1")
    public abstract List<CarEntity> carEntitiesToCarList(List<Car> list);
 
    @IterableMapping(qualifiedByName = "useMe")
    public abstract List<Car> carsToCarEntities(List<CarEntity> list);
}