Improve Vote Comment
Add "targetReference" field into Extra Entity Add VoteCommentRoute to OpenApi
This commit is contained in:
@@ -84,10 +84,8 @@ abstract class Comment <T: UuidEntity>(override var requester: Requester): Repos
|
||||
}
|
||||
}
|
||||
|
||||
class GenericTargetEntity(id: UUID = UUID.randomUUID()): UuidEntity(id)
|
||||
|
||||
class CommentGeneric (requester: Requester): Comment<GenericTargetEntity>(requester) {
|
||||
override fun findById(id: UUID): CommentEntity<GenericTargetEntity>? {
|
||||
class CommentGeneric (requester: Requester): Comment<UuidEntity>(requester) {
|
||||
override fun findById(id: UUID): CommentEntity<UuidEntity>? {
|
||||
return requester
|
||||
.getFunction("find_comment_by_id")
|
||||
.selectOne(mapOf("id" to id))
|
||||
@@ -97,7 +95,7 @@ class CommentGeneric (requester: Requester): Comment<GenericTargetEntity>(reques
|
||||
citizen: CitizenEntity,
|
||||
page: Int,
|
||||
limit: Int
|
||||
): Paginated<CommentEntity<GenericTargetEntity>> {
|
||||
): Paginated<CommentEntity<UuidEntity>> {
|
||||
return requester.run {
|
||||
getFunction("find_comments_by_citizen")
|
||||
.select(page, limit,
|
||||
|
||||
@@ -22,7 +22,7 @@ open class Vote <T: UuidEntity>(override var requester: Requester): RepositoryI<
|
||||
val reference = if (target is Comment<*>) {
|
||||
target::class.simpleName!!.toLowerCase() +
|
||||
"_on_" +
|
||||
target.target::class.simpleName!!.toLowerCase()
|
||||
target.targetReference
|
||||
} else {
|
||||
target::class.simpleName!!.toLowerCase()
|
||||
}
|
||||
@@ -101,6 +101,21 @@ class VoteArticleComment (requester: Requester): Vote<Comment<Article>>(requeste
|
||||
)
|
||||
}
|
||||
|
||||
class VoteComment (requester: Requester): Vote<Comment<UuidEntity>>(requester) {
|
||||
fun findByCitizen(
|
||||
citizen: CitizenEntity,
|
||||
page: Int = 1,
|
||||
limit: Int = 50
|
||||
): Paginated<VoteEntity<Comment<UuidEntity>>> =
|
||||
findByCitizen(
|
||||
citizen.id ?: error("The citizen must have an id"),
|
||||
"article",
|
||||
object: TypeReference<List<VoteEntity<Comment<UuidEntity>>>>() {},
|
||||
page,
|
||||
limit
|
||||
)
|
||||
}
|
||||
|
||||
class VoteConstitution (requester: Requester): Vote<Constitution>(requester) {
|
||||
fun findByCitizen(
|
||||
citizen: CitizenEntity,
|
||||
|
||||
Reference in New Issue
Block a user