Skip to content

Commit

Permalink
[chore] 코드 정리 - #146
Browse files Browse the repository at this point in the history
  • Loading branch information
sjk4618 committed Jul 17, 2024
1 parent 99a47a8 commit 25fe1f7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public ResponseEntity<UserJwtInfoRes> signUp(@RequestHeader(AUTHORIZATION) final
@RequestPart("userSignUpReq") final UserSignUpReq userSignUPReq,
@RequestPart("image") MultipartFile image,
@RequestPart("tag") List<DateTagType> tag
) throws IOException, ExecutionException, InterruptedException {
) {
UserJwtInfoRes userSignUpRes = authService.signUp(token, userSignUPReq, image, tag);
return ResponseEntity.status(HttpStatus.CREATED).body(userSignUpRes);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,12 @@ public class AuthService {
private String cachePath;

@Transactional
public UserJwtInfoRes signUp(final String token, final UserSignUpReq userSignUpReq, MultipartFile image, List<DateTagType> tag)
throws IOException, ExecutionException, InterruptedException {
public UserJwtInfoRes signUp(final String token, final UserSignUpReq userSignUpReq, MultipartFile image, List<DateTagType> tag) {
String platformUserId = getUserPlatformId(userSignUpReq.platform(), token);
validateUserTagSize(tag);
checkNickname(userSignUpReq.name());
validateDuplicatedUser(userSignUpReq.platform(), platformUserId);
User newUser = saveUser(userSignUpReq.name(), cachePath + s3Service.uploadImage("/user", image).get(), userSignUpReq.platform(), platformUserId);
User newUser = saveUser(userSignUpReq.name(), getImage(image), userSignUpReq.platform(), platformUserId);
saveUserTag(newUser, tag);
Token issuedToken = issueToken(newUser.getId());
return UserJwtInfoRes.of(newUser.getId(), issuedToken.accessToken(), issuedToken.refreshToken());
Expand Down Expand Up @@ -179,7 +178,17 @@ private void deleteRefreshToken(final long userId) {
}

//토큰 발급
Token issueToken(final Long userId) {
private Token issueToken(final Long userId) {
return jwtProvider.issueToken(userId);
}

//이미지 생성
private String getImage(MultipartFile image) {
try {
return cachePath + s3Service.uploadImage("/user", image).get();
} catch (InterruptedException | ExecutionException | IOException e) {
log.error(e.getMessage());
throw new BadRequestException(FailureCode.WRONG_IMAGE_URL);
}
}
}

0 comments on commit 25fe1f7

Please sign in to comment.