Fix get comments children

This commit is contained in:
2020-01-30 17:30:11 +01:00
parent 5161dca1d5
commit 77658c5f6b
4 changed files with 23 additions and 4 deletions

View File

@@ -38,4 +38,4 @@ open class Comment<T : TargetI>(
open class CommentRef(id: UUID = UUID.randomUUID()) : CommentS(id) open class CommentRef(id: UUID = UUID.randomUUID()) : CommentS(id)
sealed class CommentS(id: UUID) : UuidEntity(id) sealed class CommentS(id: UUID) : TargetRef(id)

View File

@@ -42,9 +42,7 @@ interface TargetI : UuidEntityI {
fun getReference(t: TargetI): String { fun getReference(t: TargetI): String {
val ref = this.getReference(t::class) val ref = this.getReference(t::class)
return if (t is ExtraI<*>) { return if (t is ExtraI<*>) {
ref + "${ref}_on_${t.target.reference}"
"_on_" +
t.target.reference
} else { } else {
ref ref
} }

View File

@@ -104,6 +104,20 @@ class CommentGeneric(requester: Requester) : Comment<TargetRef>(requester) {
) )
} }
} }
override fun findByParent(
parentId: UUID,
page: Int,
limit: Int
): Paginated<CommentEntity<TargetRef>> {
return requester.run {
getFunction("find_comments_by_parent")
.select(
page, limit,
"parent_id" to parentId
)
}
}
} }
class CommentArticle(requester: Requester) : Comment<ArticleRef>(requester) { class CommentArticle(requester: Requester) : Comment<ArticleRef>(requester) {

View File

@@ -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