Skip to content

Commit

Permalink
add :: match api
Browse files Browse the repository at this point in the history
  • Loading branch information
meltapplee committed Oct 6, 2024
1 parent 8d0f4d3 commit 21ddc3c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import org.meogo.domain.review.service.DeleteReviewService
import org.meogo.domain.review.service.ModifyReviewService
import org.meogo.domain.review.service.QueryAllBySchoolIdService
import org.meogo.domain.review.service.QueryKeywordsService
import org.meogo.domain.review.service.QueryMatchService
import org.meogo.domain.review.service.QueryReviewPictureService
import org.meogo.domain.review.service.QuerySchoolReviewResultService
import org.springframework.http.HttpStatus
Expand All @@ -32,7 +33,8 @@ class ReviewController(
private val deleteReviewService: DeleteReviewService,
private val queryReviewPictureService: QueryReviewPictureService,
private val querySchoolReviewResultService: QuerySchoolReviewResultService,
private val queryKeywordsService: QueryKeywordsService
private val queryKeywordsService: QueryKeywordsService,
private val queryMatchService: QueryMatchService
) {
@PostMapping
@ResponseStatus(value = HttpStatus.CREATED)
Expand Down Expand Up @@ -70,4 +72,8 @@ class ReviewController(

@GetMapping("/keyword")
fun queryKeyword() = queryKeywordsService.execute()

@GetMapping("/match")
fun schoolMatch(@RequestParam(name = "school_id") schoolId: Int) =
queryMatchService.execute(schoolId)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.meogo.domain.review.service

import org.meogo.domain.user.exception.UserNotFoundException
import org.meogo.domain.user.facade.UserFacade
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional

@Service
class QueryMatchService(
private val userFacade: UserFacade
) {

@Transactional(readOnly = true)
fun execute(schoolId: Int): Boolean {
val user = userFacade.currentUser() ?: throw UserNotFoundException
return user.enrolledSchool == schoolId
}
}

0 comments on commit 21ddc3c

Please sign in to comment.