有没有办法将封闭的对象引用作为参数传递给映射方法?
public class Car {
public int id;
public Person driver;
}
public class Person {
public int carId;
}
personToPersonDtoAfterMapping
在自定义方法中映射人员对象时,我需要对封闭汽车对象的引用。
@Mapper
public abstract class CarMapper {
public abstract CarDto carToCarDto(Car car);
public abstract PersonDto personToPersonDto(Person person);
@AfterMapping
protected void personToPersonDtoAfterMapping(Person person, @MappingTarget PersonDto dto, Car enclosedCar) {
dto.setCarId(enclosedCar.getId())
}
}