diff --git a/backend/src/main/java/com/funeat/exception/CommonErrorCode.java b/backend/src/main/java/com/funeat/exception/CommonErrorCode.java index 8f0a2d363..2265a1f81 100644 --- a/backend/src/main/java/com/funeat/exception/CommonErrorCode.java +++ b/backend/src/main/java/com/funeat/exception/CommonErrorCode.java @@ -6,7 +6,6 @@ public enum CommonErrorCode { UNKNOWN_SERVER_ERROR_CODE(HttpStatus.INTERNAL_SERVER_ERROR, "알 수 없는 에러입니다.", "0000"), REQUEST_VALID_ERROR_CODE(HttpStatus.BAD_REQUEST, "요청을 다시 확인해주세요.", "0001"), - IMAGE_VALID_ERROR_CODE(HttpStatus.BAD_REQUEST, "이미지를 다시 확인해주세요.", "0002"), ; private final HttpStatus status; diff --git a/backend/src/main/java/com/funeat/exception/CommonException.java b/backend/src/main/java/com/funeat/exception/CommonException.java deleted file mode 100644 index 4a6d0def5..000000000 --- a/backend/src/main/java/com/funeat/exception/CommonException.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.funeat.exception; - -import org.springframework.http.HttpStatus; - -public class CommonException extends GlobalException { - - public CommonException(final HttpStatus status, final ErrorCode errorCode) { - super(status, errorCode); - } - - public static class ImageNotExistException extends CommonException { - public ImageNotExistException(final CommonErrorCode errorCode) { - super(errorCode.getStatus(), new ErrorCode<>(errorCode.getCode(), errorCode.getMessage())); - } - } -} diff --git a/backend/src/main/java/com/funeat/member/application/MemberService.java b/backend/src/main/java/com/funeat/member/application/MemberService.java index ee92dead5..83ccc96b2 100644 --- a/backend/src/main/java/com/funeat/member/application/MemberService.java +++ b/backend/src/main/java/com/funeat/member/application/MemberService.java @@ -1,12 +1,10 @@ package com.funeat.member.application; -import static com.funeat.exception.CommonErrorCode.IMAGE_VALID_ERROR_CODE; import static org.springframework.transaction.annotation.Propagation.REQUIRES_NEW; import com.funeat.auth.dto.SignUserDto; import com.funeat.auth.dto.UserInfoDto; import com.funeat.common.ImageService; -import com.funeat.exception.CommonException.ImageNotExistException; import com.funeat.member.domain.Member; import com.funeat.member.dto.MemberProfileResponse; import com.funeat.member.dto.MemberRequest; @@ -55,24 +53,18 @@ public MemberProfileResponse getMemberProfile(final Long memberId) { @Transactional public void modify(final Long memberId, final MultipartFile image, final MemberRequest request) { - checkExistImage(image); final Member findMember = memberRepository.findById(memberId) .orElseThrow(() -> new MemberNotFoundException(MemberErrorCode.MEMBER_NOT_FOUND, memberId)); final String nickname = request.getNickname(); - final String newImageName = imageService.getRandomImageName(image); - if (findMember.isSameImage(image.getOriginalFilename())) { - findMember.modifyProfile(nickname, image.getOriginalFilename()); + if (Objects.isNull(image)) { + findMember.modifyName(nickname); return; } + + final String newImageName = imageService.getRandomImageName(image); findMember.modifyProfile(nickname, newImageName); imageService.upload(image, newImageName); } - - private void checkExistImage(final MultipartFile image) { - if (Objects.isNull(image)) { - throw new ImageNotExistException(IMAGE_VALID_ERROR_CODE); - } - } } diff --git a/backend/src/main/java/com/funeat/member/domain/Member.java b/backend/src/main/java/com/funeat/member/domain/Member.java index 2b3950965..82fa4050b 100644 --- a/backend/src/main/java/com/funeat/member/domain/Member.java +++ b/backend/src/main/java/com/funeat/member/domain/Member.java @@ -74,7 +74,7 @@ public void modifyProfile(final String nickname, final String profileImage) { this.profileImage = profileImage; } - public boolean isSameImage(final String profileImage) { - return profileImage.equals(profileImage); + public void modifyName(final String nickname) { + this.nickname = nickname; } } diff --git a/backend/src/test/java/com/funeat/member/application/MemberServiceTest.java b/backend/src/test/java/com/funeat/member/application/MemberServiceTest.java index 6eb2ea802..a6532a6f2 100644 --- a/backend/src/test/java/com/funeat/member/application/MemberServiceTest.java +++ b/backend/src/test/java/com/funeat/member/application/MemberServiceTest.java @@ -8,8 +8,6 @@ import com.funeat.auth.dto.UserInfoDto; import com.funeat.common.ServiceTest; -import com.funeat.exception.CommonException.ImageNotExistException; -import com.funeat.member.domain.Member; import com.funeat.member.dto.MemberProfileResponse; import com.funeat.member.dto.MemberRequest; import com.funeat.member.exception.MemberException.MemberNotFoundException; @@ -272,18 +270,5 @@ class modify_실패_테스트 { assertThatThrownBy(() -> memberService.modify(memberId, image, request)) .isInstanceOf(MemberUpdateException.class); } - - @Test - void 프로필_이미지_요청_값을_null로_설정하면_예외가_발생해야_하지만_통과하고_있다() { - // given - final var member = new Member("before", "test.jpg", "1"); - final var memberId = 단일_멤버_저장(member); - - final var request = new MemberRequest("test"); - - // when & then - assertThatThrownBy(() -> memberService.modify(memberId, null, request)) - .isInstanceOf(ImageNotExistException.class); - } } }