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 that
s
Shawn A
11/18/2019, 7:51 PM
I just stick an extension function on my models called
Model.toDto()
in the web/api layer.
h
Hullaballoonatic
11/18/2019, 10:06 PM
yeah, i usually do something like this:
Copy code
@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
the lazy delegation isn't really necessary. could just do
=
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.