Skip to content

Commit

Permalink
🔧 Delete userId from User
Browse files Browse the repository at this point in the history
  • Loading branch information
alpakar02 committed Jan 6, 2025
1 parent 2c087dc commit 4659c5b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import com.toyProject7.karrot.user.persistence.UserEntity
data class User(
val id: String,
val nickname: String,
val userId: String,
val location: String,
val temperature: Double,
val email: String,
Expand All @@ -15,7 +14,6 @@ data class User(
return User(
id = entity.id!!,
nickname = entity.nickname,
userId = entity.userId,
location = entity.location,
temperature = entity.temperature,
email = entity.email,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ import org.springframework.web.bind.annotation.RestController
class UserController(
private val userService: UserService,
) {
@PostMapping("/auth/register")
@PostMapping("/auth/sign/up")
fun signUp(
@RequestBody request: SignUpRequest,
): ResponseEntity<SignUpResponse> {
val user = userService.signUp(request.nickname, request.userId, request.password, request.email)
return ResponseEntity.ok(SignUpResponse(user))
}

@PostMapping("/auth/login")
@PostMapping("/auth/sign/in")
fun signIn(
@RequestBody request: SignInRequest,
): ResponseEntity<SignInResponse> {
Expand All @@ -32,7 +32,7 @@ class UserController(
fun me(
@AuthUser user: User,
): ResponseEntity<UserMeResponse> {
return ResponseEntity.ok(UserMeResponse(user.userId, user.nickname))
return ResponseEntity.ok(UserMeResponse(user.id, user.nickname))
}
}

Expand All @@ -57,6 +57,6 @@ data class SignInResponse(
)

data class UserMeResponse(
val userId: String,
val id: String,
val nickname: String,
)
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,9 @@ class UserService(
val user = userRepository.findByIdOrNull(id) ?: throw AuthenticateException()
return User.fromEntity(user)
}

@Transactional
fun getUserEntityById(id: String): UserEntity {
return userRepository.findByIdOrNull(id) ?: throw AuthenticateException()
}
}

0 comments on commit 4659c5b

Please sign in to comment.