Refactors Articles and Voter
- Move files into components (article) - Split articles routes - Refactoring for remove ktor-voter (ArticleVoter) - Remove mutability - Move DataConversion to separate file (Converter.kt) - Add Schemas for Articles routes - Fix SQL Query for Workgroup roles - rename container_name in docker-compose
This commit is contained in:
@@ -1,12 +1,10 @@
|
||||
package fr.dcproject.routes
|
||||
|
||||
import fr.dcproject.citizen
|
||||
import fr.dcproject.entity.Comment
|
||||
import fr.dcproject.entity.CommentForUpdate
|
||||
import fr.dcproject.entity.CommentRef
|
||||
import fr.dcproject.routes.CommentPaths.CreateCommentRequest.Content
|
||||
import fr.dcproject.security.voter.CommentVoter.Action.CREATE
|
||||
import fr.dcproject.security.voter.CommentVoter.Action.UPDATE
|
||||
import fr.dcproject.security.voter.CommentVoter.Action.VIEW
|
||||
import fr.dcproject.security.voter.CommentVoter.Action.*
|
||||
import fr.ktorVoter.assertCan
|
||||
import fr.ktorVoter.assertCanAll
|
||||
import io.ktor.application.*
|
||||
@@ -67,7 +65,7 @@ fun Route.comment(repo: CommentRepository) {
|
||||
|
||||
post<CommentPaths.CreateCommentRequest> {
|
||||
val parent = repo.findById(it.comment.id) ?: throw NotFoundException("Comment not found")
|
||||
val newComment = Comment(
|
||||
val newComment = CommentForUpdate(
|
||||
content = call.receive<Content>().content,
|
||||
createdBy = citizen,
|
||||
parent = parent
|
||||
@@ -83,6 +81,7 @@ fun Route.comment(repo: CommentRepository) {
|
||||
val comment = repo.findById(it.comment.id)!!
|
||||
assertCan(UPDATE, comment)
|
||||
|
||||
|
||||
comment.content = call.receiveText()
|
||||
repo.edit(comment)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user