update postgresjson
This commit is contained in:
@@ -15,6 +15,7 @@ import fr.dcproject.routes.*
|
||||
import fr.dcproject.security.voter.ArticleVoter
|
||||
import fr.dcproject.security.voter.AuthorizationVoter
|
||||
import fr.dcproject.security.voter.CitizenVoter
|
||||
import fr.dcproject.security.voter.CommentVoter
|
||||
import fr.postgresjson.migration.Migrations
|
||||
import io.ktor.application.Application
|
||||
import io.ktor.application.call
|
||||
@@ -104,7 +105,8 @@ fun Application.module() {
|
||||
install(AuthorizationVoter) {
|
||||
voters = mutableListOf(
|
||||
ArticleVoter(),
|
||||
CitizenVoter()
|
||||
CitizenVoter(),
|
||||
CommentVoter()
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -15,4 +15,4 @@ class Article(
|
||||
UuidEntity(id),
|
||||
EntityVersioning<UUID, Int> by UuidEntityVersioning(),
|
||||
EntityCreatedAt by EntityCreatedAtImp(),
|
||||
CreatedBy<Citizen> by EntityCreatedByImp(createdBy)
|
||||
EntityCreatedBy<Citizen> by EntityCreatedByImp(createdBy)
|
||||
@@ -12,7 +12,7 @@ class Constitution(
|
||||
): UuidEntity(id),
|
||||
EntityVersioning<UUID, Int> by UuidEntityVersioning(),
|
||||
EntityCreatedAt by EntityCreatedAtImp(),
|
||||
CreatedBy<Citizen> by EntityCreatedByImp(createdBy) {
|
||||
EntityCreatedBy<Citizen> by EntityCreatedByImp(createdBy) {
|
||||
|
||||
init{
|
||||
titles.forEachIndexed { index, title ->
|
||||
@@ -28,5 +28,5 @@ class Constitution(
|
||||
createdBy: Citizen? = null
|
||||
): UuidEntity(id),
|
||||
EntityCreatedAt by EntityCreatedAtImp(),
|
||||
CreatedBy<Citizen> by EntityCreatedByImp(createdBy)
|
||||
EntityCreatedBy<Citizen> by EntityCreatedByImp(createdBy)
|
||||
}
|
||||
|
||||
@@ -1,22 +1,20 @@
|
||||
package fr.dcproject.entity
|
||||
|
||||
import fr.postgresjson.entity.EntityCreatedAt
|
||||
import fr.postgresjson.entity.EntityCreatedAtImp
|
||||
import fr.postgresjson.entity.EntityI
|
||||
import fr.postgresjson.entity.UuidEntity
|
||||
import fr.postgresjson.entity.*
|
||||
import java.util.*
|
||||
|
||||
interface ExtraI <T: EntityI<UUID>>:
|
||||
EntityI<UUID>,
|
||||
EntityCreatedAt {
|
||||
var citizen: Citizen
|
||||
EntityCreatedAt,
|
||||
EntityCreatedBy<Citizen>{
|
||||
var target: T
|
||||
}
|
||||
|
||||
abstract class Extra<T: EntityI<UUID>>(
|
||||
id: UUID? = UUID.randomUUID(),
|
||||
override var citizen: Citizen
|
||||
createdBy: Citizen
|
||||
):
|
||||
ExtraI<T>,
|
||||
UuidEntity(id),
|
||||
EntityCreatedAt by EntityCreatedAtImp()
|
||||
EntityCreatedAt by EntityCreatedAtImp(),
|
||||
EntityCreatedBy<Citizen> by EntityCreatedByImp(createdBy)
|
||||
@@ -4,6 +4,6 @@ import java.util.*
|
||||
|
||||
class Follow <T: UuidEntity> (
|
||||
id: UUID = UUID.randomUUID(),
|
||||
citizen: Citizen,
|
||||
createdBy: Citizen,
|
||||
override var target: T
|
||||
): Extra<T>(id, citizen)
|
||||
): Extra<T>(id, createdBy)
|
||||
|
||||
@@ -28,7 +28,7 @@ open class Follow <T: UuidEntity>(override var requester: Requester): Repository
|
||||
return requester.run {
|
||||
getFunction("find_follows_by_citizen")
|
||||
.select(page, limit,
|
||||
"citizen_id" to citizenId
|
||||
"created_by_id" to citizenId
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,7 @@ open class Follow <T: UuidEntity>(override var requester: Requester): Repository
|
||||
.sendQuery(
|
||||
"reference" to reference,
|
||||
"target_id" to follow.target.id,
|
||||
"citizen_id" to follow.citizen.id
|
||||
"created_by_id" to follow.createdBy?.id
|
||||
)
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ open class Follow <T: UuidEntity>(override var requester: Requester): Repository
|
||||
.sendQuery(
|
||||
"reference" to reference,
|
||||
"target_id" to follow.target.id,
|
||||
"citizen_id" to follow.citizen.id
|
||||
"created_by_id" to follow.createdBy?.id
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -65,7 +65,7 @@ class FollowArticle (requester: Requester): Follow<ArticleEntity>(requester) {
|
||||
return requester.run {
|
||||
getFunction("find_follows_article_by_citizen")
|
||||
.select(page, limit,
|
||||
"citizen_id" to citizenId
|
||||
"created_by_id" to citizenId
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -80,7 +80,7 @@ class FollowConstitution (requester: Requester): Follow<ConstitutionEntity>(requ
|
||||
return requester.run {
|
||||
getFunction("find_follows_constitution_by_citizen")
|
||||
.select(page, limit,
|
||||
"citizen_id" to citizenId
|
||||
"created_by_id" to citizenId
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,12 +30,12 @@ object FollowArticlePaths {
|
||||
@KtorExperimentalLocationsAPI
|
||||
fun Route.followArticle(repo: FollowArticleRepository) {
|
||||
post<FollowArticlePaths.ArticleFollowRequest> {
|
||||
repo.follow(FollowEntity(target = it.article, citizen = currentCitizen))
|
||||
repo.follow(FollowEntity(target = it.article, createdBy = currentCitizen))
|
||||
call.respond(HttpStatusCode.Created)
|
||||
}
|
||||
|
||||
delete<FollowArticlePaths.ArticleFollowRequest> {
|
||||
repo.unfollow(FollowEntity(target = it.article, citizen = currentCitizen))
|
||||
repo.unfollow(FollowEntity(target = it.article, createdBy = currentCitizen))
|
||||
call.respond(HttpStatusCode.NoContent)
|
||||
}
|
||||
|
||||
|
||||
@@ -30,12 +30,12 @@ object FollowConstitutionPaths {
|
||||
@KtorExperimentalLocationsAPI
|
||||
fun Route.followConstitution(repo: FollowConstitutionRepository) {
|
||||
post<FollowConstitutionPaths.ConstitutionFollowRequest> {
|
||||
repo.follow(FollowEntity(target = it.constitution, citizen = currentCitizen2))
|
||||
repo.follow(FollowEntity(target = it.constitution, createdBy = currentCitizen2))
|
||||
call.respond(HttpStatusCode.Created)
|
||||
}
|
||||
|
||||
delete<FollowConstitutionPaths.ConstitutionFollowRequest> {
|
||||
repo.unfollow(FollowEntity(target = it.constitution, citizen = currentCitizen2))
|
||||
repo.unfollow(FollowEntity(target = it.constitution, createdBy = currentCitizen2))
|
||||
call.respond(HttpStatusCode.NoContent)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user