Skip to content

Commit

Permalink
fix(GlobalExceptionHandler): 정렬기준으로 존재하지 않은 칼럼을 지정한 경우 InvalidColumnE…
Browse files Browse the repository at this point in the history
…xception을 발생시키고 핸들러에 등록 #354
  • Loading branch information
mingmingmon committed May 26, 2024
1 parent b3f7cdc commit 22def75
Show file tree
Hide file tree
Showing 31 changed files with 96 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import page.clab.api.domain.accuse.dto.response.AccuseResponseDto;
import page.clab.api.global.common.dto.PagedResponseDto;
import page.clab.api.global.common.dto.ApiResponse;
import page.clab.api.global.exception.InvalidColumnException;
import page.clab.api.global.exception.SortingArgumentException;
import page.clab.api.global.util.PageableUtils;

Expand Down Expand Up @@ -63,7 +64,7 @@ public ApiResponse<PagedResponseDto<AccuseResponseDto>> getAccusesByConditions(
@RequestParam(name = "size", defaultValue = "20") int size,
@RequestParam(name = "sortBy", required = false) Optional<List<String>> sortBy,
@RequestParam(name = "sortDirection", required = false) Optional<List<String>> sortDirection
) throws SortingArgumentException {
) throws SortingArgumentException, InvalidColumnException {
List<String> sortByList = sortBy.orElse(List.of("createdAt"));
List<String> sortDirectionList = sortDirection.orElse(List.of("desc"));
Pageable pageable = PageableUtils.createPageable(page, size, sortByList, sortDirectionList, AccuseTarget.class);
Expand All @@ -79,7 +80,7 @@ public ApiResponse<PagedResponseDto<AccuseMyResponseDto>> getMyAccuses(
@RequestParam(name = "size", defaultValue = "20") int size,
@RequestParam(name = "sortBy", required = false) Optional<List<String>> sortBy,
@RequestParam(name = "sortDirection", required = false) Optional<List<String>> sortDirection
) throws SortingArgumentException {
) throws SortingArgumentException, InvalidColumnException {
List<String> sortByList = sortBy.orElse(List.of("createdAt"));
List<String> sortDirectionList = sortDirection.orElse(List.of("desc"));
Pageable pageable = PageableUtils.createPageable(page, size, sortByList, sortDirectionList, Accuse.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import page.clab.api.domain.award.dto.response.AwardResponseDto;
import page.clab.api.global.common.dto.PagedResponseDto;
import page.clab.api.global.common.dto.ApiResponse;
import page.clab.api.global.exception.InvalidColumnException;
import page.clab.api.global.exception.PermissionDeniedException;

import java.util.List;
Expand Down Expand Up @@ -121,7 +122,7 @@ public ApiResponse<PagedResponseDto<ActivityGroupMemberWithApplyReasonResponseDt
@RequestParam(name = "size", defaultValue = "20") int size,
@RequestParam(name = "sortBy", required = false) Optional<List<String>> sortBy,
@RequestParam(name = "sortDirection", required = false) Optional<List<String>> sortDirection
) throws SortingArgumentException, PermissionDeniedException {
) throws SortingArgumentException, PermissionDeniedException, InvalidColumnException {
List<String> sortByList = sortBy.orElse(List.of("memberId"));
List<String> sortDirectionList = sortDirection.orElse(List.of("asc"));
Pageable pageable = PageableUtils.createPageable(page, size, sortByList, sortDirectionList, GroupMember.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import page.clab.api.domain.award.dto.response.AwardResponseDto;
import page.clab.api.global.common.dto.PagedResponseDto;
import page.clab.api.global.common.dto.ApiResponse;
import page.clab.api.global.exception.InvalidColumnException;
import page.clab.api.global.exception.PermissionDeniedException;

import java.util.List;
Expand Down Expand Up @@ -71,7 +72,7 @@ public ApiResponse<PagedResponseDto<ActivityGroupBoardResponseDto>> getActivityG
@RequestParam(name = "size", defaultValue = "20") int size,
@RequestParam(name = "sortBy", required = false) Optional<List<String>> sortBy,
@RequestParam(name = "sortDirection", required = false) Optional<List<String>> sortDirection
) throws SortingArgumentException {
) throws SortingArgumentException, InvalidColumnException {
List<String> sortByList = sortBy.orElse(List.of("createdAt"));
List<String> sortDirectionList = sortDirection.orElse(List.of("desc"));
Pageable pageable = PageableUtils.createPageable(page, size, sortByList, sortDirectionList, ActivityGroupBoard.class);
Expand Down Expand Up @@ -99,7 +100,7 @@ public ApiResponse<PagedResponseDto<ActivityGroupBoardResponseDto>> getActivityG
@RequestParam(name = "size", defaultValue = "20") int size,
@RequestParam(name = "sortBy", required = false) Optional<List<String>> sortBy,
@RequestParam(name = "sortDirection", required = false) Optional<List<String>> sortDirection
) throws SortingArgumentException {
) throws SortingArgumentException, InvalidColumnException {
List<String> sortByList = sortBy.orElse(List.of("createdAt"));
List<String> sortDirectionList = sortDirection.orElse(List.of("desc"));
Pageable pageable = PageableUtils.createPageable(page, size, sortByList, sortDirectionList, ActivityGroupBoard.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import page.clab.api.domain.application.domain.Application;
import page.clab.api.global.common.dto.PagedResponseDto;
import page.clab.api.global.common.dto.ApiResponse;
import page.clab.api.global.exception.InvalidColumnException;
import page.clab.api.global.exception.SortingArgumentException;
import page.clab.api.global.util.PageableUtils;

Expand All @@ -50,7 +51,7 @@ public ApiResponse<PagedResponseDto<ActivityGroupResponseDto>> getActivityGroups
@RequestParam(name = "size", defaultValue = "20") int size,
@RequestParam(name = "sortBy", required = false) Optional<List<String>> sortBy,
@RequestParam(name = "sortDirection", required = false) Optional<List<String>> sortDirection
) throws SortingArgumentException {
) throws SortingArgumentException, InvalidColumnException {
List<String> sortByList = sortBy.orElse(List.of("createdAt"));
List<String> sortDirectionList = sortDirection.orElse(List.of("desc"));
Pageable pageable = PageableUtils.createPageable(page, size, sortByList, sortDirectionList, ActivityGroup.class);
Expand Down Expand Up @@ -100,7 +101,7 @@ public ApiResponse<PagedResponseDto<ActivityGroupResponseDto>> getActivityGroups
@RequestParam(name = "size", defaultValue = "20") int size,
@RequestParam(name = "sortBy", required = false) Optional<List<String>> sortBy,
@RequestParam(name = "sortDirection", required = false) Optional<List<String>> sortDirection
) throws SortingArgumentException {
) throws SortingArgumentException, InvalidColumnException {
List<String> sortByList = sortBy.orElse(List.of("createdAt"));
List<String> sortDirectionList = sortDirection.orElse(List.of("desc"));
Pageable pageable = PageableUtils.createPageable(page, size, sortByList, sortDirectionList, ActivityGroup.class);
Expand All @@ -117,7 +118,7 @@ public ApiResponse<PagedResponseDto<GroupScheduleDto>> getGroupScheduleList(
@RequestParam(name = "size", defaultValue = "20") int size,
@RequestParam(name = "sortBy", required = false) Optional<List<String>> sortBy,
@RequestParam(name = "sortDirection", required = false) Optional<List<String>> sortDirection
) throws SortingArgumentException {
) throws SortingArgumentException, InvalidColumnException {
List<String> sortByList = sortBy.orElse(List.of("id"));
List<String> sortDirectionList = sortDirection.orElse(List.of("desc"));
Pageable pageable = PageableUtils.createPageable(page, size, sortByList, sortDirectionList, GroupSchedule.class);
Expand All @@ -135,7 +136,7 @@ public ApiResponse<PagedResponseDto<GroupMemberResponseDto>> getActivityGroupMem
@RequestParam(name = "size", defaultValue = "20") int size,
@RequestParam(name = "sortBy", required = false) Optional<List<String>> sortBy,
@RequestParam(name = "sortDirection", required = false) Optional<List<String>> sortDirection
) throws SortingArgumentException {
) throws SortingArgumentException, InvalidColumnException {
List<String> sortByList = sortBy.orElse(List.of("memberId"));
List<String> sortDirectionList = sortDirection.orElse(List.of("asc"));
Pageable pageable = PageableUtils.createPageable(page, size, sortByList, sortDirectionList, GroupMember.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import page.clab.api.domain.application.domain.Application;
import page.clab.api.global.common.dto.ApiResponse;
import page.clab.api.global.common.dto.PagedResponseDto;
import page.clab.api.global.exception.InvalidColumnException;
import page.clab.api.global.exception.PermissionDeniedException;
import page.clab.api.global.exception.SortingArgumentException;
import page.clab.api.global.util.PageableUtils;
Expand Down Expand Up @@ -59,7 +60,7 @@ public ApiResponse<PagedResponseDto<ActivityGroupReportResponseDto>> getReports(
@RequestParam(name = "size", defaultValue = "20") int size,
@RequestParam(name = "sortBy", required = false) Optional<List<String>> sortBy,
@RequestParam(name = "sortDirection", required = false) Optional<List<String>> sortDirection
) throws SortingArgumentException {
) throws SortingArgumentException, InvalidColumnException {
List<String> sortByList = sortBy.orElse(List.of("createdAt"));
List<String> sortDirectionList = sortDirection.orElse(List.of("desc"));
Pageable pageable = PageableUtils.createPageable(page, size, sortByList, sortDirectionList, ActivityGroupReport.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import page.clab.api.domain.application.domain.Application;
import page.clab.api.global.common.dto.PagedResponseDto;
import page.clab.api.global.common.dto.ApiResponse;
import page.clab.api.global.exception.InvalidColumnException;
import page.clab.api.global.exception.PermissionDeniedException;

import java.io.IOException;
Expand Down Expand Up @@ -72,7 +73,7 @@ public ApiResponse<PagedResponseDto<AttendanceResponseDto>> searchMyAttendance(
@RequestParam(name = "size", defaultValue = "20") int size,
@RequestParam(name = "sortBy", required = false) Optional<List<String>> sortBy,
@RequestParam(name = "sortDirection", required = false) Optional<List<String>> sortDirection
) throws SortingArgumentException, IllegalAccessException {
) throws SortingArgumentException, IllegalAccessException, InvalidColumnException {
List<String> sortByList = sortBy.orElse(List.of("createdAt"));
List<String> sortDirectionList = sortDirection.orElse(List.of("desc"));
Pageable pageable = PageableUtils.createPageable(page, size, sortByList, sortDirectionList, Attendance.class);
Expand All @@ -89,7 +90,7 @@ public ApiResponse<PagedResponseDto<AttendanceResponseDto>> searchGroupAttendanc
@RequestParam(name = "size", defaultValue = "20") int size,
@RequestParam(name = "sortBy", required = false) Optional<List<String>> sortBy,
@RequestParam(name = "sortDirection", required = false) Optional<List<String>> sortDirection
) throws SortingArgumentException, PermissionDeniedException {
) throws SortingArgumentException, PermissionDeniedException, InvalidColumnException {
List<String> sortByList = sortBy.orElse(List.of("activityDate", "member"));
List<String> sortDirectionList = sortDirection.orElse(List.of("asc", "asc"));
Pageable pageable = PageableUtils.createPageable(page, size, sortByList, sortDirectionList, Attendance.class);
Expand All @@ -116,7 +117,7 @@ public ApiResponse<PagedResponseDto<AbsentResponseDto>> getActivityGroupAbsentEx
@RequestParam(name = "size", defaultValue = "20") int size,
@RequestParam(name = "sortBy", required = false) Optional<List<String>> sortBy,
@RequestParam(name = "sortDirection", required = false) Optional<List<String>> sortDirection
) throws SortingArgumentException, PermissionDeniedException {
) throws SortingArgumentException, PermissionDeniedException, InvalidColumnException {
List<String> sortByList = sortBy.orElse(List.of("createdAt"));
List<String> sortDirectionList = sortDirection.orElse(List.of("desc"));
Pageable pageable = PageableUtils.createPageable(page, size, sortByList, sortDirectionList, Absent.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import page.clab.api.domain.application.domain.Application;
import page.clab.api.global.common.dto.PagedResponseDto;
import page.clab.api.global.common.dto.ApiResponse;
import page.clab.api.global.exception.InvalidColumnException;
import page.clab.api.global.exception.SortingArgumentException;
import page.clab.api.global.util.PageableUtils;

Expand Down Expand Up @@ -57,7 +58,7 @@ public ApiResponse<PagedResponseDto<ActivityPhotoResponseDto>> getActivityPhotos
@RequestParam(name = "size", defaultValue = "20") int size,
@RequestParam(name = "sortBy", required = false) Optional<List<String>> sortBy,
@RequestParam(name = "sortDirection", required = false) Optional<List<String>> sortDirection
) throws SortingArgumentException {
) throws SortingArgumentException, InvalidColumnException {
List<String> sortByList = sortBy.orElse(List.of("createdAt"));
List<String> sortDirectionList = sortDirection.orElse(List.of("desc"));
Pageable pageable = PageableUtils.createPageable(page, size, sortByList, sortDirectionList, ActivityPhoto.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import page.clab.api.domain.schedule.domain.Schedule;
import page.clab.api.global.common.dto.PagedResponseDto;
import page.clab.api.global.common.dto.ApiResponse;
import page.clab.api.global.exception.InvalidColumnException;
import page.clab.api.global.exception.SortingArgumentException;
import page.clab.api.global.util.PageableUtils;

Expand Down Expand Up @@ -63,7 +64,7 @@ public ApiResponse<PagedResponseDto<ApplicationResponseDto>> getApplicationsByCo
@RequestParam(name = "size", defaultValue = "20") int size,
@RequestParam(name = "sortBy", required = false) Optional<List<String>> sortBy,
@RequestParam(name = "sortDirection", required = false) Optional<List<String>> sortDirection
) throws SortingArgumentException {
) throws SortingArgumentException, InvalidColumnException {
List<String> sortByList = sortBy.orElse(List.of("createdAt"));
List<String> sortDirectionList = sortDirection.orElse(List.of("desc"));
Pageable pageable = PageableUtils.createPageable(page, size, sortByList, sortDirectionList, Application.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import page.clab.api.domain.award.dto.response.AwardResponseDto;
import page.clab.api.global.common.dto.ApiResponse;
import page.clab.api.global.common.dto.PagedResponseDto;
import page.clab.api.global.exception.InvalidColumnException;
import page.clab.api.global.exception.PermissionDeniedException;
import page.clab.api.global.exception.SortingArgumentException;
import page.clab.api.global.util.PageableUtils;
Expand Down Expand Up @@ -62,7 +63,7 @@ public ApiResponse<PagedResponseDto<AwardResponseDto>> getAwardsByConditions(
@RequestParam(name = "size", defaultValue = "20") int size,
@RequestParam(name = "sortBy", required = false) Optional<List<String>> sortBy,
@RequestParam(name = "sortDirection", required = false) Optional<List<String>> sortDirection
) throws SortingArgumentException {
) throws SortingArgumentException, InvalidColumnException {
List<String> sortByList = sortBy.orElse(List.of("awardDate"));
List<String> sortDirectionList = sortDirection.orElse(List.of("desc"));
Pageable pageable = PageableUtils.createPageable(page, size, sortByList, sortDirectionList, Award.class);
Expand All @@ -78,7 +79,7 @@ public ApiResponse<PagedResponseDto<AwardResponseDto>> getMyAwards(
@RequestParam(name = "size", defaultValue = "20") int size,
@RequestParam(name = "sortBy", required = false) Optional<List<String>> sortBy,
@RequestParam(name = "sortDirection", required = false) Optional<List<String>> sortDirection
) throws SortingArgumentException {
) throws SortingArgumentException, InvalidColumnException {
List<String> sortByList = sortBy.orElse(List.of("awardDate"));
List<String> sortDirectionList = sortDirection.orElse(List.of("desc"));
Pageable pageable = PageableUtils.createPageable(page, size, sortByList, sortDirectionList, Award.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import page.clab.api.global.common.dto.ApiResponse;

import java.util.List;
import page.clab.api.global.exception.InvalidColumnException;
import page.clab.api.global.exception.SortingArgumentException;
import page.clab.api.global.util.PageableUtils;

Expand Down Expand Up @@ -56,7 +57,7 @@ public ApiResponse<PagedResponseDto<BlacklistIp>> getBlacklistedIps(
@RequestParam(name = "size", defaultValue = "20") int size,
@RequestParam(name = "sortBy", required = false) Optional<List<String>> sortBy,
@RequestParam(name = "sortDirection", required = false) Optional<List<String>> sortDirection
) throws SortingArgumentException {
) throws SortingArgumentException, InvalidColumnException {
List<String> sortByList = sortBy.orElse(List.of("createdAt"));
List<String> sortDirectionList = sortDirection.orElse(List.of("desc"));
Pageable pageable = PageableUtils.createPageable(page, size, sortByList, sortDirectionList, BlacklistIp.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import page.clab.api.domain.blog.dto.response.BlogResponseDto;
import page.clab.api.global.common.dto.ApiResponse;
import page.clab.api.global.common.dto.PagedResponseDto;
import page.clab.api.global.exception.InvalidColumnException;
import page.clab.api.global.exception.PermissionDeniedException;
import page.clab.api.global.exception.SortingArgumentException;
import page.clab.api.global.util.PageableUtils;
Expand Down Expand Up @@ -63,7 +64,7 @@ public ApiResponse<PagedResponseDto<BlogResponseDto>> getBlogsByConditions(
@RequestParam(name = "size", defaultValue = "20") int size,
@RequestParam(name = "sortBy", required = false) Optional<List<String>> sortBy,
@RequestParam(name = "sortDirection", required = false) Optional<List<String>> sortDirection
) throws SortingArgumentException {
) throws SortingArgumentException, InvalidColumnException {
List<String> sortByList = sortBy.orElse(List.of("createdAt"));
List<String> sortDirectionList = sortDirection.orElse(List.of("desc"));
Pageable pageable = PageableUtils.createPageable(page, size, sortByList, sortDirectionList, Blog.class);
Expand Down
Loading

0 comments on commit 22def75

Please sign in to comment.