Refactors Articles and Voter
- Move files into components (article) - Split articles routes - Refactoring for remove ktor-voter (ArticleVoter) - Remove mutability - Move DataConversion to separate file (Converter.kt) - Add Schemas for Articles routes - Fix SQL Query for Workgroup roles - rename container_name in docker-compose
This commit is contained in:
@@ -1,30 +1,28 @@
|
||||
package fr.dcproject.entity
|
||||
|
||||
import fr.postgresjson.entity.immutable.*
|
||||
import fr.postgresjson.entity.mutable.EntityDeletedAt
|
||||
import fr.postgresjson.entity.mutable.EntityDeletedAtImp
|
||||
import fr.postgresjson.entity.*
|
||||
import org.joda.time.DateTime
|
||||
import java.util.*
|
||||
|
||||
open class Comment<T : TargetI>(
|
||||
class CommentForView<T : TargetI, C : CitizenRef>(
|
||||
id: UUID = UUID.randomUUID(),
|
||||
override val createdBy: CitizenBasic,
|
||||
override var target: T,
|
||||
var content: String,
|
||||
val responses: List<Comment<T>>? = null,
|
||||
var parent: Comment<T>? = null,
|
||||
val parentsIds: List<UUID>? = null,
|
||||
val childrenCount: Int? = null
|
||||
) : ExtraI<T, CitizenBasicI>,
|
||||
CommentRef(id),
|
||||
EntityCreatedAt by EntityCreatedAtImp(),
|
||||
EntityCreatedBy<CitizenBasicI> by EntityCreatedByImp(createdBy),
|
||||
override val createdBy: C,
|
||||
override val target: T,
|
||||
override var content: String,
|
||||
override val parent: CommentParent<T>? = null,
|
||||
val childrenCount: Int? = null,
|
||||
override val deletedAt: DateTime? = null
|
||||
) : ExtraI<T, C>,
|
||||
CommentForUpdate<T, C>(id, createdBy, target, content, parent, deletedAt),
|
||||
CommentWithTargetI<T>,
|
||||
EntityCreatedBy<C> by EntityCreatedByImp(createdBy),
|
||||
EntityUpdatedAt by EntityUpdatedAtImp(),
|
||||
EntityDeletedAt by EntityDeletedAtImp(),
|
||||
Votable by VotableImp(),
|
||||
TargetI {
|
||||
constructor(
|
||||
createdBy: CitizenBasic,
|
||||
parent: Comment<T>,
|
||||
createdBy: C,
|
||||
parent: CommentParent<T>,
|
||||
content: String
|
||||
) : this(
|
||||
createdBy = createdBy,
|
||||
@@ -34,6 +32,43 @@ open class Comment<T : TargetI>(
|
||||
)
|
||||
}
|
||||
|
||||
open class CommentRef(id: UUID = UUID.randomUUID()) : CommentS(id)
|
||||
open class CommentForUpdate<T : TargetI, C: CitizenRef>(
|
||||
override val id: UUID = UUID.randomUUID(),
|
||||
override val createdBy: C,
|
||||
override val target: T,
|
||||
open var content: String,
|
||||
open val parent: CommentParent<T>? = null,
|
||||
override val deletedAt: DateTime? = null
|
||||
) : CommentParent<T>(id, deletedAt, target),
|
||||
ExtraI<T, C>,
|
||||
CommentWithTargetI<T>,
|
||||
EntityCreatedAt by EntityCreatedAtImp(),
|
||||
EntityCreatedBy<C>,
|
||||
EntityDeletedAt,
|
||||
TargetI {
|
||||
constructor(
|
||||
createdBy: C,
|
||||
parent: CommentParent<T>,
|
||||
content: String
|
||||
) : this(
|
||||
createdBy = createdBy,
|
||||
parent = parent,
|
||||
target = parent.target,
|
||||
content = content
|
||||
)
|
||||
}
|
||||
|
||||
sealed class CommentS(id: UUID) : TargetRef(id)
|
||||
open class CommentParent<T: TargetI>(
|
||||
override val id: UUID,
|
||||
override val deletedAt: DateTime?,
|
||||
override val target: T
|
||||
) : CommentRef(id),
|
||||
CommentParentI<T>
|
||||
|
||||
interface CommentParentI<T: TargetI> : CommentI, EntityDeletedAt, CommentWithTargetI<T>
|
||||
|
||||
interface CommentWithTargetI<T : TargetI> : CommentI, TargetI, AsTarget<T>
|
||||
|
||||
open class CommentRef(id: UUID = UUID.randomUUID()) : CommentI, TargetRef(id)
|
||||
|
||||
interface CommentI : EntityI
|
||||
|
||||
Reference in New Issue
Block a user