Skip to content

Commit

Permalink
[fix] #5 RequestDto Builder 패턴 삭제 및 커스텀 에러 핸들링 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
dogsub committed Jan 18, 2025
1 parent 88e30ea commit 39e3b18
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.wedit.weditapp.domain.shared.BaseTimeEntity;
import com.wedit.weditapp.domain.shared.MemberRole;
import com.wedit.weditapp.domain.shared.MemberStatus;
import com.wedit.weditapp.global.error.ErrorCode;
import com.wedit.weditapp.global.error.exception.CommonException;
import jakarta.persistence.*;
import lombok.AccessLevel;
import lombok.Builder;
Expand Down Expand Up @@ -53,15 +55,15 @@ public static Member createUser(String email, String name) {
// 사용자 이메일 변경 Method
public void updateEmail(String newEmail) {
if (newEmail == null || newEmail.trim().isEmpty()) {
throw new IllegalArgumentException("공백이면 안됩니다.");
throw new CommonException(ErrorCode.EMPTY_FIELD);
}
this.name = newEmail;
this.email = newEmail;
}

// 사용자 이름 변경 Method
public void updateName(String newName) {
if (newName == null || newName.trim().isEmpty()) {
throw new IllegalArgumentException("공백이면 안됩니다.");
throw new CommonException(ErrorCode.EMPTY_FIELD);
}
this.name = newName;
}
Expand All @@ -74,7 +76,7 @@ public void deactivate() {
// 사용자 역할 변경 Method
public void updateRole(MemberRole newRole) {
if (newRole == null) {
throw new IllegalArgumentException("공백이면 안됩니다.");
throw new CommonException(ErrorCode.EMPTY_FIELD);
}
this.role = newRole;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,4 @@
public class LoginRequestDto {
private String email;

@Builder
public LoginRequestDto(String email) {
this.email = email;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,4 @@ public class MemberRequestDto {

@NotBlank(message = "이름을 반드시 입력해야 합니다.")
private String name;

@Builder
public MemberRequestDto(String email, String name) {
this.email = email;
this.name = name;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public enum ErrorCode {
INVALID_FILE_FORMAT(400, "INVALID_FILE_FORMAT", "올바르지 않은 파일 형식입니다."),
INVALID_TOKEN(401, "INVALID_TOKEN", "유효하지 않은 토큰입니다."),
REJECT_DUPLICATION(409, "REJECT_DUPLICATION", "중복된 값입니다."),
EMPTY_FIELD(400, "EMPTY_FIELD", "공백이면 안됩니다."),

//회원
LOGIN_FAIL(401, "LOGIN_FAIL", "로그인에 실패하였습니다."),
Expand Down

0 comments on commit 39e3b18

Please sign in to comment.