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);
|
}
|