Skip to content

Commit

Permalink
닉네임 중복 확인 코드 추가, JWT 코드 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
injoon149 committed Mar 26, 2023
1 parent 252c640 commit 0663073
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "config"]
path = config
url = https://github.com/Today-s-Gym/application.git
branch = "main"
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
@AllArgsConstructor
public enum MemberErrorCode implements ErrorCode {
EMPTY_MEMBER("MEMBER_001", "존재하지 않는 사용자입니다."),
NICKNAME_ERROR("MEMBER_002", "이미 존재하는 닉네임입니다.")
NICKNAME_ERROR("MEMBER_002", "이미 존재하는 닉네임입니다."),
ALREADY_EXIST("MEMBER_003", "이미 존재하는 사용자입니다.")
;
private final String errorCode;
private final String message;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.todaysgym.todaysgym.member;

import com.todaysgym.todaysgym.exception.BaseResponse;
import com.todaysgym.todaysgym.exception.BaseResponseStatus;
import com.todaysgym.todaysgym.config.exception.BaseException;
import com.todaysgym.todaysgym.config.exception.errorCode.MemberErrorCode;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
Expand All @@ -19,13 +19,12 @@ public void join(Member member) {
memberRepository.save(member);
}

private BaseResponse<?> validateDuplicateMember(Member member) {
private void validateDuplicateMember(Member member) {
Optional<Member> findMembers =
memberRepository.findByNickName(member.getNickName());
if (!findMembers.isEmpty()) {
return new BaseResponse<>(BaseResponseStatus.Already_Exist);
throw new BaseException(MemberErrorCode.ALREADY_EXIST);
}
else return new BaseResponse<>(BaseResponseStatus.SUCCESS);
}

public Member findOne(Long memberId) {
Expand Down

0 comments on commit 0663073

Please sign in to comment.