Skip to content

Commit

Permalink
Merge pull request #8 from MEOGO-DSM/7-review
Browse files Browse the repository at this point in the history
🏄 :: (Meogo-7) review
  • Loading branch information
meltapplee authored Sep 3, 2024
2 parents 5bd41b4 + fe2b5b7 commit 5ed99c4
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 5 deletions.
29 changes: 29 additions & 0 deletions src/main/kotlin/org/meogo/domain/review/domain/Review.kt
Original file line number Diff line number Diff line change
@@ -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?

)
Original file line number Diff line number Diff line change
@@ -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()
Original file line number Diff line number Diff line change
@@ -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<Review, Long> {
fun save(review: Review): Review
}
5 changes: 2 additions & 3 deletions src/main/kotlin/org/meogo/domain/user/facade/UserFacade.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
@@ -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<User, UUID> {
interface UserRepository : JpaRepository<User, UUID> {
fun save(entity: User): User

fun findByAccountId(accountId: String): User?
Expand Down

0 comments on commit 5ed99c4

Please sign in to comment.