Skip to content

Commit

Permalink
[FIX/#115] Transactional 어노테이션으로 묶는 범위 수정
Browse files Browse the repository at this point in the history
내부에서 호출되는 private 메서드에는 자동으로 Transactional이 적용
  • Loading branch information
ckkim817 committed Jul 17, 2024
1 parent 34f6641 commit 1602312
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public void init() {
}

// JWT Access Token 생성
@Transactional
public LoginSuccessResponse create(
final String authorizationCode,
final MemberLoginRequest loginRequest
Expand All @@ -73,7 +74,7 @@ public LoginSuccessResponse create(
}

// 소셜 플랫폼으로부터 해당 유저 정보를 받아옴
public MemberInfoResponse getMemberInfoResponse(
private MemberInfoResponse getMemberInfoResponse(
final String authorizationCode,
final MemberLoginRequest loginRequest
) {
Expand Down Expand Up @@ -106,14 +107,14 @@ private LoginSuccessResponse getTokenDto(final MemberInfoResponse memberInfoResp
}
}

public boolean isExistingMember(
private boolean isExistingMember(
final SocialType socialType,
final String socialId
) {
return memberRepository.findBySocialTypeAndSocialId(socialType, socialId).isPresent();
}

public Long getMemberIdBySocialId(
private Long getMemberIdBySocialId(
final SocialType socialType,
final String socialId
) {
Expand All @@ -124,13 +125,14 @@ public Long getMemberIdBySocialId(
return member.getId();
}

public LoginSuccessResponse getTokenByMemberId(final Long id) {
private LoginSuccessResponse getTokenByMemberId(final Long id) {
MemberAuthentication memberAuthentication = new MemberAuthentication(id, null, null);

return LoginSuccessResponse.of(jwtTokenProvider.issueAccessToken(memberAuthentication));
}

// 닉네임 유효성 검증
@Transactional(readOnly = true)
public void validNickname(final NicknameRequest nicknameRequest) {
if (!nicknameRequest.nickname().matches(NICKNAME_PATTERN)) { // 형식 체크
throw new CustomException(ErrorType.INVALID_NICKNAME_ERROR);
Expand Down Expand Up @@ -168,6 +170,7 @@ public MemberJoinResponse patchMemberJoin(MemberJoinRequest memberJoinRequest) {
);
}

@Transactional
public void sendMessage(SendCodeRequest sendCodeRequest) {
Message message = new Message();

Expand Down Expand Up @@ -198,6 +201,7 @@ private String generateRandomNumber(int digitCount) {
}

// 인증번호 일치 여부 확인
@Transactional
public void verifyCode(VerifyCodeRequest verifyCodeRequest) {
String number = verifyCodeRequest.phoneNumber().replaceAll("-", "");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public class CodeService {

private final CodeRepository codeRepository;

@Transactional
public void saveVerificationCode(
final String phoneNumber,
final String verificationCode
Expand All @@ -27,7 +26,6 @@ public void saveVerificationCode(
);
}

@Transactional(readOnly = true)
public String findCodeByPhoneNumber(final String phoneNumber) {
Code code = codeRepository.findByPhoneNumber(phoneNumber).orElseThrow(
() -> new CustomException(ErrorType.NO_VERIFICATION_REQUEST_HISTORY)
Expand Down

0 comments on commit 1602312

Please sign in to comment.