Skip to content

Commit

Permalink
[♻️ refactor/#101]: SignUpService 클래스 제거 및 AuthService에 회원가입 로직 통합
Browse files Browse the repository at this point in the history
- `SignUpService` 클래스를 제거하고, 해당 로직을 `AuthService`로 통합하였습니다.
- `AuthController`에서 `SignUpService`를 호출하던 부분을 `AuthService` 호출로 수정하였습니다.
- 코드 중복을 줄이고, 회원가입 로직을 `AuthService`로 일원화하여 서비스 구조를 단순화하였습니다.
  • Loading branch information
jsoonworld committed Aug 26, 2024
1 parent b83d489 commit 3e18889
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.terning.terningserver.exception.dto.SuccessResponse;
import org.terning.terningserver.service.AuthService;
import org.terning.terningserver.service.SignUpFilterService;
import org.terning.terningserver.service.SignUpService;

import static org.terning.terningserver.exception.enums.SuccessMessage.*;

Expand All @@ -28,7 +27,6 @@
public class AuthController implements AuthSwagger {

private final AuthService authService;
private final SignUpService signUpService;
private final SignUpFilterService signUpFilterService;

@PostMapping("/sign-in")
Expand Down Expand Up @@ -56,7 +54,7 @@ public ResponseEntity<SuccessResponse<SignUpResponseDto>> signUp(
@RequestBody SignUpRequestDto request
) {

SignUpResponseDto signUpResponseDto = signUpService.signUp(authId, request.name(), request.profileImage(), request.authType());
SignUpResponseDto signUpResponseDto = authService.signUp(authId, request.name(), request.profileImage(), request.authType());
return ResponseEntity.ok(SuccessResponse.of(SUCCESS_SIGN_UP, signUpResponseDto));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package org.terning.terningserver.service;

import org.terning.terningserver.domain.enums.AuthType;
import org.terning.terningserver.dto.auth.request.SignInRequestDto;
import org.terning.terningserver.dto.auth.response.AccessTokenGetResponseDto;
import org.terning.terningserver.dto.auth.response.SignInResponseDto;
import org.terning.terningserver.dto.auth.response.SignUpResponseDto;

public interface AuthService {

SignInResponseDto signIn(String authAccessToken, SignInRequestDto request);

SignUpResponseDto signUp(String authId, String name, Integer profileImage, AuthType authType);

void signOut(long userId);

void withdraw(long userId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.terning.terningserver.dto.auth.response.AccessTokenGetResponseDto;
import org.terning.terningserver.dto.auth.response.SignInResponseDto;
import org.terning.terningserver.domain.enums.AuthType;
import org.terning.terningserver.dto.auth.response.SignUpResponseDto;
import org.terning.terningserver.exception.CustomException;
import org.terning.terningserver.jwt.JwtTokenProvider;
import org.terning.terningserver.jwt.UserAuthentication;
Expand Down Expand Up @@ -57,11 +58,19 @@ public SignInResponseDto signIn(String authAccessToken, SignInRequestDto request
}

@Transactional
public User saveUser(SignInRequestDto request) {
User user = User.builder()
.authType(request.authType())
.build();
return userRepository.save(user);
public SignUpResponseDto signUp(String authId, String name, Integer profileImage, AuthType authType) {

User user = userRepository.save(User.builder()
.authId(authId)
.name(name)
.authType(authType)
.profileImage(profileImage)
.build());

Token token = getToken(user);
userRepository.save(user);

return SignUpResponseDto.of(token.getAccessToken(), token.getRefreshToken(), user.getId(), authType);
}

@Override
Expand Down
38 changes: 0 additions & 38 deletions src/main/java/org/terning/terningserver/service/SignUpService.java

This file was deleted.

0 comments on commit 3e18889

Please sign in to comment.