-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
21ddc3c
commit e8146f0
Showing
1 changed file
with
4 additions
and
1 deletion.
There are no files selected for viewing
5 changes: 4 additions & 1 deletion
5
src/main/kotlin/org/meogo/domain/review/service/QueryMatchService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,21 @@ | ||
package org.meogo.domain.review.service | ||
|
||
import org.meogo.domain.review.domain.ReviewRepository | ||
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 | ||
private val userFacade: UserFacade, | ||
private val reviewRepository: ReviewRepository | ||
) { | ||
|
||
@Transactional(readOnly = true) | ||
fun execute(schoolId: Int): Boolean { | ||
val user = userFacade.currentUser() ?: throw UserNotFoundException | ||
if (reviewRepository.existsByUserId(user.id!!)) return false | ||
return user.enrolledSchool == schoolId | ||
} | ||
} |