Big refactoring #77

Merged
flecomte merged 166 commits from refactoring-component-and-immutable into master 2021-03-24 19:06:07 +01:00
4 changed files with 13 additions and 11 deletions
Showing only changes of commit 8ead83941f - Show all commits

View File

@@ -4,7 +4,6 @@ import fr.dcproject.component.citizen.Citizen
import fr.dcproject.component.citizen.CitizenBasic
import fr.dcproject.component.citizen.CitizenRef
import fr.dcproject.component.citizen.CitizenRepository
import fr.dcproject.component.comment.generic.CommentRef
import fr.dcproject.component.constitution.Constitution
import fr.dcproject.component.constitution.ConstitutionRef
import fr.dcproject.component.constitution.ConstitutionRepository
@@ -43,13 +42,8 @@ val converters: ConverterDeclaration = {
}
}
convert<CommentRef> {
decode { values, _ ->
values.singleOrNull()?.let {
CommentRef(UUID.fromString(it))
} ?: throw NotFoundException("""UUID "$values" is not valid for Comment""")
}
}
// TODO remove converters of entities
convert<ConstitutionRef> {
decode { values, _ ->
values.singleOrNull()?.let {

View File

@@ -16,11 +16,13 @@ import io.ktor.locations.post
import io.ktor.request.receive
import io.ktor.response.respond
import io.ktor.routing.Route
import java.util.UUID
@KtorExperimentalLocationsAPI
object CreateCommentChildren {
@Location("/comments/{comment}/children")
class CreateCommentChildrenRequest(val comment: CommentRef) {
class CreateCommentChildrenRequest(comment: UUID) {
val comment = CommentRef(comment)
class Input(val content: String)
}

View File

@@ -14,11 +14,14 @@ import io.ktor.locations.put
import io.ktor.request.receiveText
import io.ktor.response.respond
import io.ktor.routing.Route
import java.util.UUID
@KtorExperimentalLocationsAPI
object EditComment {
@Location("/comments/{comment}")
class EditCommentRequest(val comment: CommentRef)
class EditCommentRequest(comment: UUID) {
val comment = CommentRef(comment)
}
fun Route.editComment(repo: CommentRepository, ac: CommentAccessControl) {
put<EditCommentRequest> {

View File

@@ -13,11 +13,14 @@ import io.ktor.locations.Location
import io.ktor.locations.get
import io.ktor.response.respond
import io.ktor.routing.Route
import java.util.UUID
@KtorExperimentalLocationsAPI
object GetOneComment {
@Location("/comments/{comment}")
class CommentRequest(val comment: CommentRef)
class CommentRequest(comment: UUID) {
val comment = CommentRef(comment)
}
fun Route.getOneComment(repo: CommentRepository, ac: CommentAccessControl) {
get<CommentRequest> {