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

[FEAT/#16] 회원가입 API 구현 #30

Merged
merged 13 commits into from
Jan 10, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ ResponseEntity<BaseResponse<?>> authenticateSocialAuthInfoFromWeb(

ResponseEntity<BaseResponse<?>> authenticateSocialAuthInfoFromApp(
AuthRequest.AuthenticateSocialAuthInfo socialAuthInfo);

ResponseEntity<BaseResponse<?>> signUp(AuthRequest.SignUp signUp);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import sopt.makers.authentication.usecase.auth.port.in.AuthenticateSocialAccountUsecase;
import sopt.makers.authentication.usecase.auth.port.in.AuthenticateSocialAccountUsecase.AuthenticateTokenInfo;
import sopt.makers.authentication.usecase.auth.port.in.CreatePhoneVerificationUsecase;
import sopt.makers.authentication.usecase.auth.port.in.SignUpUsecase;
import sopt.makers.authentication.usecase.auth.port.in.VerifyPhoneVerificationUsecase;

import org.springframework.http.HttpHeaders;
Expand All @@ -28,6 +29,7 @@ public class AuthApiController implements AuthApi {
private final CreatePhoneVerificationUsecase createVerificationUsecase;
private final VerifyPhoneVerificationUsecase verifyVerificationUsecase;
private final AuthenticateSocialAccountUsecase authenticateSocialAccountUsecase;
private final SignUpUsecase signUpUsecase;
private final CookieUtil cookieUtil;

@Override
Expand Down Expand Up @@ -74,4 +76,11 @@ public ResponseEntity<BaseResponse<?>> authenticateSocialAuthInfoFromApp(
AuthResponse.AuthenticateSocialAuthInfoForApp.of(
tokenInfo.accessToken(), tokenInfo.refreshToken()));
}

@Override
@PostMapping("/signup")
public ResponseEntity<BaseResponse<?>> signUp(AuthRequest.SignUp signUp) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3

오 이 부분 signUp이 직관적이긴 한데, 행위를 뜻하는 것 같아서 signUpRequest 정도로 바꾸는건 어떠신가요 ?!

signUpUsecase.signUp(signUp.toCommand());
return ResponseUtil.success(AuthSuccess.CREATE_SIGN_UP_USER);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

import static lombok.AccessLevel.PRIVATE;

import sopt.makers.authentication.domain.auth.AuthPlatform;
import sopt.makers.authentication.domain.auth.PhoneVerificationType;
import sopt.makers.authentication.usecase.auth.port.in.AuthenticateSocialAccountUsecase.AuthenticateSocialAccountCommand;
import sopt.makers.authentication.usecase.auth.port.in.CreatePhoneVerificationUsecase.CreateVerificationCommand;
import sopt.makers.authentication.usecase.auth.port.in.SignUpUsecase.SignUpCommand;
import sopt.makers.authentication.usecase.auth.port.in.VerifyPhoneVerificationUsecase.VerifyVerificationCommand;

import com.fasterxml.jackson.annotation.JsonProperty;
Expand Down Expand Up @@ -43,4 +45,15 @@ public AuthenticateSocialAccountCommand toCommand() {
return AuthenticateSocialAccountCommand.of(authPlatform, code);
}
}

public record SignUp(
@JsonProperty("name") String name,
@JsonProperty("phone") String phone,
@JsonProperty("code") String code,
@JsonProperty("authPlatform") String authPlatform) {
public SignUpCommand toCommand() {
return new SignUpCommand(
this.name, this.phone, this.code, AuthPlatform.find(this.authPlatform));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public enum AuthSuccess implements SuccessCode {

// 201
CREATE_PHONE_VERIFICATION(HttpStatus.CREATED, "번호 인증 생성에 성공했습니다."),
CREATE_SIGN_UP_USER(HttpStatus.CREATED, "회원 가입에 성공했습니다."),
;

private final HttpStatus status;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package sopt.makers.authentication.usecase.auth.port.in;

import sopt.makers.authentication.domain.auth.AuthPlatform;

public interface SignUpUsecase {

void signUp(SignUpCommand command);

record SignUpCommand(String name, String phone, String authCode, AuthPlatform authPlatform) {}
}
Loading