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:
12
src/main/kotlin/dto/CreatedAt.kt
Normal file
12
src/main/kotlin/dto/CreatedAt.kt
Normal file
@@ -0,0 +1,12 @@
|
||||
package fr.dcproject.dto
|
||||
|
||||
import fr.postgresjson.entity.EntityCreatedAt
|
||||
import org.joda.time.DateTime
|
||||
|
||||
interface CreatedAt {
|
||||
val createdAt: DateTime
|
||||
|
||||
class Imp(parent: EntityCreatedAt) : CreatedAt {
|
||||
override val createdAt: DateTime = parent.createdAt
|
||||
}
|
||||
}
|
||||
11
src/main/kotlin/dto/Opinionable.kt
Normal file
11
src/main/kotlin/dto/Opinionable.kt
Normal file
@@ -0,0 +1,11 @@
|
||||
package fr.dcproject.dto
|
||||
|
||||
typealias Opinions = Map<String, Int>
|
||||
|
||||
interface Opinionable {
|
||||
val opinions: Opinions
|
||||
|
||||
class Imp(parent: fr.dcproject.entity.Opinionable): Opinionable {
|
||||
override val opinions: Opinions = parent.opinions
|
||||
}
|
||||
}
|
||||
15
src/main/kotlin/dto/Versionable.kt
Normal file
15
src/main/kotlin/dto/Versionable.kt
Normal file
@@ -0,0 +1,15 @@
|
||||
package fr.dcproject.dto
|
||||
|
||||
import fr.postgresjson.entity.EntityVersioning
|
||||
import java.util.*
|
||||
|
||||
interface Versionable {
|
||||
val versionId: UUID
|
||||
val versionNumber: Int
|
||||
|
||||
class Imp(parent: EntityVersioning<UUID, Int>) : Versionable {
|
||||
override val versionNumber: Int = parent.versionNumber
|
||||
override val versionId: UUID = parent.versionId
|
||||
}
|
||||
}
|
||||
|
||||
10
src/main/kotlin/dto/ViewAggregation.kt
Normal file
10
src/main/kotlin/dto/ViewAggregation.kt
Normal file
@@ -0,0 +1,10 @@
|
||||
package fr.dcproject.dto
|
||||
|
||||
import fr.dcproject.entity.ViewAggregation
|
||||
|
||||
class ViewAggregation(
|
||||
val total: Int,
|
||||
val unique: Int
|
||||
) {
|
||||
constructor(views: ViewAggregation) : this(views.total, views.unique)
|
||||
}
|
||||
9
src/main/kotlin/dto/Viewable.kt
Normal file
9
src/main/kotlin/dto/Viewable.kt
Normal file
@@ -0,0 +1,9 @@
|
||||
package fr.dcproject.dto
|
||||
|
||||
interface Viewable {
|
||||
var views: ViewAggregation
|
||||
|
||||
class Imp(views: fr.dcproject.entity.ViewAggregation) : Viewable {
|
||||
override var views: ViewAggregation = ViewAggregation(views.total, views.unique)
|
||||
}
|
||||
}
|
||||
9
src/main/kotlin/dto/Votable.kt
Normal file
9
src/main/kotlin/dto/Votable.kt
Normal file
@@ -0,0 +1,9 @@
|
||||
package fr.dcproject.dto
|
||||
|
||||
interface Votable {
|
||||
val votes: VoteAggregation
|
||||
|
||||
class Imp(parent: fr.dcproject.entity.Votable): Votable {
|
||||
override val votes: VoteAggregation = VoteAggregation(parent)
|
||||
}
|
||||
}
|
||||
11
src/main/kotlin/dto/VoteAggregation.kt
Normal file
11
src/main/kotlin/dto/VoteAggregation.kt
Normal file
@@ -0,0 +1,11 @@
|
||||
package fr.dcproject.dto
|
||||
|
||||
import fr.dcproject.entity.Votable
|
||||
|
||||
class VoteAggregation(parent: Votable) {
|
||||
val up: Int = parent.votes.up
|
||||
val neutral: Int = parent.votes.neutral
|
||||
val down: Int = parent.votes.down
|
||||
val total: Int = parent.votes.total
|
||||
val score: Int = parent.votes.score
|
||||
}
|
||||
Reference in New Issue
Block a user