Auto stash before merge of "dev" and "origin/dev"

This commit is contained in:
yoosangwook 2024-09-30 15:43:19 +09:00
parent 0271a145c9
commit c7c90a2a5d
7 changed files with 114 additions and 22 deletions

View File

@ -6,10 +6,8 @@ import com.interplug.qcast.config.Exception.CanvasStatusException;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import java.util.List; import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -48,7 +46,7 @@ public class CanvasStatusController {
@Operation(description = "견적서를 삭제 한다.") @Operation(description = "견적서를 삭제 한다.")
@DeleteMapping("/canvas-statuses/by-object/{objectNo}") @DeleteMapping("/canvas-statuses/by-object/{objectNo}")
@ResponseStatus(HttpStatus.NO_CONTENT) @ResponseStatus(HttpStatus.NO_CONTENT)
public void deleteObjectNoCanvasStatus(@PathVariable String objectNo) { public void deleteObjectNoCanvasStatus(@PathVariable String objectNo) throws QcastException {
canvasStatusService.deleteObjectNoCanvasStatus(objectNo); canvasStatusService.deleteObjectNoCanvasStatus(objectNo);
} }

View File

@ -7,7 +7,7 @@ import com.interplug.qcast.config.Exception.CanvasStatusException;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import java.util.List; import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@Service @Service

View File

@ -4,8 +4,9 @@ import java.io.Serial;
public class BaseException extends Exception { public class BaseException extends Exception {
@Serial @Serial private static final long serialVersionUID = 6263785244527827114L;
private static final long serialVersionUID = 6263785244527827114L;
private ErrorCode errorCode;
public BaseException() { public BaseException() {
super(); super();
@ -15,7 +16,16 @@ public class BaseException extends Exception{
super(message); super(message);
} }
public BaseException(ErrorCode errorCode, String message) {
super(message);
this.errorCode = errorCode;
}
public BaseException(Throwable cause) { public BaseException(Throwable cause) {
super(cause); super(cause);
} }
public ErrorCode getErrorCode() {
return errorCode;
}
} }

View File

@ -0,0 +1,20 @@
package com.interplug.qcast.config.Exception;
import lombok.Getter;
import org.springframework.http.HttpStatus;
@Getter
public enum ErrorCode {
INVALID_INPUT_VALUE(HttpStatus.BAD_REQUEST, "올바르지 않은 입력값입니다."),
METHOD_NOT_ALLOWED(HttpStatus.METHOD_NOT_ALLOWED, "허용되지 않은 메소드입니다."),
INTERNAL_SERVER_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "서버에러입니다."),
NOT_FOUND(HttpStatus.NOT_FOUND, "데이터를 찾을 수 없습니다.");
private final String message;
private final HttpStatus status;
ErrorCode(final HttpStatus status, final String message) {
this.status = status;
this.message = message;
}
}

View File

@ -0,0 +1,19 @@
package com.interplug.qcast.config.Exception;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class ErrorResponse {
private String message;
public ErrorResponse(String message) {
this.message = message;
}
public static ErrorResponse of(String message) {
return new ErrorResponse(message);
}
}

View File

@ -0,0 +1,30 @@
package com.interplug.qcast.config.Exception;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
@Slf4j
@ControllerAdvice
public class GlobalExceptionHandler {
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
protected ResponseEntity<ErrorResponse> handle(HttpRequestMethodNotSupportedException e) {
return ResponseEntity.badRequest()
.body(ErrorResponse.of(ErrorCode.METHOD_NOT_ALLOWED.getMessage()));
}
@ExceptionHandler(BaseException.class)
protected ResponseEntity<ErrorResponse> handle(BaseException e) {
final ErrorCode errorCode = e.getErrorCode();
return ResponseEntity.status(errorCode.getStatus())
.body(ErrorResponse.of(errorCode.getMessage()));
}
@ExceptionHandler(Exception.class)
protected ResponseEntity<ErrorResponse> handle(Exception e) {
return ResponseEntity.internalServerError()
.body(ErrorResponse.of(ErrorCode.INTERNAL_SERVER_ERROR.getMessage()));
}
}

View File

@ -0,0 +1,15 @@
package com.interplug.qcast.config.Exception;
public class QcastException extends BaseException {
public QcastException() {
super();
}
public QcastException(ErrorCode errorCode) {
super(errorCode, errorCode.getMessage());
}
public QcastException(ErrorCode errorCode, String message) {
super(errorCode, message);
}
}