feature #14: create route for follow article

This commit is contained in:
2019-08-14 18:44:07 +02:00
parent c1f228e3c5
commit 7dffc005b9
9 changed files with 198 additions and 1 deletions

View File

@@ -0,0 +1,25 @@
package fr.dcproject.repository
import fr.postgresjson.connexion.Requester
import fr.postgresjson.entity.EntityI
import fr.postgresjson.repository.RepositoryI
import java.util.*
import kotlin.reflect.KClass
import fr.dcproject.entity.Article as ArticleEntity
import fr.dcproject.entity.Follow as FollowEntity
open class Follow <T: EntityI<UUID>>(override var requester: Requester): RepositoryI<FollowEntity<T>> {
override val entityName = FollowEntity::class as KClass<FollowEntity<T>>
fun follow(follow: FollowEntity<T>) {
val reference = follow.target::class.simpleName!!.toLowerCase()
requester
.getFunction("follow")
.sendQuery(
"reference" to reference,
"target_id" to follow.target.id,
"citizen_id" to follow.citizen.id
)
}
}
class FollowArticleRepository(override var requester: Requester): Follow<ArticleEntity>(requester)