Skip to content

Commit

Permalink
refactor: user 패키지 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
sang-w0o committed Oct 16, 2022
1 parent 25e8921 commit dbcf862
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.template.user.controller

import com.template.config.annotation.LoggedInUser
import com.template.user.controller.response.UserInfoResponse
import com.template.user.dto.UserDto
import com.template.user.service.UserService
import org.springframework.web.bind.annotation.GetMapping
Expand All @@ -14,5 +15,5 @@ class UserApiController(
) {

@GetMapping
fun getUserInfo(@LoggedInUser user: UserDto) = userService.getUserInfo(user)
fun getUserInfo(@LoggedInUser user: UserDto) = UserInfoResponse.from(userService.getUserInfo(user))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.template.user.controller.response

import com.template.user.dto.UserDto

data class UserInfoResponse(
val id: Int,
val name: String,
val email: String
) {
companion object {
fun from(userDto: UserDto) = UserInfoResponse(userDto.id, userDto.name, userDto.email)
}
}
2 changes: 0 additions & 2 deletions src/main/kotlin/com/template/user/dto/UserDto.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,4 @@ data class UserDto(
val email: String
) {
constructor(user: User) : this(user.id!!, user.name, user.password!!, user.email)

fun toResponseDto() = UserInfoResponseDto(this.id, this.name, this.email)
}
7 changes: 0 additions & 7 deletions src/main/kotlin/com/template/user/dto/UserInfoResponseDto.kt

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/kotlin/com/template/user/service/UserService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ class UserService(
private val userRepository: UserRepository
) {

fun getUserInfo(userDto: UserDto) = userDto.toResponseDto()
fun getUserInfo(userDto: UserDto) = userDto
}

0 comments on commit dbcf862

Please sign in to comment.