Skip to content

Commit

Permalink
예외 처리 수정 및 update 메서드 매개변수 수정 완료 (Fastcampus-Final-Team3#176)
Browse files Browse the repository at this point in the history
* refactor : Exception Handler & API 응답 클래스 리팩토링으로 인한 예외 처리 수정 (Fastcampus-Final-Team3#175)

* refactor : Exception Handler & API 응답 클래스 리팩토링으로 인한 예외 처리 수정 (Fastcampus-Final-Team3#175)

* refactor : 예외 처리 변경으로 인한 불 필요한 클래스 삭제 (Fastcampus-Final-Team3#175)

* refactor : entity 클래스에서 update 메서드의 인자를 dto 클래스로 변경 (Fastcampus-Final-Team3#175)
  • Loading branch information
dpdmstjs authored Oct 20, 2023
1 parent 92c0694 commit b7aafaa
Show file tree
Hide file tree
Showing 65 changed files with 137 additions and 1,293 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

import org.springframework.data.repository.Repository;

import com.javajober.core.error.exception.Exception404;
import com.javajober.core.message.ErrorMessage;
import com.javajober.backgroundSetting.domain.BackgroundSetting;
import com.javajober.exception.ApiStatus;
import com.javajober.exception.ApplicationException;

public interface BackgroundSettingRepository extends Repository<BackgroundSetting, Long> {

Expand All @@ -16,6 +16,6 @@ public interface BackgroundSettingRepository extends Repository<BackgroundSettin

default BackgroundSetting getById (final Long id) {
return findById(id)
.orElseThrow(() -> new Exception404(ErrorMessage.NOT_FOUND));
.orElseThrow(() -> new ApplicationException(ApiStatus.NOT_FOUND, "블록 설정 데이터를 찾을 수 없습니다."));
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import javax.persistence.*;
import java.time.LocalDateTime;

import com.javajober.blockSetting.dto.request.BlockSettingUpdateRequest;

@Getter
@Table(name = "block_setting")
@EntityListeners(AuditingEntityListener.class)
Expand Down Expand Up @@ -54,10 +56,10 @@ public BlockSetting(final String shape, final String style, final String styleCo
this.gradation = gradation;
}

public void update(final String shape, final String style, final String styleColor, final Boolean gradation) {
this.shape = shape;
this.style = style;
this.styleColor = styleColor;
this.gradation = gradation;
public void update(final BlockSettingUpdateRequest request) {
this.shape = request.getShape();
this.style = request.getStyle();
this.styleColor = request.getStyleColor();
this.gradation = request.getGradation();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

import org.springframework.data.repository.Repository;

import com.javajober.core.error.exception.Exception404;
import com.javajober.core.message.ErrorMessage;
import com.javajober.blockSetting.domain.BlockSetting;
import com.javajober.exception.ApiStatus;
import com.javajober.exception.ApplicationException;

public interface BlockSettingRepository extends Repository<BlockSetting, Long> {

Expand All @@ -16,6 +16,6 @@ public interface BlockSettingRepository extends Repository<BlockSetting, Long> {

default BlockSetting getById (final Long id) {
return findById(id)
.orElseThrow(() -> new Exception404(ErrorMessage.NOT_FOUND));
.orElseThrow(() -> new ApplicationException(ApiStatus.NOT_FOUND, "블록 설정 데이터를 찾을 수 없습니다."));
}
}
15 changes: 7 additions & 8 deletions src/main/java/com/javajober/core/component/FileImageService.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.javajober.core.component;

import com.javajober.core.config.FileDirectoryConfig;
import com.javajober.core.error.exception.Exception404;
import com.javajober.core.error.exception.Exception500;
import com.javajober.core.message.ErrorMessage;
import com.javajober.exception.ApiStatus;
import com.javajober.exception.ApplicationException;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;

Expand All @@ -27,15 +26,15 @@ public String uploadFile(final MultipartFile file) {
return null;
}
if (file.getOriginalFilename() == null) {
throw new Exception404(ErrorMessage.INVALID_FILE_NAME);
throw new ApplicationException(ApiStatus.NOT_FOUND, "이름이 없는 파일입니다.");
}
String fileName = UUID.randomUUID() + "_" + file.getOriginalFilename();
String fileUploadPath = getDirectoryPath() + fileName;

try {
file.transferTo(new File(fileUploadPath));
} catch (IOException e) {
throw new Exception500(ErrorMessage.FILE_UPLOAD_FAILED);
throw new ApplicationException(ApiStatus.IO_EXCEPTION, "파일 업로드 중 실패하였습니다.");
}
return fileName;
}
Expand All @@ -48,15 +47,15 @@ public void validatePdfFile(final List<MultipartFile> files) {

for (MultipartFile file : files) {
if (file == null || file.isEmpty()) {
throw new Exception404(ErrorMessage.FILE_IS_EMPTY);
throw new ApplicationException(ApiStatus.INVALID_DATA, "업로드할 파일이 없습니다.");
}
String originalFilename = file.getOriginalFilename();
if (originalFilename == null) {
throw new Exception404(ErrorMessage.INVALID_FILE_NAME);
throw new ApplicationException(ApiStatus.NOT_FOUND, "이름이 없는 파일입니다.");
}
int dotIndex = originalFilename.lastIndexOf('.');
if (dotIndex < 0 || !(originalFilename.substring(dotIndex + 1).equalsIgnoreCase("pdf"))) {
throw new Exception404(ErrorMessage.INVALID_FILE_TYPE);
throw new ApplicationException(ApiStatus.INVALID_DATA, "첨부 파일은 pdf만 가능합니다.");
}
}
}
Expand Down

This file was deleted.

31 changes: 0 additions & 31 deletions src/main/java/com/javajober/core/error/exception/Exception400.java

This file was deleted.

18 changes: 0 additions & 18 deletions src/main/java/com/javajober/core/error/exception/Exception401.java

This file was deleted.

21 changes: 0 additions & 21 deletions src/main/java/com/javajober/core/error/exception/Exception403.java

This file was deleted.

24 changes: 0 additions & 24 deletions src/main/java/com/javajober/core/error/exception/Exception404.java

This file was deleted.

22 changes: 0 additions & 22 deletions src/main/java/com/javajober/core/error/exception/Exception500.java

This file was deleted.

7 changes: 4 additions & 3 deletions src/main/java/com/javajober/core/fcm/FcmInitializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
import com.google.auth.oauth2.GoogleCredentials;
import com.google.firebase.FirebaseApp;
import com.google.firebase.FirebaseOptions;
import com.javajober.core.error.exception.Exception500;
import com.javajober.core.message.ErrorMessage;
import com.javajober.exception.ApiStatus;
import com.javajober.exception.ApplicationException;

import org.springframework.beans.factory.annotation.Value;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.io.ClassPathResource;
Expand Down Expand Up @@ -36,7 +37,7 @@ public void initialize() {

} catch (IOException e) {
log.error("FCM initialization ERROR {}", e.getMessage());
throw new Exception500(ErrorMessage.FCM_INITIALIZATION_FAILED);
throw new ApplicationException(ApiStatus.IO_EXCEPTION, "FCM 초기화에 실패하였습니다.");
}
}
}
Loading

0 comments on commit b7aafaa

Please sign in to comment.