diff --git a/src/main/kotlin/org/meogo/domain/review/domain/Review.kt b/src/main/kotlin/org/meogo/domain/review/domain/Review.kt new file mode 100644 index 0000000..b39a4e2 --- /dev/null +++ b/src/main/kotlin/org/meogo/domain/review/domain/Review.kt @@ -0,0 +1,29 @@ +package org.meogo.domain.review.domain + +import java.time.LocalDateTime +import java.util.UUID +import javax.persistence.Entity +import javax.persistence.GeneratedValue +import javax.persistence.GenerationType +import javax.persistence.Id + +@Entity +class Review( + + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Id + val id: Long = 0, + + val date: LocalDateTime, + + val userId: UUID, + + val schoolId: Int, + + val star: Long, + + val content: String, + + val picture: String? + +) diff --git a/src/main/kotlin/org/meogo/domain/review/presentation/ReviewController.kt b/src/main/kotlin/org/meogo/domain/review/presentation/ReviewController.kt new file mode 100644 index 0000000..3266b95 --- /dev/null +++ b/src/main/kotlin/org/meogo/domain/review/presentation/ReviewController.kt @@ -0,0 +1,10 @@ +package org.meogo.domain.review.presentation + +import lombok.RequiredArgsConstructor +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController + +@RestController +@RequiredArgsConstructor +@RequestMapping("/review") +class ReviewController() diff --git a/src/main/kotlin/org/meogo/domain/review/repository/ReviewRepository.kt b/src/main/kotlin/org/meogo/domain/review/repository/ReviewRepository.kt new file mode 100644 index 0000000..60dae40 --- /dev/null +++ b/src/main/kotlin/org/meogo/domain/review/repository/ReviewRepository.kt @@ -0,0 +1,8 @@ +package org.meogo.domain.review.repository + +import org.meogo.domain.review.domain.Review +import org.springframework.data.repository.Repository + +interface ReviewRepository : Repository { + fun save(review: Review): Review +} diff --git a/src/main/kotlin/org/meogo/domain/user/facade/UserFacade.kt b/src/main/kotlin/org/meogo/domain/user/facade/UserFacade.kt index 55340e2..0f61e87 100644 --- a/src/main/kotlin/org/meogo/domain/user/facade/UserFacade.kt +++ b/src/main/kotlin/org/meogo/domain/user/facade/UserFacade.kt @@ -12,11 +12,10 @@ class UserFacade( ) { fun currentUser(): User? { - val authentication = SecurityContextHolder.getContext().authentication - val accountId = authentication?.name + val accountId = SecurityContextHolder.getContext().authentication.name return accountId?.let { getUserByAccountId(it) } } - fun getUserByAccountId(accountId: String): User = + fun getUserByAccountId(accountId: String) = userRepository.findByAccountId(accountId) ?: throw UserNotFoundException } diff --git a/src/main/kotlin/org/meogo/domain/user/repository/UserRepository.kt b/src/main/kotlin/org/meogo/domain/user/repository/UserRepository.kt index 77972e1..0dda506 100644 --- a/src/main/kotlin/org/meogo/domain/user/repository/UserRepository.kt +++ b/src/main/kotlin/org/meogo/domain/user/repository/UserRepository.kt @@ -1,10 +1,10 @@ package org.meogo.domain.user.repository import org.meogo.domain.user.domain.User -import org.springframework.data.repository.Repository +import org.springframework.data.jpa.repository.JpaRepository import java.util.UUID -interface UserRepository : Repository { +interface UserRepository : JpaRepository { fun save(entity: User): User fun findByAccountId(accountId: String): User?