1
1
package com.sns.user.endpoints.user
2
2
3
+ import com.sns.commons.utils.ifTrue
3
4
import com.sns.user.component.authcode.application.AuthCodeCommand
4
5
import com.sns.user.component.authcode.domain.Purpose
6
+ import com.sns.user.component.user.application.UserCommandService
7
+ import com.sns.user.component.user.application.UserQueryService
5
8
import com.sns.user.core.config.SwaggerTag
6
9
import com.sns.user.endpoints.user.requests.SignUpRequest
7
10
import io.swagger.v3.oas.annotations.media.Content
@@ -25,13 +28,17 @@ import org.springframework.web.bind.annotation.RestController
25
28
@RestController
26
29
@Tag(name = SwaggerTag .SIGN_UP )
27
30
@RequestMapping(" /api" )
28
- class SignUpController (val authCodeCommand : AuthCodeCommand ) {
31
+ class SignUpController (
32
+ val authCodeCommand : AuthCodeCommand ,
33
+ val userQueryService : UserQueryService ,
34
+ val userCommandService : UserCommandService
35
+ ) {
29
36
30
37
@ApiResponse(description = " 회원 가입" , responseCode = " 202" )
31
38
@ResponseStatus(HttpStatus .CREATED )
32
39
@PostMapping(" /v1/sign-up" )
33
40
fun signUp (@RequestBody request : SignUpRequest ) {
34
- // TODO 패스워드 유효성 검증
41
+ userCommandService.create(request.name, request.password, request.email)
35
42
}
36
43
37
44
@ApiResponse(
@@ -41,15 +48,14 @@ class SignUpController(val authCodeCommand: AuthCodeCommand) {
41
48
@ResponseStatus(HttpStatus .OK )
42
49
@GetMapping(" /v1/sign-up/verifications/emails/{email}" )
43
50
fun verifyEmail (@Email @PathVariable email : String ): ResponseEntity <Boolean > {
44
- // TODO email 중복 검사
45
- return ResponseEntity .ok(false )
51
+ return (userQueryService.getByEmail( email) != null )
52
+ . let { ResponseEntity .ok(it) }
46
53
}
47
54
48
55
@ApiResponse(description = " 가입 인증 코드 재발송" , responseCode = " 202" )
49
56
@ResponseStatus(HttpStatus .CREATED )
50
57
@PutMapping(" /v1/sign-up/verifications/auth-code/ids/{userId}" )
51
58
fun createAuthenticationCode (@PathVariable userId : String ) {
52
-
53
59
authCodeCommand.create(userId)
54
60
}
55
61
@@ -60,6 +66,10 @@ class SignUpController(val authCodeCommand: AuthCodeCommand) {
60
66
@ResponseStatus(HttpStatus .OK )
61
67
@PostMapping(" /v1/sign-up/verifications/auth-code/ids/{userId}" )
62
68
fun verifyAuthenticationCode (@PathVariable userId : String , @RequestBody code : String ): ResponseEntity <Boolean > {
63
- return ResponseEntity .ok(authCodeCommand.verify(userId, Purpose .SIGN_UP , code))
69
+ return authCodeCommand.verify(userId, Purpose .SIGN_UP , code)
70
+ .ifTrue { userCommandService.activate(userId) }
71
+ .let {
72
+ ResponseEntity .ok(it)
73
+ }
64
74
}
65
75
}
0 commit comments