implement route /articles/{article}/follows

create repository for find_follow
This commit is contained in:
2020-02-27 17:14:56 +01:00
parent 3a08052728
commit 967b370a41
4 changed files with 38 additions and 5 deletions

View File

@@ -38,6 +38,13 @@ fun Route.followArticle(repo: FollowArticleRepository) {
call.respond(HttpStatusCode.NoContent)
}
get<FollowArticlePaths.ArticleFollowRequest> {
repo.findFollow(citizen, it.article)?.let { follow ->
assertCan(VIEW, follow)
call.respond(follow)
} ?: call.respond(HttpStatusCode.NotFound)
}
get<FollowArticlePaths.CitizenFollowArticleRequest> {
val follows = repo.findByCitizen(it.citizen)
assertCan(VIEW, follows.result)