Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🏄 :: (Meogo-7) review #8

Merged
merged 3 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,21 @@
package org.meogo.domain.review.presentation

import lombok.RequiredArgsConstructor
import org.meogo.domain.review.presentation.dto.ReviewRequest
import org.meogo.domain.review.service.CreateReviewService
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

@RestController
@RequiredArgsConstructor
@RequestMapping("/review")
class ReviewController(
private val createReviewService: CreateReviewService
) {

@PostMapping()
fun create(@RequestBody request: ReviewRequest) =
createReviewService.execute(request)
}
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
Loading