Skip to content

Commit

Permalink
Merge pull request #101 from depromeet/feature/#99
Browse files Browse the repository at this point in the history
feat(#99): add dto, edit open-in-view
  • Loading branch information
ManHyuk authored Jan 9, 2024
2 parents d82d81f + 06dd99f commit 2f34282
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.raemian.api.auth.controller.response

import io.raemian.api.auth.domain.UserDTO
import io.raemian.api.goal.controller.response.GoalsResponse
import io.raemian.storage.db.core.user.User
import java.time.LocalDate
import java.time.LocalDateTime

Expand All @@ -16,9 +16,9 @@ data class UserResponse(
val createdAt: LocalDateTime?,
) {
companion object {
fun of(user: User, goal: GoalsResponse): UserResponse {
fun of(user: UserDTO, goal: GoalsResponse): UserResponse {
return UserResponse(
id = user.id!!,
id = user.id,
email = user.email,
username = user.username,
nickname = user.nickname,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package io.raemian.api.auth.domain

import io.raemian.storage.db.core.user.User
import java.time.LocalDate
import java.time.LocalDateTime

data class UserDTO(
val id: Long,
val email: String,
val username: String? = null,
val nickname: String? = null,
val birth: LocalDate? = null,
val image: String,
val provider: String,
val authority: String,
val createdAt: LocalDateTime? = null,
) {
companion object {
fun of(user: User): UserDTO {
return UserDTO(
id = user.id!!,
email = user.email,
nickname = user.nickname,
username = user.username,
birth = user.birth,
image = user.image,
provider = user.provider.name,
authority = user.authority.name,
createdAt = user.createdAt,
)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.raemian.api.auth.service

import io.raemian.api.auth.domain.CurrentUser
import io.raemian.api.auth.domain.UserDTO
import io.raemian.storage.db.core.user.User
import io.raemian.storage.db.core.user.UserRepository
import org.springframework.security.core.userdetails.UserDetails
Expand All @@ -15,9 +16,9 @@ class AuthService(
private val userRepository: UserRepository,
) : UserDetailsService {

fun getUserById(id: Long): User {
fun getUserById(id: Long): UserDTO {
val user = userRepository.getById(id)
return user
return UserDTO.of(user)
}

fun update(id: Long, nickname: String, birth: LocalDate): User {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ class OAuth2UserService(
authority = Authority.ROLE_USER,
),
)
val new = created.updateUsername("BANDIBOODI-${created.id!!}")

val updated = userRepository.save(created.updateUsername("BANDIBOODI-${created.id!!}"))
val updated = userRepository.save(new)

// lifemap

Expand Down
2 changes: 1 addition & 1 deletion storage/db-core/src/main/resources/application-db-core.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# default
spring:
jpa:
open-in-view: false
open-in-view: true
hibernate:
ddl-auto: none

Expand Down

0 comments on commit 2f34282

Please sign in to comment.