Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -56,6 +56,11 @@ public List<Member> parseDataAndMapToMember(MultipartFile file) {
}

private Member mapToMember(String[] fields, List<Department> departments) {

if (!validateEmailAndNickname(fields[4].trim(), fields[1].trim())) {
throw new ApplicationException(MemberErrorCode.INVALID_EMAIL_NICKNAME_MATCH);
}

Long departmentId = Long.parseLong(fields[2].trim());
Department department = departments.stream()
.filter(dept -> dept.getDepartmentId().equals(departmentId))
Expand All @@ -77,4 +82,12 @@ private Member mapToMember(String[] fields, List<Department> departments) {
.memberInfo(memberInfo)
.build();
}
}

private boolean validateEmailAndNickname(String email, String nickname) {
String extractedEmail = email.split("@")[0].replace(".", "");
String extractedNickname = nickname.replace(".", "");
System.out.println(extractedNickname);
System.out.println(extractedEmail);
return extractedEmail.equals(extractedNickname);
}
}
5 changes: 3 additions & 2 deletions src/main/java/clap/server/exception/code/MemberErrorCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ public enum MemberErrorCode implements BaseErrorCode {
DUPLICATE_NICKNAME(HttpStatus.BAD_REQUEST,"MEMBER_011", "중복된 닉네임입니다"),
DUPLICATE_NICKNAME_OR_EMAIL(HttpStatus.BAD_REQUEST, "MEMBER_012", "중복된 닉네임이나 email이 존재합니다"),
MANAGER_PERMISSION_DENIED(HttpStatus.BAD_REQUEST, "MEMBER_013", "담당자 권한이 없는 부서입니다."),
;
INVALID_EMAIL_NICKNAME_MATCH(HttpStatus.BAD_REQUEST, "MEMBER_014", "닉네임과 이메일이 일치하지 않습니다"),
;

private final HttpStatus httpStatus;
private final String customCode;
private final String message;
}
}