diff --git a/src/main/kotlin/fr/dcproject/entity/Comment.kt b/src/main/kotlin/fr/dcproject/entity/Comment.kt index 7661790..cbcb059 100644 --- a/src/main/kotlin/fr/dcproject/entity/Comment.kt +++ b/src/main/kotlin/fr/dcproject/entity/Comment.kt @@ -38,4 +38,4 @@ open class Comment( open class CommentRef(id: UUID = UUID.randomUUID()) : CommentS(id) -sealed class CommentS(id: UUID) : UuidEntity(id) +sealed class CommentS(id: UUID) : TargetRef(id) diff --git a/src/main/kotlin/fr/dcproject/entity/Extra.kt b/src/main/kotlin/fr/dcproject/entity/Extra.kt index 5d32250..17b8bea 100644 --- a/src/main/kotlin/fr/dcproject/entity/Extra.kt +++ b/src/main/kotlin/fr/dcproject/entity/Extra.kt @@ -42,9 +42,7 @@ interface TargetI : UuidEntityI { fun getReference(t: TargetI): String { val ref = this.getReference(t::class) return if (t is ExtraI<*>) { - ref + - "_on_" + - t.target.reference + "${ref}_on_${t.target.reference}" } else { ref } diff --git a/src/main/kotlin/fr/dcproject/repository/Comment.kt b/src/main/kotlin/fr/dcproject/repository/Comment.kt index 532ce46..89a3547 100644 --- a/src/main/kotlin/fr/dcproject/repository/Comment.kt +++ b/src/main/kotlin/fr/dcproject/repository/Comment.kt @@ -104,6 +104,20 @@ class CommentGeneric(requester: Requester) : Comment(requester) { ) } } + + override fun findByParent( + parentId: UUID, + page: Int, + limit: Int + ): Paginated> { + return requester.run { + getFunction("find_comments_by_parent") + .select( + page, limit, + "parent_id" to parentId + ) + } + } } class CommentArticle(requester: Requester) : Comment(requester) { diff --git a/src/test/resources/feature/comment.feature b/src/test/resources/feature/comment.feature new file mode 100644 index 0000000..77d607d --- /dev/null +++ b/src/test/resources/feature/comment.feature @@ -0,0 +1,7 @@ +Feature: comment + + Scenario: Can comment childrens + Given I am authenticated as John Doe with id "64b7b379-2298-43ec-b428-ba134930cabd" + And I have article with id "9226c1a3-8091-c3fa-7d0d-c2e98c9bee7b" + When I send a GET request to "/comments/9226c1a3-8091-c3fa-7d0d-c2e98c9bee7b/children" + Then the response status code should be 200 \ No newline at end of file