Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package leets.weeth.domain.account.application.exception;

import leets.weeth.global.common.exception.ErrorCodeInterface;
import leets.weeth.global.common.exception.ExplainError;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.http.HttpStatus;

@Getter
@AllArgsConstructor
public enum AccountErrorCode implements ErrorCodeInterface {

@ExplainError("요청한 회비 장부 ID가 존재하지 않을 때 발생합니다.")
ACCOUNT_NOT_FOUND(404, HttpStatus.NOT_FOUND, "존재하지 않는 장부입니다."),

@ExplainError("이미 존재하는 장부를 중복 생성하려고 할 때 발생합니다.")
ACCOUNT_EXISTS(400, HttpStatus.BAD_REQUEST, "이미 생성된 장부입니다."),

@ExplainError("요청한 영수증 내역이 존재하지 않을 때 발생합니다.")
RECEIPT_NOT_FOUND(404, HttpStatus.NOT_FOUND, "존재하지 않는 내역입니다.");

private final int code;
private final HttpStatus status;
private final String message;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import leets.weeth.global.common.exception.BusinessLogicException;

public class AccountExistsException extends BusinessLogicException {
public AccountExistsException() { super(400, "이미 생성된 장부입니다.");}
public AccountExistsException() {
super(AccountErrorCode.ACCOUNT_EXISTS);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
import leets.weeth.global.common.exception.BusinessLogicException;

public class AccountNotFoundException extends BusinessLogicException {
public AccountNotFoundException() {super(404, "존재하지 않는 장부입니다.");}
public AccountNotFoundException() {
super(AccountErrorCode.ACCOUNT_NOT_FOUND);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import leets.weeth.global.common.exception.BusinessLogicException;

public class ReceiptNotFoundException extends BusinessLogicException {
public ReceiptNotFoundException() { super(404, "존재하지 않는 내역입니다.");}
public ReceiptNotFoundException() {
super(AccountErrorCode.RECEIPT_NOT_FOUND);
}
}

Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
package leets.weeth.domain.account.presentation;

import static leets.weeth.domain.account.presentation.ResponseMessage.ACCOUNT_SAVE_SUCCESS;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import leets.weeth.domain.account.application.dto.AccountDTO;
import leets.weeth.domain.account.application.exception.AccountErrorCode;
import leets.weeth.domain.account.application.usecase.AccountUseCase;
import leets.weeth.global.common.exception.ApiErrorCodeExample;
import leets.weeth.global.common.response.CommonResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import static leets.weeth.domain.account.presentation.ResponseMessage.ACCOUNT_SAVE_SUCCESS;

@Tag(name = "ACCOUNT ADMIN", description = "[ADMIN] 회비 어드민 API")
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/v1/admin/account")
@ApiErrorCodeExample(AccountErrorCode.class)
public class AccountAdminController {

private final AccountUseCase accountUseCase;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
package leets.weeth.domain.account.presentation;

import static leets.weeth.domain.account.presentation.ResponseMessage.ACCOUNT_FIND_SUCCESS;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import leets.weeth.domain.account.application.dto.AccountDTO;
import leets.weeth.domain.account.application.exception.AccountErrorCode;
import leets.weeth.domain.account.application.usecase.AccountUseCase;
import leets.weeth.global.common.exception.ApiErrorCodeExample;
import leets.weeth.global.common.response.CommonResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import static leets.weeth.domain.account.presentation.ResponseMessage.ACCOUNT_FIND_SUCCESS;
@Tag(name = "ACCOUNT", description = "회비 API")
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/v1/account")
@ApiErrorCodeExample(AccountErrorCode.class)
public class AccountController {

private final AccountUseCase accountUseCase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import leets.weeth.domain.account.application.dto.ReceiptDTO;
import leets.weeth.domain.account.application.exception.AccountErrorCode;
import leets.weeth.domain.account.application.usecase.ReceiptUseCase;
import leets.weeth.global.common.exception.ApiErrorCodeExample;
import leets.weeth.global.common.response.CommonResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
Expand All @@ -14,6 +16,7 @@
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/v1/admin/receipts")
@ApiErrorCodeExample(AccountErrorCode.class)
public class ReceiptAdminController {

private final ReceiptUseCase receiptUseCase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
import leets.weeth.global.common.exception.BusinessLogicException;

public class AttendanceCodeMismatchException extends BusinessLogicException {
public AttendanceCodeMismatchException() {super(400 ,"출석 코드가 일치하지 않습니다.");}
}
public AttendanceCodeMismatchException() {
super(AttendanceErrorCode.ATTENDANCE_CODE_MISMATCH);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package leets.weeth.domain.attendance.application.exception;

import leets.weeth.global.common.exception.ErrorCodeInterface;
import leets.weeth.global.common.exception.ExplainError;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.http.HttpStatus;

@Getter
@AllArgsConstructor
public enum AttendanceErrorCode implements ErrorCodeInterface {

@ExplainError("출석 정보를 찾을 수 없을 때 발생합니다.")
ATTENDANCE_NOT_FOUND(404, HttpStatus.NOT_FOUND, "출석 정보가 존재하지 않습니다."),

@ExplainError("입력한 출석 코드가 생성된 코드와 일치하지 않을 때 발생합니다.")
ATTENDANCE_CODE_MISMATCH(400, HttpStatus.BAD_REQUEST, "출석 코드가 일치하지 않습니다."),

@ExplainError("사용자가 출석 일정을 직접 수정하려고 시도할 때 발생합니다. (출석 로직 위반)")
ATTENDANCE_EVENT_TYPE_NOT_MATCH(400, HttpStatus.BAD_REQUEST, "출석일정은 직접 수정할 수 없습니다.");

private final int code;
private final HttpStatus status;
private final String message;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
import leets.weeth.global.common.exception.BusinessLogicException;

public class AttendanceEventTypeNotMatchException extends BusinessLogicException {
public AttendanceEventTypeNotMatchException() {super(400, "출석일정은 직접 수정할 수 없습니다.");}
public AttendanceEventTypeNotMatchException() {
super(AttendanceErrorCode.ATTENDANCE_EVENT_TYPE_NOT_MATCH);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
import leets.weeth.global.common.exception.BusinessLogicException;

public class AttendanceNotFoundException extends BusinessLogicException {
public AttendanceNotFoundException() {super(404, "출석 정보가 존재하지 않습니다.");}
}
public AttendanceNotFoundException() {
super(AttendanceErrorCode.ATTENDANCE_NOT_FOUND);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import leets.weeth.domain.attendance.application.dto.AttendanceDTO;
import leets.weeth.domain.attendance.application.exception.AttendanceErrorCode;
import leets.weeth.domain.attendance.application.usecase.AttendanceUseCase;
import leets.weeth.domain.schedule.application.dto.MeetingDTO;
import leets.weeth.domain.schedule.application.usecase.MeetingUseCase;
import leets.weeth.global.common.exception.ApiErrorCodeExample;
import leets.weeth.global.common.response.CommonResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
Expand All @@ -20,6 +22,7 @@
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/v1/admin/attendances")
@ApiErrorCodeExample(AttendanceErrorCode.class)
public class AttendanceAdminController {

private final AttendanceUseCase attendanceUseCase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import leets.weeth.domain.attendance.application.dto.AttendanceDTO;
import leets.weeth.domain.attendance.application.exception.AttendanceErrorCode;
import leets.weeth.domain.attendance.application.usecase.AttendanceUseCase;
import leets.weeth.global.auth.annotation.CurrentUser;
import leets.weeth.domain.attendance.application.exception.AttendanceCodeMismatchException;
import leets.weeth.global.common.exception.ApiErrorCodeExample;
import leets.weeth.global.common.response.CommonResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
Expand All @@ -20,6 +22,7 @@
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/v1/attendances")
@ApiErrorCodeExample(AttendanceErrorCode.class)
public class AttendanceController {

private final AttendanceUseCase attendanceUseCase;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package leets.weeth.domain.board.application.exception;

import leets.weeth.global.common.exception.ErrorCodeInterface;
import leets.weeth.global.common.exception.ExplainError;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.http.HttpStatus;

@Getter
@AllArgsConstructor
public enum BoardErrorCode implements ErrorCodeInterface {

@ExplainError("검색 조건에 맞는 게시글이 하나도 없을 때 발생합니다.")
NO_SEARCH_RESULT(404, HttpStatus.NOT_FOUND, "일치하는 검색 결과를 찾을 수 없습니다."),

@ExplainError("요청한 페이지 번호가 유효 범위를 벗어났을 때 발생합니다.")
PAGE_NOT_FOUND(404, HttpStatus.NOT_FOUND, "존재하지 않는 페이지입니다."),

@ExplainError("일반 유저가 어드민 전용 카테고리에 접근하려 할 때 발생합니다.")
CATEGORY_ACCESS_DENIED(403, HttpStatus.FORBIDDEN, "어드민 유저만 접근 가능한 카테고리입니다");

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이제 적용되는 새로운 예외 컨벤션은 application/exception 계층에 위와같이 추가하고 예외클래스를 만들어 호출하면 되는 거 맞겠죠!?

private final int code;
private final HttpStatus status;
private final String message;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

public class CategoryAccessDeniedException extends BusinessLogicException {
public CategoryAccessDeniedException() {
super(403, "어드민 유저만 접근 가능한 카테고리입니다");
super(BoardErrorCode.CATEGORY_ACCESS_DENIED);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import leets.weeth.global.common.exception.BusinessLogicException;

public class NoSearchResultException extends BusinessLogicException {
public NoSearchResultException(){
super(404, "일치하는 검색 결과를 찾을 수 없습니다.");
public NoSearchResultException() {
super(BoardErrorCode.NO_SEARCH_RESULT);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package leets.weeth.domain.board.application.exception;

import leets.weeth.global.common.exception.ErrorCodeInterface;
import leets.weeth.global.common.exception.ExplainError;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.http.HttpStatus;

@Getter
@AllArgsConstructor
public enum NoticeErrorCode implements ErrorCodeInterface {

@ExplainError("요청한 공지사항 ID에 해당하는 공지사항이 없을 때 발생합니다.")
NOTICE_NOT_FOUND(404, HttpStatus.NOT_FOUND, "존재하지 않는 공지사항입니다."),

@ExplainError("일반 게시판에서 공지사항을 수정하려 하거나, 그 반대의 경우 발생합니다.")
NOTICE_TYPE_NOT_MATCH(400, HttpStatus.BAD_REQUEST, "공지사항은 공지사항 게시판에서 수정하세요.");

private final int code;
private final HttpStatus status;
private final String message;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
import leets.weeth.global.common.exception.BusinessLogicException;

public class NoticeNotFoundException extends BusinessLogicException {
public NoticeNotFoundException() {super(404, "존재하지 않는 공지사항입니다.");}
public NoticeNotFoundException() {
super(NoticeErrorCode.NOTICE_NOT_FOUND);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
import leets.weeth.global.common.exception.BusinessLogicException;

public class NoticeTypeNotMatchException extends BusinessLogicException {
public NoticeTypeNotMatchException() {super(400, "공지사항은 공지사항 게시판에서 수정하세요.");}
public NoticeTypeNotMatchException() {
super(NoticeErrorCode.NOTICE_TYPE_NOT_MATCH);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

public class PageNotFoundException extends BusinessLogicException {
public PageNotFoundException() {
super(404, "존재하지 않는 페이지입니다.");

super(BoardErrorCode.PAGE_NOT_FOUND);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package leets.weeth.domain.board.application.exception;

import leets.weeth.global.common.exception.ErrorCodeInterface;
import leets.weeth.global.common.exception.ExplainError;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.http.HttpStatus;

@Getter
@AllArgsConstructor
public enum PostErrorCode implements ErrorCodeInterface {

@ExplainError("요청한 게시글 ID에 해당하는 게시글이 없을 때 발생합니다.")
POST_NOT_FOUND(404, HttpStatus.NOT_FOUND, "존재하지 않는 게시물입니다.");

private final int code;
private final HttpStatus status;
private final String message;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

public class PostNotFoundException extends BusinessLogicException {
public PostNotFoundException() {
super(404, "존재하지 않는 게시물입니다.");
super(PostErrorCode.POST_NOT_FOUND);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import leets.weeth.domain.board.application.dto.PostDTO;
import leets.weeth.domain.board.application.exception.BoardErrorCode;
import leets.weeth.domain.board.application.exception.PostErrorCode;
import leets.weeth.domain.board.application.usecase.PostUsecase;
import leets.weeth.domain.user.application.exception.UserNotMatchException;
import leets.weeth.global.auth.annotation.CurrentUser;
import leets.weeth.global.common.exception.ApiErrorCodeExample;
import leets.weeth.global.common.response.CommonResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
Expand All @@ -19,6 +22,7 @@
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/v1/admin/educations")
@ApiErrorCodeExample({BoardErrorCode.class, PostErrorCode.class})
public class EducationAdminController {
private final PostUsecase postUsecase;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import leets.weeth.domain.board.application.dto.NoticeDTO;
import leets.weeth.domain.board.application.exception.BoardErrorCode;
import leets.weeth.domain.board.application.exception.NoticeErrorCode;
import leets.weeth.domain.board.application.usecase.NoticeUsecase;
import leets.weeth.domain.user.application.exception.UserNotMatchException;
import leets.weeth.global.auth.annotation.CurrentUser;
import leets.weeth.global.common.exception.ApiErrorCodeExample;
import leets.weeth.global.common.response.CommonResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
Expand All @@ -18,6 +21,7 @@
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/v1/admin/notices")
@ApiErrorCodeExample({BoardErrorCode.class, NoticeErrorCode.class})
public class NoticeAdminController {

private final NoticeUsecase noticeUsecase;
Expand Down
Loading