Clean code
This commit is contained in:
@@ -12,7 +12,7 @@ import fr.dcproject.entity.Citizen as CitizenEntity
|
||||
import fr.dcproject.entity.Comment as CommentEntity
|
||||
import fr.dcproject.entity.Constitution as ConstitutionEntity
|
||||
|
||||
abstract class Comment <T : TargetI>(override var requester: Requester) : RepositoryI {
|
||||
abstract class Comment<T : TargetI>(override var requester: Requester) : RepositoryI {
|
||||
abstract fun findById(id: UUID): CommentEntity<T>?
|
||||
|
||||
abstract fun findByCitizen(
|
||||
@@ -36,9 +36,10 @@ abstract class Comment <T : TargetI>(override var requester: Requester) : Reposi
|
||||
): Paginated<CommentEntity<T>> {
|
||||
return requester.run {
|
||||
getFunction("find_comments_by_parent")
|
||||
.select(page, limit,
|
||||
"parent_id" to parentId
|
||||
)
|
||||
.select(
|
||||
page, limit,
|
||||
"parent_id" to parentId
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,9 +58,10 @@ abstract class Comment <T : TargetI>(override var requester: Requester) : Reposi
|
||||
): Paginated<CommentEntity<T>> {
|
||||
return requester.run {
|
||||
getFunction("find_comments_by_target")
|
||||
.select(page, limit,
|
||||
"target_id" to targetId
|
||||
)
|
||||
.select(
|
||||
page, limit,
|
||||
"target_id" to targetId
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +98,8 @@ class CommentGeneric(requester: Requester) : Comment<TargetRef>(requester) {
|
||||
): Paginated<CommentEntity<TargetRef>> {
|
||||
return requester.run {
|
||||
getFunction("find_comments_by_citizen")
|
||||
.select(page, limit,
|
||||
.select(
|
||||
page, limit,
|
||||
"created_by_id" to citizen.id
|
||||
)
|
||||
}
|
||||
@@ -117,7 +120,8 @@ class CommentArticle(requester: Requester) : Comment<ArticleRef>(requester) {
|
||||
): Paginated<CommentEntity<ArticleRef>> {
|
||||
return requester.run {
|
||||
getFunction("find_comments_by_citizen")
|
||||
.select(page, limit,
|
||||
.select(
|
||||
page, limit,
|
||||
"created_by_id" to citizen.id,
|
||||
"reference" to TargetI.getReference(ArticleRef::class)
|
||||
)
|
||||
@@ -139,7 +143,8 @@ class CommentConstitution(requester: Requester) : Comment<ConstitutionEntity>(re
|
||||
): Paginated<CommentEntity<ConstitutionEntity>> {
|
||||
return requester.run {
|
||||
getFunction("find_comments_by_citizen")
|
||||
.select(page, limit,
|
||||
.select(
|
||||
page, limit,
|
||||
"created_by_id" to citizen.id,
|
||||
"reference" to TargetI.getReference(ConstitutionEntity::class)
|
||||
)
|
||||
|
||||
@@ -10,7 +10,7 @@ import fr.dcproject.entity.Article as ArticleEntity
|
||||
import fr.dcproject.entity.Constitution as ConstitutionEntity
|
||||
import fr.dcproject.entity.Follow as FollowEntity
|
||||
|
||||
open class Follow <T : TargetI>(override var requester: Requester) : RepositoryI {
|
||||
open class Follow<T : TargetI>(override var requester: Requester) : RepositoryI {
|
||||
open fun findByCitizen(
|
||||
citizen: CitizenI,
|
||||
page: Int = 1,
|
||||
@@ -25,9 +25,10 @@ open class Follow <T : TargetI>(override var requester: Requester) : RepositoryI
|
||||
): Paginated<FollowEntity<T>> {
|
||||
return requester.run {
|
||||
getFunction("find_follows_by_citizen")
|
||||
.select(page, limit,
|
||||
"created_by_id" to citizenId
|
||||
)
|
||||
.select(
|
||||
page, limit,
|
||||
"created_by_id" to citizenId
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +61,8 @@ class FollowArticle(requester: Requester) : Follow<ArticleEntity>(requester) {
|
||||
): Paginated<FollowEntity<ArticleEntity>> {
|
||||
return requester.run {
|
||||
getFunction("find_follows_article_by_citizen")
|
||||
.select(page, limit,
|
||||
.select(
|
||||
page, limit,
|
||||
"created_by_id" to citizenId
|
||||
)
|
||||
}
|
||||
@@ -75,7 +77,8 @@ class FollowConstitution(requester: Requester) : Follow<ConstitutionEntity>(requ
|
||||
): Paginated<FollowEntity<ConstitutionEntity>> {
|
||||
return requester.run {
|
||||
getFunction("find_follows_constitution_by_citizen")
|
||||
.select(page, limit,
|
||||
.select(
|
||||
page, limit,
|
||||
"created_by_id" to citizenId
|
||||
)
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import java.util.*
|
||||
import fr.dcproject.entity.Citizen as CitizenEntity
|
||||
import fr.dcproject.entity.Vote as VoteEntity
|
||||
|
||||
open class Vote <T : TargetI>(override var requester: Requester) : RepositoryI {
|
||||
open class Vote<T : TargetI>(override var requester: Requester) : RepositoryI {
|
||||
fun vote(vote: VoteEntity<T>): VoteAggregation {
|
||||
val author = vote.createdBy
|
||||
val anonymous = author.voteAnonymous
|
||||
@@ -36,10 +36,12 @@ open class Vote <T : TargetI>(override var requester: Requester) : RepositoryI {
|
||||
): Paginated<VoteEntity<T>> {
|
||||
return requester.run {
|
||||
getFunction("find_votes_by_citizen")
|
||||
.select(page, limit, typeReference, mapOf(
|
||||
"created_by_id" to citizenId,
|
||||
"reference" to target
|
||||
))
|
||||
.select(
|
||||
page, limit, typeReference, mapOf(
|
||||
"created_by_id" to citizenId,
|
||||
"reference" to target
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,10 +52,12 @@ open class Vote <T : TargetI>(override var requester: Requester) : RepositoryI {
|
||||
val typeReference = object : TypeReference<List<VoteEntity<TargetRef>>>() {}
|
||||
return requester.run {
|
||||
getFunction("find_citizen_votes_by_target_ids")
|
||||
.select(typeReference, mapOf(
|
||||
"citizen_id" to citizen.id,
|
||||
"ids" to targets
|
||||
))
|
||||
.select(
|
||||
typeReference, mapOf(
|
||||
"citizen_id" to citizen.id,
|
||||
"ids" to targets
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user