Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Study Controller, Service 추가 #11

Merged
merged 22 commits into from
Feb 4, 2025
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
22dd9b1
feat: 스터디 생성 기능 추가
ybkang1108 Jan 16, 2025
90ad73f
feat: StudyCreateResponse DTO 추가
ybkang1108 Jan 16, 2025
2ea0826
feat: 스터디 전체 목록 조회 기능 추가
ybkang1108 Jan 16, 2025
3310c20
feat: 스터디 정보 조회 기능 추가
ybkang1108 Jan 16, 2025
b700946
feat: 스터디 삭제 기능 추가
ybkang1108 Jan 16, 2025
e99cab5
refactor: delete, detail response dto수정 및 cascade 설정
ybkang1108 Jan 17, 2025
52858dc
feat: 스터디 수정 기능 추가
ybkang1108 Jan 17, 2025
33b6e77
refactor: response에 메시지 제거
ybkang1108 Jan 17, 2025
baf1a6e
refactor: dto를 record로 변경
ybkang1108 Jan 21, 2025
e45b8ad
feat: exception 추가
ybkang1108 Jan 21, 2025
a412bbf
refactor: curriculum 수정
ybkang1108 Jan 22, 2025
2a4f89f
feat: day에 create 추가
ybkang1108 Jan 22, 2025
d864b11
refactor: record로 변경
ybkang1108 Jan 22, 2025
eb57a8f
feat: custom exception 추가
ybkang1108 Jan 22, 2025
6633caf
refactor: record로 변경
ybkang1108 Jan 22, 2025
047112b
feat: study 도메인에 create, update 추가
ybkang1108 Jan 22, 2025
2ce3d78
refactor: study service 수정
ybkang1108 Jan 22, 2025
889051a
refactor: study controller 수정
ybkang1108 Jan 22, 2025
ee5864b
refactor: springdoc 버전 수정
ybkang1108 Jan 23, 2025
ff5eb99
refactor: 불필요한 생성자 제거
ybkang1108 Jan 24, 2025
31ad47d
refactor: create, update 메소드 도메인으로 이동
ybkang1108 Jan 24, 2025
872757d
fix: 잘못된 로직 수정
ybkang1108 Jan 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: exception 추가
ybkang1108 committed Jan 21, 2025
commit e45b8ad795055b8ce08001e6664c9397bd54c271
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
package com.gdgoc.study_group.exception;

public class CustomException {
import lombok.Getter;

@Getter
public class CustomException extends RuntimeException {

private final ErrorCode errorCode;

public CustomException(ErrorCode errorCode) {
super(errorCode.getMessage());
this.errorCode = errorCode;
}

public CustomException(ErrorCode errorCode, String errorMessage) {
super(errorMessage);
this.errorCode = errorCode;
}
}
12 changes: 11 additions & 1 deletion src/main/java/com/gdgoc/study_group/exception/ErrorCode.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
package com.gdgoc.study_group.exception;

public class ErrorCode {
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.http.HttpStatus;

@Getter
@AllArgsConstructor
public enum ErrorCode {
INTERNAL_SERVER_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "내부 서버 에러가 발생했습니다."),
;
private final HttpStatus status;
private final String message;
}
14 changes: 13 additions & 1 deletion src/main/java/com/gdgoc/study_group/exception/ErrorResponse.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
package com.gdgoc.study_group.exception;

public class ErrorResponse {
public record ErrorResponse (String errorCodeName, String errorMessage){

public static ErrorResponse of(ErrorCode errorCode) {
return new ErrorResponse(errorCode.name(), errorCode.getMessage());
}

public static ErrorResponse of(ErrorCode errorCode, String errorMessage) {
return new ErrorResponse(errorCode.name(), errorMessage);
}

public static ErrorResponse of(String errorCodeName, String errorMessage) {
return new ErrorResponse(errorCodeName, errorMessage);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
package com.gdgoc.study_group.exception;

public class GlobalExceptionHandler {
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;

@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler extends ResponseEntityExceptionHandler {

@ExceptionHandler(CustomException.class)
public ResponseEntity<ErrorResponse> handleCustomException(CustomException e) {
log.info("CustomException : {}", e.getMessage());
return ResponseEntity.status(e.getErrorCode().getStatus()).body(ErrorResponse.of(e.getErrorCode()));
}

@ExceptionHandler(Exception.class)
public ResponseEntity<ErrorResponse> handleException(Exception e) {
log.error("INTERNAL_SERVER_ERROR : {}", e.getMessage());
return ResponseEntity.status(ErrorCode.INTERNAL_SERVER_ERROR.getStatus())
.body(ErrorResponse.of(ErrorCode.INTERNAL_SERVER_ERROR));
}
}