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.tags.Tag;
import lombok.RequiredArgsConstructor;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
@ -48,7 +46,7 @@ public class CanvasStatusController {
@Operation(description = "견적서를 삭제 한다.")
@DeleteMapping("/canvas-statuses/by-object/{objectNo}")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void deleteObjectNoCanvasStatus(@PathVariable String objectNo) {
public void deleteObjectNoCanvasStatus(@PathVariable String objectNo) throws QcastException {
canvasStatusService.deleteObjectNoCanvasStatus(objectNo);
}

View File

@ -7,18 +7,18 @@ import com.interplug.qcast.config.Exception.CanvasStatusException;
import lombok.RequiredArgsConstructor;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor
public class CanvasStatusService {
private final CanvasStatusMapper canvasStatusMapper;
private final CanvasStatusMapper canvasStatusMapper;
// 전체 견적서 조회
public List<CanvasStatusResponse> selectAllCanvasStatus(String userId) {
return canvasStatusMapper.selectAllCanvasStatus(userId);
}
// 전체 견적서 조회
public List<CanvasStatusResponse> selectAllCanvasStatus(String userId) {
return canvasStatusMapper.selectAllCanvasStatus(userId);
}
// 견적서 조회(objectNo)
public List<CanvasStatusResponse> selectObjectNoCanvasStatus(String objectNo, String userId) {

View File

@ -2,20 +2,30 @@ package com.interplug.qcast.config.Exception;
import java.io.Serial;
public class BaseException extends Exception{
public class BaseException extends Exception {
@Serial
private static final long serialVersionUID = 6263785244527827114L;
@Serial private static final long serialVersionUID = 6263785244527827114L;
public BaseException() {
super();
}
private ErrorCode errorCode;
public BaseException(String message) {
super(message);
}
public BaseException() {
super();
}
public BaseException(Throwable cause) {
super(cause);
}
public BaseException(String message) {
super(message);
}
public BaseException(ErrorCode errorCode, String message) {
super(message);
this.errorCode = errorCode;
}
public BaseException(Throwable 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);
}
}