Hullaballoonatic
11/18/2019, 7:01 PMinterface Repository<E : MyEntity> : JpaRepository<E, String> {
operator fun contains(id: String) = existsById(id)
operator fun get(id: String) = findByIdOrNull(id)
}
I'm exploring the possibility of having route controllers talk directly to repos, but a service in the middle to transform dao and dto is probably still too useful to warrant thatShawn A
11/18/2019, 7:51 PMModel.toDto()
in the web/api layer.Hullaballoonatic
11/18/2019, 10:06 PM@Entity
class User(
@Email var email: String,
var password: String? = null,
var createdOn: LocalDateTime = now()) : DAO() {
val dto by lazy { DTO() }
inner class DTO {
val email get() = this@User.email
val createdOn get() = this@User.createdOn
override fun toString() = Json.stringify(this)
}
}
Hullaballoonatic
11/18/2019, 10:07 PM=
this is another example of why i'd love to have something like inner object
in kotlin or the like, so I don't have to define an entire class per property of this sort. feels weird.kqr
11/19/2019, 7:54 AM