我正在使用 Kotlin 和 Springboot。
一些最佳实践?
示例:
@DecoratedWith(NameOfYourDecorator::class) abstract class NameOfYourMapperDecorated : YourMapper
开放类 BatchMapperDecorator : BatchMapperDecolated() { // 注入你的映射器 私有 var mapperProperty: YourMapper = Mappers.getMapper(YourMapper::class.java)
override fun mapMethod(source: DTO): YourEntity {
val result = mapperProperty.mapMethod(source)
result.collection = source.collection.map { … map logic … }.toList()
return result
}