From 7d925d376df54d8ad358500f99776fdb394fa4fa Mon Sep 17 00:00:00 2001 From: mingmingmon Date: Sun, 22 Dec 2024 19:06:19 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=ED=86=B5=EC=9D=BC=EB=90=9C=20impor?= =?UTF-8?q?t=EB=AC=B8=20=EC=A0=95=EB=A0=AC=EA=B3=BC=20=EC=BD=94=EB=93=9C?= =?UTF-8?q?=20=EC=A0=95=EB=A6=AC=20=EB=B0=A9=EC=8B=9D=EC=9D=84=20=ED=99=9C?= =?UTF-8?q?=EC=9A=A9=ED=95=9C=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/ActivityGroupAdminController.java | 73 +- .../api/ActivityGroupBoardController.java | 93 ++- .../api/ActivityGroupMemberController.java | 116 +-- .../api/ActivityGroupReportController.java | 42 +- .../api/AttendanceController.java | 70 +- .../ActivityGroupAdminService.java | 128 ++-- .../ActivityGroupBoardService.java | 188 +++-- .../ActivityGroupMemberService.java | 143 ++-- .../ActivityGroupReportService.java | 29 +- .../application/AttendanceService.java | 75 +- .../activitygroup/dao/AbsentRepository.java | 6 +- .../dao/ActivityGroupBoardRepository.java | 9 +- .../ActivityGroupBoardRepositoryCustom.java | 4 +- .../dao/ActivityGroupBoardRepositoryImpl.java | 11 +- .../dao/ActivityGroupDetailsRepository.java | 1 + .../ActivityGroupDetailsRepositoryImpl.java | 35 +- .../dao/ActivityGroupRepository.java | 8 +- .../ActivityGroupRepositoryCustomImpl.java | 23 +- .../dao/ApplyFormRepository.java | 4 +- .../dao/AttendanceRepository.java | 6 +- .../dao/GroupMemberRepository.java | 23 +- .../dao/GroupMemberRepositoryCustom.java | 3 +- .../dao/GroupMemberRepositoryImpl.java | 84 +- .../dao/GroupScheduleRepository.java | 3 +- .../dao/RedisQRKeyRepository.java | 1 + .../activity/activitygroup/domain/Absent.java | 3 +- .../activitygroup/domain/ActivityGroup.java | 5 +- .../domain/ActivityGroupBoard.java | 15 +- .../domain/ActivityGroupReport.java | 3 +- .../activitygroup/domain/Attendance.java | 11 +- .../activitygroup/domain/GroupMember.java | 13 +- .../activitygroup/domain/GroupMemberId.java | 3 +- .../activitygroup/domain/GroupSchedule.java | 3 +- .../activitygroup/domain/RedisQRKey.java | 4 +- .../dto/mapper/ActivityGroupDtoMapper.java | 366 ++++----- .../dto/param/ActivityGroupDetails.java | 3 +- .../dto/param/GroupScheduleDto.java | 3 +- .../dto/request/AbsentRequestDto.java | 3 +- .../request/ActivityGroupBoardRequestDto.java | 5 +- .../ActivityGroupBoardUpdateRequestDto.java | 5 +- .../dto/request/ActivityGroupRequestDto.java | 3 +- .../ActivityGroupUpdateRequestDto.java | 3 +- .../dto/response/AbsentResponseDto.java | 3 +- .../ActivityGroupBoardChildResponseDto.java | 5 +- .../ActivityGroupBoardResponseDto.java | 5 +- .../ActivityGroupReportResponseDto.java | 3 +- .../response/ActivityGroupResponseDto.java | 3 +- .../ActivityGroupStatusResponseDto.java | 5 +- ...mentSubmissionWithFeedbackResponseDto.java | 5 +- .../dto/response/AttendanceResponseDto.java | 3 +- .../dto/response/FeedbackResponseDto.java | 5 +- .../dto/response/LeaderInfo.java | 3 +- ...ySubmittedThisWeekAssignmentException.java | 2 +- .../SingleLeaderModificationException.java | 2 +- .../DeletedReviewsRetrievalController.java | 4 +- .../in/web/MyReviewsRetrievalController.java | 13 +- .../in/web/ReviewRegisterController.java | 2 +- .../in/web/ReviewRemoveController.java | 2 +- .../in/web/ReviewUpdateController.java | 4 +- ...eviewsByConditionsRetrievalController.java | 28 +- .../persistence/ReviewPersistenceAdapter.java | 17 +- .../out/persistence/ReviewRepository.java | 3 +- .../persistence/ReviewRepositoryCustom.java | 4 +- .../out/persistence/ReviewRepositoryImpl.java | 38 +- .../dto/mapper/ReviewDtoMapper.java | 36 +- .../dto/request/ReviewRequestDto.java | 2 +- .../dto/response/ReviewResponseDto.java | 3 +- .../port/in/RegisterReviewUseCase.java | 1 + .../port/in/RemoveReviewUseCase.java | 1 + .../in/RetrieveDeletedReviewsUseCase.java | 1 + .../port/in/RetrieveMyReviewsUseCase.java | 1 + .../RetrieveReviewsByConditionsUseCase.java | 4 +- .../port/in/UpdateReviewUseCase.java | 1 + .../port/out/RegisterReviewPort.java | 1 + .../port/out/RetrieveReviewPort.java | 3 +- .../service/ReviewRegisterService.java | 10 +- .../ReviewsByConditionsRetrievalService.java | 6 +- .../domain/activity/review/domain/Review.java | 5 +- .../AccountAccessLogJpaEntity.java | 3 +- .../AccountAccessLogPersistenceAdapter.java | 2 +- .../AccountAccessLogRepository.java | 1 + .../out/RegisterAccountAccessLogPort.java | 1 + .../domain/AccountAccessLog.java | 20 +- .../in/web/BanMembersRetrievalController.java | 7 +- .../adapter/in/web/MemberBanController.java | 4 +- .../adapter/in/web/MemberUnbanController.java | 4 +- .../persistence/AccountLockInfoJpaEntity.java | 3 +- .../AccountLockInfoPersistenceAdapter.java | 11 +- .../AccountLockInfoRepository.java | 5 +- .../dto/mapper/AccountLockInfoDtoMapper.java | 6 +- .../application/port/in/BanMemberUseCase.java | 1 + .../port/in/RetrieveBannedMembersUseCase.java | 1 + .../port/in/UnbanMemberUseCase.java | 1 + .../port/out/RegisterAccountLockInfoPort.java | 1 + .../port/out/RemoveAccountLockInfoPort.java | 1 + .../port/out/RetrieveAccountLockInfoPort.java | 5 +- .../service/BanMembersRetrievalService.java | 6 +- .../application/service/MemberBanService.java | 4 +- .../service/MemberUnbanService.java | 4 +- .../domain/AccountLockInfo.java | 13 +- .../in/web/BlacklistIpRegisterController.java | 4 +- .../in/web/BlacklistIpRemoveController.java | 4 +- .../web/BlacklistIpRetrievalController.java | 19 +- .../in/web/BlacklistResetController.java | 5 +- .../out/persistence/BlacklistIpJpaEntity.java | 6 +- .../BlacklistIpPersistenceAdapter.java | 23 +- .../persistence/BlacklistIpRepository.java | 3 +- .../dto/mapper/BlacklistIpDtoMapper.java | 16 +- .../dto/response/BlacklistIpResponseDto.java | 3 +- .../port/in/RegisterBlacklistIpUseCase.java | 1 + .../port/in/RemoveBlacklistIpUseCase.java | 1 + .../port/in/ResetBlacklistIpsUseCase.java | 2 +- .../port/in/RetrieveBlacklistIpsUseCase.java | 1 + .../port/out/RegisterBlacklistIpPort.java | 1 + .../port/out/RetrieveBlacklistIpPort.java | 5 +- .../service/BlacklistIpRegisterService.java | 20 +- .../service/BlacklistIpRemoveService.java | 4 +- .../service/BlacklistIpResetService.java | 10 +- .../auth/blacklistIp/domain/BlacklistIp.java | 9 +- .../adapter/in/web/MemberLoginController.java | 14 +- .../in/web/TokenManagementController.java | 13 +- .../TwoFactorAuthenticationController.java | 12 +- .../AuthenticatorPersistenceAdapter.java | 14 +- .../persistence/AuthenticatorRepository.java | 1 + .../RedisTokenPersistenceAdapter.java | 11 +- .../out/persistence/RedisTokenRepository.java | 3 +- .../application/dto/response/TokenInfo.java | 6 +- .../port/in/ManageLoginUseCase.java | 9 +- .../port/in/ManageRedisTokenUseCase.java | 3 +- .../port/out/RegisterAuthenticatorPort.java | 1 + .../port/out/RegisterRedisTokenPort.java | 1 + .../port/out/RemoveAuthenticatorPort.java | 1 + .../port/out/RetrieveAuthenticatorPort.java | 3 +- .../port/out/RetrieveRedisTokenPort.java | 3 +- .../service/RedisTokenManagementService.java | 25 +- .../service/TokenManagementService.java | 12 +- .../TwoFactorAuthenticationService.java | 14 +- .../application/service/UserLoginService.java | 16 +- .../auth/login/domain/Authenticator.java | 6 +- .../domain/auth/login/domain/RedisToken.java | 17 +- .../web/AbnormalAccessIpRemoveController.java | 6 +- .../web/AbnormalAccessIpsClearController.java | 7 +- .../AbnormalAccessIpsRetrieveController.java | 9 +- .../RedisIpAccessMonitorAdapter.java | 21 +- .../RedisIpAccessMonitorRepository.java | 1 + .../in/ClearAbnormalAccessIpsUseCase.java | 4 +- .../in/RemoveAbnormalAccessIpUseCase.java | 1 + .../in/RetrieveAbnormalAccessIpsUseCase.java | 1 + .../port/out/ClearIpAccessMonitorPort.java | 1 + .../port/out/RegisterIpAccessMonitorPort.java | 1 + .../port/out/RemoveIpAccessMonitorPort.java | 1 + .../port/out/RetrieveIpAccessMonitorPort.java | 3 +- .../AbnormalAccessIpRemoveService.java | 4 +- .../AbnormalAccessIpsClearService.java | 4 +- .../AbnormalAccessIpsRetrieveService.java | 15 +- .../domain/RedisIpAccessMonitor.java | 3 +- .../in/web/AccusationReportController.java | 2 +- .../in/web/AccusationRetrievalController.java | 28 +- .../in/web/AccusationStatusController.java | 6 +- .../in/web/MyAccusationsController.java | 13 +- .../out/persistence/AccuseJpaEntity.java | 4 +- .../persistence/AccusePersistenceAdapter.java | 29 +- .../out/persistence/AccuseRepository.java | 5 +- .../out/persistence/AccuseTargetId.java | 3 +- .../AccuseTargetPersistenceAdapter.java | 19 +- .../persistence/AccuseTargetRepository.java | 3 +- .../AccuseTargetRepositoryCustom.java | 4 +- .../AccuseTargetRepositoryImpl.java | 20 +- .../dto/mapper/AccuseDtoMapper.java | 51 +- .../dto/response/AccuseMyResponseDto.java | 3 +- .../dto/response/AccuseResponseDto.java | 5 +- .../event/AccuseEventProcessor.java | 3 +- .../in/ChangeAccusationStatusUseCase.java | 1 + .../port/in/ReportAccusationUseCase.java | 1 + .../port/in/RetrieveAccusationUseCase.java | 4 +- .../port/in/RetrieveMyAccusationsUseCase.java | 1 + .../port/out/RegisterAccusePort.java | 3 +- .../port/out/RegisterAccuseTargetPort.java | 1 + .../port/out/RetrieveAccusePort.java | 5 +- .../port/out/RetrieveAccuseTargetPort.java | 3 +- .../service/AccusationReportService.java | 21 +- .../service/AccusationRetrievalService.java | 36 +- .../service/AccusationStatusService.java | 15 +- .../community/accuse/domain/Accuse.java | 3 +- .../community/accuse/domain/AccuseTarget.java | 3 +- .../web/BoardDetailsRetrievalController.java | 2 +- .../in/web/BoardEmojiToggleController.java | 4 +- .../in/web/BoardRegisterController.java | 3 +- .../adapter/in/web/BoardRemoveController.java | 2 +- .../adapter/in/web/BoardUpdateController.java | 4 +- .../BoardsByCategoryRetrievalController.java | 21 +- .../BoardsByHashtagRetrievalController.java | 20 +- .../in/web/BoardsRetrievalController.java | 13 +- .../web/DeletedBoardsRetrievalController.java | 4 +- .../in/web/MyBoardsRetrievalController.java | 13 +- .../out/persistence/BoardEmojiJpaEntity.java | 7 +- .../BoardEmojiPersistenceAdapter.java | 11 +- .../out/persistence/BoardEmojiRepository.java | 18 +- .../BoardHashtagPersistenceAdapter.java | 15 +- .../persistence/BoardHashtagRepository.java | 20 +- .../out/persistence/BoardJpaEntity.java | 3 +- .../persistence/BoardPersistenceAdapter.java | 20 +- .../dto/mapper/BoardDtoMapper.java | 138 ++-- .../dto/mapper/BoardHashtagDtoMapper.java | 24 +- .../dto/request/BoardRequestDto.java | 3 +- .../dto/response/BoardDetailsResponseDto.java | 5 +- .../dto/response/BoardListResponseDto.java | 3 +- .../dto/response/BoardMyResponseDto.java | 3 +- .../response/BoardOverviewResponseDto.java | 3 +- .../event/BoardEventDispatcher.java | 3 +- .../event/BoardEventProcessorRegistry.java | 5 +- .../port/in/RegisterBoardHashtagUseCase.java | 1 + .../port/in/RegisterBoardUseCase.java | 2 +- .../port/in/RemoveBoardUseCase.java | 1 + .../port/in/RetrieveBoardDetailsUseCase.java | 1 + .../in/RetrieveBoardsByCategoryUseCase.java | 1 + .../in/RetrieveBoardsByHashtagUseCase.java | 1 + .../port/in/RetrieveDeletedBoardsUseCase.java | 1 + .../port/in/RetrieveMyBoardsUseCase.java | 1 + .../port/in/ToggleBoardEmojiUseCase.java | 1 + .../port/in/UpdateBoardUseCase.java | 1 + .../port/out/RegisterBoardEmojiPort.java | 1 + .../port/out/RegisterBoardHashtagPort.java | 1 + .../port/out/RegisterBoardPort.java | 1 + .../port/out/RetrieveBoardEmojiPort.java | 3 +- .../port/out/RetrieveBoardHashtagPort.java | 2 - .../service/BoardDetailsRetrievalService.java | 21 +- .../service/BoardEmojiToggleService.java | 12 +- .../service/BoardHashtagRegisterService.java | 1 - .../service/BoardHashtagRetrieveService.java | 16 +- .../service/BoardRegisterService.java | 13 +- .../service/BoardRetrievalService.java | 7 +- .../service/BoardUpdateService.java | 93 ++- .../BoardsByCategoryRetrievalService.java | 10 +- .../BoardsByHashtagRetrievalService.java | 18 +- .../DeletedBoardsRetrievalService.java | 5 +- .../service/MyBoardsRetrievalService.java | 5 +- .../domain/community/board/domain/Board.java | 11 +- .../community/board/domain/BoardEmoji.java | 13 +- .../community/board/domain/BoardHashtag.java | 5 +- .../in/web/CommentLikeToggleController.java | 2 +- .../in/web/CommentRegisterController.java | 6 +- .../in/web/CommentRemoveController.java | 2 +- .../in/web/CommentRetrievalController.java | 15 +- .../in/web/CommentUpdateController.java | 4 +- .../DeletedCommentsRetrievalController.java | 9 +- .../in/web/MyCommentsRetrievalController.java | 13 +- .../out/persistence/CommentJpaEntity.java | 5 +- .../CommentLikePersistenceAdapter.java | 11 +- .../persistence/CommentLikeRepository.java | 3 +- .../out/persistence/CommentMapper.java | 59 +- .../CommentPersistenceAdapter.java | 31 +- .../out/persistence/CommentRepository.java | 3 +- .../dto/mapper/CommentDtoMapper.java | 97 +-- .../dto/response/CommentMyResponseDto.java | 3 +- .../dto/response/CommentResponseDto.java | 5 +- .../response/DeletedCommentResponseDto.java | 3 +- .../event/CommentEventProcessor.java | 3 +- .../port/in/RegisterCommentUseCase.java | 1 + .../port/in/RemoveCommentUseCase.java | 1 + .../in/RetrieveDeletedCommentsUseCase.java | 1 + .../port/in/RetrieveMyCommentsUseCase.java | 1 + .../port/in/ToggleCommentLikeUseCase.java | 1 + .../port/in/UpdateCommentUseCase.java | 1 + .../port/out/RegisterCommentLikePort.java | 1 + .../port/out/RegisterCommentPort.java | 3 +- .../port/out/RemoveCommentLikePort.java | 1 + .../port/out/RetrieveCommentLikePort.java | 4 +- .../port/out/RetrieveCommentPort.java | 5 +- .../service/CommentLikeToggleService.java | 25 +- .../service/CommentRetrievalService.java | 23 +- .../DeletedCommentsRetrievalService.java | 14 +- .../service/MyCommentsRetrievalService.java | 14 +- .../community/comment/domain/Comment.java | 9 +- .../community/comment/domain/CommentLike.java | 6 +- .../in/web/HashtagRegisterController.java | 2 +- .../out/persistence/HashtagJpaEntity.java | 1 - .../HashtagPersistenceAdapter.java | 12 +- .../dto/mapper/HashtagDtoMapper.java | 16 +- .../port/in/RegisterHashtagUseCase.java | 1 + .../port/out/RegisterHashtagPort.java | 1 + .../service/HashtagRetrieveService.java | 5 +- .../community/hashtag/domain/Hashtag.java | 1 - .../JobPostingDetailsRetrievalController.java | 5 +- ...stingsByConditionsRetrievalController.java | 31 +- .../JobPostingPersistenceAdapter.java | 12 +- .../out/persistence/JobPostingRepository.java | 4 +- .../JobPostingRepositoryCustom.java | 4 +- .../persistence/JobPostingRepositoryImpl.java | 35 +- .../dto/mapper/JobPostingDtoMapper.java | 30 +- .../JobPostingDetailsResponseDto.java | 3 +- .../dto/response/JobPostingResponseDto.java | 3 +- .../in/RetrieveJobPostingDetailsUseCase.java | 1 + ...etrieveJobPostingsByConditionsUseCase.java | 4 +- .../port/out/RetrieveJobPostingPort.java | 3 +- ...bPostingsByConditionsRetrievalService.java | 6 +- .../jobPosting/domain/JobPosting.java | 3 +- .../NewsByConditionsRetrievalController.java | 24 +- .../web/NewsDetailsRetrievalController.java | 2 +- .../out/persistence/NewsJpaEntity.java | 5 +- .../persistence/NewsPersistenceAdapter.java | 8 +- .../out/persistence/NewsRepository.java | 4 +- .../out/persistence/NewsRepositoryCustom.java | 1 + .../out/persistence/NewsRepositoryImpl.java | 25 +- .../application/dto/mapper/NewsDtoMapper.java | 32 +- .../dto/response/NewsDetailsResponseDto.java | 7 +- .../dto/response/NewsResponseDto.java | 5 +- .../in/RetrieveNewsByConditionsUseCase.java | 1 + .../port/in/RetrieveNewsDetailsUseCase.java | 1 + .../domain/community/news/domain/News.java | 5 +- .../in/web/ApplicationApplyController.java | 2 +- .../in/web/ApplicationApprovalController.java | 12 +- .../ApplicationMemberRegisterController.java | 9 +- .../web/ApplicationPassCheckController.java | 4 +- .../web/ApplicationRetrievalController.java | 29 +- .../out/persistence/ApplicationId.java | 3 +- .../out/persistence/ApplicationJpaEntity.java | 3 +- .../ApplicationPersistenceAdapter.java | 27 +- .../persistence/ApplicationRepository.java | 8 +- .../ApplicationRepositoryCustom.java | 4 +- .../ApplicationRepositoryImpl.java | 32 +- .../dto/mapper/ApplicationDtoMapper.java | 98 +-- .../request/ApplicationMemberCreationDto.java | 3 +- .../dto/request/ApplicationRequestDto.java | 3 +- .../response/ApplicationPassResponseDto.java | 4 +- .../dto/response/ApplicationResponseDto.java | 5 +- .../event/ApplicationEventDispatcher.java | 3 +- .../ApplicationEventProcessorRegistry.java | 5 +- .../port/in/ApplyForApplicationUseCase.java | 1 + .../port/in/ApproveApplicationUseCase.java | 1 + .../in/CheckApplicationPassStatusUseCase.java | 1 + .../port/in/RejectApplicationUseCase.java | 1 + .../port/in/RetrieveApplicationsUseCase.java | 4 +- .../port/out/RegisterApplicationPort.java | 1 + .../port/out/RetrieveApplicationPort.java | 5 +- .../service/ApplicationApplyService.java | 4 +- .../ApplicationMemberRegisterService.java | 28 +- .../service/ApplicationPassCheckService.java | 4 +- .../service/ApplicationRetrievalService.java | 6 +- .../application/domain/Application.java | 5 +- ...RecentRecruitmentsRetrievalController.java | 7 +- .../in/web/RecruitmentRegisterController.java | 2 +- .../in/web/RecruitmentUpdateController.java | 4 +- .../out/persistence/RecruitmentJpaEntity.java | 3 +- .../RecruitmentPersistenceAdapter.java | 28 +- .../persistence/RecruitmentRepository.java | 5 +- .../dto/mapper/RecruitmentDtoMapper.java | 34 +- .../dto/request/RecruitmentRequestDto.java | 3 +- .../request/RecruitmentUpdateRequestDto.java | 3 +- .../dto/response/RecruitmentResponseDto.java | 3 +- .../port/in/RegisterRecruitmentUseCase.java | 1 + .../in/RetrieveRecentRecruitmentsUseCase.java | 3 +- .../port/in/RetrieveRecruitmentUseCase.java | 1 + .../port/in/UpdateRecruitmentUseCase.java | 1 + .../port/out/RegisterRecruitmentPort.java | 1 + .../port/out/RetrieveRecruitmentPort.java | 3 +- .../port/out/UpdateRecruitmentPort.java | 1 + .../RecentRecruitmentsRetrievalService.java | 15 +- .../service/RecruitmentStatusUpdater.java | 5 +- .../recruitment/domain/Recruitment.java | 7 +- .../web/BookDetailsRetrievalController.java | 2 +- .../in/web/BookRegisterController.java | 2 +- .../adapter/in/web/BookRemoveController.java | 2 +- .../adapter/in/web/BookUpdateController.java | 4 +- .../BooksByConditionsRetrievalController.java | 30 +- .../out/persistence/BookJpaEntity.java | 3 +- .../persistence/BookPersistenceAdapter.java | 15 +- .../out/persistence/BookRepository.java | 4 +- .../out/persistence/BookRepositoryCustom.java | 4 +- .../out/persistence/BookRepositoryImpl.java | 44 +- .../application/dto/mapper/BookDtoMapper.java | 71 +- .../dto/request/BookRequestDto.java | 3 +- .../dto/request/BookUpdateRequestDto.java | 3 +- .../dto/response/BookDetailsResponseDto.java | 5 +- .../dto/response/BookResponseDto.java | 3 +- .../port/in/RegisterBookUseCase.java | 1 + .../port/in/RemoveBookUseCase.java | 1 + .../port/in/RetrieveBookDetailsUseCase.java | 1 + .../in/RetrieveBooksByConditionsUseCase.java | 4 +- .../port/in/UpdateBookUseCase.java | 1 + .../port/out/RegisterBookPort.java | 1 + .../application/port/out/RemoveBookPort.java | 1 + .../port/out/RetrieveBookPort.java | 3 +- .../port/out/RetrieveDeletedBooksPort.java | 1 + .../service/BookDetailsRetrievalService.java | 3 +- .../BooksByConditionsRetrievalService.java | 9 +- .../api/domain/library/book/domain/Book.java | 7 +- .../in/web/BookLoanApprovalController.java | 2 +- .../in/web/BookLoanExtensionController.java | 2 +- ...ecordsByConditionsRetrievalController.java | 28 +- .../in/web/BookLoanRejectionController.java | 2 +- .../in/web/BookLoanRequestController.java | 2 +- .../adapter/in/web/BookReturnController.java | 2 +- ...dueBookLoanRecordsRetrievalController.java | 18 +- .../persistence/BookLoanRecordJpaEntity.java | 3 +- .../BookLoanRecordPersistenceAdapter.java | 29 +- .../persistence/BookLoanRecordRepository.java | 12 +- .../BookLoanRecordRepositoryCustom.java | 3 +- .../BookLoanRecordRepositoryImpl.java | 124 +-- .../BookLoanRecordOverdueResponseDto.java | 3 +- .../response/BookLoanRecordResponseDto.java | 3 +- .../port/in/ApproveBookLoanUseCase.java | 1 + .../port/in/ExtendBookLoanUseCase.java | 1 + .../port/in/RejectBookLoanUseCase.java | 1 + .../port/in/RequestBookLoanUseCase.java | 1 + ...eveBookLoanRecordsByConditionsUseCase.java | 4 +- ...RetrieveOverdueBookLoanRecordsUseCase.java | 1 + .../port/in/ReturnBookUseCase.java | 1 + .../port/out/RegisterBookLoanRecordPort.java | 1 + .../port/out/RetrieveBookLoanRecordPort.java | 9 +- .../service/BookLoanApprovalService.java | 3 +- .../service/BookLoanExtensionService.java | 10 +- ...anRecordsByConditionsRetrievalService.java | 6 +- .../service/BookLoanRequestService.java | 12 +- .../service/BookReturnService.java | 13 +- ...verdueBookLoanRecordsRetrievalService.java | 3 +- .../bookLoanRecord/domain/BookLoanRecord.java | 17 +- .../in/web/AwardRegisterController.java | 2 +- .../adapter/in/web/AwardRemoveController.java | 4 +- .../in/web/AwardRetrievalController.java | 21 +- .../adapter/in/web/AwardUpdateController.java | 6 +- .../web/DeletedAwardRetrievalController.java | 4 +- .../in/web/MyAwardRetrievalController.java | 13 +- .../out/persistence/AwardJpaEntity.java | 3 +- .../persistence/AwardPersistenceAdapter.java | 27 +- .../out/persistence/AwardRepository.java | 3 +- .../persistence/AwardRepositoryCustom.java | 1 + .../out/persistence/AwardRepositoryImpl.java | 27 +- .../dto/mapper/AwardDtoMapper.java | 26 +- .../dto/request/AwardRequestDto.java | 3 +- .../dto/request/AwardUpdateRequestDto.java | 3 +- .../dto/response/AwardResponseDto.java | 3 +- .../event/AwardEventProcessor.java | 3 +- .../port/in/RegisterAwardUseCase.java | 1 + .../port/in/RemoveAwardUseCase.java | 1 + .../port/in/RetrieveAwardsUseCase.java | 1 + .../port/in/RetrieveDeletedAwardsUseCase.java | 1 + .../port/in/RetrieveMyAwardsUseCase.java | 1 + .../port/in/UpdateAwardUseCase.java | 1 + .../port/out/RegisterAwardPort.java | 3 +- .../application/port/out/RemoveAwardPort.java | 1 + .../port/out/RetrieveAwardPort.java | 3 +- .../memberManagement/award/domain/Award.java | 5 +- .../web/CloudUsageRetrievalAllController.java | 7 +- ...oudUsageRetrievalByMemberIdController.java | 4 +- ...sInMemberDirectoryRetrievalController.java | 11 +- .../dto/mapper/CloudDtoMapper.java | 6 +- .../port/in/RetrieveAllCloudUsageUseCase.java | 1 + .../RetrieveCloudUsageByMemberIdUseCase.java | 1 + ...RetrieveFilesInMemberDirectoryUseCase.java | 1 + .../CloudUsageRetrievalAllService.java | 3 +- .../CloudUsageRetrievalByMemberIdService.java | 3 +- ...ilesInMemberDirectoryRetrievalService.java | 5 +- ...rBirthdayRetrievalThisMonthController.java | 20 +- .../in/web/MemberInfoUpdateController.java | 6 +- .../in/web/MemberPasswordController.java | 6 +- .../in/web/MemberRegisterController.java | 2 +- .../in/web/MemberRemoveController.java | 2 +- .../MemberRoleInfoRetrievalController.java | 29 +- .../web/MemberRoleManagementController.java | 10 +- ...embersByConditionsRetrievalController.java | 20 +- .../out/persistence/MemberJpaEntity.java | 5 +- .../persistence/MemberPersistenceAdapter.java | 29 +- .../out/persistence/MemberRepository.java | 6 +- .../persistence/MemberRepositoryCustom.java | 3 +- .../out/persistence/MemberRepositoryImpl.java | 82 +- .../dto/mapper/MemberDtoMapper.java | 178 ++--- .../dto/request/MemberRequestDto.java | 3 +- .../dto/request/MemberUpdateRequestDto.java | 3 +- .../response/MemberBirthdayResponseDto.java | 3 +- .../dto/response/MemberResponseDto.java | 5 +- .../dto/response/MyProfileResponseDto.java | 3 +- .../dto/shared/MemberBorrowerInfoDto.java | 3 +- .../event/MemberEventDispatcher.java | 3 +- .../event/MemberEventProcessorRegistry.java | 3 +- .../port/in/ManageMemberRoleUseCase.java | 1 + .../port/in/RegisterMemberUseCase.java | 1 + .../port/in/RemoveMemberUseCase.java | 1 + ...trieveMemberBirthdaysThisMonthUseCase.java | 1 + .../in/RetrieveMemberRoleInfoUseCase.java | 4 +- .../port/in/RetrieveMemberUseCase.java | 1 + .../RetrieveMembersByConditionsUseCase.java | 1 + .../port/in/RetrieveMyProfileUseCase.java | 1 + .../port/in/UpdateMemberUseCase.java | 1 + .../port/out/RegisterMemberPort.java | 1 + .../port/out/RetrieveMemberPort.java | 5 +- .../port/out/UpdateMemberPort.java | 1 + .../MemberPasswordManagementService.java | 4 +- .../service/MemberRegisterService.java | 24 +- .../MemberRoleInfoRetrievalService.java | 3 +- .../service/MemberRoleManagementService.java | 8 +- .../member/domain/Member.java | 45 +- .../web/NotificationsRetrievalController.java | 19 +- .../NotificationPersistenceAdapter.java | 21 +- .../persistence/NotificationRepository.java | 3 +- .../dto/mapper/NotificationDtoMapper.java | 8 +- .../dto/response/NotificationResponseDto.java | 3 +- .../event/NotificationEventProcessor.java | 3 +- .../port/in/RetrieveNotificationsUseCase.java | 1 + .../port/out/RegisterNotificationPort.java | 3 +- .../port/out/RetrieveNotificationPort.java | 3 +- .../notification/domain/Notification.java | 11 +- .../MyPositionsByYearRetrievalController.java | 2 +- .../in/web/PositionRegisterController.java | 2 +- .../in/web/PositionRemoveController.java | 2 +- ...itionsByConditionsRetrievalController.java | 24 +- .../PositionPersistenceAdapter.java | 34 +- .../out/persistence/PositionRepository.java | 11 +- .../persistence/PositionRepositoryCustom.java | 1 + .../persistence/PositionRepositoryImpl.java | 25 +- .../dto/mapper/PositionDtoMapper.java | 57 +- .../dto/response/PositionMyResponseDto.java | 5 +- .../event/PositionEventProcessor.java | 4 +- .../port/in/RegisterPositionUseCase.java | 1 + .../port/in/RemovePositionUseCase.java | 1 + .../in/RetrieveMyPositionsByYearUseCase.java | 1 + .../RetrievePositionsByConditionsUseCase.java | 1 + .../port/out/RegisterPositionPort.java | 3 +- .../port/out/RetrievePositionPort.java | 5 +- .../port/out/UpdatePositionPort.java | 1 + .../MyPositionsByYearRetrievalService.java | 5 +- .../service/PositionRegisterService.java | 12 +- ...PositionsByConditionsRetrievalService.java | 3 +- .../position/domain/Position.java | 13 +- ...tedWorkExperiencesRetrievalController.java | 6 +- .../MyWorkExperienceRetrievalController.java | 21 +- .../web/WorkExperienceRegisterController.java | 2 +- .../web/WorkExperienceRemoveController.java | 4 +- .../web/WorkExperienceUpdateController.java | 6 +- ...iencesByConditionsRetrievalController.java | 23 +- .../persistence/WorkExperienceJpaEntity.java | 3 +- .../WorkExperiencePersistenceAdapter.java | 29 +- .../persistence/WorkExperienceRepository.java | 3 +- .../dto/mapper/WorkExperienceDtoMapper.java | 26 +- .../dto/request/WorkExperienceRequestDto.java | 3 +- .../WorkExperienceUpdateRequestDto.java | 3 +- .../response/WorkExperienceResponseDto.java | 3 +- .../event/WorkExperienceEventProcessor.java | 3 +- .../in/RegisterWorkExperienceUseCase.java | 1 + .../port/in/RemoveWorkExperienceUseCase.java | 1 + ...RetrieveDeletedWorkExperiencesUseCase.java | 1 + .../in/RetrieveMyWorkExperienceUseCase.java | 1 + ...eveWorkExperiencesByConditionsUseCase.java | 1 + .../port/in/UpdateWorkExperienceUseCase.java | 4 +- .../port/out/RegisterWorkExperiencePort.java | 3 +- .../port/out/RetrieveWorkExperiencePort.java | 3 +- .../port/out/UpdateWorkExperiencePort.java | 1 + .../service/WorkExperienceUpdateService.java | 3 +- .../workExperience/domain/WorkExperience.java | 5 +- .../web/ActivityPhotoRegisterController.java | 2 +- .../in/web/ActivityPhotoRemoveController.java | 2 +- .../web/ActivityPhotoRetrievalController.java | 23 +- .../ActivityPhotoVisibilityController.java | 2 +- .../persistence/ActivityPhotoJpaEntity.java | 5 +- .../ActivityPhotoPersistenceAdapter.java | 11 +- .../persistence/ActivityPhotoRepository.java | 4 +- .../ActivityPhotoRepositoryCustom.java | 1 + .../ActivityPhotoRepositoryImpl.java | 21 +- .../dto/mapper/ActivityPhotoDtoMapper.java | 29 +- .../dto/request/ActivityPhotoRequestDto.java | 5 +- .../response/ActivityPhotoResponseDto.java | 7 +- .../port/in/RegisterActivityPhotoUseCase.java | 1 + .../port/in/RemoveActivityPhotoUseCase.java | 1 + .../port/in/RetrieveActivityPhotoUseCase.java | 1 + .../ToggleActivityPhotoVisibilityUseCase.java | 1 + .../port/out/RegisterActivityPhotoPort.java | 1 + .../service/ActivityPhotoRegisterService.java | 3 +- .../activityPhoto/domain/ActivityPhoto.java | 5 +- .../web/BlogDetailsRetrievalController.java | 2 +- .../in/web/BlogRegisterController.java | 2 +- .../adapter/in/web/BlogRemoveController.java | 2 +- .../adapter/in/web/BlogUpdateController.java | 4 +- .../in/web/BlogsRetrievalController.java | 21 +- .../web/DeletedBlogsRetrievalController.java | 4 +- .../persistence/BlogPersistenceAdapter.java | 12 +- .../out/persistence/BlogRepository.java | 6 +- .../out/persistence/BlogRepositoryCustom.java | 1 + .../out/persistence/BlogRepositoryImpl.java | 31 +- .../application/dto/mapper/BlogDtoMapper.java | 52 +- .../dto/response/BlogDetailsResponseDto.java | 3 +- .../dto/response/BlogResponseDto.java | 3 +- .../port/in/RegisterBlogUseCase.java | 1 + .../port/in/RemoveBlogUseCase.java | 1 + .../port/in/RetrieveBlogDetailsUseCase.java | 1 + .../port/in/RetrieveBlogsUseCase.java | 1 + .../port/in/RetrieveDeletedBlogsUseCase.java | 1 + .../port/in/UpdateBlogUseCase.java | 1 + .../port/out/RegisterBlogPort.java | 1 + .../service/DeletedBlogsRetrievalService.java | 3 +- .../api/domain/members/blog/domain/Blog.java | 5 +- .../DeletedDonationsRetrievalController.java | 7 +- .../in/web/DonationRegisterController.java | 2 +- .../in/web/DonationRemoveController.java | 2 +- .../in/web/DonationUpdateController.java | 4 +- ...ationsByConditionsRetrievalController.java | 30 +- .../web/MyDonationsRetrievalController.java | 13 +- .../DonationPersistenceAdapter.java | 20 +- .../out/persistence/DonationRepository.java | 3 +- .../persistence/DonationRepositoryCustom.java | 7 +- .../persistence/DonationRepositoryImpl.java | 46 +- .../dto/mapper/DonationDtoMapper.java | 24 +- .../dto/response/DonationResponseDto.java | 3 +- .../port/in/RegisterDonationUseCase.java | 1 + .../port/in/RemoveDonationUseCase.java | 1 + .../in/RetrieveDeletedDonationsUseCase.java | 1 + .../RetrieveDonationsByConditionsUseCase.java | 7 +- .../port/in/RetrieveMyDonationsUseCase.java | 1 + .../port/in/UpdateDonationUseCase.java | 4 +- .../port/out/RegisterDonationPort.java | 1 + .../port/out/RetrieveDonationPort.java | 6 +- .../DeletedDonationsRetrievalService.java | 3 +- .../service/DonationUpdateService.java | 3 +- ...DonationsByConditionsRetrievalService.java | 9 +- .../service/MyDonationsRetrievalService.java | 3 +- .../members/donation/domain/Donation.java | 5 +- ...etedMembershipFeesRetrievalController.java | 6 +- .../web/MembershipFeeRegisterController.java | 2 +- .../in/web/MembershipFeeRemoveController.java | 2 +- .../in/web/MembershipFeeUpdateController.java | 4 +- ...ipFeesByConditionsRetrievalController.java | 33 +- .../MembershipFeePersistenceAdapter.java | 17 +- .../persistence/MembershipFeeRepository.java | 2 +- .../MembershipFeeRepositoryCustom.java | 4 +- .../MembershipFeeRepositoryImpl.java | 40 +- .../dto/mapper/MembershipFeeDtoMapper.java | 40 +- .../response/MembershipFeeResponseDto.java | 3 +- .../port/in/RegisterMembershipFeeUseCase.java | 1 + .../port/in/RemoveMembershipFeeUseCase.java | 1 + .../RetrieveDeletedMembershipFeesUseCase.java | 1 + ...ieveMembershipFeesByConditionsUseCase.java | 4 +- .../port/in/UpdateMembershipFeeUseCase.java | 4 +- .../port/out/RegisterMembershipFeePort.java | 1 + .../port/out/RetrieveMembershipFeePort.java | 3 +- .../port/out/UpdateMembershipFeePort.java | 1 + ...DeletedMembershipFeesRetrievalService.java | 2 +- .../service/MembershipFeeRegisterService.java | 4 +- .../service/MembershipFeeUpdateService.java | 3 +- ...rshipFeesByConditionsRetrievalService.java | 12 +- .../membershipFee/domain/MembershipFee.java | 5 +- .../DeletedProductsRetrievalController.java | 7 +- .../in/web/ProductRegisterController.java | 2 +- .../in/web/ProductRemoveController.java | 2 +- .../in/web/ProductUpdateController.java | 4 +- ...oductsByConditionsRetrievalController.java | 20 +- .../ProductPersistenceAdapter.java | 14 +- .../out/persistence/ProductRepository.java | 3 +- .../persistence/ProductRepositoryCustom.java | 1 + .../persistence/ProductRepositoryImpl.java | 17 +- .../dto/mapper/ProductDtoMapper.java | 22 +- .../dto/response/ProductResponseDto.java | 3 +- .../port/in/RegisterProductUseCase.java | 1 + .../port/in/RemoveProductUseCase.java | 1 + .../in/RetrieveDeletedProductsUseCase.java | 1 + .../RetrieveProductsByConditionsUseCase.java | 1 + .../port/in/UpdateProductUseCase.java | 1 + .../port/out/RegisterProductPort.java | 1 + .../port/out/UpdateProductPort.java | 1 + .../members/product/domain/Product.java | 5 +- .../ActivitySchedulesRetrievalController.java | 21 +- .../in/web/ScheduleRegisterController.java | 2 +- .../in/web/ScheduleRemoveController.java | 2 +- ...edulesByConditionsRetrievalController.java | 25 +- ...lesWithinDateRangeRetrievalController.java | 21 +- .../out/persistence/ScheduleJpaEntity.java | 3 +- .../SchedulePersistenceAdapter.java | 25 +- .../out/persistence/ScheduleRepository.java | 4 +- .../persistence/ScheduleRepositoryCustom.java | 11 +- .../persistence/ScheduleRepositoryImpl.java | 78 +- .../dto/mapper/ScheduleDtoMapper.java | 42 +- .../dto/request/ScheduleRequestDto.java | 3 +- .../dto/response/ScheduleResponseDto.java | 3 +- .../port/in/RegisterScheduleUseCase.java | 1 + .../port/in/RemoveScheduleUseCase.java | 1 + .../in/RetrieveActivitySchedulesUseCase.java | 7 +- .../in/RetrieveCollectSchedulesUseCase.java | 1 + .../RetrieveSchedulesByConditionsUseCase.java | 4 +- ...trieveSchedulesWithinDateRangeUseCase.java | 7 +- .../port/out/RegisterSchedulePort.java | 1 + .../port/out/RetrieveSchedulePort.java | 11 +- .../ActivitySchedulesRetrievalService.java | 9 +- .../service/ScheduleRegisterService.java | 19 +- ...SchedulesByConditionsRetrievalService.java | 3 +- ...edulesWithinDateRangeRetrievalService.java | 17 +- .../members/schedule/domain/Schedule.java | 3 +- ...ternalRegisterAccountAccessLogUseCase.java | 1 + ...ternalAccountAccessLogRegisterService.java | 6 +- .../ExternalManageAccountLockUseCase.java | 3 +- .../ExternalAccountLockManagementService.java | 8 +- .../ExternalRegisterBlacklistIpUseCase.java | 1 + .../ExternalRetrieveBlacklistIpUseCase.java | 1 + .../port/ExternalCheckIpBlockedUseCase.java | 1 + ...xternalRegisterIpAccessMonitorUseCase.java | 1 + ...xternalIpAccessMonitorRegisterService.java | 16 +- .../port/ExternalRegisterCommentUseCase.java | 1 + .../ExternalHashtagRetrievalService.java | 1 - .../ExternalRetrieveRecruitmentUseCase.java | 1 + .../port/ExternalRegisterBookUseCase.java | 1 + ...xternalBookLoanRecordRetrievalService.java | 7 +- ...alRetrieveCloudUsageByMemberIdUseCase.java | 1 + .../port/ExternalRegisterMemberUseCase.java | 1 + .../port/ExternalRetrieveMemberUseCase.java | 5 +- .../ExternalMemberRetrievalService.java | 33 +- .../service/ExternalMemberUpdateService.java | 3 +- .../ExternalSendNotificationService.java | 17 +- .../port/ExternalRegisterPositionUseCase.java | 1 + .../port/ExternalRetrievePositionUseCase.java | 4 +- .../ExternalPositionRetrievalService.java | 6 +- .../application/CustomUserDetailsService.java | 4 +- .../CustomBasicAuthenticationFilter.java | 26 +- .../auth/filter/FileAccessControlFilter.java | 6 +- .../filter/InvalidEndpointAccessFilter.java | 10 +- .../auth/filter/IpAuthenticationFilter.java | 13 +- .../auth/filter/JwtAuthenticationFilter.java | 12 +- .../api/global/auth/jwt/JwtTokenProvider.java | 69 +- .../clab/api/global/auth/util/AuthUtil.java | 3 +- .../auth/util/IpWhitelistValidator.java | 10 +- .../global/auth/util/WhitelistFileLoader.java | 28 +- .../api/global/common/domain/BaseEntity.java | 3 +- .../api/global/common/dto/ApiResponse.java | 22 +- .../api/global/common/dto/ErrorResponse.java | 6 +- .../global/common/dto/PagedResponseDto.java | 65 +- .../email/application/EmailAsyncService.java | 35 +- .../email/application/EmailService.java | 60 +- .../global/common/email/domain/EmailTask.java | 5 +- .../email/dto/mapper/EmailDtoMapper.java | 13 +- .../common/email/dto/request/EmailDto.java | 6 +- .../common/file/api/FileController.java | 58 +- .../file/application/AutoDeleteService.java | 22 +- .../common/file/application/FileHandler.java | 26 +- .../common/file/application/FileService.java | 84 +- .../file/application/UploadedFileService.java | 9 +- .../common/file/dao/UploadFileRepository.java | 5 +- .../common/file/domain/UploadedFile.java | 23 +- .../common/file/dto/mapper/FileDtoMapper.java | 35 +- .../common/file/dto/response/FileInfo.java | 3 +- .../dto/response/UploadedFileResponseDto.java | 3 +- .../NotificationSettingToggleController.java | 2 +- ...NotificationSettingPersistenceAdapter.java | 4 +- .../out/webhook/AbstractWebhookClient.java | 4 +- .../webhook/DiscordNotificationSender.java | 2 +- .../out/webhook/DiscordWebhookClient.java | 96 +-- .../out/webhook/SlackNotificationSender.java | 2 +- .../out/webhook/SlackWebhookClient.java | 160 ++-- .../mapper/NotificationSettingDtoMapper.java | 6 +- .../notification/BoardNotificationInfo.java | 10 +- .../BookLoanRecordNotificationInfo.java | 12 +- .../MembershipFeeNotificationInfo.java | 12 +- .../event/ApplicationStartupListener.java | 2 +- .../event/NotificationListener.java | 32 +- .../application/port/out/WebhookClient.java | 2 +- .../ManageNotificationSettingService.java | 2 +- .../RetrieveNotificationSettingService.java | 4 +- .../service/WebhookCommonService.java | 14 +- .../config/NotificationConfigProperties.java | 3 + .../domain/NotificationSetting.java | 6 +- .../application/VerificationService.java | 9 +- .../dao/VerificationRepository.java | 4 +- .../verification/domain/Verification.java | 6 +- .../clab/api/global/config/AppConfig.java | 8 +- .../clab/api/global/config/AsyncConfig.java | 3 +- .../global/config/AuthenticationConfig.java | 9 +- .../clab/api/global/config/CorsConfig.java | 5 +- .../config/EmailTemplateProperties.java | 4 +- .../clab/api/global/config/IPInfoConfig.java | 10 +- .../clab/api/global/config/JpaConfig.java | 1 + .../clab/api/global/config/OpenApiConfig.java | 40 +- .../global/config/RoleHierarchyConfig.java | 8 +- .../api/global/config/SecurityConfig.java | 92 +-- .../api/global/config/SecurityConstants.java | 48 +- .../api/global/config/ThymeleafConfig.java | 6 +- .../clab/api/global/config/WebConfig.java | 38 +- .../config/WhitelistPatternsProperties.java | 9 +- .../api/global/filter/IPinfoSpringFilter.java | 15 +- .../api/global/filter/PostResponseFilter.java | 9 +- .../global/handler/ApiLoggingInterceptor.java | 6 +- .../handler/GlobalExceptionHandler.java | 182 ++--- .../page/clab/api/global/util/ApiLogger.java | 16 +- .../clab/api/global/util/ColumnValidator.java | 9 +- .../page/clab/api/global/util/EmojiUtils.java | 11 +- .../clab/api/global/util/EncryptionUtil.java | 18 +- .../clab/api/global/util/FileSystemUtil.java | 4 +- .../page/clab/api/global/util/FileUtil.java | 33 +- .../api/global/util/HtmlCharacterEscapes.java | 5 +- .../clab/api/global/util/HttpReqResUtil.java | 147 ++-- .../page/clab/api/global/util/IPInfoUtil.java | 18 +- .../page/clab/api/global/util/ImageUtil.java | 32 +- .../clab/api/global/util/IpAddressUtil.java | 3 +- .../api/global/util/LogSanitizerUtil.java | 7 +- .../api/global/util/OrderSpecifierUtil.java | 9 +- .../clab/api/global/util/PageableUtils.java | 20 +- .../clab/api/global/util/PaginationUtils.java | 51 +- .../page/clab/api/global/util/QRCodeUtil.java | 4 +- .../api/global/util/RandomNicknameUtil.java | 25 +- .../clab/api/global/util/ResponseUtil.java | 6 +- .../global/util/SecurityPatternChecker.java | 156 ++-- .../api/global/util/StringJsonConverter.java | 3 +- .../clab/api/global/util/TempFileUtil.java | 2 +- .../api/global/util/WhitelistPathMatcher.java | 6 +- src/main/resources/logback-spring.xml | 100 +-- src/main/resources/templates/clabEmail.html | 721 +++++++++++------- 800 files changed, 5409 insertions(+), 4926 deletions(-) diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/api/ActivityGroupAdminController.java b/src/main/java/page/clab/api/domain/activity/activitygroup/api/ActivityGroupAdminController.java index 1f3c4980e..5fc50e875 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/api/ActivityGroupAdminController.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/api/ActivityGroupAdminController.java @@ -3,6 +3,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; @@ -33,8 +34,6 @@ import page.clab.api.global.exception.SortingArgumentException; import page.clab.api.global.util.PageableUtils; -import java.util.List; - @RestController @RequestMapping("/api/v1/activity-group/admin") @RequiredArgsConstructor @@ -48,7 +47,7 @@ public class ActivityGroupAdminController { @PreAuthorize("hasRole('USER')") @PostMapping("") public ApiResponse createActivityGroup( - @Valid @RequestBody ActivityGroupRequestDto requestDto + @Valid @RequestBody ActivityGroupRequestDto requestDto ) { Long id = activityGroupAdminService.createActivityGroup(requestDto); return ApiResponse.success(id); @@ -58,8 +57,8 @@ public ApiResponse createActivityGroup( @PreAuthorize("hasRole('USER')") @PatchMapping("/{activityGroupId}") public ApiResponse updateActivityGroup( - @PathVariable(name = "activityGroupId") Long activityGroupId, - @Valid @RequestBody ActivityGroupUpdateRequestDto requestDto + @PathVariable(name = "activityGroupId") Long activityGroupId, + @Valid @RequestBody ActivityGroupUpdateRequestDto requestDto ) throws PermissionDeniedException { Long id = activityGroupAdminService.updateActivityGroup(activityGroupId, requestDto); return ApiResponse.success(id); @@ -69,10 +68,11 @@ public ApiResponse updateActivityGroup( @PreAuthorize("hasRole('ADMIN')") @PatchMapping("manage/{activityGroupId}") public ApiResponse manageActivityGroupStatus( - @PathVariable(name = "activityGroupId") Long activityGroupId, - @RequestParam(name = "activityGroupStatus") ActivityGroupStatus status + @PathVariable(name = "activityGroupId") Long activityGroupId, + @RequestParam(name = "activityGroupStatus") ActivityGroupStatus status ) { - ActivityGroupBoardStatusUpdatedResponseDto updatedStatusDto = activityGroupAdminService.manageActivityGroup(activityGroupId, status); + ActivityGroupBoardStatusUpdatedResponseDto updatedStatusDto = activityGroupAdminService.manageActivityGroup( + activityGroupId, status); return ApiResponse.success(updatedStatusDto); } @@ -80,19 +80,19 @@ public ApiResponse manageActivityGro @PreAuthorize("hasRole('USER')") @DeleteMapping("/{activityGroupId}") public ApiResponse deleteActivityGroup( - @PathVariable(name = "activityGroupId") Long activityGroupId + @PathVariable(name = "activityGroupId") Long activityGroupId ) throws PermissionDeniedException { Long id = activityGroupAdminService.deleteActivityGroup(activityGroupId); return ApiResponse.success(id); } @Operation(summary = "[U] 프로젝트 진행도 수정", description = "ROLE_USER 이상의 권한이 필요함
" + - "진행도는 0~100 사이의 값으로 입력해야 함") + "진행도는 0~100 사이의 값으로 입력해야 함") @PreAuthorize("hasRole('USER')") @PatchMapping("/progress/{activityGroupId}") public ApiResponse updateProjectProgress( - @PathVariable(name = "activityGroupId") Long activityGroupId, - @RequestParam(name = "progress") Long progress + @PathVariable(name = "activityGroupId") Long activityGroupId, + @RequestParam(name = "progress") Long progress ) throws PermissionDeniedException { Long id = activityGroupAdminService.updateProjectProgress(activityGroupId, progress); return ApiResponse.success(id); @@ -102,27 +102,29 @@ public ApiResponse updateProjectProgress( @PreAuthorize("hasRole('USER')") @PostMapping("/schedule") public ApiResponse addSchedule( - @RequestParam(name = "activityGroupId") Long activityGroupId, - @Valid @RequestBody List scheduleDtos + @RequestParam(name = "activityGroupId") Long activityGroupId, + @Valid @RequestBody List scheduleDtos ) throws PermissionDeniedException { Long id = activityGroupAdminService.addSchedule(activityGroupId, scheduleDtos); return ApiResponse.success(id); } @Operation(summary = "[U] 활동 멤버 및 지원서 조회", description = "ROLE_USER 이상의 권한이 필요함
" + - "관리자 또는 리더만 조회 가능
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") + "관리자 또는 리더만 조회 가능
" + + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") @PreAuthorize("hasRole('USER')") @GetMapping("/members") public ApiResponse> getApplyGroupMemberList( - @RequestParam(name = "activityGroupId") Long activityGroupId, - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "status") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "asc") List sortDirection + @RequestParam(name = "activityGroupId") Long activityGroupId, + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "status") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "asc") List sortDirection ) throws SortingArgumentException, PermissionDeniedException, InvalidColumnException { - Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, ActivityGroupMemberWithApplyReasonResponseDto.class); - PagedResponseDto groupMembers = activityGroupAdminService.getGroupMembersWithApplyReason(activityGroupId, pageable); + Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, + ActivityGroupMemberWithApplyReasonResponseDto.class); + PagedResponseDto groupMembers = activityGroupAdminService.getGroupMembersWithApplyReason( + activityGroupId, pageable); return ApiResponse.success(groupMembers); } @@ -130,24 +132,24 @@ public ApiResponse acceptGroupMember( - @RequestParam(name = "activityGroupId") Long activityGroupId, - @RequestParam(name = "memberId") List memberIds, - @RequestParam(name = "status") GroupMemberStatus status + @RequestParam(name = "activityGroupId") Long activityGroupId, + @RequestParam(name = "memberId") List memberIds, + @RequestParam(name = "status") GroupMemberStatus status ) throws PermissionDeniedException { Long id = activityGroupAdminService.manageGroupMemberStatus(activityGroupId, memberIds, status); return ApiResponse.success(id); } @Operation(summary = "[U] 활동 멤버 직책 변경", description = "ROLE_USER 이상의 권한이 필요함

" + - "직책은 팀장만 변경 가능
" + - "LEADER: 팀장, MEMBER: 팀원, NONE: 없음
" + - "LEADER -> MEMBER, MEMBER -> LEADER 변경만 허용함") + "직책은 팀장만 변경 가능
" + + "LEADER: 팀장, MEMBER: 팀원, NONE: 없음
" + + "LEADER -> MEMBER, MEMBER -> LEADER 변경만 허용함") @PreAuthorize("hasRole('USER')") @PatchMapping("/position") public ApiResponse changeGroupMemberPosition( - @RequestParam(name = "activityGroupId") Long activityGroupId, - @RequestParam(name = "memberId") String memberId, - @RequestParam(name = "position") ActivityGroupRole position + @RequestParam(name = "activityGroupId") Long activityGroupId, + @RequestParam(name = "memberId") String memberId, + @RequestParam(name = "position") ActivityGroupRole position ) throws PermissionDeniedException { Long id = activityGroupAdminService.changeGroupMemberPosition(activityGroupId, memberId, position); return ApiResponse.success(id); @@ -157,11 +159,12 @@ public ApiResponse changeGroupMemberPosition( @Operation(summary = "[S] 삭제된 활동그룹 조회하기", description = "ROLE_SUPER 이상의 권한이 필요함") @PreAuthorize("hasRole('SUPER')") public ApiResponse> getDeletedActivityGroups( - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size ) { Pageable pageable = PageRequest.of(page, size); - PagedResponseDto activityGroups = activityGroupAdminService.getDeletedActivityGroups(pageable); + PagedResponseDto activityGroups = activityGroupAdminService.getDeletedActivityGroups( + pageable); return ApiResponse.success(activityGroups); } } diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/api/ActivityGroupBoardController.java b/src/main/java/page/clab/api/domain/activity/activitygroup/api/ActivityGroupBoardController.java index 1f2e65903..6903cc040 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/api/ActivityGroupBoardController.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/api/ActivityGroupBoardController.java @@ -3,6 +3,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; @@ -30,8 +31,6 @@ import page.clab.api.global.exception.SortingArgumentException; import page.clab.api.global.util.PageableUtils; -import java.util.List; - @RestController @RequestMapping("/api/v1/activity-group/boards") @RequiredArgsConstructor @@ -42,35 +41,38 @@ public class ActivityGroupBoardController { private final PageableUtils pageableUtils; @Operation(summary = "[U] 활동 그룹 게시판 생성", description = "ROLE_USER 이상의 권한이 필요함

" + - "활동 그룹 게시판 카테고리별 requestDto에 들어가야 할 필수내용입니다.

" + - "공지사항, 주차별활동 : 카테고리
" + - "과제 : 부모 게시판(주차별활동), 카테고리, 마감일자
" + - "제출 : 부모 게시판(과제), 카테고리
" + - "피드백 : 부모 게시판(제출), 카테고리" + "활동 그룹 게시판 카테고리별 requestDto에 들어가야 할 필수내용입니다.

" + + "공지사항, 주차별활동 : 카테고리
" + + "과제 : 부모 게시판(주차별활동), 카테고리, 마감일자
" + + "제출 : 부모 게시판(과제), 카테고리
" + + "피드백 : 부모 게시판(제출), 카테고리" ) @PreAuthorize("hasRole('USER')") @PostMapping("") public ApiResponse createActivityGroupBoard( - @RequestParam(name = "parentId", required = false) Long parentId, - @RequestParam(name = "activityGroupId") Long activityGroupId, - @Valid @RequestBody ActivityGroupBoardRequestDto requestDto + @RequestParam(name = "parentId", required = false) Long parentId, + @RequestParam(name = "activityGroupId") Long activityGroupId, + @Valid @RequestBody ActivityGroupBoardRequestDto requestDto ) throws PermissionDeniedException { - ActivityGroupBoardReferenceDto referenceDto = activityGroupBoardService.createActivityGroupBoard(parentId, activityGroupId, requestDto); + ActivityGroupBoardReferenceDto referenceDto = activityGroupBoardService.createActivityGroupBoard(parentId, + activityGroupId, requestDto); return ApiResponse.success(referenceDto); } @Operation(summary = "[U] 활동 그룹 게시판 조회", description = "ROLE_USER 이상의 권한이 필요함
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") @PreAuthorize("hasRole('USER')") @GetMapping("/list") public ApiResponse> getActivityGroupBoardList( - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection ) throws SortingArgumentException, InvalidColumnException { - Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, ActivityGroupBoardResponseDto.class); - PagedResponseDto boards = activityGroupBoardService.getAllActivityGroupBoard(pageable); + Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, + ActivityGroupBoardResponseDto.class); + PagedResponseDto boards = activityGroupBoardService.getAllActivityGroupBoard( + pageable); return ApiResponse.success(boards); } @@ -78,26 +80,28 @@ public ApiResponse> getActivityG @PreAuthorize("hasRole('USER')") @GetMapping("") public ApiResponse getActivityGroupBoardById( - @RequestParam(name = "activityGroupBoardId") Long activityGroupBoardId + @RequestParam(name = "activityGroupBoardId") Long activityGroupBoardId ) throws PermissionDeniedException { ActivityGroupBoardResponseDto board = activityGroupBoardService.getActivityGroupBoard(activityGroupBoardId); return ApiResponse.success(board); } @Operation(summary = "[U] 활동 그룹 ID에 대한 카테고리별 게시판 조회", description = "ROLE_USER 이상의 권한이 필요함
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") @PreAuthorize("hasRole('USER')") @GetMapping("/by-category") public ApiResponse> getActivityGroupBoardByCategory( - @RequestParam(name = "activityGroupId") Long activityGroupId, - @RequestParam(name = "category") ActivityGroupBoardCategory category, - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection + @RequestParam(name = "activityGroupId") Long activityGroupId, + @RequestParam(name = "category") ActivityGroupBoardCategory category, + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection ) throws SortingArgumentException, InvalidColumnException, PermissionDeniedException { - Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, ActivityGroupBoardResponseDto.class); - PagedResponseDto boards = activityGroupBoardService.getActivityGroupBoardByCategory(activityGroupId, category, pageable); + Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, + ActivityGroupBoardResponseDto.class); + PagedResponseDto boards = activityGroupBoardService.getActivityGroupBoardByCategory( + activityGroupId, category, pageable); return ApiResponse.success(boards); } @@ -105,12 +109,13 @@ public ApiResponse> getActivityG @PreAuthorize("hasRole('USER')") @GetMapping("/by-parent") public ApiResponse> getActivityGroupBoardByParent( - @RequestParam(name = "parentId") Long parentId, - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size + @RequestParam(name = "parentId") Long parentId, + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size ) throws PermissionDeniedException { Pageable pageable = PageRequest.of(page, size); - PagedResponseDto boards = activityGroupBoardService.getActivityGroupBoardByParent(parentId, pageable); + PagedResponseDto boards = activityGroupBoardService.getActivityGroupBoardByParent( + parentId, pageable); return ApiResponse.success(boards); } @@ -118,9 +123,10 @@ public ApiResponse> getActi @PreAuthorize("hasRole('USER')") @GetMapping("/my-assignment") public ApiResponse> getMyAssignmentBoardWithFeedback( - @RequestParam(name = "parentId") Long parentId + @RequestParam(name = "parentId") Long parentId ) { - List boards = activityGroupBoardService.getMyAssignmentsWithFeedbacks(parentId); + List boards = activityGroupBoardService.getMyAssignmentsWithFeedbacks( + parentId); return ApiResponse.success(boards); } @@ -128,10 +134,11 @@ public ApiResponse> getMyAssig @PreAuthorize("hasRole('USER')") @PatchMapping("") public ApiResponse updateActivityGroupBoard( - @RequestParam(name = "activityGroupBoardId") Long activityGroupBoardId, - @Valid @RequestBody ActivityGroupBoardUpdateRequestDto requestDto + @RequestParam(name = "activityGroupBoardId") Long activityGroupBoardId, + @Valid @RequestBody ActivityGroupBoardUpdateRequestDto requestDto ) throws PermissionDeniedException { - ActivityGroupBoardReferenceDto referenceDto = activityGroupBoardService.updateActivityGroupBoard(activityGroupBoardId, requestDto); + ActivityGroupBoardReferenceDto referenceDto = activityGroupBoardService.updateActivityGroupBoard( + activityGroupBoardId, requestDto); return ApiResponse.success(referenceDto); } @@ -139,9 +146,10 @@ public ApiResponse updateActivityGroupBoard( @PreAuthorize("hasRole('USER')") @DeleteMapping("") public ApiResponse deleteActivityGroupBoard( - @RequestParam Long activityGroupBoardId + @RequestParam Long activityGroupBoardId ) throws PermissionDeniedException { - ActivityGroupBoardReferenceDto referenceDto = activityGroupBoardService.deleteActivityGroupBoard(activityGroupBoardId); + ActivityGroupBoardReferenceDto referenceDto = activityGroupBoardService.deleteActivityGroupBoard( + activityGroupBoardId); return ApiResponse.success(referenceDto); } @@ -149,11 +157,12 @@ public ApiResponse deleteActivityGroupBoard( @PreAuthorize("hasRole('SUPER')") @GetMapping("/deleted") public ApiResponse> getDeletedActivityGroupBoards( - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size ) { Pageable pageable = PageRequest.of(page, size); - PagedResponseDto activityBoards = activityGroupBoardService.getDeletedActivityGroupBoards(pageable); + PagedResponseDto activityBoards = activityGroupBoardService.getDeletedActivityGroupBoards( + pageable); return ApiResponse.success(activityBoards); } } diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/api/ActivityGroupMemberController.java b/src/main/java/page/clab/api/domain/activity/activitygroup/api/ActivityGroupMemberController.java index 4559f449c..75a421c30 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/api/ActivityGroupMemberController.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/api/ActivityGroupMemberController.java @@ -3,6 +3,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.security.access.prepost.PreAuthorize; @@ -28,8 +29,6 @@ import page.clab.api.global.exception.SortingArgumentException; import page.clab.api.global.util.PageableUtils; -import java.util.List; - @RestController @RequestMapping("/api/v1/activity-group/member") @RequiredArgsConstructor @@ -43,90 +42,99 @@ public class ActivityGroupMemberController { @PreAuthorize("hasRole('USER')") @GetMapping("/{activityGroupId}") public ApiResponse getActivityGroup( - @PathVariable(name = "activityGroupId") Long activityGroupId + @PathVariable(name = "activityGroupId") Long activityGroupId ) { ActivityGroupDetailResponseDto activityGroup = activityGroupMemberService.getActivityGroup(activityGroupId); return ApiResponse.success(activityGroup); } @Operation(summary = "[G] 나의 활동 목록 조회", description = "ROLE_GUEST 이상의 권한이 필요함
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") @PreAuthorize("hasRole('GUEST')") @GetMapping("/my") public ApiResponse> getMyActivityGroups( - @RequestParam(name = "status", required = false) ActivityGroupStatus status, - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection + @RequestParam(name = "status", required = false) ActivityGroupStatus status, + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection ) throws InvalidColumnException, SortingArgumentException { - Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, ActivityGroupStatusResponseDto.class); - PagedResponseDto activityGroups = activityGroupMemberService.getMyActivityGroups(status, pageable); + Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, + ActivityGroupStatusResponseDto.class); + PagedResponseDto activityGroups = activityGroupMemberService.getMyActivityGroups( + status, pageable); return ApiResponse.success(activityGroups); } @Operation(summary = "[U] 활동 상태별 조회", description = "ROLE_USER 이상의 권한이 필요함
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") @PreAuthorize("hasRole('USER')") @GetMapping("/status") public ApiResponse> getActivityGroupsByStatus( - @RequestParam(name = "activityGroupStatus") ActivityGroupStatus status, - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection + @RequestParam(name = "activityGroupStatus") ActivityGroupStatus status, + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection ) throws InvalidColumnException, SortingArgumentException { - Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, ActivityGroupStatusResponseDto.class); - PagedResponseDto activityGroups = activityGroupMemberService.getActivityGroupsByStatus(status, pageable); + Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, + ActivityGroupStatusResponseDto.class); + PagedResponseDto activityGroups = activityGroupMemberService.getActivityGroupsByStatus( + status, pageable); return ApiResponse.success(activityGroups); } @Operation(summary = "[G] 카테고리별 활동 목록 조회", description = "ROLE_GUEST 이상의 권한이 필요함
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") @PreAuthorize("hasRole('GUEST')") @GetMapping("/list") public ApiResponse> getActivityGroupsByCategory( - @RequestParam(name = "category") ActivityGroupCategory category, - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection + @RequestParam(name = "category") ActivityGroupCategory category, + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection ) throws SortingArgumentException, InvalidColumnException { - Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, ActivityGroupResponseDto.class); - PagedResponseDto activityGroups = activityGroupMemberService.getActivityGroupsByCategory(category, pageable); + Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, + ActivityGroupResponseDto.class); + PagedResponseDto activityGroups = activityGroupMemberService.getActivityGroupsByCategory( + category, pageable); return ApiResponse.success(activityGroups); } @Operation(summary = "[G] 활동 일정 조회", description = "ROLE_GUEST 이상의 권한이 필요함
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") @PreAuthorize("hasRole('GUEST')") @GetMapping("/schedule") public ApiResponse> getGroupScheduleList( - @RequestParam(name = "activityGroupId") Long activityGroupId, - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "schedule") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection + @RequestParam(name = "activityGroupId") Long activityGroupId, + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "schedule") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection ) throws SortingArgumentException, InvalidColumnException { Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, GroupScheduleDto.class); - PagedResponseDto groupSchedules = activityGroupMemberService.getGroupSchedules(activityGroupId, pageable); + PagedResponseDto groupSchedules = activityGroupMemberService.getGroupSchedules( + activityGroupId, pageable); return ApiResponse.success(groupSchedules); } @Operation(summary = "[U] 활동 멤버 조회", description = "ROLE_USER 이상의 권한이 필요함
" + - "활동에 참여(수락)된 멤버만 조회 가능
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") + "활동에 참여(수락)된 멤버만 조회 가능
" + + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") @PreAuthorize("hasRole('USER')") @GetMapping("/members") public ApiResponse> getActivityGroupMemberList( - @RequestParam(name = "activityGroupId") Long activityGroupId, - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "memberId") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "asc") List sortDirection + @RequestParam(name = "activityGroupId") Long activityGroupId, + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "memberId") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "asc") List sortDirection ) throws SortingArgumentException, InvalidColumnException { - Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, GroupMemberResponseDto.class); - PagedResponseDto activityGroupMembers = activityGroupMemberService.getActivityGroupMembers(activityGroupId, pageable); + Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, + GroupMemberResponseDto.class); + PagedResponseDto activityGroupMembers = activityGroupMemberService.getActivityGroupMembers( + activityGroupId, pageable); return ApiResponse.success(activityGroupMembers); } @@ -134,25 +142,27 @@ public ApiResponse> getActivityGroupMem @PreAuthorize("hasRole('USER')") @PostMapping("/apply") public ApiResponse applyActivityGroup( - @RequestParam Long activityGroupId, - @Valid @RequestBody ApplyFormRequestDto requestDto + @RequestParam Long activityGroupId, + @Valid @RequestBody ApplyFormRequestDto requestDto ) { Long id = activityGroupMemberService.applyActivityGroup(activityGroupId, requestDto); return ApiResponse.success(id); } - + @Operation(summary = "[U] 내가 지원한 활동 목록 조회", description = "ROLE_USER 이상의 권한이 필요함
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") @PreAuthorize("hasRole('USER')") @GetMapping("/applied") public ApiResponse> getAppliedActivityGroups( - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection ) throws InvalidColumnException, SortingArgumentException { - Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, ActivityGroupStatusResponseDto.class); - PagedResponseDto activityGroups = activityGroupMemberService.getAppliedActivityGroups(pageable); + Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, + ActivityGroupStatusResponseDto.class); + PagedResponseDto activityGroups = activityGroupMemberService.getAppliedActivityGroups( + pageable); return ApiResponse.success(activityGroups); } } diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/api/ActivityGroupReportController.java b/src/main/java/page/clab/api/domain/activity/activitygroup/api/ActivityGroupReportController.java index 5c6978699..bb4ad1b75 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/api/ActivityGroupReportController.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/api/ActivityGroupReportController.java @@ -3,6 +3,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; @@ -27,8 +28,6 @@ import page.clab.api.global.exception.SortingArgumentException; import page.clab.api.global.util.PageableUtils; -import java.util.List; - @RestController @RequestMapping("/api/v1/activity-group/report") @RequiredArgsConstructor @@ -42,25 +41,27 @@ public class ActivityGroupReportController { @PreAuthorize("hasRole('USER')") @PostMapping("") public ApiResponse writeReport( - @Valid @RequestBody ActivityGroupReportRequestDto requestDto + @Valid @RequestBody ActivityGroupReportRequestDto requestDto ) throws PermissionDeniedException, IllegalAccessException { Long id = activityGroupReportService.writeReport(requestDto); return ApiResponse.success(id); } @Operation(summary = "[U] 특정 그룹의 활동 보고서 전체 조회", description = "ROLE_USER 이상의 권한이 필요함
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") @PreAuthorize("hasRole('USER')") @GetMapping("") public ApiResponse> getReports( - @RequestParam(name = "activityGroupId") Long activityGroupId, - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection + @RequestParam(name = "activityGroupId") Long activityGroupId, + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection ) throws SortingArgumentException, InvalidColumnException { - Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, ActivityGroupReportResponseDto.class); - PagedResponseDto reports = activityGroupReportService.getReports(activityGroupId, pageable); + Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, + ActivityGroupReportResponseDto.class); + PagedResponseDto reports = activityGroupReportService.getReports( + activityGroupId, pageable); return ApiResponse.success(reports); } @@ -68,8 +69,8 @@ public ApiResponse> getReports( @PreAuthorize("hasRole('USER')") @GetMapping("/search") public ApiResponse searchReport( - @RequestParam(name = "activityGroupId") Long activityGroupId, - @RequestParam(name = "turn") Long turn + @RequestParam(name = "activityGroupId") Long activityGroupId, + @RequestParam(name = "turn") Long turn ) { ActivityGroupReportResponseDto report = activityGroupReportService.searchReport(activityGroupId, turn); return ApiResponse.success(report); @@ -79,9 +80,9 @@ public ApiResponse searchReport( @PreAuthorize("hasRole('USER')") @PatchMapping("/{reportId}") public ApiResponse updateReport( - @PathVariable(name = "reportId") Long reportId, - @RequestParam(name = "activityGroupId") Long activityGroupId, - @Valid @RequestBody ActivityGroupReportUpdateRequestDto requestDto + @PathVariable(name = "reportId") Long reportId, + @RequestParam(name = "activityGroupId") Long activityGroupId, + @Valid @RequestBody ActivityGroupReportUpdateRequestDto requestDto ) throws PermissionDeniedException, IllegalAccessException { Long id = activityGroupReportService.updateReport(reportId, activityGroupId, requestDto); return ApiResponse.success(id); @@ -91,7 +92,7 @@ public ApiResponse updateReport( @PreAuthorize("hasRole('USER')") @DeleteMapping("/{reportId}") public ApiResponse deleteAward( - @PathVariable(name = "reportId") Long reportId + @PathVariable(name = "reportId") Long reportId ) throws PermissionDeniedException { Long id = activityGroupReportService.deleteReport(reportId); return ApiResponse.success(id); @@ -102,11 +103,12 @@ public ApiResponse deleteAward( @PreAuthorize("hasRole('SUPER')") @GetMapping("/deleted") public ApiResponse> getDeletedActivityGroupReports( - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size ) { Pageable pageable = PageRequest.of(page, size); - PagedResponseDto activityGroupReports = activityGroupReportService.getDeletedActivityGroupReports(pageable); + PagedResponseDto activityGroupReports = activityGroupReportService.getDeletedActivityGroupReports( + pageable); return ApiResponse.success(activityGroupReports); } } diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/api/AttendanceController.java b/src/main/java/page/clab/api/domain/activity/activitygroup/api/AttendanceController.java index 3cf425f68..5391c7487 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/api/AttendanceController.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/api/AttendanceController.java @@ -3,6 +3,8 @@ import com.google.zxing.WriterException; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import java.io.IOException; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.security.access.prepost.PreAuthorize; @@ -26,9 +28,6 @@ import page.clab.api.global.exception.SortingArgumentException; import page.clab.api.global.util.PageableUtils; -import java.io.IOException; -import java.util.List; - @RestController @RequestMapping("/api/v1/attendance") @RequiredArgsConstructor @@ -42,7 +41,7 @@ public class AttendanceController { @PreAuthorize("hasRole('USER')") @PostMapping(value = "") public ApiResponse generateAttendanceQRCode( - @RequestParam(name = "activityGroupId") Long activityGroupId + @RequestParam(name = "activityGroupId") Long activityGroupId ) throws IOException, WriterException, PermissionDeniedException, IllegalAccessException { String QRCodeURL = attendanceService.generateAttendanceQRCode(activityGroupId); return ApiResponse.success(QRCodeURL); @@ -52,67 +51,72 @@ public ApiResponse generateAttendanceQRCode( @PreAuthorize("hasRole('USER')") @PostMapping("/check-in") public ApiResponse checkInAttendance( - @RequestBody AttendanceRequestDto requestDto + @RequestBody AttendanceRequestDto requestDto ) throws IllegalAccessException { Long id = attendanceService.checkMemberAttendance(requestDto); return ApiResponse.success(id); } @Operation(summary = "[G] 내 출석기록 조회", description = "ROLE_GUEST 이상의 권한이 필요함
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") @PreAuthorize("hasRole('GUEST')") - @GetMapping({ "/my-attendance" }) + @GetMapping({"/my-attendance"}) public ApiResponse> searchMyAttendance( - @RequestParam(name = "activityGroupId", defaultValue = "1") Long activityGroupId, - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "attendanceDateTime") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection + @RequestParam(name = "activityGroupId", defaultValue = "1") Long activityGroupId, + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "attendanceDateTime") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection ) throws SortingArgumentException, IllegalAccessException, InvalidColumnException { - Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, AttendanceResponseDto.class); - PagedResponseDto myAttendances = attendanceService.getMyAttendances(activityGroupId, pageable); + Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, + AttendanceResponseDto.class); + PagedResponseDto myAttendances = attendanceService.getMyAttendances(activityGroupId, + pageable); return ApiResponse.success(myAttendances); } @Operation(summary = "[U] 특정 그룹의 출석기록 조회", description = "ROLE_USER 이상의 권한이 필요함
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") @PreAuthorize("hasRole('USER')") - @GetMapping({ "/group-attendance" }) + @GetMapping({"/group-attendance"}) public ApiResponse> searchGroupAttendance( - @RequestParam(name = "activityGroupId", defaultValue = "1") Long activityGroupId, - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "memberId") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "asc") List sortDirection + @RequestParam(name = "activityGroupId", defaultValue = "1") Long activityGroupId, + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "memberId") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "asc") List sortDirection ) throws SortingArgumentException, PermissionDeniedException, InvalidColumnException { - Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, AttendanceResponseDto.class); - PagedResponseDto attendances = attendanceService.getGroupAttendances(activityGroupId, pageable); + Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, + AttendanceResponseDto.class); + PagedResponseDto attendances = attendanceService.getGroupAttendances(activityGroupId, + pageable); return ApiResponse.success(attendances); } @Operation(summary = "[U] 불참 사유서 등록", description = "ROLE_USER 이상의 권한이 필요함") @PreAuthorize("hasRole('USER')") - @PostMapping({ "/absent" }) + @PostMapping({"/absent"}) public ApiResponse writeAbsentExcuse( - @RequestBody AbsentRequestDto requestDto + @RequestBody AbsentRequestDto requestDto ) throws IllegalAccessException, DuplicateAbsentExcuseException { Long id = attendanceService.writeAbsentExcuse(requestDto); return ApiResponse.success(id); } @Operation(summary = "[U] 그룹의 불참 사유서 열람", description = "ROLE_USER 이상의 권한이 필요함
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") @PreAuthorize("hasRole('USER')") - @GetMapping({ "/absent/{activityGroupId}" }) + @GetMapping({"/absent/{activityGroupId}"}) public ApiResponse> getActivityGroupAbsentExcuses( - @PathVariable(name = "activityGroupId") Long activityGroupId, - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "absentDate") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection + @PathVariable(name = "activityGroupId") Long activityGroupId, + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "absentDate") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection ) throws SortingArgumentException, PermissionDeniedException, InvalidColumnException { Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, AbsentResponseDto.class); - PagedResponseDto absentExcuses = attendanceService.getActivityGroupAbsentExcuses(activityGroupId, pageable); + PagedResponseDto absentExcuses = attendanceService.getActivityGroupAbsentExcuses( + activityGroupId, pageable); return ApiResponse.success(absentExcuses); } } diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupAdminService.java b/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupAdminService.java index c55a0f1e4..e64d69b97 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupAdminService.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupAdminService.java @@ -1,5 +1,9 @@ package page.clab.api.domain.activity.activitygroup.application; +import java.time.LocalDate; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; @@ -36,11 +40,6 @@ import page.clab.api.global.exception.NotFoundException; import page.clab.api.global.exception.PermissionDeniedException; -import java.time.LocalDate; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - @Service @RequiredArgsConstructor public class ActivityGroupAdminService { @@ -60,15 +59,18 @@ public Long createActivityGroup(ActivityGroupRequestDto requestDto) { activityGroup.validateAndSetGithubUrl(activityGroup.getGithubUrl()); activityGroupRepository.save(activityGroup); - GroupMember groupLeader = GroupMember.create(currentMember.getId(), activityGroup, ActivityGroupRole.LEADER, GroupMemberStatus.ACCEPTED); + GroupMember groupLeader = GroupMember.create(currentMember.getId(), activityGroup, ActivityGroupRole.LEADER, + GroupMemberStatus.ACCEPTED); activityGroupMemberService.save(groupLeader); - externalSendNotificationUseCase.sendNotificationToMember(currentMember.getId(), "활동 그룹 생성이 완료되었습니다. 활동 승인이 완료되면 활동 그룹을 이용할 수 있습니다."); + externalSendNotificationUseCase.sendNotificationToMember(currentMember.getId(), + "활동 그룹 생성이 완료되었습니다. 활동 승인이 완료되면 활동 그룹을 이용할 수 있습니다."); return activityGroup.getId(); } @Transactional - public Long updateActivityGroup(Long activityGroupId, ActivityGroupUpdateRequestDto requestDto) throws PermissionDeniedException { + public Long updateActivityGroup(Long activityGroupId, ActivityGroupUpdateRequestDto requestDto) + throws PermissionDeniedException { Member currentMember = externalRetrieveMemberUseCase.getCurrentMember(); ActivityGroup activityGroup = getActivityGroupById(activityGroupId); validateLeaderOrAdminPermission(activityGroup, currentMember, "해당 활동을 수정할 권한이 없습니다."); @@ -78,14 +80,18 @@ public Long updateActivityGroup(Long activityGroupId, ActivityGroupUpdateRequest // 활동 그룹의 status를 수정합니다. @Transactional - public ActivityGroupBoardStatusUpdatedResponseDto manageActivityGroup(Long activityGroupId, ActivityGroupStatus status) { + public ActivityGroupBoardStatusUpdatedResponseDto manageActivityGroup(Long activityGroupId, + ActivityGroupStatus status) { ActivityGroup activityGroup = getActivityGroupById(activityGroupId); activityGroup.updateStatus(status); activityGroupRepository.save(activityGroup); - List groupLeaders = activityGroupMemberService.getGroupMemberByActivityGroupIdAndRole(activityGroupId, ActivityGroupRole.LEADER); + List groupLeaders = activityGroupMemberService.getGroupMemberByActivityGroupIdAndRole( + activityGroupId, ActivityGroupRole.LEADER); if (!CollectionUtils.isEmpty(groupLeaders)) { - groupLeaders.forEach(leader -> externalSendNotificationUseCase.sendNotificationToMember(leader.getMemberId(), "활동 그룹이 [" + status.getDescription() + "] 상태로 변경되었습니다.")); + groupLeaders.forEach( + leader -> externalSendNotificationUseCase.sendNotificationToMember(leader.getMemberId(), + "활동 그룹이 [" + status.getDescription() + "] 상태로 변경되었습니다.")); } return mapper.of(activityGroupId, status); } @@ -100,8 +106,10 @@ public PagedResponseDto getDeletedActivityGroups(Pagea public Long deleteActivityGroup(Long activityGroupId) throws PermissionDeniedException { ActivityGroup activityGroup = getActivityGroupById(activityGroupId); List groupMembers = activityGroupMemberService.getGroupMemberByActivityGroupId(activityGroupId); - List groupSchedules = groupScheduleRepository.findAllByActivityGroupIdOrderByIdDesc(activityGroupId); - List groupLeaders = activityGroupMemberService.getGroupMemberByActivityGroupIdAndRole(activityGroupId, ActivityGroupRole.LEADER); + List groupSchedules = groupScheduleRepository.findAllByActivityGroupIdOrderByIdDesc( + activityGroupId); + List groupLeaders = activityGroupMemberService.getGroupMemberByActivityGroupIdAndRole( + activityGroupId, ActivityGroupRole.LEADER); Member currentMember = externalRetrieveMemberUseCase.getCurrentMember(); validateLeaderOrAdminPermission(activityGroup, currentMember, "해당 활동을 삭제할 권한이 없습니다."); @@ -111,7 +119,9 @@ public Long deleteActivityGroup(Long activityGroupId) throws PermissionDeniedExc activityGroupRepository.delete(activityGroup); if (!CollectionUtils.isEmpty(groupLeaders)) { - groupLeaders.forEach(leader -> externalSendNotificationUseCase.sendNotificationToMember(leader.getMemberId(), "활동 그룹 [" + activityGroup.getName() + "]이 삭제되었습니다.")); + groupLeaders.forEach( + leader -> externalSendNotificationUseCase.sendNotificationToMember(leader.getMemberId(), + "활동 그룹 [" + activityGroup.getName() + "]이 삭제되었습니다.")); } return activityGroup.getId(); } @@ -126,46 +136,53 @@ public Long updateProjectProgress(Long activityGroupId, Long progress) throws Pe } @Transactional - public Long addSchedule(Long activityGroupId, List scheduleDtos) throws PermissionDeniedException { + public Long addSchedule(Long activityGroupId, List scheduleDtos) + throws PermissionDeniedException { Member currentMember = externalRetrieveMemberUseCase.getCurrentMember(); ActivityGroup activityGroup = getActivityGroupById(activityGroupId); validateLeaderOrAdminPermission(activityGroup, currentMember, "해당 일정을 등록할 권한이 없습니다."); List groupSchedules = scheduleDtos.stream() - .map(scheduleDto -> mapper.fromDto(scheduleDto, activityGroup)) - .toList(); + .map(scheduleDto -> mapper.fromDto(scheduleDto, activityGroup)) + .toList(); groupScheduleRepository.saveAll(groupSchedules); return activityGroup.getId(); } @Transactional(readOnly = true) - public PagedResponseDto getGroupMembersWithApplyReason(Long activityGroupId, Pageable pageable) throws PermissionDeniedException { + public PagedResponseDto getGroupMembersWithApplyReason( + Long activityGroupId, Pageable pageable) throws PermissionDeniedException { Member currentMember = externalRetrieveMemberUseCase.getCurrentMember(); ActivityGroup activityGroup = getActivityGroupById(activityGroupId); validateLeaderOrAdminPermission(activityGroup, currentMember, "해당 활동의 멤버를 조회할 권한이 없습니다."); List applyForms = applyFormRepository.findAllByActivityGroup(activityGroup); Map memberIdToApplyReasonMap = applyForms.stream() - .collect(Collectors.toMap( - ApplyForm::getMemberId, - ApplyForm::getApplyReason - )); - - Page groupMembers = activityGroupMemberService.getGroupMemberByActivityGroupId(activityGroupId, pageable); - List groupMembersWithApplyReason = groupMembers.getContent().stream() - .map(groupMember -> { - String applyReason = memberIdToApplyReasonMap.getOrDefault(groupMember.getMemberId(), ""); - Member member = externalRetrieveMemberUseCase.getById(groupMember.getMemberId()); - return mapper.toDto(member, groupMember, applyReason); - }) - .toList(); - - Page paginatedGroupMembersWithApplyReason = new PageImpl<>(groupMembersWithApplyReason, pageable, groupMembers.getTotalElements()); - return new PagedResponseDto<>(paginatedGroupMembersWithApplyReason, groupMembers.getTotalElements(), groupMembersWithApplyReason.size()); + .collect(Collectors.toMap( + ApplyForm::getMemberId, + ApplyForm::getApplyReason + )); + + Page groupMembers = activityGroupMemberService.getGroupMemberByActivityGroupId(activityGroupId, + pageable); + List groupMembersWithApplyReason = groupMembers.getContent() + .stream() + .map(groupMember -> { + String applyReason = memberIdToApplyReasonMap.getOrDefault(groupMember.getMemberId(), ""); + Member member = externalRetrieveMemberUseCase.getById(groupMember.getMemberId()); + return mapper.toDto(member, groupMember, applyReason); + }) + .toList(); + + Page paginatedGroupMembersWithApplyReason = new PageImpl<>( + groupMembersWithApplyReason, pageable, groupMembers.getTotalElements()); + return new PagedResponseDto<>(paginatedGroupMembersWithApplyReason, groupMembers.getTotalElements(), + groupMembersWithApplyReason.size()); } // 활동 멤버들의 status를 수정합니다. @Transactional - public Long manageGroupMemberStatus(Long activityGroupId, List memberIds, GroupMemberStatus status) throws PermissionDeniedException { + public Long manageGroupMemberStatus(Long activityGroupId, List memberIds, GroupMemberStatus status) + throws PermissionDeniedException { Member currentMember = externalRetrieveMemberUseCase.getCurrentMember(); ActivityGroup activityGroup = getActivityGroupById(activityGroupId); validateLeaderOrAdminPermission(activityGroup, currentMember, "해당 활동의 신청 멤버를 조회할 권한이 없습니다."); @@ -174,9 +191,11 @@ public Long manageGroupMemberStatus(Long activityGroupId, List memberIds } @Transactional - public Long changeGroupMemberPosition(Long activityGroupId, String memberId, ActivityGroupRole position) throws PermissionDeniedException { + public Long changeGroupMemberPosition(Long activityGroupId, String memberId, ActivityGroupRole position) + throws PermissionDeniedException { ActivityGroup activityGroup = getActivityGroupById(activityGroupId); - GroupMember groupMember = activityGroupMemberService.getGroupMemberByActivityGroupAndMember(activityGroup, memberId); + GroupMember groupMember = activityGroupMemberService.getGroupMemberByActivityGroupAndMember(activityGroup, + memberId); Member currentMember = externalRetrieveMemberUseCase.getCurrentMember(); validateLeaderOrAdminPermission(activityGroup, currentMember, "해당 활동의 멤버 직책을 변경할 권한이 없습니다."); @@ -192,8 +211,9 @@ public Long changeGroupMemberPosition(Long activityGroupId, String memberId, Act @Scheduled(cron = "0 0 0 * * *") public void updateActivityGroupStatusEnd() { - List activityGroups = activityGroupRepository.findByEndDateBeforeAndStatusNot(LocalDate.now(), ActivityGroupStatus.END); - if(!activityGroups.isEmpty()){ + List activityGroups = activityGroupRepository.findByEndDateBeforeAndStatusNot(LocalDate.now(), + ActivityGroupStatus.END); + if (!activityGroups.isEmpty()) { activityGroups.forEach(this::updateActivityGroupStatusEnd); } } @@ -205,24 +225,26 @@ private void updateActivityGroupStatusEnd(ActivityGroup activityGroup) { private void updateGroupMemberStatus(String memberId, GroupMemberStatus status, ActivityGroup activityGroup) { Member member = externalRetrieveMemberUseCase.getById(memberId); - GroupMember groupMember = activityGroupMemberService.getGroupMemberByActivityGroupAndMember(activityGroup, member.getId()); + GroupMember groupMember = activityGroupMemberService.getGroupMemberByActivityGroupAndMember(activityGroup, + member.getId()); groupMember.validateAccessPermission(); groupMember.updateStatus(status); activityGroupMemberService.save(groupMember); - externalSendNotificationUseCase.sendNotificationToMember(member.getId(), "[" + activityGroup.getName() + "]" + " 신청이 [" + status.getDescription() + "] 상태로 변경되었습니다."); + externalSendNotificationUseCase.sendNotificationToMember(member.getId(), + "[" + activityGroup.getName() + "]" + " 신청이 [" + status.getDescription() + "] 상태로 변경되었습니다."); } public ActivityGroup getActivityGroupById(Long activityGroupId) { return activityGroupRepository.findById(activityGroupId) - .orElseThrow(() -> new NotFoundException("존재하지 않는 활동입니다.")); + .orElseThrow(() -> new NotFoundException("존재하지 않는 활동입니다.")); } // 해당 멤버가 특정 활동 그룹의 리더 또는 관리자인지 검증합니다. // 예외가 발생하지 않고 안전하게 처리됩니다. public boolean hasLeaderOrAdminRole(ActivityGroup activityGroup, Member member) { return activityGroupMemberService.findGroupMemberByActivityGroupAndMember(activityGroup, member.getId()) - .map(GroupMember::isLeader) - .orElseGet(member::isAdminRole); + .map(GroupMember::isLeader) + .orElseGet(member::isAdminRole); } // 해당 멤버가 특정 활동 그룹의 리더 또는 관리자인지 검증합니다. @@ -230,8 +252,9 @@ public boolean hasLeaderOrAdminRole(ActivityGroup activityGroup, Member member) public boolean isMemberGroupLeaderRole(Long activityGroupId, String memberId) { ActivityGroup activityGroup = getActivityGroupById(activityGroupId); Member member = externalRetrieveMemberUseCase.getById(memberId); - try{ - GroupMember groupMember = activityGroupMemberService.getGroupMemberByActivityGroupAndMember(activityGroup, member.getId()); + try { + GroupMember groupMember = activityGroupMemberService.getGroupMemberByActivityGroupAndMember(activityGroup, + member.getId()); return groupMember.isLeader() || member.isAdminRole(); } catch (NotFoundException e) { return false; @@ -242,17 +265,19 @@ public boolean isMemberHasRoleInActivityGroup(Member member, ActivityGroupRole r List groupMemberList = activityGroupMemberService.getGroupMemberByMemberId(member.getId()); ActivityGroup activityGroup = activityGroupMemberService.getActivityGroupById(activityGroupId); return groupMemberList.stream() - .anyMatch(groupMember -> groupMember.isSameRoleAndActivityGroup(role, activityGroup)); + .anyMatch(groupMember -> groupMember.isSameRoleAndActivityGroup(role, activityGroup)); } private void validateLeaderRoleChange(ActivityGroup activityGroup, GroupMember groupMember) { - List groupMembers = activityGroupMemberService.getGroupMemberByActivityGroupIdAndRole(activityGroup.getId(), ActivityGroupRole.LEADER); - if(groupMembers.size() == 1 && groupMember.isLeader()) { + List groupMembers = activityGroupMemberService.getGroupMemberByActivityGroupIdAndRole( + activityGroup.getId(), ActivityGroupRole.LEADER); + if (groupMembers.size() == 1 && groupMember.isLeader()) { throw new SingleLeaderModificationException("그룹에는 최소 한 명의 리더가 있어야 하므로, 리더의 역할을 변경할 수 없습니다."); } } - public ActivityGroup validateAndGetActivityGroupForReporting(Long activityGroupId, Member member) throws PermissionDeniedException, IllegalAccessException { + public ActivityGroup validateAndGetActivityGroupForReporting(Long activityGroupId, Member member) + throws PermissionDeniedException, IllegalAccessException { ActivityGroup activityGroup = getActivityGroupById(activityGroupId); if (!isMemberHasRoleInActivityGroup(member, ActivityGroupRole.LEADER, activityGroupId)) { throw new PermissionDeniedException("해당 그룹의 리더만 보고서를 작성할 수 있습니다."); @@ -263,7 +288,8 @@ public ActivityGroup validateAndGetActivityGroupForReporting(Long activityGroupI return activityGroup; } - private void validateLeaderOrAdminPermission(ActivityGroup activityGroup, Member member, String message) throws PermissionDeniedException { + private void validateLeaderOrAdminPermission(ActivityGroup activityGroup, Member member, String message) + throws PermissionDeniedException { if (!hasLeaderOrAdminRole(activityGroup, member)) { throw new PermissionDeniedException(message); } diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupBoardService.java b/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupBoardService.java index cb858d0fb..c990e955c 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupBoardService.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupBoardService.java @@ -1,5 +1,7 @@ package page.clab.api.domain.activity.activitygroup.application; +import java.util.Comparator; +import java.util.List; import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; @@ -36,9 +38,6 @@ import page.clab.api.global.exception.NotFoundException; import page.clab.api.global.exception.PermissionDeniedException; -import java.util.Comparator; -import java.util.List; - @Service @RequiredArgsConstructor public class ActivityGroupBoardService { @@ -55,21 +54,19 @@ public class ActivityGroupBoardService { * 새로운 활동 그룹 게시판을 생성합니다. * *

새 게시판을 생성하기 전 다음 검증이 수행됩니다:

- * - 현재 사용자가 해당 활동 그룹의 멤버인지 확인 - * - 공지, 주차별 활동, 과제, 피드백 카테고리는 관리자 또는 리더 권한 필요 - * - 부모 게시판의 유효성 확인 - * - 이번 주에 이미 과제를 제출했는지 확인 + * - 현재 사용자가 해당 활동 그룹의 멤버인지 확인 - 공지, 주차별 활동, 과제, 피드백 카테고리는 관리자 또는 리더 권한 필요 - 부모 게시판의 유효성 확인 - 이번 주에 이미 과제를 제출했는지 확인 * *

부모 게시판이 있을 경우 자식 게시판으로 추가하며, 게시판 생성 후 알림을 전송합니다.

* - * @param parentId 부모 게시판의 ID (없을 수 있음) + * @param parentId 부모 게시판의 ID (없을 수 있음) * @param activityGroupId 활동 그룹의 ID - * @param requestDto 게시판 생성 요청 DTO + * @param requestDto 게시판 생성 요청 DTO * @return ActivityGroupBoardReferenceDto * @throws PermissionDeniedException 권한이 없는 경우 예외 발생 */ @Transactional - public ActivityGroupBoardReferenceDto createActivityGroupBoard(Long parentId, Long activityGroupId, ActivityGroupBoardRequestDto requestDto) throws PermissionDeniedException { + public ActivityGroupBoardReferenceDto createActivityGroupBoard(Long parentId, Long activityGroupId, + ActivityGroupBoardRequestDto requestDto) throws PermissionDeniedException { Member currentMember = externalRetrieveMemberUseCase.getCurrentMember(); ActivityGroup activityGroup = activityGroupAdminService.getActivityGroupById(activityGroupId); @@ -94,21 +91,24 @@ public ActivityGroupBoardReferenceDto createActivityGroupBoard(Long parentId, Lo return mapper.of(board.getId(), activityGroupId, parentId); } - private void validateGroupMember(ActivityGroup activityGroup, Member currentMember) throws PermissionDeniedException { + private void validateGroupMember(ActivityGroup activityGroup, Member currentMember) + throws PermissionDeniedException { if (!activityGroupMemberService.isGroupMember(activityGroup, currentMember.getId())) { throw new PermissionDeniedException("해당 활동 그룹의 멤버가 아닙니다."); } } - private void validateCanCreateBoard(ActivityGroup activityGroup, ActivityGroupBoardCategory category, Member currentMember) throws PermissionDeniedException { + private void validateCanCreateBoard(ActivityGroup activityGroup, ActivityGroupBoardCategory category, + Member currentMember) throws PermissionDeniedException { Role role = currentMember.getRole(); boolean isRequireAdminOrLeaderCategory = category.isNotice() || - category.isWeeklyActivity() || - category.isAssignment() || - category.isFeedback(); + category.isWeeklyActivity() || + category.isAssignment() || + category.isFeedback(); // NOTICE, WEEKLY_ACTIVITY, ASSIGNMENT, FEEDBACK 카테고리에서 권한이 ADMIN 이상이 아니거나, 리더가 아니면 예외처리 - if (isRequireAdminOrLeaderCategory && !(role.isHigherThanOrEqual(Role.ADMIN) || activityGroupAdminService.hasLeaderOrAdminRole(activityGroup, currentMember))) { + if (isRequireAdminOrLeaderCategory && !(role.isHigherThanOrEqual(Role.ADMIN) + || activityGroupAdminService.hasLeaderOrAdminRole(activityGroup, currentMember))) { throw new PermissionDeniedException("해당 카테고리에서 게시글을 작성할 권한이 없습니다."); } } @@ -128,16 +128,18 @@ private boolean isSubmitterOrLeader(ActivityGroup activityGroup, ActivityGroupBo if (board.getCategory().isFeedback()) { ActivityGroupBoard parentBoard = board.getParent(); boolean isParentSubmitter = parentBoard != null - && parentBoard.getCategory().isSubmit() - && parentBoard.isOwner(currentMember.getId()); + && parentBoard.getCategory().isSubmit() + && parentBoard.isOwner(currentMember.getId()); return isLeader || isParentSubmitter; } return isSubmitter || isLeader; } - private void validateAlreadySubmittedAssignmentThisWeek(ActivityGroupBoardCategory category, Long parentId, String memberId) { + private void validateAlreadySubmittedAssignmentThisWeek(ActivityGroupBoardCategory category, Long parentId, + String memberId) { if (category.isSubmit()) { - boolean hasSubmitted = activityGroupBoardRepository.existsByParentIdAndCategoryAndMemberId(parentId, ActivityGroupBoardCategory.SUBMIT, memberId); + boolean hasSubmitted = activityGroupBoardRepository.existsByParentIdAndCategoryAndMemberId(parentId, + ActivityGroupBoardCategory.SUBMIT, memberId); if (hasSubmitted) { throw new AlreadySubmittedThisWeekAssignmentException(); } @@ -148,56 +150,64 @@ private void validateAlreadySubmittedAssignmentThisWeek(ActivityGroupBoardCatego public PagedResponseDto getAllActivityGroupBoard(Pageable pageable) { Page boards = activityGroupBoardRepository.findAll(pageable); return new PagedResponseDto<>(boards.map(board -> { - MemberBasicInfoDto memberBasicInfoDto = externalRetrieveMemberUseCase.getMemberBasicInfoById(board.getMemberId()); + MemberBasicInfoDto memberBasicInfoDto = externalRetrieveMemberUseCase.getMemberBasicInfoById( + board.getMemberId()); return mapper.toBoardDto(board, memberBasicInfoDto); })); } @Transactional(readOnly = true) - public ActivityGroupBoardResponseDto getActivityGroupBoard(Long activityGroupBoardId) throws PermissionDeniedException { + public ActivityGroupBoardResponseDto getActivityGroupBoard(Long activityGroupBoardId) + throws PermissionDeniedException { Member currentMember = externalRetrieveMemberUseCase.getCurrentMember(); ActivityGroupBoard board = getActivityGroupBoardById(activityGroupBoardId); validateGroupMember(board.getActivityGroup(), currentMember); if (!hasAccessToBoard(board.getActivityGroup(), board, currentMember)) { throw new PermissionDeniedException("해당 게시물을 조회할 권한이 없습니다."); } - MemberBasicInfoDto memberBasicInfoDto = externalRetrieveMemberUseCase.getMemberBasicInfoById(board.getMemberId()); + MemberBasicInfoDto memberBasicInfoDto = externalRetrieveMemberUseCase.getMemberBasicInfoById( + board.getMemberId()); return mapper.toBoardDto(board, memberBasicInfoDto); } @Transactional(readOnly = true) - public PagedResponseDto getActivityGroupBoardByCategory(Long activityGroupId, ActivityGroupBoardCategory category, Pageable pageable) throws PermissionDeniedException { + public PagedResponseDto getActivityGroupBoardByCategory(Long activityGroupId, + ActivityGroupBoardCategory category, Pageable pageable) throws PermissionDeniedException { Member currentMember = externalRetrieveMemberUseCase.getCurrentMember(); ActivityGroup activityGroup = activityGroupAdminService.getActivityGroupById(activityGroupId); validateGroupMember(activityGroup, currentMember); - Page boards = activityGroupBoardRepository.findAllByActivityGroup_IdAndCategory(activityGroupId, category, pageable); + Page boards = activityGroupBoardRepository.findAllByActivityGroup_IdAndCategory( + activityGroupId, category, pageable); // 사용자 권한에 따라 접근 가능한 게시판만 반환합니다. List filteredBoards = boards.stream() - .filter(board -> hasAccessToBoard(board.getActivityGroup(), board, currentMember)) - .map(board -> { - MemberBasicInfoDto memberBasicInfoDto = externalRetrieveMemberUseCase.getMemberBasicInfoById(board.getMemberId()); - return mapper.toBoardDto(board, memberBasicInfoDto); - }) - .toList(); + .filter(board -> hasAccessToBoard(board.getActivityGroup(), board, currentMember)) + .map(board -> { + MemberBasicInfoDto memberBasicInfoDto = externalRetrieveMemberUseCase.getMemberBasicInfoById( + board.getMemberId()); + return mapper.toBoardDto(board, memberBasicInfoDto); + }) + .toList(); return new PagedResponseDto<>(new PageImpl<>(filteredBoards, pageable, boards.getTotalElements())); } @Transactional(readOnly = true) - public PagedResponseDto getActivityGroupBoardByParent(Long parentId, Pageable pageable) throws PermissionDeniedException { + public PagedResponseDto getActivityGroupBoardByParent(Long parentId, + Pageable pageable) throws PermissionDeniedException { Member currentMember = externalRetrieveMemberUseCase.getCurrentMember(); ActivityGroupBoard parentBoard = getActivityGroupBoardById(parentId); Long activityGroupId = parentBoard.getActivityGroup().getId(); validateGroupMember(parentBoard.getActivityGroup(), currentMember); - List groupLeaders = activityGroupMemberService.getGroupMemberByActivityGroupIdAndRole(activityGroupId, ActivityGroupRole.LEADER); + List groupLeaders = activityGroupMemberService.getGroupMemberByActivityGroupIdAndRole( + activityGroupId, ActivityGroupRole.LEADER); parentBoard.validateAccessPermission(currentMember, groupLeaders); List childBoards = getChildBoards(parentId); // 접근 가능한 자식 게시판만 조회합니다. List filteredBoards = childBoards.stream() - .filter(board -> hasAccessToBoard(board.getActivityGroup(), board, currentMember)) - .map(this::toActivityGroupBoardChildResponseDtoWithMemberInfo) - .toList(); + .filter(board -> hasAccessToBoard(board.getActivityGroup(), board, currentMember)) + .map(this::toActivityGroupBoardChildResponseDtoWithMemberInfo) + .toList(); return new PagedResponseDto<>(new PageImpl<>(filteredBoards, pageable, filteredBoards.size())); } @@ -206,25 +216,29 @@ public PagedResponseDto getActivityGroupBoar public List getMyAssignmentsWithFeedbacks(Long parentId) { Member currentMember = externalRetrieveMemberUseCase.getCurrentMember(); - List mySubmissions = activityGroupBoardRepository.findMySubmissionsWithFeedbacks(parentId, currentMember.getId()); + List mySubmissions = activityGroupBoardRepository.findMySubmissionsWithFeedbacks(parentId, + currentMember.getId()); // 해당 과제에 대한 피드백 목록을 조회합니다. return mySubmissions.stream() - .map(submission -> { - List feedbackDtos = submission.getChildren().stream() - .filter(ActivityGroupBoard::isFeedback) - .map(board -> { - MemberBasicInfoDto memberBasicInfoDto = externalRetrieveMemberUseCase.getMemberBasicInfoById(board.getMemberId()); - return mapper.toFeedbackDto(board, memberBasicInfoDto); - }) - .toList(); - MemberBasicInfoDto memberBasicInfoDto = externalRetrieveMemberUseCase.getMemberBasicInfoById(submission.getMemberId()); - return mapper.toAssignmentDto(submission, memberBasicInfoDto, feedbackDtos); - }) - .toList(); + .map(submission -> { + List feedbackDtos = submission.getChildren().stream() + .filter(ActivityGroupBoard::isFeedback) + .map(board -> { + MemberBasicInfoDto memberBasicInfoDto = externalRetrieveMemberUseCase.getMemberBasicInfoById( + board.getMemberId()); + return mapper.toFeedbackDto(board, memberBasicInfoDto); + }) + .toList(); + MemberBasicInfoDto memberBasicInfoDto = externalRetrieveMemberUseCase.getMemberBasicInfoById( + submission.getMemberId()); + return mapper.toAssignmentDto(submission, memberBasicInfoDto, feedbackDtos); + }) + .toList(); } @Transactional - public ActivityGroupBoardReferenceDto updateActivityGroupBoard(Long activityGroupBoardId, ActivityGroupBoardUpdateRequestDto requestDto) throws PermissionDeniedException { + public ActivityGroupBoardReferenceDto updateActivityGroupBoard(Long activityGroupBoardId, + ActivityGroupBoardUpdateRequestDto requestDto) throws PermissionDeniedException { Member currentMember = externalRetrieveMemberUseCase.getCurrentMember(); ActivityGroupBoard board = getActivityGroupBoardById(activityGroupBoardId); board.validateAccessPermission(currentMember); @@ -235,7 +249,8 @@ public ActivityGroupBoardReferenceDto updateActivityGroupBoard(Long activityGrou return mapper.of(board.getId(), board.getActivityGroup().getId(), parentId); } - public ActivityGroupBoardReferenceDto deleteActivityGroupBoard(Long activityGroupBoardId) throws PermissionDeniedException { + public ActivityGroupBoardReferenceDto deleteActivityGroupBoard(Long activityGroupBoardId) + throws PermissionDeniedException { Member currentMember = externalRetrieveMemberUseCase.getCurrentMember(); ActivityGroupBoard board = getActivityGroupBoardById(activityGroupBoardId); board.validateAccessPermission(currentMember); @@ -248,29 +263,33 @@ public ActivityGroupBoardReferenceDto deleteActivityGroupBoard(Long activityGrou public PagedResponseDto getDeletedActivityGroupBoards(Pageable pageable) { Page boards = activityGroupBoardRepository.findAllByIsDeletedTrue(pageable); return new PagedResponseDto<>(boards.map(board -> { - MemberBasicInfoDto memberBasicInfoDto = externalRetrieveMemberUseCase.getMemberBasicInfoById(board.getMemberId()); + MemberBasicInfoDto memberBasicInfoDto = externalRetrieveMemberUseCase.getMemberBasicInfoById( + board.getMemberId()); return mapper.toBoardDto(board, memberBasicInfoDto); })); } public ActivityGroupBoard getActivityGroupBoardById(Long activityGroupBoardId) { return activityGroupBoardRepository.findById(activityGroupBoardId) - .orElseThrow(() -> new NotFoundException("해당 활동 그룹 게시글을 찾을 수 없습니다.")); + .orElseThrow(() -> new NotFoundException("해당 활동 그룹 게시글을 찾을 수 없습니다.")); } private List getChildBoards(Long activityGroupBoardId) { - List children = activityGroupBoardRepository.findAllChildrenByParentId(activityGroupBoardId); + List children = activityGroupBoardRepository.findAllChildrenByParentId( + activityGroupBoardId); children.sort(Comparator.comparing(ActivityGroupBoard::getCreatedAt).reversed()); return children; } - public ActivityGroupBoardChildResponseDto toActivityGroupBoardChildResponseDtoWithMemberInfo(ActivityGroupBoard activityGroupBoard) { + public ActivityGroupBoardChildResponseDto toActivityGroupBoardChildResponseDtoWithMemberInfo( + ActivityGroupBoard activityGroupBoard) { Member currentMember = externalRetrieveMemberUseCase.getCurrentMember(); - MemberBasicInfoDto memberBasicInfo = externalRetrieveMemberUseCase.getMemberBasicInfoById(activityGroupBoard.getMemberId()); + MemberBasicInfoDto memberBasicInfo = externalRetrieveMemberUseCase.getMemberBasicInfoById( + activityGroupBoard.getMemberId()); List childrenDtos = activityGroupBoard.getChildren().stream() - .filter(children -> hasAccessToBoard(children.getActivityGroup(), children, currentMember)) - .map(this::toActivityGroupBoardChildResponseDtoWithMemberInfo) - .toList(); + .filter(children -> hasAccessToBoard(children.getActivityGroup(), children, currentMember)) + .map(this::toActivityGroupBoardChildResponseDtoWithMemberInfo) + .toList(); return mapper.toChildDto(activityGroupBoard, memberBasicInfo, childrenDtos); } @@ -278,17 +297,15 @@ public ActivityGroupBoardChildResponseDto toActivityGroupBoardChildResponseDtoWi * 주어진 카테고리와 부모 게시판의 유효성을 검증합니다. * *

다음 규칙을 따릅니다:

- * - 공지와 주차별 활동 게시판은 부모 게시판을 가질 수 없습니다. - * - 과제, 제출, 피드백 게시판은 부모 게시판이 반드시 필요합니다. - * - 과제의 부모는 주차별 활동 게시판이어야 합니다. - * - 제출의 부모는 과제 게시판이어야 합니다. - * - 피드백의 부모는 제출 게시판이어야 합니다. + * - 공지와 주차별 활동 게시판은 부모 게시판을 가질 수 없습니다. - 과제, 제출, 피드백 게시판은 부모 게시판이 반드시 필요합니다. - 과제의 부모는 주차별 활동 게시판이어야 합니다. - 제출의 부모는 + * 과제 게시판이어야 합니다. - 피드백의 부모는 제출 게시판이어야 합니다. * * @param category 게시판 카테고리 * @param parentId 부모 게시판의 ID * @throws InvalidParentBoardException 부모 게시판이 유효하지 않은 경우 예외 발생 */ - private void validateParentBoard(ActivityGroupBoardCategory category, Long parentId) throws InvalidParentBoardException { + private void validateParentBoard(ActivityGroupBoardCategory category, Long parentId) + throws InvalidParentBoardException { if ((category.isNotice() || category.isWeeklyActivity())) { if (parentId != null) { throw new InvalidParentBoardException(category.getDescription() + " 게시물은 부모 게시판을 가질 수 없습니다."); @@ -325,33 +342,42 @@ private void validateParentBoard(ActivityGroupBoardCategory category, Long paren * 새 게시판 생성에 대한 알림을 활동 그룹 멤버들에게 전송합니다. * *

이 메서드는 활동 그룹에서 새 게시판이 생성될 때 관련 멤버들에게 알림을 전송합니다. - * 만약 게시판을 생성한 멤버가 그룹 리더일 경우, 본인을 제외한 다른 모든 멤버들에게 알림이 전송됩니다. - * 단, 게시판이 피드백 유형일 경우에는 과제 제출한 멤버에게만 알림이 전송됩니다. - * 만약 게시판을 생성한 멤버가 팀원인 경우, 그룹 리더에게만 알림이 전송됩니다.

+ * 만약 게시판을 생성한 멤버가 그룹 리더일 경우, 본인을 제외한 다른 모든 멤버들에게 알림이 전송됩니다. 단, 게시판이 피드백 유형일 경우에는 과제 제출한 멤버에게만 알림이 전송됩니다. 만약 게시판을 + * 생성한 멤버가 팀원인 경우, 그룹 리더에게만 알림이 전송됩니다.

* * @param activityGroupId 게시판이 생성된 활동 그룹의 ID - * @param activityGroup 게시판이 생성된 활동 그룹 - * @param board 생성된 게시판 객체 - * @param member 게시판을 생성한 멤버 객체 + * @param activityGroup 게시판이 생성된 활동 그룹 + * @param board 생성된 게시판 객체 + * @param member 게시판을 생성한 멤버 객체 */ - private void notifyMembersAboutNewBoard(Long activityGroupId, ActivityGroup activityGroup, ActivityGroupBoard board, Member member) { - GroupMember groupMember = activityGroupMemberService.getGroupMemberByActivityGroupAndMember(activityGroup, member.getId()); + private void notifyMembersAboutNewBoard(Long activityGroupId, ActivityGroup activityGroup, ActivityGroupBoard board, + Member member) { + GroupMember groupMember = activityGroupMemberService.getGroupMemberByActivityGroupAndMember(activityGroup, + member.getId()); if (groupMember.isLeader()) { if (board.isFeedback()) { String submitMemberId = board.getParent().getMemberId(); - externalSendNotificationUseCase.sendNotificationToMember(submitMemberId, "[" + activityGroup.getName() + "] " + member.getName() + "님이 새 피드백을 등록하였습니다."); + externalSendNotificationUseCase.sendNotificationToMember(submitMemberId, + "[" + activityGroup.getName() + "] " + member.getName() + "님이 새 피드백을 등록하였습니다."); } else { - List groupMembers = activityGroupMemberService.getGroupMemberByActivityGroupIdAndStatus(activityGroupId, GroupMemberStatus.ACCEPTED); + List groupMembers = activityGroupMemberService.getGroupMemberByActivityGroupIdAndStatus( + activityGroupId, GroupMemberStatus.ACCEPTED); List groupMembersId = groupMembers.stream() - .map(GroupMember::getMemberId) - .filter(memberId -> !memberId.equals(groupMember.getMemberId())) - .collect(Collectors.toList()); - externalSendNotificationUseCase.sendNotificationToMembers(groupMembersId, "[" + activityGroup.getName() + "] " + member.getName() + "님이 새 " + board.getCategory().getDescription() + "을(를) 등록하였습니다."); + .map(GroupMember::getMemberId) + .filter(memberId -> !memberId.equals(groupMember.getMemberId())) + .collect(Collectors.toList()); + externalSendNotificationUseCase.sendNotificationToMembers(groupMembersId, + "[" + activityGroup.getName() + "] " + member.getName() + "님이 새 " + board.getCategory() + .getDescription() + "을(를) 등록하였습니다."); } } else { - List groupLeaders = activityGroupMemberService.getGroupMemberByActivityGroupIdAndRole(activityGroupId, ActivityGroupRole.LEADER); + List groupLeaders = activityGroupMemberService.getGroupMemberByActivityGroupIdAndRole( + activityGroupId, ActivityGroupRole.LEADER); if (!CollectionUtils.isEmpty(groupLeaders)) { - groupLeaders.forEach(leader -> externalSendNotificationUseCase.sendNotificationToMember(leader.getMemberId(), "[" + activityGroup.getName() + "] " + member.getName() + "님이 새 " + board.getCategory().getDescription() + "을(를) 등록하였습니다.")); + groupLeaders.forEach( + leader -> externalSendNotificationUseCase.sendNotificationToMember(leader.getMemberId(), + "[" + activityGroup.getName() + "] " + member.getName() + "님이 새 " + board.getCategory() + .getDescription() + "을(를) 등록하였습니다.")); } } } diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupMemberService.java b/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupMemberService.java index 06fb731a8..9c072636a 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupMemberService.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupMemberService.java @@ -1,5 +1,12 @@ package page.clab.api.domain.activity.activitygroup.application; +import java.time.LocalDateTime; +import java.util.Comparator; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.function.Function; +import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -40,14 +47,6 @@ import page.clab.api.global.exception.NotFoundException; import page.clab.api.global.util.PaginationUtils; -import java.time.LocalDateTime; -import java.util.Comparator; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.function.Function; -import java.util.stream.Collectors; - @Service @RequiredArgsConstructor public class ActivityGroupMemberService { @@ -68,56 +67,63 @@ public ActivityGroupDetailResponseDto getActivityGroup(Long activityGroupId) { Member currentMember = externalRetrieveMemberUseCase.getCurrentMember(); boolean isOwner = details.getGroupMembers().stream() - .anyMatch(groupMember -> groupMember.isOwnerAndLeader(currentMember)); + .anyMatch(groupMember -> groupMember.isOwnerAndLeader(currentMember)); // 활동 그룹 멤버를 조회합니다. List groupMemberResponseDtos = details.getGroupMembers().stream() - .map(groupMember -> mapper.toDto(externalRetrieveMemberUseCase.getById(groupMember.getMemberId()), groupMember)) - .toList(); + .map(groupMember -> mapper.toDto(externalRetrieveMemberUseCase.getById(groupMember.getMemberId()), + groupMember)) + .toList(); // 활동 그룹 게시판을 조회합니다. List activityGroupBoardResponseDtos = - details.getActivityGroupBoards().stream() - .map(board -> { - MemberBasicInfoDto memberBasicInfoDto = externalRetrieveMemberUseCase.getMemberBasicInfoById(board.getMemberId()); - return mapper.toBoardDto(board, memberBasicInfoDto); - }) - .toList(); - - return mapper.toDto(details.getActivityGroup(), activityGroupBoardResponseDtos, groupMemberResponseDtos, isOwner); + details.getActivityGroupBoards().stream() + .map(board -> { + MemberBasicInfoDto memberBasicInfoDto = externalRetrieveMemberUseCase.getMemberBasicInfoById( + board.getMemberId()); + return mapper.toBoardDto(board, memberBasicInfoDto); + }) + .toList(); + + return mapper.toDto(details.getActivityGroup(), activityGroupBoardResponseDtos, groupMemberResponseDtos, + isOwner); } @Transactional(readOnly = true) - public PagedResponseDto getMyActivityGroups(ActivityGroupStatus status, Pageable pageable) { + public PagedResponseDto getMyActivityGroups(ActivityGroupStatus status, + Pageable pageable) { String currentMemberId = externalRetrieveMemberUseCase.getCurrentMemberId(); List groupMembers = getGroupMemberByMemberId(currentMemberId); // 현재 로그인한 멤버가 활동중인 그룹을 조회합니다. // 상태가 전달되지 않으면 모든 그룹을 조회합니다. List activityGroups = groupMembers.stream() - .filter(GroupMember::isAccepted) - .map(GroupMember::getActivityGroup) - .filter(activityGroup -> status == null || activityGroup.isSameStatus(status)) - .distinct() - .toList(); + .filter(GroupMember::isAccepted) + .map(GroupMember::getActivityGroup) + .filter(activityGroup -> status == null || activityGroup.isSameStatus(status)) + .distinct() + .toList(); List activityGroupDtos = activityGroups.stream() - .map(this::getActivityGroupStatusResponseDto) - .toList(); + .map(this::getActivityGroupStatusResponseDto) + .toList(); - List paginatedActivityGroupDtos = PaginationUtils.applySortingAndSlicing(activityGroupDtos, pageable); + List paginatedActivityGroupDtos = PaginationUtils.applySortingAndSlicing( + activityGroupDtos, pageable); return new PagedResponseDto<>(paginatedActivityGroupDtos, activityGroups.size(), pageable); } @Transactional(readOnly = true) - public PagedResponseDto getActivityGroupsByStatus(ActivityGroupStatus status, Pageable pageable) { + public PagedResponseDto getActivityGroupsByStatus(ActivityGroupStatus status, + Pageable pageable) { Page activityGroups = activityGroupRepository.findActivityGroupsByStatus(status, pageable); return new PagedResponseDto<>(activityGroups.map(this::getActivityGroupStatusResponseDto)); } @Transactional(readOnly = true) - public PagedResponseDto getActivityGroupsByCategory(ActivityGroupCategory category, Pageable pageable) { + public PagedResponseDto getActivityGroupsByCategory(ActivityGroupCategory category, + Pageable pageable) { Page activityGroupList = getActivityGroupByCategory(category, pageable); return new PagedResponseDto<>(activityGroupList.map(mapper::toDto)); } @@ -130,7 +136,8 @@ public PagedResponseDto getGroupSchedules(Long activityGroupId @Transactional(readOnly = true) public PagedResponseDto getActivityGroupMembers(Long activityGroupId, Pageable pageable) { - Page groupMembers = getGroupMemberByActivityGroupIdAndStatus(activityGroupId, GroupMemberStatus.ACCEPTED, pageable); + Page groupMembers = getGroupMemberByActivityGroupIdAndStatus(activityGroupId, + GroupMemberStatus.ACCEPTED, pageable); return new PagedResponseDto<>(groupMembers.map(groupMember -> { Member member = externalRetrieveMemberUseCase.getById(groupMember.getMemberId()); return mapper.toDto(member, groupMember); @@ -149,12 +156,16 @@ public Long applyActivityGroup(Long activityGroupId, ApplyFormRequestDto formReq ApplyForm form = mapper.fromDto(formRequestDto, activityGroup, currentMember); applyFormRepository.save(form); - GroupMember groupMember = GroupMember.create(currentMember.getId(), activityGroup, ActivityGroupRole.NONE, GroupMemberStatus.WAITING); + GroupMember groupMember = GroupMember.create(currentMember.getId(), activityGroup, ActivityGroupRole.NONE, + GroupMemberStatus.WAITING); groupMemberRepository.save(groupMember); - List groupLeaders = getGroupMemberByActivityGroupIdAndRole(activityGroup.getId(), ActivityGroupRole.LEADER); + List groupLeaders = getGroupMemberByActivityGroupIdAndRole(activityGroup.getId(), + ActivityGroupRole.LEADER); if (!CollectionUtils.isEmpty(groupLeaders)) { - groupLeaders.forEach(leader -> externalSendNotificationUseCase.sendNotificationToMember(leader.getMemberId(), "[" + activityGroup.getName() + "] " + currentMember.getName() + "님이 활동 참가 신청을 하였습니다.")); + groupLeaders.forEach( + leader -> externalSendNotificationUseCase.sendNotificationToMember(leader.getMemberId(), + "[" + activityGroup.getName() + "] " + currentMember.getName() + "님이 활동 참가 신청을 하였습니다.")); } return activityGroup.getId(); } @@ -164,22 +175,23 @@ public PagedResponseDto getAppliedActivityGroups List groupMembers = getGroupMemberByMemberId(currentMemberId); List activityGroupIds = groupMembers.stream() - .map(GroupMember::getActivityGroup) - .map(ActivityGroup::getId) - .distinct() - .toList(); + .map(GroupMember::getActivityGroup) + .map(ActivityGroup::getId) + .distinct() + .toList(); Map activityGroupOwners = findActivityGroupOwners(activityGroupIds); List activityGroups = groupMembers.stream() - .filter(groupMember -> !isActivityGroupOwner(groupMember, activityGroupOwners)) - .map(GroupMember::getActivityGroup) - .filter(ActivityGroup::isProgressing) - .distinct() - .map(this::getActivityGroupStatusResponseDto) - .toList(); + .filter(groupMember -> !isActivityGroupOwner(groupMember, activityGroupOwners)) + .map(GroupMember::getActivityGroup) + .filter(ActivityGroup::isProgressing) + .distinct() + .map(this::getActivityGroupStatusResponseDto) + .toList(); - List paginatedActivityGroups = PaginationUtils.applySortingAndSlicing(activityGroups, pageable); + List paginatedActivityGroups = PaginationUtils.applySortingAndSlicing( + activityGroups, pageable); return new PagedResponseDto<>(paginatedActivityGroups, activityGroups.size(), pageable); } @@ -189,32 +201,33 @@ private ActivityGroupStatusResponseDto getActivityGroupStatusResponseDto(Activit Long participantCount = groupMemberRepository.countAcceptedMembersByActivityGroupId(activityGroupId); List leaderMembers = groupMemberRepository.findLeaderByActivityGroupId(activityGroupId) - .stream() - .map(leader -> { - Member member = externalRetrieveMemberUseCase.getById(leader.getMemberId()); - LocalDateTime createdAt = leader.getCreatedAt(); - return mapper.create(member, createdAt); - }) - // LEADER 직책을 가진 사람 중 가장 먼저 활동에 참여한 사람 순으로 정렬 - .sorted(Comparator.comparing(LeaderInfo::getCreatedAt)) - .toList(); - - Long weeklyActivityCount = activityGroupBoardRepository.countByActivityGroupIdAndCategory(activityGroupId, ActivityGroupBoardCategory.WEEKLY_ACTIVITY); + .stream() + .map(leader -> { + Member member = externalRetrieveMemberUseCase.getById(leader.getMemberId()); + LocalDateTime createdAt = leader.getCreatedAt(); + return mapper.create(member, createdAt); + }) + // LEADER 직책을 가진 사람 중 가장 먼저 활동에 참여한 사람 순으로 정렬 + .sorted(Comparator.comparing(LeaderInfo::getCreatedAt)) + .toList(); + + Long weeklyActivityCount = activityGroupBoardRepository.countByActivityGroupIdAndCategory(activityGroupId, + ActivityGroupBoardCategory.WEEKLY_ACTIVITY); return mapper.toDto(activityGroup, leaderMembers, participantCount, weeklyActivityCount); } public ActivityGroup getActivityGroupById(Long activityGroupId) { return activityGroupRepository.findById(activityGroupId) - .orElseThrow(() -> new NotFoundException("해당 활동이 존재하지 않습니다.")); + .orElseThrow(() -> new NotFoundException("해당 활동이 존재하지 않습니다.")); } public Map findActivityGroupOwners(List activityGroupIds) { return groupMemberRepository.findFirstByActivityGroupIdIn(activityGroupIds).stream() - .collect(Collectors.toMap( - groupMember -> groupMember.getActivityGroup().getId(), - Function.identity() - )); + .collect(Collectors.toMap( + groupMember -> groupMember.getActivityGroup().getId(), + Function.identity() + )); } public Optional findGroupMemberByActivityGroupAndMember(ActivityGroup activityGroup, String memberId) { @@ -223,7 +236,7 @@ public Optional findGroupMemberByActivityGroupAndMember(ActivityGro public GroupMember getGroupMemberByActivityGroupAndMember(ActivityGroup activityGroup, String memberId) { return groupMemberRepository.findByActivityGroupAndMemberId(activityGroup, memberId) - .orElseThrow(() -> new NotFoundException("해당 멤버가 활동에 참여하지 않았습니다.")); + .orElseThrow(() -> new NotFoundException("해당 멤버가 활동에 참여하지 않았습니다.")); } private Page getActivityGroupByCategory(ActivityGroupCategory category, Pageable pageable) { @@ -246,7 +259,8 @@ public List getGroupMemberByActivityGroupIdAndStatus(Long activityG return groupMemberRepository.findAllByActivityGroupIdAndStatus(activityGroupId, status); } - public Page getGroupMemberByActivityGroupIdAndStatus(Long activityGroupId, GroupMemberStatus status, Pageable pageable) { + public Page getGroupMemberByActivityGroupIdAndStatus(Long activityGroupId, GroupMemberStatus status, + Pageable pageable) { return groupMemberRepository.findAllByActivityGroupIdAndStatus(activityGroupId, status, pageable); } @@ -259,7 +273,8 @@ public List getGroupMemberByMemberId(String memberId) { } public boolean isGroupMember(ActivityGroup activityGroup, String memberId) { - return groupMemberRepository.existsByActivityGroupAndMemberIdAndStatus(activityGroup, memberId, GroupMemberStatus.ACCEPTED); + return groupMemberRepository.existsByActivityGroupAndMemberIdAndStatus(activityGroup, memberId, + GroupMemberStatus.ACCEPTED); } private boolean isActivityGroupOwner(GroupMember groupMember, Map activityGroupOwners) { diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupReportService.java b/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupReportService.java index 441beddd8..c17a91a8c 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupReportService.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupReportService.java @@ -31,10 +31,12 @@ public class ActivityGroupReportService { private final ActivityGroupDtoMapper mapper; @Transactional - public Long writeReport(ActivityGroupReportRequestDto requestDto) throws PermissionDeniedException, IllegalAccessException { + public Long writeReport(ActivityGroupReportRequestDto requestDto) + throws PermissionDeniedException, IllegalAccessException { Member currentMember = externalRetrieveMemberUseCase.getCurrentMember(); Long activityGroupId = requestDto.getActivityGroupId(); - ActivityGroup activityGroup = activityGroupAdminService.validateAndGetActivityGroupForReporting(activityGroupId, currentMember); + ActivityGroup activityGroup = activityGroupAdminService.validateAndGetActivityGroupForReporting(activityGroupId, + currentMember); ActivityGroupReport report = validateReportCreationPermission(requestDto, activityGroup); return activityGroupReportRepository.save(report).getId(); } @@ -42,7 +44,8 @@ public Long writeReport(ActivityGroupReportRequestDto requestDto) throws Permiss @Transactional(readOnly = true) public PagedResponseDto getReports(Long activityGroupId, Pageable pageable) { ActivityGroup activityGroup = activityGroupAdminService.getActivityGroupById(activityGroupId); - Page reports = activityGroupReportRepository.findAllByActivityGroup(activityGroup, pageable); + Page reports = activityGroupReportRepository.findAllByActivityGroup(activityGroup, + pageable); return new PagedResponseDto<>(reports.map(mapper::toDto)); } @@ -54,7 +57,8 @@ public ActivityGroupReportResponseDto searchReport(Long activityGroupId, Long tu } @Transactional - public Long updateReport(Long reportId, Long activityGroupId, ActivityGroupReportUpdateRequestDto requestDto) throws PermissionDeniedException, IllegalAccessException { + public Long updateReport(Long reportId, Long activityGroupId, ActivityGroupReportUpdateRequestDto requestDto) + throws PermissionDeniedException, IllegalAccessException { Member currentMember = externalRetrieveMemberUseCase.getCurrentMember(); ActivityGroup activityGroup = activityGroupAdminService.getActivityGroupById(activityGroupId); validateReportUpdatePermission(activityGroupId, currentMember, activityGroup); @@ -78,18 +82,21 @@ public PagedResponseDto getDeletedActivityGroupR public ActivityGroupReport getReportById(Long reportId) { return activityGroupReportRepository.findById(reportId) - .orElseThrow(() -> new NotFoundException("활동 보고서를 찾을 수 없습니다.")); + .orElseThrow(() -> new NotFoundException("활동 보고서를 찾을 수 없습니다.")); } - private ActivityGroupReport validateReportCreationPermission(ActivityGroupReportRequestDto requestDto, ActivityGroup activityGroup) { + private ActivityGroupReport validateReportCreationPermission(ActivityGroupReportRequestDto requestDto, + ActivityGroup activityGroup) { if (activityGroupReportRepository.existsByActivityGroupAndTurn(activityGroup, requestDto.getTurn())) { throw new DuplicateReportException("이미 해당 차시의 보고서가 존재합니다."); } return mapper.fromDto(requestDto, activityGroup); } - private void validateReportUpdatePermission(Long activityGroupId, Member currentMember, ActivityGroup activityGroup) throws PermissionDeniedException, IllegalAccessException { - if (!activityGroupAdminService.isMemberHasRoleInActivityGroup(currentMember, ActivityGroupRole.LEADER, activityGroupId)) { + private void validateReportUpdatePermission(Long activityGroupId, Member currentMember, ActivityGroup activityGroup) + throws PermissionDeniedException, IllegalAccessException { + if (!activityGroupAdminService.isMemberHasRoleInActivityGroup(currentMember, ActivityGroupRole.LEADER, + activityGroupId)) { throw new PermissionDeniedException("해당 그룹의 리더만 보고서를 수정할 수 있습니다."); } if (!activityGroup.isProgressing()) { @@ -98,9 +105,11 @@ private void validateReportUpdatePermission(Long activityGroupId, Member current } @NotNull - private ActivityGroupReport validateReportDeletionPermission(Long reportId, Member member) throws PermissionDeniedException { + private ActivityGroupReport validateReportDeletionPermission(Long reportId, Member member) + throws PermissionDeniedException { ActivityGroupReport report = getReportById(reportId); - if (!activityGroupAdminService.isMemberHasRoleInActivityGroup(member, ActivityGroupRole.LEADER, report.getActivityGroup().getId())) { + if (!activityGroupAdminService.isMemberHasRoleInActivityGroup(member, ActivityGroupRole.LEADER, + report.getActivityGroup().getId())) { throw new PermissionDeniedException("해당 그룹의 리더만 보고서를 삭제할 수 있습니다."); } return report; diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/application/AttendanceService.java b/src/main/java/page/clab/api/domain/activity/activitygroup/application/AttendanceService.java index 53e0f8ae7..79a1516f0 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/application/AttendanceService.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/application/AttendanceService.java @@ -2,6 +2,11 @@ import com.google.zxing.WriterException; import com.warrenstrange.googleauth.GoogleAuthenticator; +import java.io.File; +import java.io.IOException; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import lombok.RequiredArgsConstructor; import org.jetbrains.annotations.NotNull; import org.springframework.data.domain.Page; @@ -32,12 +37,6 @@ import page.clab.api.global.exception.PermissionDeniedException; import page.clab.api.global.util.QRCodeUtil; -import java.io.File; -import java.io.IOException; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; - @Service @RequiredArgsConstructor public class AttendanceService { @@ -57,8 +56,8 @@ public class AttendanceService { @NotNull private static String buildPathForQRCode(ActivityGroup activityGroup) { return "attendance" + File.separator - + activityGroup.getCategory().toString() + File.separator - + activityGroup.getId().toString(); + + activityGroup.getCategory().toString() + File.separator + + activityGroup.getId().toString(); } @NotNull @@ -67,7 +66,8 @@ private static String generateQRCodeURL(Long activityGroupId, String secretKey) } @Transactional - public String generateAttendanceQRCode(Long activityGroupId) throws IOException, WriterException, PermissionDeniedException, IllegalAccessException { + public String generateAttendanceQRCode(Long activityGroupId) + throws IOException, WriterException, PermissionDeniedException, IllegalAccessException { Member currentMember = externalRetrieveMemberUseCase.getCurrentMember(); ActivityGroup activityGroup = validateAttendanceQRCodeGeneration(activityGroupId, currentMember); @@ -77,7 +77,8 @@ public String generateAttendanceQRCode(Long activityGroupId) throws IOException, redisQRKeyRepository.save(redisQRKey); String url = generateQRCodeURL(activityGroupId, secretKey); - Attendance attendance = Attendance.create(currentMember.getId(), activityGroup, LocalDate.parse(nowDateTime.split(" ")[0], dateFormatter)); + Attendance attendance = Attendance.create(currentMember.getId(), activityGroup, + LocalDate.parse(nowDateTime.split(" ")[0], dateFormatter)); attendanceRepository.save(attendance); byte[] QRCodeImage = QRCodeUtil.encodeQRCode(url); @@ -95,7 +96,8 @@ public Long checkMemberAttendance(AttendanceRequestDto requestDto) throws Illega } @Transactional(readOnly = true) - public PagedResponseDto getMyAttendances(Long activityGroupId, Pageable pageable) throws IllegalAccessException { + public PagedResponseDto getMyAttendances(Long activityGroupId, Pageable pageable) + throws IllegalAccessException { Member currentMember = externalRetrieveMemberUseCase.getCurrentMember(); ActivityGroup activityGroup = validateGroupAndMemberForAttendance(activityGroupId, currentMember); Page attendances = getAttendanceByMemberId(activityGroup, currentMember.getId(), pageable); @@ -103,7 +105,8 @@ public PagedResponseDto getMyAttendances(Long activityGro } @Transactional(readOnly = true) - public PagedResponseDto getGroupAttendances(Long activityGroupId, Pageable pageable) throws PermissionDeniedException { + public PagedResponseDto getGroupAttendances(Long activityGroupId, Pageable pageable) + throws PermissionDeniedException { Member currentMember = externalRetrieveMemberUseCase.getCurrentMember(); ActivityGroup activityGroup = getActivityGroupWithValidPermissions(activityGroupId, currentMember); Page attendances = getAttendanceByActivityGroup(activityGroup, pageable); @@ -111,7 +114,8 @@ public PagedResponseDto getGroupAttendances(Long activity } @Transactional - public Long writeAbsentExcuse(AbsentRequestDto requestDto) throws IllegalAccessException, DuplicateAbsentExcuseException { + public Long writeAbsentExcuse(AbsentRequestDto requestDto) + throws IllegalAccessException, DuplicateAbsentExcuseException { Member absentee = externalRetrieveMemberUseCase.getById(requestDto.getAbsenteeId()); ActivityGroup activityGroup = getValidActivityGroup(requestDto.getActivityGroupId()); validateAbsentExcuseConditions(absentee, activityGroup, requestDto.getAbsentDate()); @@ -120,7 +124,8 @@ public Long writeAbsentExcuse(AbsentRequestDto requestDto) throws IllegalAccessE } @Transactional(readOnly = true) - public PagedResponseDto getActivityGroupAbsentExcuses(Long activityGroupId, Pageable pageable) throws PermissionDeniedException { + public PagedResponseDto getActivityGroupAbsentExcuses(Long activityGroupId, Pageable pageable) + throws PermissionDeniedException { Member currentMember = externalRetrieveMemberUseCase.getCurrentMember(); ActivityGroup activityGroup = getActivityGroupWithPermissionCheck(activityGroupId, currentMember); Page absents = absentRepository.findAllByActivityGroup(activityGroup, pageable); @@ -139,7 +144,8 @@ private Page getAttendanceByActivityGroup(ActivityGroup activityGrou } public boolean hasAttendanceHistory(ActivityGroup activityGroup, String memberId, LocalDate activityDate) { - Attendance attendanceHistory = attendanceRepository.findByActivityGroupAndMemberIdAndActivityDate(activityGroup, memberId, activityDate); + Attendance attendanceHistory = attendanceRepository.findByActivityGroupAndMemberIdAndActivityDate(activityGroup, + memberId, activityDate); return attendanceHistory != null; } @@ -148,15 +154,18 @@ public boolean isActivityExistedAt(ActivityGroup activityGroup, LocalDate date) } public boolean hasAbsentExcuseHistory(ActivityGroup activityGroup, Member absentee, LocalDate absentDate) { - Absent absentHistory = absentRepository.findByActivityGroupAndMemberIdAndAbsentDate(activityGroup, absentee.getId(), absentDate); + Absent absentHistory = absentRepository.findByActivityGroupAndMemberIdAndAbsentDate(activityGroup, + absentee.getId(), absentDate); return absentHistory != null; } @NotNull - private ActivityGroup validateAttendanceQRCodeGeneration(Long activityGroupId, Member member) throws PermissionDeniedException, IllegalAccessException { + private ActivityGroup validateAttendanceQRCodeGeneration(Long activityGroupId, Member member) + throws PermissionDeniedException, IllegalAccessException { ActivityGroup activityGroup = activityGroupAdminService.getActivityGroupById(activityGroupId); - if (!activityGroupAdminService.isMemberHasRoleInActivityGroup(member, ActivityGroupRole.LEADER, activityGroupId)) { + if (!activityGroupAdminService.isMemberHasRoleInActivityGroup(member, ActivityGroupRole.LEADER, + activityGroupId)) { throw new PermissionDeniedException("해당 그룹의 LEADER만 출석체크 QR을 생성할 수 있습니다."); } if (!activityGroup.isProgressing()) { @@ -165,9 +174,11 @@ private ActivityGroup validateAttendanceQRCodeGeneration(Long activityGroupId, M return activityGroup; } - private ActivityGroup validateMemberForAttendance(Member member, Long activityGroupId) throws IllegalAccessException, DuplicateAttendanceException { + private ActivityGroup validateMemberForAttendance(Member member, Long activityGroupId) + throws IllegalAccessException, DuplicateAttendanceException { ActivityGroup activityGroup = activityGroupAdminService.getActivityGroupById(activityGroupId); - if (!activityGroupAdminService.isMemberHasRoleInActivityGroup(member, ActivityGroupRole.MEMBER, activityGroupId)) { + if (!activityGroupAdminService.isMemberHasRoleInActivityGroup(member, ActivityGroupRole.MEMBER, + activityGroupId)) { throw new IllegalAccessException("해당 그룹의 멤버가 아닙니다. 출석체크 인증을 진행할 수 없습니다."); } LocalDate today = LocalDate.now(); @@ -184,9 +195,11 @@ private void validateQRCodeData(String QRCodeData) throws InvalidInformationExce } @NotNull - private ActivityGroup validateGroupAndMemberForAttendance(Long activityGroupId, Member member) throws IllegalAccessException { + private ActivityGroup validateGroupAndMemberForAttendance(Long activityGroupId, Member member) + throws IllegalAccessException { ActivityGroup activityGroup = activityGroupAdminService.getActivityGroupById(activityGroupId); - if (!activityGroupAdminService.isMemberHasRoleInActivityGroup(member, ActivityGroupRole.MEMBER, activityGroupId)) { + if (!activityGroupAdminService.isMemberHasRoleInActivityGroup(member, ActivityGroupRole.MEMBER, + activityGroupId)) { throw new IllegalAccessException("해당 그룹의 멤버가 아닙니다. 출석체크 인증을 진행할 수 없습니다."); } if (!activityGroup.isProgressing()) { @@ -195,9 +208,11 @@ private ActivityGroup validateGroupAndMemberForAttendance(Long activityGroupId, return activityGroup; } - private ActivityGroup getActivityGroupWithValidPermissions(Long activityGroupId, Member member) throws PermissionDeniedException { + private ActivityGroup getActivityGroupWithValidPermissions(Long activityGroupId, Member member) + throws PermissionDeniedException { ActivityGroup activityGroup = activityGroupAdminService.getActivityGroupById(activityGroupId); - if (!member.isAdminRole() || !activityGroupAdminService.isMemberHasRoleInActivityGroup(member, ActivityGroupRole.LEADER, activityGroupId)) { + if (!member.isAdminRole() || !activityGroupAdminService.isMemberHasRoleInActivityGroup(member, + ActivityGroupRole.LEADER, activityGroupId)) { throw new PermissionDeniedException("그룹의 출석기록을 조회할 권한이 없습니다."); } return activityGroup; @@ -211,8 +226,10 @@ private ActivityGroup getValidActivityGroup(Long activityGroupId) throws Illegal return activityGroup; } - private void validateAbsentExcuseConditions(Member absentee, ActivityGroup activityGroup, LocalDate absentDate) throws IllegalAccessException, DuplicateAbsentExcuseException { - if (!activityGroupAdminService.isMemberHasRoleInActivityGroup(absentee, ActivityGroupRole.MEMBER, activityGroup.getId())) { + private void validateAbsentExcuseConditions(Member absentee, ActivityGroup activityGroup, LocalDate absentDate) + throws IllegalAccessException, DuplicateAbsentExcuseException { + if (!activityGroupAdminService.isMemberHasRoleInActivityGroup(absentee, ActivityGroupRole.MEMBER, + activityGroup.getId())) { throw new IllegalAccessException("해당 그룹의 멤버가 아닙니다. 불참 사유서를 등록할 수 없습니다."); } if (!isActivityExistedAt(activityGroup, absentDate)) { @@ -226,9 +243,11 @@ private void validateAbsentExcuseConditions(Member absentee, ActivityGroup activ } } - private ActivityGroup getActivityGroupWithPermissionCheck(Long activityGroupId, Member member) throws PermissionDeniedException { + private ActivityGroup getActivityGroupWithPermissionCheck(Long activityGroupId, Member member) + throws PermissionDeniedException { ActivityGroup activityGroup = activityGroupAdminService.getActivityGroupById(activityGroupId); - if (!member.isAdminRole() && !activityGroupAdminService.isMemberHasRoleInActivityGroup(member, ActivityGroupRole.LEADER, activityGroupId)) { + if (!member.isAdminRole() && !activityGroupAdminService.isMemberHasRoleInActivityGroup(member, + ActivityGroupRole.LEADER, activityGroupId)) { throw new PermissionDeniedException("해당 그룹의 불참사유서를 열람할 권한이 부족합니다."); } return activityGroup; diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/dao/AbsentRepository.java b/src/main/java/page/clab/api/domain/activity/activitygroup/dao/AbsentRepository.java index f2cf76c48..f608ff96d 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/dao/AbsentRepository.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/dao/AbsentRepository.java @@ -1,5 +1,6 @@ package page.clab.api.domain.activity.activitygroup.dao; +import java.time.LocalDate; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; @@ -7,12 +8,11 @@ import page.clab.api.domain.activity.activitygroup.domain.Absent; import page.clab.api.domain.activity.activitygroup.domain.ActivityGroup; -import java.time.LocalDate; - @Repository public interface AbsentRepository extends JpaRepository { Page findAllByActivityGroup(ActivityGroup activityGroup, Pageable pageable); - Absent findByActivityGroupAndMemberIdAndAbsentDate(ActivityGroup activityGroup, String memberId, LocalDate absentDate); + Absent findByActivityGroupAndMemberIdAndAbsentDate(ActivityGroup activityGroup, String memberId, + LocalDate absentDate); } diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/dao/ActivityGroupBoardRepository.java b/src/main/java/page/clab/api/domain/activity/activitygroup/dao/ActivityGroupBoardRepository.java index 1aba07fd7..bc0075bee 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/dao/ActivityGroupBoardRepository.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/dao/ActivityGroupBoardRepository.java @@ -1,5 +1,6 @@ package page.clab.api.domain.activity.activitygroup.dao; +import java.util.List; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; @@ -9,12 +10,12 @@ import page.clab.api.domain.activity.activitygroup.domain.ActivityGroupBoard; import page.clab.api.domain.activity.activitygroup.domain.ActivityGroupBoardCategory; -import java.util.List; - @Repository -public interface ActivityGroupBoardRepository extends JpaRepository, ActivityGroupBoardRepositoryCustom, QuerydslPredicateExecutor { +public interface ActivityGroupBoardRepository extends JpaRepository, + ActivityGroupBoardRepositoryCustom, QuerydslPredicateExecutor { - Page findAllByActivityGroup_IdAndCategory(Long activityGroupId, ActivityGroupBoardCategory category, Pageable pageable); + Page findAllByActivityGroup_IdAndCategory(Long activityGroupId, + ActivityGroupBoardCategory category, Pageable pageable); Long countByActivityGroupIdAndCategory(Long id, ActivityGroupBoardCategory category); diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/dao/ActivityGroupBoardRepositoryCustom.java b/src/main/java/page/clab/api/domain/activity/activitygroup/dao/ActivityGroupBoardRepositoryCustom.java index 737f00fc6..354d05ff0 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/dao/ActivityGroupBoardRepositoryCustom.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/dao/ActivityGroupBoardRepositoryCustom.java @@ -1,9 +1,9 @@ package page.clab.api.domain.activity.activitygroup.dao; -import page.clab.api.domain.activity.activitygroup.domain.ActivityGroupBoard; - import java.util.List; +import page.clab.api.domain.activity.activitygroup.domain.ActivityGroupBoard; public interface ActivityGroupBoardRepositoryCustom { + List findMySubmissionsWithFeedbacks(Long parentId, String memberId); } diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/dao/ActivityGroupBoardRepositoryImpl.java b/src/main/java/page/clab/api/domain/activity/activitygroup/dao/ActivityGroupBoardRepositoryImpl.java index c4497ca07..0c09d7fb1 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/dao/ActivityGroupBoardRepositoryImpl.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/dao/ActivityGroupBoardRepositoryImpl.java @@ -2,14 +2,13 @@ import com.querydsl.core.BooleanBuilder; import com.querydsl.jpa.impl.JPAQueryFactory; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Repository; import page.clab.api.domain.activity.activitygroup.domain.ActivityGroupBoard; import page.clab.api.domain.activity.activitygroup.domain.ActivityGroupBoardCategory; import page.clab.api.domain.activity.activitygroup.domain.QActivityGroupBoard; -import java.util.List; - @Repository @RequiredArgsConstructor public class ActivityGroupBoardRepositoryImpl implements ActivityGroupBoardRepositoryCustom { @@ -27,9 +26,9 @@ public List findMySubmissionsWithFeedbacks(Long parentId, St builder.and(qBoard.category.eq(ActivityGroupBoardCategory.SUBMIT)); return queryFactory.selectFrom(qBoard) - .leftJoin(qBoard.children, qChild).fetchJoin() - .where(builder) - .distinct() - .fetch(); + .leftJoin(qBoard.children, qChild).fetchJoin() + .where(builder) + .distinct() + .fetch(); } } diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/dao/ActivityGroupDetailsRepository.java b/src/main/java/page/clab/api/domain/activity/activitygroup/dao/ActivityGroupDetailsRepository.java index 3ee9d2f66..67ec5019a 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/dao/ActivityGroupDetailsRepository.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/dao/ActivityGroupDetailsRepository.java @@ -3,5 +3,6 @@ import page.clab.api.domain.activity.activitygroup.dto.param.ActivityGroupDetails; public interface ActivityGroupDetailsRepository { + ActivityGroupDetails fetchActivityGroupDetails(Long activityGroupId); } diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/dao/ActivityGroupDetailsRepositoryImpl.java b/src/main/java/page/clab/api/domain/activity/activitygroup/dao/ActivityGroupDetailsRepositoryImpl.java index 33fb3af50..a1c2fd59b 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/dao/ActivityGroupDetailsRepositoryImpl.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/dao/ActivityGroupDetailsRepositoryImpl.java @@ -2,6 +2,7 @@ import com.querydsl.core.BooleanBuilder; import com.querydsl.jpa.impl.JPAQueryFactory; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Repository; import page.clab.api.domain.activity.activitygroup.domain.ActivityGroup; @@ -15,8 +16,6 @@ import page.clab.api.domain.activity.activitygroup.dto.mapper.ActivityGroupDtoMapper; import page.clab.api.domain.activity.activitygroup.dto.param.ActivityGroupDetails; -import java.util.List; - @Repository @RequiredArgsConstructor public class ActivityGroupDetailsRepositoryImpl implements ActivityGroupDetailsRepository { @@ -31,32 +30,40 @@ public ActivityGroupDetails fetchActivityGroupDetails(Long activityGroupId) { QActivityGroupBoard qActivityGroupBoard = QActivityGroupBoard.activityGroupBoard; BooleanBuilder groupMemberCondition = new BooleanBuilder(); - if (activityGroupId != null) groupMemberCondition.and(qGroupMember.activityGroup.id.eq(activityGroupId) + if (activityGroupId != null) { + groupMemberCondition.and(qGroupMember.activityGroup.id.eq(activityGroupId) .and(qGroupMember.status.eq(GroupMemberStatus.ACCEPTED))); + } List groupMembers = queryFactory.selectFrom(qGroupMember) - .where(groupMemberCondition) - .fetch(); + .where(groupMemberCondition) + .fetch(); BooleanBuilder boardCondition = new BooleanBuilder(); - if (activityGroupId != null) boardCondition.and(qActivityGroupBoard.activityGroup.id.eq(activityGroupId)); - if (activityGroupId != null) boardCondition.and(qActivityGroupBoard.category.in( + if (activityGroupId != null) { + boardCondition.and(qActivityGroupBoard.activityGroup.id.eq(activityGroupId)); + } + if (activityGroupId != null) { + boardCondition.and(qActivityGroupBoard.category.in( ActivityGroupBoardCategory.NOTICE, ActivityGroupBoardCategory.WEEKLY_ACTIVITY, ActivityGroupBoardCategory.ASSIGNMENT) - ); + ); + } List boards = queryFactory.selectFrom(qActivityGroupBoard) - .where(boardCondition) - .orderBy(qActivityGroupBoard.createdAt.desc()) - .fetch(); + .where(boardCondition) + .orderBy(qActivityGroupBoard.createdAt.desc()) + .fetch(); BooleanBuilder activityGroupCondition = new BooleanBuilder(); - if (activityGroupId != null) activityGroupCondition.and(qActivityGroup.id.eq(activityGroupId)); + if (activityGroupId != null) { + activityGroupCondition.and(qActivityGroup.id.eq(activityGroupId)); + } ActivityGroup foundActivityGroup = queryFactory.selectFrom(qActivityGroup) - .where(activityGroupCondition) - .fetchOne(); + .where(activityGroupCondition) + .fetchOne(); return mapper.of(foundActivityGroup, groupMembers, boards); } diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/dao/ActivityGroupRepository.java b/src/main/java/page/clab/api/domain/activity/activitygroup/dao/ActivityGroupRepository.java index a72b46a28..0355f77b1 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/dao/ActivityGroupRepository.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/dao/ActivityGroupRepository.java @@ -1,5 +1,7 @@ package page.clab.api.domain.activity.activitygroup.dao; +import java.time.LocalDate; +import java.util.List; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; @@ -10,11 +12,9 @@ import page.clab.api.domain.activity.activitygroup.domain.ActivityGroupCategory; import page.clab.api.domain.activity.activitygroup.domain.ActivityGroupStatus; -import java.time.LocalDate; -import java.util.List; - @Repository -public interface ActivityGroupRepository extends JpaRepository, ActivityGroupRepositoryCustom, QuerydslPredicateExecutor { +public interface ActivityGroupRepository extends JpaRepository, ActivityGroupRepositoryCustom, + QuerydslPredicateExecutor { Page findAllByCategory(ActivityGroupCategory category, Pageable pageable); diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/dao/ActivityGroupRepositoryCustomImpl.java b/src/main/java/page/clab/api/domain/activity/activitygroup/dao/ActivityGroupRepositoryCustomImpl.java index a90baf8fb..7342df365 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/dao/ActivityGroupRepositoryCustomImpl.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/dao/ActivityGroupRepositoryCustomImpl.java @@ -2,6 +2,7 @@ import com.querydsl.core.BooleanBuilder; import com.querydsl.jpa.impl.JPAQueryFactory; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; @@ -12,8 +13,6 @@ import page.clab.api.domain.activity.activitygroup.domain.QActivityGroup; import page.clab.api.global.util.OrderSpecifierUtil; -import java.util.List; - @Repository @RequiredArgsConstructor public class ActivityGroupRepositoryCustomImpl implements ActivityGroupRepositoryCustom { @@ -25,19 +24,21 @@ public Page findActivityGroupsByStatus(ActivityGroupStatus status QActivityGroup qActivityGroup = QActivityGroup.activityGroup; BooleanBuilder builder = new BooleanBuilder(); - if (status != null) builder.and(qActivityGroup.status.eq(status)); + if (status != null) { + builder.and(qActivityGroup.status.eq(status)); + } List activityGroups = queryFactory.selectFrom(qActivityGroup) - .where(builder) - .orderBy(OrderSpecifierUtil.getOrderSpecifiers(pageable, qActivityGroup)) - .offset(pageable.getOffset()) - .limit(pageable.getPageSize()) - .fetch(); + .where(builder) + .orderBy(OrderSpecifierUtil.getOrderSpecifiers(pageable, qActivityGroup)) + .offset(pageable.getOffset()) + .limit(pageable.getPageSize()) + .fetch(); Long total = queryFactory.select(qActivityGroup.count()) - .from(qActivityGroup) - .where(builder) - .fetchOne(); + .from(qActivityGroup) + .where(builder) + .fetchOne(); long totalElements = total != null ? total : 0; diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/dao/ApplyFormRepository.java b/src/main/java/page/clab/api/domain/activity/activitygroup/dao/ApplyFormRepository.java index dc4d0aeda..aeb8d11fc 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/dao/ApplyFormRepository.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/dao/ApplyFormRepository.java @@ -1,11 +1,11 @@ package page.clab.api.domain.activity.activitygroup.dao; +import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import page.clab.api.domain.activity.activitygroup.domain.ActivityGroup; import page.clab.api.domain.activity.activitygroup.domain.ApplyForm; -import java.util.List; - public interface ApplyFormRepository extends JpaRepository { + List findAllByActivityGroup(ActivityGroup activityGroup); } diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/dao/AttendanceRepository.java b/src/main/java/page/clab/api/domain/activity/activitygroup/dao/AttendanceRepository.java index 35c29b411..2e2c11345 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/dao/AttendanceRepository.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/dao/AttendanceRepository.java @@ -1,20 +1,20 @@ package page.clab.api.domain.activity.activitygroup.dao; +import java.time.LocalDate; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import page.clab.api.domain.activity.activitygroup.domain.ActivityGroup; import page.clab.api.domain.activity.activitygroup.domain.Attendance; -import java.time.LocalDate; - public interface AttendanceRepository extends JpaRepository { Page findAllByMemberIdAndActivityGroup(String memberId, ActivityGroup activityGroup, Pageable pageable); Page findAllByActivityGroup(ActivityGroup activityGroup, Pageable pageable); - Attendance findByActivityGroupAndMemberIdAndActivityDate(ActivityGroup activityGroup, String memberId, LocalDate activityDate); + Attendance findByActivityGroupAndMemberIdAndActivityDate(ActivityGroup activityGroup, String memberId, + LocalDate activityDate); boolean existsByActivityGroupAndActivityDate(ActivityGroup activityGroup, LocalDate activityDate); } diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/dao/GroupMemberRepository.java b/src/main/java/page/clab/api/domain/activity/activitygroup/dao/GroupMemberRepository.java index ba759eec8..6d433326a 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/dao/GroupMemberRepository.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/dao/GroupMemberRepository.java @@ -1,5 +1,7 @@ package page.clab.api.domain.activity.activitygroup.dao; +import java.util.List; +import java.util.Optional; import org.springframework.data.domain.Page; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; @@ -12,11 +14,9 @@ import page.clab.api.domain.activity.activitygroup.domain.GroupMemberId; import page.clab.api.domain.activity.activitygroup.domain.GroupMemberStatus; -import java.util.List; -import java.util.Optional; - @Repository -public interface GroupMemberRepository extends JpaRepository, GroupMemberRepositoryCustom, QuerydslPredicateExecutor { +public interface GroupMemberRepository extends JpaRepository, GroupMemberRepositoryCustom, + QuerydslPredicateExecutor { List findAllByMemberId(String memberId); @@ -28,18 +28,21 @@ public interface GroupMemberRepository extends JpaRepository findAllByActivityGroupIdOrderByMemberIdAsc(Long activityGroupId); - Page findAllByActivityGroupIdAndStatus(Long activityGroupId, GroupMemberStatus status, org.springframework.data.domain.Pageable pageable); + Page findAllByActivityGroupIdAndStatus(Long activityGroupId, GroupMemberStatus status, + org.springframework.data.domain.Pageable pageable); List findAllByActivityGroupIdAndStatus(Long activityGroupId, GroupMemberStatus status); - boolean existsByActivityGroupAndMemberIdAndStatus(ActivityGroup activityGroup, String memberId, GroupMemberStatus status); + boolean existsByActivityGroupAndMemberIdAndStatus(ActivityGroup activityGroup, String memberId, + GroupMemberStatus status); - boolean existsByActivityGroupIdAndMemberIdAndStatus(Long activityGroupId, String memberId, GroupMemberStatus status); + boolean existsByActivityGroupIdAndMemberIdAndStatus(Long activityGroupId, String memberId, + GroupMemberStatus status); // activityGroupIds 리스트에 해당하는 각 ActivityGroup에서, 가장 createdAt이 오래된 GroupMember를 조회합니다. @Query(value = "SELECT DISTINCT ON (gm.activity_group_id) * " + - "FROM group_member gm " + - "WHERE gm.activity_group_id IN :activityGroupIds " + - "ORDER BY gm.activity_group_id, gm.created_at ASC", nativeQuery = true) + "FROM group_member gm " + + "WHERE gm.activity_group_id IN :activityGroupIds " + + "ORDER BY gm.activity_group_id, gm.created_at ASC", nativeQuery = true) List findFirstByActivityGroupIdIn(@Param("activityGroupIds") List activityGroupIds); } diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/dao/GroupMemberRepositoryCustom.java b/src/main/java/page/clab/api/domain/activity/activitygroup/dao/GroupMemberRepositoryCustom.java index ba09f4fc4..1c7922488 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/dao/GroupMemberRepositoryCustom.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/dao/GroupMemberRepositoryCustom.java @@ -1,11 +1,10 @@ package page.clab.api.domain.activity.activitygroup.dao; +import java.util.List; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import page.clab.api.domain.activity.activitygroup.domain.GroupMember; -import java.util.List; - public interface GroupMemberRepositoryCustom { long countAcceptedMembersByActivityGroupId(Long activityGroupId); diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/dao/GroupMemberRepositoryImpl.java b/src/main/java/page/clab/api/domain/activity/activitygroup/dao/GroupMemberRepositoryImpl.java index fb1ce48c6..29a51f100 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/dao/GroupMemberRepositoryImpl.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/dao/GroupMemberRepositoryImpl.java @@ -4,19 +4,21 @@ import com.querydsl.core.types.OrderSpecifier; import com.querydsl.core.types.dsl.CaseBuilder; import com.querydsl.jpa.impl.JPAQueryFactory; +import java.util.Arrays; +import java.util.List; +import java.util.Objects; +import java.util.stream.Stream; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Repository; -import page.clab.api.domain.activity.activitygroup.domain.*; +import page.clab.api.domain.activity.activitygroup.domain.ActivityGroupRole; +import page.clab.api.domain.activity.activitygroup.domain.GroupMember; +import page.clab.api.domain.activity.activitygroup.domain.GroupMemberStatus; +import page.clab.api.domain.activity.activitygroup.domain.QGroupMember; import page.clab.api.global.util.OrderSpecifierUtil; -import java.util.Arrays; -import java.util.List; -import java.util.Objects; -import java.util.stream.Stream; - @Repository @RequiredArgsConstructor public class GroupMemberRepositoryImpl implements GroupMemberRepositoryCustom { @@ -28,12 +30,14 @@ public long countAcceptedMembersByActivityGroupId(Long activityGroupId) { QGroupMember qGroupMember = QGroupMember.groupMember; BooleanBuilder builder = new BooleanBuilder(); - if (activityGroupId != null) builder.and(qGroupMember.activityGroup.id.eq(activityGroupId)); + if (activityGroupId != null) { + builder.and(qGroupMember.activityGroup.id.eq(activityGroupId)); + } builder.and(qGroupMember.status.eq(GroupMemberStatus.ACCEPTED)); return queryFactory.selectFrom(qGroupMember) - .where(builder) - .fetchCount(); + .where(builder) + .fetchCount(); } @Override @@ -41,12 +45,16 @@ public List findLeaderByActivityGroupId(Long activityGroupId) { QGroupMember qGroupMember = QGroupMember.groupMember; BooleanBuilder builder = new BooleanBuilder(); - if (activityGroupId != null) builder.and(qGroupMember.activityGroup.id.eq(activityGroupId)); - if (activityGroupId != null) builder.and(qGroupMember.role.eq(ActivityGroupRole.LEADER)); + if (activityGroupId != null) { + builder.and(qGroupMember.activityGroup.id.eq(activityGroupId)); + } + if (activityGroupId != null) { + builder.and(qGroupMember.role.eq(ActivityGroupRole.LEADER)); + } return queryFactory.selectFrom(qGroupMember) - .where(builder) - .fetch(); + .where(builder) + .fetch(); } @Override @@ -54,40 +62,42 @@ public Page findAllByActivityGroupId(Long activityGroupId, Pageable QGroupMember qGroupMember = QGroupMember.groupMember; BooleanBuilder builder = new BooleanBuilder(); - if (activityGroupId != null) builder.and(qGroupMember.activityGroup.id.eq(activityGroupId)); + if (activityGroupId != null) { + builder.and(qGroupMember.activityGroup.id.eq(activityGroupId)); + } OrderSpecifier leaderOrder = new CaseBuilder() - .when(qGroupMember.role.eq(ActivityGroupRole.LEADER)).then(0) - .otherwise(1) - .asc(); + .when(qGroupMember.role.eq(ActivityGroupRole.LEADER)).then(0) + .otherwise(1) + .asc(); OrderSpecifier statusOrder = pageable.getSort().stream() - .filter(order -> order.getProperty().equals("status")) - .findFirst() - .map(order -> new CaseBuilder() - .when(qGroupMember.status.eq(GroupMemberStatus.WAITING)).then(0) - .when(qGroupMember.status.eq(GroupMemberStatus.ACCEPTED)).then(1) - .when(qGroupMember.status.eq(GroupMemberStatus.REJECTED)).then(2) - .otherwise(3) - .asc()) - .orElse(null); + .filter(order -> order.getProperty().equals("status")) + .findFirst() + .map(order -> new CaseBuilder() + .when(qGroupMember.status.eq(GroupMemberStatus.WAITING)).then(0) + .when(qGroupMember.status.eq(GroupMemberStatus.ACCEPTED)).then(1) + .when(qGroupMember.status.eq(GroupMemberStatus.REJECTED)).then(2) + .otherwise(3) + .asc()) + .orElse(null); OrderSpecifier[] dynamicOrderSpecifiers = OrderSpecifierUtil.getOrderSpecifiers(pageable, qGroupMember); List groupMembers = queryFactory.selectFrom(qGroupMember) - .where(builder) - .orderBy(Stream.concat( - Stream.of(leaderOrder, statusOrder).filter(Objects::nonNull), - Arrays.stream(dynamicOrderSpecifiers) - ).toArray(OrderSpecifier[]::new)) - .offset(pageable.getOffset()) - .limit(pageable.getPageSize()) - .fetch(); + .where(builder) + .orderBy(Stream.concat( + Stream.of(leaderOrder, statusOrder).filter(Objects::nonNull), + Arrays.stream(dynamicOrderSpecifiers) + ).toArray(OrderSpecifier[]::new)) + .offset(pageable.getOffset()) + .limit(pageable.getPageSize()) + .fetch(); Long total = queryFactory.select(qGroupMember.count()) - .from(qGroupMember) - .where(builder) - .fetchOne(); + .from(qGroupMember) + .where(builder) + .fetchOne(); long totalElements = total != null ? total : 0; diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/dao/GroupScheduleRepository.java b/src/main/java/page/clab/api/domain/activity/activitygroup/dao/GroupScheduleRepository.java index f99dff5fe..7726739f1 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/dao/GroupScheduleRepository.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/dao/GroupScheduleRepository.java @@ -1,13 +1,12 @@ package page.clab.api.domain.activity.activitygroup.dao; +import java.util.List; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; import page.clab.api.domain.activity.activitygroup.domain.GroupSchedule; -import java.util.List; - @Repository public interface GroupScheduleRepository extends JpaRepository { diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/dao/RedisQRKeyRepository.java b/src/main/java/page/clab/api/domain/activity/activitygroup/dao/RedisQRKeyRepository.java index 8f9246194..1831c3758 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/dao/RedisQRKeyRepository.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/dao/RedisQRKeyRepository.java @@ -4,5 +4,6 @@ import page.clab.api.domain.activity.activitygroup.domain.RedisQRKey; public interface RedisQRKeyRepository extends CrudRepository { + boolean existsByQRCodeKey(String qrCodeData); } diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/domain/Absent.java b/src/main/java/page/clab/api/domain/activity/activitygroup/domain/Absent.java index 60bd1b453..8cad66927 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/domain/Absent.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/domain/Absent.java @@ -7,6 +7,7 @@ import jakarta.persistence.Id; import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; +import java.time.LocalDate; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -16,8 +17,6 @@ import lombok.Setter; import page.clab.api.global.common.domain.BaseEntity; -import java.time.LocalDate; - @Entity @Getter @Setter diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/domain/ActivityGroup.java b/src/main/java/page/clab/api/domain/activity/activitygroup/domain/ActivityGroup.java index 0acd963e1..e9cec048d 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/domain/ActivityGroup.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/domain/ActivityGroup.java @@ -8,6 +8,8 @@ import jakarta.persistence.GenerationType; import jakarta.persistence.Id; import jakarta.validation.constraints.Size; +import java.time.LocalDate; +import java.util.Optional; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -22,9 +24,6 @@ import page.clab.api.domain.activity.activitygroup.exception.InvalidGithubUrlException; import page.clab.api.global.common.domain.BaseEntity; -import java.time.LocalDate; -import java.util.Optional; - @Entity(name = "activity_group") @Getter @Setter diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/domain/ActivityGroupBoard.java b/src/main/java/page/clab/api/domain/activity/activitygroup/domain/ActivityGroupBoard.java index b50484927..cbb37c37c 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/domain/ActivityGroupBoard.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/domain/ActivityGroupBoard.java @@ -12,6 +12,10 @@ import jakarta.persistence.ManyToOne; import jakarta.persistence.OneToMany; import jakarta.validation.constraints.Future; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -30,11 +34,6 @@ import page.clab.api.global.common.file.domain.UploadedFile; import page.clab.api.global.exception.PermissionDeniedException; -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - @Entity @Getter @Setter @@ -87,7 +86,8 @@ public void update(ActivityGroupBoardUpdateRequestDto requestDto, UploadedFileSe Optional.ofNullable(requestDto.getTitle()).ifPresent(this::setTitle); Optional.ofNullable(requestDto.getContent()).ifPresent(this::setContent); Optional.ofNullable(requestDto.getDueDateTime()).ifPresent(this::setDueDateTime); - Optional.ofNullable(requestDto.getFileUrls()).ifPresent(urls -> this.setUploadedFiles(uploadedFileService.getUploadedFilesByUrls(urls))); + Optional.ofNullable(requestDto.getFileUrls()) + .ifPresent(urls -> this.setUploadedFiles(uploadedFileService.getUploadedFilesByUrls(urls))); } public void addChild(ActivityGroupBoard child) { @@ -113,7 +113,8 @@ public boolean isFeedback() { } public void validateAccessPermission(Member member, List leaders) throws PermissionDeniedException { - if (!member.isAdminRole() && !CollectionUtils.isEmpty(leaders) && leaders.stream().noneMatch(leader -> leader.isOwner(member.getId()))) { + if (!member.isAdminRole() && !CollectionUtils.isEmpty(leaders) && leaders.stream() + .noneMatch(leader -> leader.isOwner(member.getId()))) { if (this.isAssignment()) { throw new PermissionDeniedException("과제 게시판에 접근할 권한이 없습니다."); } diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/domain/ActivityGroupReport.java b/src/main/java/page/clab/api/domain/activity/activitygroup/domain/ActivityGroupReport.java index 311bd003f..4ca1c295a 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/domain/ActivityGroupReport.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/domain/ActivityGroupReport.java @@ -7,6 +7,7 @@ import jakarta.persistence.Id; import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; +import java.util.Optional; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -18,8 +19,6 @@ import page.clab.api.domain.activity.activitygroup.dto.request.ActivityGroupReportUpdateRequestDto; import page.clab.api.global.common.domain.BaseEntity; -import java.util.Optional; - @Entity @Getter @Setter diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/domain/Attendance.java b/src/main/java/page/clab/api/domain/activity/activitygroup/domain/Attendance.java index 05880dd37..defcf0bd7 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/domain/Attendance.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/domain/Attendance.java @@ -7,6 +7,7 @@ import jakarta.persistence.Id; import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; +import java.time.LocalDate; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -15,8 +16,6 @@ import lombok.Setter; import page.clab.api.global.common.domain.BaseEntity; -import java.time.LocalDate; - @Entity @Getter @Setter @@ -40,9 +39,9 @@ public class Attendance extends BaseEntity { public static Attendance create(String memberId, ActivityGroup activityGroup, LocalDate activityDate) { return Attendance.builder() - .memberId(memberId) - .activityGroup(activityGroup) - .activityDate(activityDate) - .build(); + .memberId(memberId) + .activityGroup(activityGroup) + .activityDate(activityDate) + .build(); } } diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/domain/GroupMember.java b/src/main/java/page/clab/api/domain/activity/activitygroup/domain/GroupMember.java index 1942d91e2..c5c9de654 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/domain/GroupMember.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/domain/GroupMember.java @@ -42,13 +42,14 @@ public class GroupMember extends BaseEntity { @Enumerated(EnumType.STRING) private GroupMemberStatus status; - public static GroupMember create(String memberId, ActivityGroup activityGroup, ActivityGroupRole role, GroupMemberStatus status) { + public static GroupMember create(String memberId, ActivityGroup activityGroup, ActivityGroupRole role, + GroupMemberStatus status) { return GroupMember.builder() - .memberId(memberId) - .activityGroup(activityGroup) - .role(role) - .status(status) - .build(); + .memberId(memberId) + .activityGroup(activityGroup) + .role(role) + .status(status) + .build(); } public boolean isLeader() { diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/domain/GroupMemberId.java b/src/main/java/page/clab/api/domain/activity/activitygroup/domain/GroupMemberId.java index b0e897162..5ca0ae4f8 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/domain/GroupMemberId.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/domain/GroupMemberId.java @@ -1,13 +1,12 @@ package page.clab.api.domain.activity.activitygroup.domain; import jakarta.persistence.Embeddable; +import java.io.Serializable; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; -import java.io.Serializable; - @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor(access = AccessLevel.PRIVATE) @EqualsAndHashCode(onlyExplicitlyIncluded = true) diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/domain/GroupSchedule.java b/src/main/java/page/clab/api/domain/activity/activitygroup/domain/GroupSchedule.java index e4e4783f2..f8224dd2f 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/domain/GroupSchedule.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/domain/GroupSchedule.java @@ -7,6 +7,7 @@ import jakarta.persistence.Id; import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; +import java.time.LocalDateTime; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -15,8 +16,6 @@ import lombok.Setter; import page.clab.api.global.common.domain.BaseEntity; -import java.time.LocalDateTime; - @Entity @Getter @Setter diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/domain/RedisQRKey.java b/src/main/java/page/clab/api/domain/activity/activitygroup/domain/RedisQRKey.java index e525827c6..6f0add73a 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/domain/RedisQRKey.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/domain/RedisQRKey.java @@ -24,7 +24,7 @@ public class RedisQRKey { public static RedisQRKey create(String QRCodeKey) { return RedisQRKey.builder() - .QRCodeKey(QRCodeKey) - .build(); + .QRCodeKey(QRCodeKey) + .build(); } } diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/mapper/ActivityGroupDtoMapper.java b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/mapper/ActivityGroupDtoMapper.java index 1c683879b..46bc55cf0 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/mapper/ActivityGroupDtoMapper.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/mapper/ActivityGroupDtoMapper.java @@ -1,5 +1,7 @@ package page.clab.api.domain.activity.activitygroup.dto.mapper; +import java.time.LocalDateTime; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; @@ -39,9 +41,6 @@ import page.clab.api.global.common.file.domain.UploadedFile; import page.clab.api.global.common.file.dto.mapper.FileDtoMapper; -import java.time.LocalDateTime; -import java.util.List; - @Component @RequiredArgsConstructor public class ActivityGroupDtoMapper { @@ -50,264 +49,271 @@ public class ActivityGroupDtoMapper { public GroupSchedule fromDto(GroupScheduleDto groupScheduleDto, ActivityGroup activityGroup) { return GroupSchedule.builder() - .activityGroup(activityGroup) - .schedule(groupScheduleDto.getSchedule()) - .content(groupScheduleDto.getContent()) - .build(); + .activityGroup(activityGroup) + .schedule(groupScheduleDto.getSchedule()) + .content(groupScheduleDto.getContent()) + .build(); } public Absent fromDto(AbsentRequestDto requestDto, Member absentee, ActivityGroup activityGroup) { return Absent.builder() - .memberId(absentee.getId()) - .activityGroup(activityGroup) - .absentDate(requestDto.getAbsentDate()) - .reason(requestDto.getReason()) - .build(); + .memberId(absentee.getId()) + .activityGroup(activityGroup) + .absentDate(requestDto.getAbsentDate()) + .reason(requestDto.getReason()) + .build(); } - public ActivityGroupBoard fromDto(ActivityGroupBoardRequestDto requestDto, Member member, ActivityGroup activityGroup, ActivityGroupBoard parentBoard, List uploadedFiles) { + public ActivityGroupBoard fromDto(ActivityGroupBoardRequestDto requestDto, Member member, + ActivityGroup activityGroup, ActivityGroupBoard parentBoard, List uploadedFiles) { return ActivityGroupBoard.builder() - .activityGroup(activityGroup) - .memberId(member.getId()) - .category(requestDto.getCategory()) - .title(requestDto.getTitle()) - .content(requestDto.getContent()) - .parent(parentBoard) - .uploadedFiles(uploadedFiles) - .dueDateTime(requestDto.getDueDateTime()) - .isDeleted(false) - .build(); + .activityGroup(activityGroup) + .memberId(member.getId()) + .category(requestDto.getCategory()) + .title(requestDto.getTitle()) + .content(requestDto.getContent()) + .parent(parentBoard) + .uploadedFiles(uploadedFiles) + .dueDateTime(requestDto.getDueDateTime()) + .isDeleted(false) + .build(); } public ActivityGroupReport fromDto(ActivityGroupReportRequestDto requestDto, ActivityGroup activityGroup) { return ActivityGroupReport.builder() - .turn(requestDto.getTurn()) - .activityGroup(activityGroup) - .title(requestDto.getTitle()) - .content(requestDto.getContent()) - .isDeleted(false) - .build(); + .turn(requestDto.getTurn()) + .activityGroup(activityGroup) + .title(requestDto.getTitle()) + .content(requestDto.getContent()) + .isDeleted(false) + .build(); } public ActivityGroup fromDto(ActivityGroupRequestDto requestDto) { return ActivityGroup.builder() - .category(requestDto.getCategory()) - .subject(requestDto.getSubject()) - .name(requestDto.getName()) - .content(requestDto.getContent()) - .status(ActivityGroupStatus.WAITING) - .progress(0L) - .imageUrl(requestDto.getImageUrl()) - .curriculum(requestDto.getCurriculum()) - .startDate(requestDto.getStartDate()) - .endDate(requestDto.getEndDate()) - .techStack(requestDto.getTechStack()) - .githubUrl(requestDto.getGithubUrl()) - .isDeleted(false) - .build(); + .category(requestDto.getCategory()) + .subject(requestDto.getSubject()) + .name(requestDto.getName()) + .content(requestDto.getContent()) + .status(ActivityGroupStatus.WAITING) + .progress(0L) + .imageUrl(requestDto.getImageUrl()) + .curriculum(requestDto.getCurriculum()) + .startDate(requestDto.getStartDate()) + .endDate(requestDto.getEndDate()) + .techStack(requestDto.getTechStack()) + .githubUrl(requestDto.getGithubUrl()) + .isDeleted(false) + .build(); } public ApplyForm fromDto(ApplyFormRequestDto requestDto, ActivityGroup activityGroup, Member member) { return ApplyForm.builder() - .activityGroup(activityGroup) - .memberId(member.getId()) - .applyReason(requestDto.getApplyReason()) - .build(); + .activityGroup(activityGroup) + .memberId(member.getId()) + .applyReason(requestDto.getApplyReason()) + .build(); } public GroupScheduleDto toDto(GroupSchedule groupSchedule) { return GroupScheduleDto.builder() - .schedule(groupSchedule.getSchedule()) - .content(groupSchedule.getContent()) - .build(); + .schedule(groupSchedule.getSchedule()) + .content(groupSchedule.getContent()) + .build(); } public AbsentResponseDto toDto(Absent absent, Member member) { return AbsentResponseDto.builder() - .absenteeId(member.getId()) - .absenteeName(member.getName()) - .activityGroupId(absent.getActivityGroup().getId()) - .activityGroupName(absent.getActivityGroup().getName()) - .reason(absent.getReason()) - .absentDate(absent.getAbsentDate()) - .build(); + .absenteeId(member.getId()) + .absenteeName(member.getName()) + .activityGroupId(absent.getActivityGroup().getId()) + .activityGroupName(absent.getActivityGroup().getName()) + .reason(absent.getReason()) + .absentDate(absent.getAbsentDate()) + .build(); } - public ActivityGroupDetailResponseDto toDto(ActivityGroup activityGroup, List boards, List groupMemberResponseDtos, boolean isOwner) { + public ActivityGroupDetailResponseDto toDto(ActivityGroup activityGroup, List boards, + List groupMemberResponseDtos, boolean isOwner) { return ActivityGroupDetailResponseDto.builder() - .id(activityGroup.getId()) - .category(activityGroup.getCategory()) - .subject(activityGroup.getSubject()) - .name(activityGroup.getName()) - .content(activityGroup.getContent()) - .status(activityGroup.getStatus()) - .progress(activityGroup.getProgress()) - .imageUrl(activityGroup.getImageUrl()) - .curriculum(activityGroup.getCurriculum()) - .groupMembers(groupMemberResponseDtos) - .startDate(activityGroup.getStartDate()) - .endDate(activityGroup.getEndDate()) - .techStack(activityGroup.getTechStack()) - .githubUrl(activityGroup.getGithubUrl()) - .activityGroupBoards(boards) - .isOwner(isOwner) - .createdAt(activityGroup.getCreatedAt()) - .build(); + .id(activityGroup.getId()) + .category(activityGroup.getCategory()) + .subject(activityGroup.getSubject()) + .name(activityGroup.getName()) + .content(activityGroup.getContent()) + .status(activityGroup.getStatus()) + .progress(activityGroup.getProgress()) + .imageUrl(activityGroup.getImageUrl()) + .curriculum(activityGroup.getCurriculum()) + .groupMembers(groupMemberResponseDtos) + .startDate(activityGroup.getStartDate()) + .endDate(activityGroup.getEndDate()) + .techStack(activityGroup.getTechStack()) + .githubUrl(activityGroup.getGithubUrl()) + .activityGroupBoards(boards) + .isOwner(isOwner) + .createdAt(activityGroup.getCreatedAt()) + .build(); } - public ActivityGroupMemberWithApplyReasonResponseDto toDto(Member member, GroupMember groupMember, String applyReason) { + public ActivityGroupMemberWithApplyReasonResponseDto toDto(Member member, GroupMember groupMember, + String applyReason) { return ActivityGroupMemberWithApplyReasonResponseDto.builder() - .memberId(member.getId()) - .memberName(member.getName()) - .role(groupMember.getRole().toString()) - .status(groupMember.getStatus()) - .applyReason(applyReason) - .build(); + .memberId(member.getId()) + .memberName(member.getName()) + .role(groupMember.getRole().toString()) + .status(groupMember.getStatus()) + .applyReason(applyReason) + .build(); } public ActivityGroupReportResponseDto toDto(ActivityGroupReport report) { return ActivityGroupReportResponseDto.builder() - .activityGroupId(report.getActivityGroup().getId()) - .activityGroupName(report.getActivityGroup().getName()) - .turn(report.getTurn()) - .title(report.getTitle()) - .content(report.getContent()) - .createdAt(report.getCreatedAt()) - .updatedAt(report.getUpdatedAt()) - .build(); + .activityGroupId(report.getActivityGroup().getId()) + .activityGroupName(report.getActivityGroup().getName()) + .turn(report.getTurn()) + .title(report.getTitle()) + .content(report.getContent()) + .createdAt(report.getCreatedAt()) + .updatedAt(report.getUpdatedAt()) + .build(); } public ActivityGroupResponseDto toDto(ActivityGroup activityGroup) { return ActivityGroupResponseDto.builder() - .id(activityGroup.getId()) - .name(activityGroup.getName()) - .category(activityGroup.getCategory()) - .subject(activityGroup.getSubject()) - .status(activityGroup.getStatus()) - .imageUrl(activityGroup.getImageUrl()) - .createdAt(activityGroup.getCreatedAt()) - .build(); + .id(activityGroup.getId()) + .name(activityGroup.getName()) + .category(activityGroup.getCategory()) + .subject(activityGroup.getSubject()) + .status(activityGroup.getStatus()) + .imageUrl(activityGroup.getImageUrl()) + .createdAt(activityGroup.getCreatedAt()) + .build(); } - public ActivityGroupStatusResponseDto toDto(ActivityGroup activityGroup, List leader, Long participantCount, Long weeklyActivityCount) { + public ActivityGroupStatusResponseDto toDto(ActivityGroup activityGroup, List leader, + Long participantCount, Long weeklyActivityCount) { return ActivityGroupStatusResponseDto.builder() - .id(activityGroup.getId()) - .name(activityGroup.getName()) - .content(activityGroup.getContent()) - .category(activityGroup.getCategory()) - .subject(activityGroup.getSubject()) - .imageUrl(activityGroup.getImageUrl()) - .leaders(CollectionUtils.isEmpty(leader) ? null : leader) - .participantCount(participantCount) - .weeklyActivityCount(weeklyActivityCount) - .createdAt(activityGroup.getCreatedAt()) - .build(); + .id(activityGroup.getId()) + .name(activityGroup.getName()) + .content(activityGroup.getContent()) + .category(activityGroup.getCategory()) + .subject(activityGroup.getSubject()) + .imageUrl(activityGroup.getImageUrl()) + .leaders(CollectionUtils.isEmpty(leader) ? null : leader) + .participantCount(participantCount) + .weeklyActivityCount(weeklyActivityCount) + .createdAt(activityGroup.getCreatedAt()) + .build(); } public AttendanceResponseDto toDto(Attendance attendance) { return AttendanceResponseDto.builder() - .activityGroupId(attendance.getActivityGroup().getId()) - .memberId(attendance.getMemberId()) - .attendanceDateTime(attendance.getCreatedAt()) - .build(); + .activityGroupId(attendance.getActivityGroup().getId()) + .memberId(attendance.getMemberId()) + .attendanceDateTime(attendance.getCreatedAt()) + .build(); } public GroupMemberResponseDto toDto(Member member, GroupMember groupMember) { return GroupMemberResponseDto.builder() - .memberId(member.getId()) - .memberName(member.getName()) - .role(groupMember.getRole().getKey()) - .status(groupMember.getStatus()) - .build(); + .memberId(member.getId()) + .memberName(member.getName()) + .role(groupMember.getRole().getKey()) + .status(groupMember.getStatus()) + .build(); } - public ActivityGroupBoardChildResponseDto toChildDto(ActivityGroupBoard board, MemberBasicInfoDto memberBasicInfoDto, List childrenDtos) { + public ActivityGroupBoardChildResponseDto toChildDto(ActivityGroupBoard board, + MemberBasicInfoDto memberBasicInfoDto, List childrenDtos) { return ActivityGroupBoardChildResponseDto.builder() - .id(board.getId()) - .memberId(memberBasicInfoDto.getMemberId()) - .memberName(memberBasicInfoDto.getMemberName()) - .category(board.getCategory()) - .title(board.getTitle()) - .content(board.getContent()) - .dueDateTime(board.getDueDateTime()) - .updatedAt(board.getUpdatedAt()) - .createdAt(board.getCreatedAt()) - .files(mapper.toDto(board.getUploadedFiles())) - .children(childrenDtos) - .build(); + .id(board.getId()) + .memberId(memberBasicInfoDto.getMemberId()) + .memberName(memberBasicInfoDto.getMemberName()) + .category(board.getCategory()) + .title(board.getTitle()) + .content(board.getContent()) + .dueDateTime(board.getDueDateTime()) + .updatedAt(board.getUpdatedAt()) + .createdAt(board.getCreatedAt()) + .files(mapper.toDto(board.getUploadedFiles())) + .children(childrenDtos) + .build(); } - public AssignmentSubmissionWithFeedbackResponseDto toAssignmentDto(ActivityGroupBoard board, MemberBasicInfoDto memberBasicInfo, List feedbackDtos) { + public AssignmentSubmissionWithFeedbackResponseDto toAssignmentDto(ActivityGroupBoard board, + MemberBasicInfoDto memberBasicInfo, List feedbackDtos) { return AssignmentSubmissionWithFeedbackResponseDto.builder() - .id(board.getId()) - .memberId(memberBasicInfo.getMemberId()) - .memberName(memberBasicInfo.getMemberName()) - .parentId(board.getParent() != null ? board.getParent().getId() : null) - .content(board.getContent()) - .files(mapper.toDto(board.getUploadedFiles())) - .createdAt(board.getCreatedAt()) - .updatedAt(board.getUpdatedAt()) - .feedbacks(feedbackDtos) - .build(); + .id(board.getId()) + .memberId(memberBasicInfo.getMemberId()) + .memberName(memberBasicInfo.getMemberName()) + .parentId(board.getParent() != null ? board.getParent().getId() : null) + .content(board.getContent()) + .files(mapper.toDto(board.getUploadedFiles())) + .createdAt(board.getCreatedAt()) + .updatedAt(board.getUpdatedAt()) + .feedbacks(feedbackDtos) + .build(); } public ActivityGroupBoardResponseDto toBoardDto(ActivityGroupBoard board, MemberBasicInfoDto memberBasicInfoDto) { return ActivityGroupBoardResponseDto.builder() - .id(board.getId()) - .memberId(memberBasicInfoDto.getMemberId()) - .memberName(memberBasicInfoDto.getMemberName()) - .parentId(board.getParent() != null ? board.getParent().getId() : null) - .category(board.getCategory()) - .title(board.getTitle()) - .content(board.getContent()) - .files(mapper.toDto(board.getUploadedFiles())) - .dueDateTime(board.getDueDateTime()) - .createdAt(board.getCreatedAt()) - .updatedAt(board.getUpdatedAt()) - .build(); + .id(board.getId()) + .memberId(memberBasicInfoDto.getMemberId()) + .memberName(memberBasicInfoDto.getMemberName()) + .parentId(board.getParent() != null ? board.getParent().getId() : null) + .category(board.getCategory()) + .title(board.getTitle()) + .content(board.getContent()) + .files(mapper.toDto(board.getUploadedFiles())) + .dueDateTime(board.getDueDateTime()) + .createdAt(board.getCreatedAt()) + .updatedAt(board.getUpdatedAt()) + .build(); } public FeedbackResponseDto toFeedbackDto(ActivityGroupBoard board, MemberBasicInfoDto memberBasicInfo) { return FeedbackResponseDto.builder() - .id(board.getId()) - .memberId(memberBasicInfo.getMemberId()) - .memberName(memberBasicInfo.getMemberName()) - .content(board.getContent()) - .files(mapper.toDto(board.getUploadedFiles())) - .createdAt(board.getCreatedAt()) - .updatedAt(board.getUpdatedAt()) - .build(); + .id(board.getId()) + .memberId(memberBasicInfo.getMemberId()) + .memberName(memberBasicInfo.getMemberName()) + .content(board.getContent()) + .files(mapper.toDto(board.getUploadedFiles())) + .createdAt(board.getCreatedAt()) + .updatedAt(board.getUpdatedAt()) + .build(); } - public ActivityGroupDetails of(ActivityGroup activityGroup, List groupMembers, List activityGroupBoards) { + public ActivityGroupDetails of(ActivityGroup activityGroup, List groupMembers, + List activityGroupBoards) { return ActivityGroupDetails.builder() - .activityGroup(activityGroup) - .groupMembers(groupMembers) - .activityGroupBoards(activityGroupBoards) - .build(); + .activityGroup(activityGroup) + .groupMembers(groupMembers) + .activityGroupBoards(activityGroupBoards) + .build(); } public ActivityGroupBoardStatusUpdatedResponseDto of(Long groupId, ActivityGroupStatus activityGroupStatus) { return ActivityGroupBoardStatusUpdatedResponseDto.builder() - .id(groupId) - .activityGroupStatus(activityGroupStatus) - .build(); + .id(groupId) + .activityGroupStatus(activityGroupStatus) + .build(); } public ActivityGroupBoardReferenceDto of(Long id, Long groupId, Long parentId) { return ActivityGroupBoardReferenceDto.builder() - .id(id) - .groupId(groupId) - .parentId(parentId) - .build(); + .id(id) + .groupId(groupId) + .parentId(parentId) + .build(); } public LeaderInfo create(Member leader, LocalDateTime createdAt) { return LeaderInfo.builder() - .id(leader.getId()) - .name(leader.getName()) - .createdAt(createdAt) - .build(); + .id(leader.getId()) + .name(leader.getName()) + .createdAt(createdAt) + .build(); } } diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/param/ActivityGroupDetails.java b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/param/ActivityGroupDetails.java index a50eed5a6..4feb72017 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/param/ActivityGroupDetails.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/param/ActivityGroupDetails.java @@ -1,13 +1,12 @@ package page.clab.api.domain.activity.activitygroup.dto.param; +import java.util.List; import lombok.Builder; import lombok.Getter; import page.clab.api.domain.activity.activitygroup.domain.ActivityGroup; import page.clab.api.domain.activity.activitygroup.domain.ActivityGroupBoard; import page.clab.api.domain.activity.activitygroup.domain.GroupMember; -import java.util.List; - @Getter @Builder public class ActivityGroupDetails { diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/param/GroupScheduleDto.java b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/param/GroupScheduleDto.java index f0c9b41f1..0d153c65f 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/param/GroupScheduleDto.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/param/GroupScheduleDto.java @@ -1,11 +1,10 @@ package page.clab.api.domain.activity.activitygroup.dto.param; +import java.time.LocalDateTime; import lombok.Builder; import lombok.Getter; import lombok.Setter; -import java.time.LocalDateTime; - @Getter @Setter @Builder diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/request/AbsentRequestDto.java b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/request/AbsentRequestDto.java index 933766213..f855737a9 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/request/AbsentRequestDto.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/request/AbsentRequestDto.java @@ -2,11 +2,10 @@ import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotNull; +import java.time.LocalDate; import lombok.Getter; import lombok.Setter; -import java.time.LocalDate; - @Getter @Setter public class AbsentRequestDto { diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/request/ActivityGroupBoardRequestDto.java b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/request/ActivityGroupBoardRequestDto.java index fc7098303..2cbc6e105 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/request/ActivityGroupBoardRequestDto.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/request/ActivityGroupBoardRequestDto.java @@ -2,13 +2,12 @@ import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotNull; +import java.time.LocalDateTime; +import java.util.List; import lombok.Getter; import lombok.Setter; import page.clab.api.domain.activity.activitygroup.domain.ActivityGroupBoardCategory; -import java.time.LocalDateTime; -import java.util.List; - @Getter @Setter public class ActivityGroupBoardRequestDto { diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/request/ActivityGroupBoardUpdateRequestDto.java b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/request/ActivityGroupBoardUpdateRequestDto.java index fb4974037..64851bb73 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/request/ActivityGroupBoardUpdateRequestDto.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/request/ActivityGroupBoardUpdateRequestDto.java @@ -1,11 +1,10 @@ package page.clab.api.domain.activity.activitygroup.dto.request; import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Getter; -import lombok.Setter; - import java.time.LocalDateTime; import java.util.List; +import lombok.Getter; +import lombok.Setter; @Getter @Setter diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/request/ActivityGroupRequestDto.java b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/request/ActivityGroupRequestDto.java index 93c4934ab..73254ece9 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/request/ActivityGroupRequestDto.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/request/ActivityGroupRequestDto.java @@ -2,12 +2,11 @@ import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotNull; +import java.time.LocalDate; import lombok.Getter; import lombok.Setter; import page.clab.api.domain.activity.activitygroup.domain.ActivityGroupCategory; -import java.time.LocalDate; - @Getter @Setter public class ActivityGroupRequestDto { diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/request/ActivityGroupUpdateRequestDto.java b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/request/ActivityGroupUpdateRequestDto.java index d552ebddb..8c4ae3399 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/request/ActivityGroupUpdateRequestDto.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/request/ActivityGroupUpdateRequestDto.java @@ -1,12 +1,11 @@ package page.clab.api.domain.activity.activitygroup.dto.request; import io.swagger.v3.oas.annotations.media.Schema; +import java.time.LocalDate; import lombok.Getter; import lombok.Setter; import page.clab.api.domain.activity.activitygroup.domain.ActivityGroupCategory; -import java.time.LocalDate; - @Getter @Setter public class ActivityGroupUpdateRequestDto { diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/AbsentResponseDto.java b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/AbsentResponseDto.java index 522a660a8..445b5f3a1 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/AbsentResponseDto.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/AbsentResponseDto.java @@ -1,10 +1,9 @@ package page.clab.api.domain.activity.activitygroup.dto.response; +import java.time.LocalDate; import lombok.Builder; import lombok.Getter; -import java.time.LocalDate; - @Getter @Builder public class AbsentResponseDto { diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/ActivityGroupBoardChildResponseDto.java b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/ActivityGroupBoardChildResponseDto.java index f817f6fc6..735596571 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/ActivityGroupBoardChildResponseDto.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/ActivityGroupBoardChildResponseDto.java @@ -1,13 +1,12 @@ package page.clab.api.domain.activity.activitygroup.dto.response; +import java.time.LocalDateTime; +import java.util.List; import lombok.Builder; import lombok.Getter; import page.clab.api.domain.activity.activitygroup.domain.ActivityGroupBoardCategory; import page.clab.api.global.common.file.dto.response.UploadedFileResponseDto; -import java.time.LocalDateTime; -import java.util.List; - @Getter @Builder public class ActivityGroupBoardChildResponseDto { diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/ActivityGroupBoardResponseDto.java b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/ActivityGroupBoardResponseDto.java index b39f8721e..4a8f9a930 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/ActivityGroupBoardResponseDto.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/ActivityGroupBoardResponseDto.java @@ -1,13 +1,12 @@ package page.clab.api.domain.activity.activitygroup.dto.response; +import java.time.LocalDateTime; +import java.util.List; import lombok.Builder; import lombok.Getter; import page.clab.api.domain.activity.activitygroup.domain.ActivityGroupBoardCategory; import page.clab.api.global.common.file.dto.response.UploadedFileResponseDto; -import java.time.LocalDateTime; -import java.util.List; - @Getter @Builder public class ActivityGroupBoardResponseDto { diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/ActivityGroupReportResponseDto.java b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/ActivityGroupReportResponseDto.java index 3e06ff955..cb024e9dc 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/ActivityGroupReportResponseDto.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/ActivityGroupReportResponseDto.java @@ -1,10 +1,9 @@ package page.clab.api.domain.activity.activitygroup.dto.response; +import java.time.LocalDateTime; import lombok.Builder; import lombok.Getter; -import java.time.LocalDateTime; - @Getter @Builder public class ActivityGroupReportResponseDto { diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/ActivityGroupResponseDto.java b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/ActivityGroupResponseDto.java index 2709c70f7..1b48bb71d 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/ActivityGroupResponseDto.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/ActivityGroupResponseDto.java @@ -1,12 +1,11 @@ package page.clab.api.domain.activity.activitygroup.dto.response; +import java.time.LocalDateTime; import lombok.Builder; import lombok.Getter; import page.clab.api.domain.activity.activitygroup.domain.ActivityGroupCategory; import page.clab.api.domain.activity.activitygroup.domain.ActivityGroupStatus; -import java.time.LocalDateTime; - @Getter @Builder public class ActivityGroupResponseDto { diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/ActivityGroupStatusResponseDto.java b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/ActivityGroupStatusResponseDto.java index 9033fa48c..d538de592 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/ActivityGroupStatusResponseDto.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/ActivityGroupStatusResponseDto.java @@ -1,12 +1,11 @@ package page.clab.api.domain.activity.activitygroup.dto.response; +import java.time.LocalDateTime; +import java.util.List; import lombok.Builder; import lombok.Getter; import page.clab.api.domain.activity.activitygroup.domain.ActivityGroupCategory; -import java.time.LocalDateTime; -import java.util.List; - @Getter @Builder public class ActivityGroupStatusResponseDto { diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/AssignmentSubmissionWithFeedbackResponseDto.java b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/AssignmentSubmissionWithFeedbackResponseDto.java index a03991ba3..af98df474 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/AssignmentSubmissionWithFeedbackResponseDto.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/AssignmentSubmissionWithFeedbackResponseDto.java @@ -1,12 +1,11 @@ package page.clab.api.domain.activity.activitygroup.dto.response; +import java.time.LocalDateTime; +import java.util.List; import lombok.Builder; import lombok.Getter; import page.clab.api.global.common.file.dto.response.UploadedFileResponseDto; -import java.time.LocalDateTime; -import java.util.List; - @Getter @Builder public class AssignmentSubmissionWithFeedbackResponseDto { diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/AttendanceResponseDto.java b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/AttendanceResponseDto.java index 01e43dbb6..2e932c36a 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/AttendanceResponseDto.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/AttendanceResponseDto.java @@ -1,10 +1,9 @@ package page.clab.api.domain.activity.activitygroup.dto.response; +import java.time.LocalDateTime; import lombok.Builder; import lombok.Getter; -import java.time.LocalDateTime; - @Getter @Builder public class AttendanceResponseDto { diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/FeedbackResponseDto.java b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/FeedbackResponseDto.java index 7da6e03fc..7426867b0 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/FeedbackResponseDto.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/FeedbackResponseDto.java @@ -1,12 +1,11 @@ package page.clab.api.domain.activity.activitygroup.dto.response; +import java.time.LocalDateTime; +import java.util.List; import lombok.Builder; import lombok.Getter; import page.clab.api.global.common.file.dto.response.UploadedFileResponseDto; -import java.time.LocalDateTime; -import java.util.List; - @Getter @Builder public class FeedbackResponseDto { diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/LeaderInfo.java b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/LeaderInfo.java index b96f293a8..2322e5d60 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/LeaderInfo.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/LeaderInfo.java @@ -1,11 +1,10 @@ package page.clab.api.domain.activity.activitygroup.dto.response; import com.fasterxml.jackson.annotation.JsonIgnore; +import java.time.LocalDateTime; import lombok.Builder; import lombok.Getter; -import java.time.LocalDateTime; - @Getter @Builder public class LeaderInfo { diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/exception/AlreadySubmittedThisWeekAssignmentException.java b/src/main/java/page/clab/api/domain/activity/activitygroup/exception/AlreadySubmittedThisWeekAssignmentException.java index f7633884f..662fe16fb 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/exception/AlreadySubmittedThisWeekAssignmentException.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/exception/AlreadySubmittedThisWeekAssignmentException.java @@ -1,6 +1,6 @@ package page.clab.api.domain.activity.activitygroup.exception; -public class AlreadySubmittedThisWeekAssignmentException extends RuntimeException{ +public class AlreadySubmittedThisWeekAssignmentException extends RuntimeException { private static final String DEFAULT_MESSAGE = "해당 주차의 과제물이 이미 제출되었습니다."; diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/exception/SingleLeaderModificationException.java b/src/main/java/page/clab/api/domain/activity/activitygroup/exception/SingleLeaderModificationException.java index e1282a61f..1285d9a00 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/exception/SingleLeaderModificationException.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/exception/SingleLeaderModificationException.java @@ -1,6 +1,6 @@ package page.clab.api.domain.activity.activitygroup.exception; -public class SingleLeaderModificationException extends RuntimeException{ +public class SingleLeaderModificationException extends RuntimeException { public SingleLeaderModificationException(String message) { super(message); diff --git a/src/main/java/page/clab/api/domain/activity/review/adapter/in/web/DeletedReviewsRetrievalController.java b/src/main/java/page/clab/api/domain/activity/review/adapter/in/web/DeletedReviewsRetrievalController.java index f6ba67534..683314bf1 100644 --- a/src/main/java/page/clab/api/domain/activity/review/adapter/in/web/DeletedReviewsRetrievalController.java +++ b/src/main/java/page/clab/api/domain/activity/review/adapter/in/web/DeletedReviewsRetrievalController.java @@ -27,8 +27,8 @@ public class DeletedReviewsRetrievalController { @PreAuthorize("hasRole('SUPER')") @GetMapping("/deleted") public ApiResponse> retrieveDeletedReviews( - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size ) { Pageable pageable = PageRequest.of(page, size); PagedResponseDto reviews = retrieveDeletedReviewsUseCase.retrieveDeletedReviews(pageable); diff --git a/src/main/java/page/clab/api/domain/activity/review/adapter/in/web/MyReviewsRetrievalController.java b/src/main/java/page/clab/api/domain/activity/review/adapter/in/web/MyReviewsRetrievalController.java index dff6e1b7b..588d52d1c 100644 --- a/src/main/java/page/clab/api/domain/activity/review/adapter/in/web/MyReviewsRetrievalController.java +++ b/src/main/java/page/clab/api/domain/activity/review/adapter/in/web/MyReviewsRetrievalController.java @@ -2,6 +2,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.security.access.prepost.PreAuthorize; @@ -17,8 +18,6 @@ import page.clab.api.global.exception.SortingArgumentException; import page.clab.api.global.util.PageableUtils; -import java.util.List; - @RestController @RequestMapping("/api/v1/reviews") @RequiredArgsConstructor @@ -29,14 +28,14 @@ public class MyReviewsRetrievalController { private final PageableUtils pageableUtils; @Operation(summary = "[G] 나의 리뷰 목록", description = "ROLE_GUEST 이상의 권한이 필요함
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") @PreAuthorize("hasRole('GUEST')") @GetMapping("/my") public ApiResponse> retrieveMyReviews( - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection ) throws SortingArgumentException, InvalidColumnException { Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, ReviewResponseDto.class); PagedResponseDto myReviews = retrieveMyReviewsUseCase.retrieveMyReviews(pageable); diff --git a/src/main/java/page/clab/api/domain/activity/review/adapter/in/web/ReviewRegisterController.java b/src/main/java/page/clab/api/domain/activity/review/adapter/in/web/ReviewRegisterController.java index 9a025fdec..45340f87e 100644 --- a/src/main/java/page/clab/api/domain/activity/review/adapter/in/web/ReviewRegisterController.java +++ b/src/main/java/page/clab/api/domain/activity/review/adapter/in/web/ReviewRegisterController.java @@ -25,7 +25,7 @@ public class ReviewRegisterController { @PreAuthorize("hasRole('USER')") @PostMapping("") public ApiResponse registerReview( - @Valid @RequestBody ReviewRequestDto requestDto + @Valid @RequestBody ReviewRequestDto requestDto ) { Long id = registerReviewUseCase.registerReview(requestDto); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/activity/review/adapter/in/web/ReviewRemoveController.java b/src/main/java/page/clab/api/domain/activity/review/adapter/in/web/ReviewRemoveController.java index 44fb9e135..974b0d83f 100644 --- a/src/main/java/page/clab/api/domain/activity/review/adapter/in/web/ReviewRemoveController.java +++ b/src/main/java/page/clab/api/domain/activity/review/adapter/in/web/ReviewRemoveController.java @@ -24,7 +24,7 @@ public class ReviewRemoveController { @PreAuthorize("hasRole('USER')") @DeleteMapping("/{reviewId}") public ApiResponse removeReview( - @PathVariable(name = "reviewId") Long reviewId + @PathVariable(name = "reviewId") Long reviewId ) throws PermissionDeniedException { Long id = removeReviewUseCase.removeReview(reviewId); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/activity/review/adapter/in/web/ReviewUpdateController.java b/src/main/java/page/clab/api/domain/activity/review/adapter/in/web/ReviewUpdateController.java index 27d4ac32b..32ed2d8ac 100644 --- a/src/main/java/page/clab/api/domain/activity/review/adapter/in/web/ReviewUpdateController.java +++ b/src/main/java/page/clab/api/domain/activity/review/adapter/in/web/ReviewUpdateController.java @@ -27,8 +27,8 @@ public class ReviewUpdateController { @PreAuthorize("hasRole('USER')") @PatchMapping("/{reviewId}") public ApiResponse updateReview( - @PathVariable(name = "reviewId") Long reviewId, - @Valid @RequestBody ReviewUpdateRequestDto requestDto + @PathVariable(name = "reviewId") Long reviewId, + @Valid @RequestBody ReviewUpdateRequestDto requestDto ) throws PermissionDeniedException { Long id = updateReviewUseCase.updateReview(reviewId, requestDto); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/activity/review/adapter/in/web/ReviewsByConditionsRetrievalController.java b/src/main/java/page/clab/api/domain/activity/review/adapter/in/web/ReviewsByConditionsRetrievalController.java index 266985e88..7d5d3ca70 100644 --- a/src/main/java/page/clab/api/domain/activity/review/adapter/in/web/ReviewsByConditionsRetrievalController.java +++ b/src/main/java/page/clab/api/domain/activity/review/adapter/in/web/ReviewsByConditionsRetrievalController.java @@ -2,6 +2,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.security.access.prepost.PreAuthorize; @@ -17,8 +18,6 @@ import page.clab.api.global.exception.SortingArgumentException; import page.clab.api.global.util.PageableUtils; -import java.util.List; - @RestController @RequestMapping("/api/v1/reviews") @RequiredArgsConstructor @@ -29,23 +28,24 @@ public class ReviewsByConditionsRetrievalController { private final PageableUtils pageableUtils; @Operation(summary = "[U] 리뷰 목록 조회(멤버 ID, 멤버 이름, 활동 ID, 공개 여부 기준)", description = "ROLE_USER 이상의 권한이 필요함
" + - "4개의 파라미터를 자유롭게 조합하여 필터링 가능
" + - "멤버 ID, 멤버 이름, 활동 ID, 공개 여부 중 하나라도 입력하지 않으면 전체 조회됨
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") + "4개의 파라미터를 자유롭게 조합하여 필터링 가능
" + + "멤버 ID, 멤버 이름, 활동 ID, 공개 여부 중 하나라도 입력하지 않으면 전체 조회됨
" + + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") @PreAuthorize("hasRole('USER')") @GetMapping("") public ApiResponse> retrieveReviewsByConditions( - @RequestParam(name = "memberId", required = false) String memberId, - @RequestParam(name = "memberName", required = false) String memberName, - @RequestParam(name = "activityId", required = false) Long activityId, - @RequestParam(name = "isPublic", required = false) Boolean isPublic, - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection + @RequestParam(name = "memberId", required = false) String memberId, + @RequestParam(name = "memberName", required = false) String memberName, + @RequestParam(name = "activityId", required = false) Long activityId, + @RequestParam(name = "isPublic", required = false) Boolean isPublic, + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection ) throws SortingArgumentException, InvalidColumnException { Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, ReviewResponseDto.class); - PagedResponseDto reviews = retrieveReviewsByConditionsUseCase.retrieveReviews(memberId, memberName, activityId, isPublic, pageable); + PagedResponseDto reviews = retrieveReviewsByConditionsUseCase.retrieveReviews(memberId, + memberName, activityId, isPublic, pageable); return ApiResponse.success(reviews); } } diff --git a/src/main/java/page/clab/api/domain/activity/review/adapter/out/persistence/ReviewPersistenceAdapter.java b/src/main/java/page/clab/api/domain/activity/review/adapter/out/persistence/ReviewPersistenceAdapter.java index f55547f76..2cdd7d62b 100644 --- a/src/main/java/page/clab/api/domain/activity/review/adapter/out/persistence/ReviewPersistenceAdapter.java +++ b/src/main/java/page/clab/api/domain/activity/review/adapter/out/persistence/ReviewPersistenceAdapter.java @@ -13,8 +13,8 @@ @Component @RequiredArgsConstructor public class ReviewPersistenceAdapter implements - RegisterReviewPort, - RetrieveReviewPort { + RegisterReviewPort, + RetrieveReviewPort { private final ReviewRepository repository; private final ReviewMapper mapper; @@ -29,20 +29,20 @@ public Review save(Review review) { @Override public Review getById(Long reviewId) { return repository.findById(reviewId) - .map(mapper::toDomain) - .orElseThrow(() -> new NotFoundException("[Review] id: " + reviewId + "에 해당하는 리뷰가 존재하지 않습니다.")); + .map(mapper::toDomain) + .orElseThrow(() -> new NotFoundException("[Review] id: " + reviewId + "에 해당하는 리뷰가 존재하지 않습니다.")); } @Override public Page findAllByIsDeletedTrue(Pageable pageable) { return repository.findAllByIsDeletedTrue(pageable) - .map(mapper::toDomain); + .map(mapper::toDomain); } @Override public Page findAllByMemberId(String memberId, Pageable pageable) { return repository.findAllByMemberId(memberId, pageable) - .map(mapper::toDomain); + .map(mapper::toDomain); } @Override @@ -51,8 +51,9 @@ public boolean existsByMemberIdAndActivityGroup(String memberId, ActivityGroup a } @Override - public Page findByConditions(String memberId, String memberName, Long activityId, Boolean isPublic, Pageable pageable) { + public Page findByConditions(String memberId, String memberName, Long activityId, Boolean isPublic, + Pageable pageable) { return repository.findByConditions(memberId, memberName, activityId, isPublic, pageable) - .map(mapper::toDomain); + .map(mapper::toDomain); } } diff --git a/src/main/java/page/clab/api/domain/activity/review/adapter/out/persistence/ReviewRepository.java b/src/main/java/page/clab/api/domain/activity/review/adapter/out/persistence/ReviewRepository.java index a2265d63e..5589b6cdb 100644 --- a/src/main/java/page/clab/api/domain/activity/review/adapter/out/persistence/ReviewRepository.java +++ b/src/main/java/page/clab/api/domain/activity/review/adapter/out/persistence/ReviewRepository.java @@ -8,7 +8,8 @@ import page.clab.api.domain.activity.activitygroup.domain.ActivityGroup; import page.clab.api.domain.activity.review.domain.Review; -public interface ReviewRepository extends JpaRepository, ReviewRepositoryCustom, QuerydslPredicateExecutor { +public interface ReviewRepository extends JpaRepository, ReviewRepositoryCustom, + QuerydslPredicateExecutor { boolean existsByMemberIdAndActivityGroup(String memberId, ActivityGroup activityGroup); diff --git a/src/main/java/page/clab/api/domain/activity/review/adapter/out/persistence/ReviewRepositoryCustom.java b/src/main/java/page/clab/api/domain/activity/review/adapter/out/persistence/ReviewRepositoryCustom.java index 1a8652a75..267913cc0 100644 --- a/src/main/java/page/clab/api/domain/activity/review/adapter/out/persistence/ReviewRepositoryCustom.java +++ b/src/main/java/page/clab/api/domain/activity/review/adapter/out/persistence/ReviewRepositoryCustom.java @@ -4,5 +4,7 @@ import org.springframework.data.domain.Pageable; public interface ReviewRepositoryCustom { - Page findByConditions(String memberId, String memberName, Long activityId, Boolean isPublic, Pageable pageable); + + Page findByConditions(String memberId, String memberName, Long activityId, Boolean isPublic, + Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/activity/review/adapter/out/persistence/ReviewRepositoryImpl.java b/src/main/java/page/clab/api/domain/activity/review/adapter/out/persistence/ReviewRepositoryImpl.java index 043ddec86..7fb8c0d48 100644 --- a/src/main/java/page/clab/api/domain/activity/review/adapter/out/persistence/ReviewRepositoryImpl.java +++ b/src/main/java/page/clab/api/domain/activity/review/adapter/out/persistence/ReviewRepositoryImpl.java @@ -3,6 +3,7 @@ import com.querydsl.core.BooleanBuilder; import com.querydsl.jpa.JPAExpressions; import com.querydsl.jpa.impl.JPAQueryFactory; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; @@ -11,8 +12,6 @@ import page.clab.api.domain.memberManagement.member.adapter.out.persistence.QMemberJpaEntity; import page.clab.api.global.util.OrderSpecifierUtil; -import java.util.List; - @Repository @RequiredArgsConstructor public class ReviewRepositoryImpl implements ReviewRepositoryCustom { @@ -20,31 +19,38 @@ public class ReviewRepositoryImpl implements ReviewRepositoryCustom { private final JPAQueryFactory queryFactory; @Override - public Page findByConditions(String memberId, String memberName, Long activityId, Boolean isPublic, Pageable pageable) { + public Page findByConditions(String memberId, String memberName, Long activityId, Boolean isPublic, + Pageable pageable) { QReviewJpaEntity review = QReviewJpaEntity.reviewJpaEntity; BooleanBuilder builder = new BooleanBuilder(); - if (memberId != null) builder.and(review.memberId.eq(memberId)); + if (memberId != null) { + builder.and(review.memberId.eq(memberId)); + } if (memberName != null && !memberName.isBlank()) { QMemberJpaEntity member = QMemberJpaEntity.memberJpaEntity; builder.and(JPAExpressions.selectFrom(member) - .where(member.name.eq(memberName) - .and(member.id.eq(review.memberId))) - .exists()); + .where(member.name.eq(memberName) + .and(member.id.eq(review.memberId))) + .exists()); + } + if (activityId != null) { + builder.and(review.activityGroup.id.eq(activityId)); + } + if (isPublic != null) { + builder.and(review.isPublic.eq(isPublic)); } - if (activityId != null) builder.and(review.activityGroup.id.eq(activityId)); - if (isPublic != null) builder.and(review.isPublic.eq(isPublic)); List reviews = queryFactory.selectFrom(review) - .where(builder) - .orderBy(OrderSpecifierUtil.getOrderSpecifiers(pageable, review)) - .offset(pageable.getOffset()) - .limit(pageable.getPageSize()) - .fetch(); + .where(builder) + .orderBy(OrderSpecifierUtil.getOrderSpecifiers(pageable, review)) + .offset(pageable.getOffset()) + .limit(pageable.getPageSize()) + .fetch(); long count = queryFactory.selectFrom(review) - .where(builder) - .fetchCount(); + .where(builder) + .fetchCount(); return new PageImpl<>(reviews, pageable, count); } diff --git a/src/main/java/page/clab/api/domain/activity/review/application/dto/mapper/ReviewDtoMapper.java b/src/main/java/page/clab/api/domain/activity/review/application/dto/mapper/ReviewDtoMapper.java index dff125ec1..f61c4670f 100644 --- a/src/main/java/page/clab/api/domain/activity/review/application/dto/mapper/ReviewDtoMapper.java +++ b/src/main/java/page/clab/api/domain/activity/review/application/dto/mapper/ReviewDtoMapper.java @@ -12,28 +12,28 @@ public class ReviewDtoMapper { public Review fromDto(ReviewRequestDto requestDto, String memberId, ActivityGroup activityGroup) { return Review.builder() - .activityGroup(activityGroup) - .memberId(memberId) - .content(requestDto.getContent()) - .isPublic(false) - .isDeleted(false) - .build(); + .activityGroup(activityGroup) + .memberId(memberId) + .content(requestDto.getContent()) + .isPublic(false) + .isDeleted(false) + .build(); } public ReviewResponseDto toDto(Review review, MemberReviewInfoDto reviewer, boolean isOwner) { ActivityGroup activityGroup = review.getActivityGroup(); return ReviewResponseDto.builder() - .id(review.getId()) - .activityGroupId(activityGroup.getId()) - .activityGroupName(activityGroup.getName()) - .activityGroupCategory(String.valueOf(activityGroup.getCategory())) - .memberId(reviewer.getMemberId()) - .name(reviewer.getMemberName()) - .department(reviewer.getDepartment()) - .content(review.getContent()) - .isPublic(review.getIsPublic()) - .isOwner(isOwner) - .createdAt(review.getCreatedAt()) - .build(); + .id(review.getId()) + .activityGroupId(activityGroup.getId()) + .activityGroupName(activityGroup.getName()) + .activityGroupCategory(String.valueOf(activityGroup.getCategory())) + .memberId(reviewer.getMemberId()) + .name(reviewer.getMemberName()) + .department(reviewer.getDepartment()) + .content(review.getContent()) + .isPublic(review.getIsPublic()) + .isOwner(isOwner) + .createdAt(review.getCreatedAt()) + .build(); } } diff --git a/src/main/java/page/clab/api/domain/activity/review/application/dto/request/ReviewRequestDto.java b/src/main/java/page/clab/api/domain/activity/review/application/dto/request/ReviewRequestDto.java index 3d255c500..1b61d4c5f 100644 --- a/src/main/java/page/clab/api/domain/activity/review/application/dto/request/ReviewRequestDto.java +++ b/src/main/java/page/clab/api/domain/activity/review/application/dto/request/ReviewRequestDto.java @@ -15,6 +15,6 @@ public class ReviewRequestDto { @NotNull(message = "{notNull.review.content}") @Schema(description = "후기", example = "C-Lab에는 다양한 분야에 대한 열정있는 사람들이 모이기 때문에 다양하고 활동적인 스터디 그룹과 프로젝트 팀이 있습니다. " + - "신입생이라도 자유롭게 스터디 그룹을 만들고 사람들을 모아서 원하는 분야와 관련된 기술을 알아보고 같이 공부하기 좋습니다!", required = true) + "신입생이라도 자유롭게 스터디 그룹을 만들고 사람들을 모아서 원하는 분야와 관련된 기술을 알아보고 같이 공부하기 좋습니다!", required = true) private String content; } diff --git a/src/main/java/page/clab/api/domain/activity/review/application/dto/response/ReviewResponseDto.java b/src/main/java/page/clab/api/domain/activity/review/application/dto/response/ReviewResponseDto.java index c5e3e85af..47819cdd3 100644 --- a/src/main/java/page/clab/api/domain/activity/review/application/dto/response/ReviewResponseDto.java +++ b/src/main/java/page/clab/api/domain/activity/review/application/dto/response/ReviewResponseDto.java @@ -1,10 +1,9 @@ package page.clab.api.domain.activity.review.application.dto.response; +import java.time.LocalDateTime; import lombok.Builder; import lombok.Getter; -import java.time.LocalDateTime; - @Getter @Builder public class ReviewResponseDto { diff --git a/src/main/java/page/clab/api/domain/activity/review/application/port/in/RegisterReviewUseCase.java b/src/main/java/page/clab/api/domain/activity/review/application/port/in/RegisterReviewUseCase.java index b0f50575e..82b264a7b 100644 --- a/src/main/java/page/clab/api/domain/activity/review/application/port/in/RegisterReviewUseCase.java +++ b/src/main/java/page/clab/api/domain/activity/review/application/port/in/RegisterReviewUseCase.java @@ -3,5 +3,6 @@ import page.clab.api.domain.activity.review.application.dto.request.ReviewRequestDto; public interface RegisterReviewUseCase { + Long registerReview(ReviewRequestDto requestDto); } diff --git a/src/main/java/page/clab/api/domain/activity/review/application/port/in/RemoveReviewUseCase.java b/src/main/java/page/clab/api/domain/activity/review/application/port/in/RemoveReviewUseCase.java index 770a03e73..2eb6b8d91 100644 --- a/src/main/java/page/clab/api/domain/activity/review/application/port/in/RemoveReviewUseCase.java +++ b/src/main/java/page/clab/api/domain/activity/review/application/port/in/RemoveReviewUseCase.java @@ -3,5 +3,6 @@ import page.clab.api.global.exception.PermissionDeniedException; public interface RemoveReviewUseCase { + Long removeReview(Long reviewId) throws PermissionDeniedException; } diff --git a/src/main/java/page/clab/api/domain/activity/review/application/port/in/RetrieveDeletedReviewsUseCase.java b/src/main/java/page/clab/api/domain/activity/review/application/port/in/RetrieveDeletedReviewsUseCase.java index ceb549e30..b9d21a6f4 100644 --- a/src/main/java/page/clab/api/domain/activity/review/application/port/in/RetrieveDeletedReviewsUseCase.java +++ b/src/main/java/page/clab/api/domain/activity/review/application/port/in/RetrieveDeletedReviewsUseCase.java @@ -5,5 +5,6 @@ import page.clab.api.global.common.dto.PagedResponseDto; public interface RetrieveDeletedReviewsUseCase { + PagedResponseDto retrieveDeletedReviews(Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/activity/review/application/port/in/RetrieveMyReviewsUseCase.java b/src/main/java/page/clab/api/domain/activity/review/application/port/in/RetrieveMyReviewsUseCase.java index 06b4d7ad6..7f01cb801 100644 --- a/src/main/java/page/clab/api/domain/activity/review/application/port/in/RetrieveMyReviewsUseCase.java +++ b/src/main/java/page/clab/api/domain/activity/review/application/port/in/RetrieveMyReviewsUseCase.java @@ -5,5 +5,6 @@ import page.clab.api.global.common.dto.PagedResponseDto; public interface RetrieveMyReviewsUseCase { + PagedResponseDto retrieveMyReviews(Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/activity/review/application/port/in/RetrieveReviewsByConditionsUseCase.java b/src/main/java/page/clab/api/domain/activity/review/application/port/in/RetrieveReviewsByConditionsUseCase.java index 972feeafc..f390e45c1 100644 --- a/src/main/java/page/clab/api/domain/activity/review/application/port/in/RetrieveReviewsByConditionsUseCase.java +++ b/src/main/java/page/clab/api/domain/activity/review/application/port/in/RetrieveReviewsByConditionsUseCase.java @@ -5,5 +5,7 @@ import page.clab.api.global.common.dto.PagedResponseDto; public interface RetrieveReviewsByConditionsUseCase { - PagedResponseDto retrieveReviews(String memberId, String memberName, Long activityId, Boolean isPublic, Pageable pageable); + + PagedResponseDto retrieveReviews(String memberId, String memberName, Long activityId, + Boolean isPublic, Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/activity/review/application/port/in/UpdateReviewUseCase.java b/src/main/java/page/clab/api/domain/activity/review/application/port/in/UpdateReviewUseCase.java index 81e6f8a7b..daa757a82 100644 --- a/src/main/java/page/clab/api/domain/activity/review/application/port/in/UpdateReviewUseCase.java +++ b/src/main/java/page/clab/api/domain/activity/review/application/port/in/UpdateReviewUseCase.java @@ -4,5 +4,6 @@ import page.clab.api.global.exception.PermissionDeniedException; public interface UpdateReviewUseCase { + Long updateReview(Long reviewId, ReviewUpdateRequestDto requestDto) throws PermissionDeniedException; } diff --git a/src/main/java/page/clab/api/domain/activity/review/application/port/out/RegisterReviewPort.java b/src/main/java/page/clab/api/domain/activity/review/application/port/out/RegisterReviewPort.java index 49370b62c..cb73ca401 100644 --- a/src/main/java/page/clab/api/domain/activity/review/application/port/out/RegisterReviewPort.java +++ b/src/main/java/page/clab/api/domain/activity/review/application/port/out/RegisterReviewPort.java @@ -3,5 +3,6 @@ import page.clab.api.domain.activity.review.domain.Review; public interface RegisterReviewPort { + Review save(Review review); } diff --git a/src/main/java/page/clab/api/domain/activity/review/application/port/out/RetrieveReviewPort.java b/src/main/java/page/clab/api/domain/activity/review/application/port/out/RetrieveReviewPort.java index 2b35088fd..46857486a 100644 --- a/src/main/java/page/clab/api/domain/activity/review/application/port/out/RetrieveReviewPort.java +++ b/src/main/java/page/clab/api/domain/activity/review/application/port/out/RetrieveReviewPort.java @@ -13,7 +13,8 @@ public interface RetrieveReviewPort { Page findAllByMemberId(String memberId, Pageable pageable); - Page findByConditions(String memberId, String memberName, Long activityId, Boolean isPublic, Pageable pageable); + Page findByConditions(String memberId, String memberName, Long activityId, Boolean isPublic, + Pageable pageable); boolean existsByMemberIdAndActivityGroup(String memberId, ActivityGroup activityGroup); } diff --git a/src/main/java/page/clab/api/domain/activity/review/application/service/ReviewRegisterService.java b/src/main/java/page/clab/api/domain/activity/review/application/service/ReviewRegisterService.java index ca2413a5f..a777df8f8 100644 --- a/src/main/java/page/clab/api/domain/activity/review/application/service/ReviewRegisterService.java +++ b/src/main/java/page/clab/api/domain/activity/review/application/service/ReviewRegisterService.java @@ -1,5 +1,6 @@ package page.clab.api.domain.activity.review.application.service; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -20,8 +21,6 @@ import page.clab.api.external.memberManagement.member.application.port.ExternalRetrieveMemberUseCase; import page.clab.api.external.memberManagement.notification.application.port.ExternalSendNotificationUseCase; -import java.util.List; - @Service @RequiredArgsConstructor public class ReviewRegisterService implements RegisterReviewUseCase { @@ -54,9 +53,12 @@ private void validateReviewCreationPermission(ActivityGroup activityGroup, Strin } private void notifyGroupLeaderOfNewReview(ActivityGroup activityGroup, String memberName) { - List groupLeaders = activityGroupMemberService.getGroupMemberByActivityGroupIdAndRole(activityGroup.getId(), ActivityGroupRole.LEADER); + List groupLeaders = activityGroupMemberService.getGroupMemberByActivityGroupIdAndRole( + activityGroup.getId(), ActivityGroupRole.LEADER); if (!CollectionUtils.isEmpty(groupLeaders)) { - groupLeaders.forEach(leader -> externalSendNotificationUseCase.sendNotificationToMember(leader.getMemberId(), "[" + activityGroup.getName() + "] " + memberName + "님이 리뷰를 등록하였습니다.")); + groupLeaders.forEach( + leader -> externalSendNotificationUseCase.sendNotificationToMember(leader.getMemberId(), + "[" + activityGroup.getName() + "] " + memberName + "님이 리뷰를 등록하였습니다.")); } } diff --git a/src/main/java/page/clab/api/domain/activity/review/application/service/ReviewsByConditionsRetrievalService.java b/src/main/java/page/clab/api/domain/activity/review/application/service/ReviewsByConditionsRetrievalService.java index 4d97fc901..f6eab85b5 100644 --- a/src/main/java/page/clab/api/domain/activity/review/application/service/ReviewsByConditionsRetrievalService.java +++ b/src/main/java/page/clab/api/domain/activity/review/application/service/ReviewsByConditionsRetrievalService.java @@ -24,9 +24,11 @@ public class ReviewsByConditionsRetrievalService implements RetrieveReviewsByCon @Transactional(readOnly = true) @Override - public PagedResponseDto retrieveReviews(String memberId, String memberName, Long activityId, Boolean isPublic, Pageable pageable) { + public PagedResponseDto retrieveReviews(String memberId, String memberName, Long activityId, + Boolean isPublic, Pageable pageable) { String currentMemberId = externalRetrieveMemberUseCase.getCurrentMemberId(); - Page reviews = retrieveReviewPort.findByConditions(memberId, memberName, activityId, isPublic, pageable); + Page reviews = retrieveReviewPort.findByConditions(memberId, memberName, activityId, isPublic, + pageable); return new PagedResponseDto<>(reviews.map(review -> { MemberReviewInfoDto reviewer = externalRetrieveMemberUseCase.getMemberReviewInfoById(review.getMemberId()); return mapper.toDto(review, reviewer, review.isOwner(currentMemberId)); diff --git a/src/main/java/page/clab/api/domain/activity/review/domain/Review.java b/src/main/java/page/clab/api/domain/activity/review/domain/Review.java index 323a16342..d3edc2e19 100644 --- a/src/main/java/page/clab/api/domain/activity/review/domain/Review.java +++ b/src/main/java/page/clab/api/domain/activity/review/domain/Review.java @@ -1,5 +1,7 @@ package page.clab.api.domain.activity.review.domain; +import java.time.LocalDateTime; +import java.util.Optional; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -11,9 +13,6 @@ import page.clab.api.domain.memberManagement.member.application.dto.shared.MemberDetailedInfoDto; import page.clab.api.global.exception.PermissionDeniedException; -import java.time.LocalDateTime; -import java.util.Optional; - @Getter @Setter @Builder diff --git a/src/main/java/page/clab/api/domain/auth/accountAccessLog/adapter/out/persistence/AccountAccessLogJpaEntity.java b/src/main/java/page/clab/api/domain/auth/accountAccessLog/adapter/out/persistence/AccountAccessLogJpaEntity.java index aa2adcd79..4bcc0c5a8 100644 --- a/src/main/java/page/clab/api/domain/auth/accountAccessLog/adapter/out/persistence/AccountAccessLogJpaEntity.java +++ b/src/main/java/page/clab/api/domain/auth/accountAccessLog/adapter/out/persistence/AccountAccessLogJpaEntity.java @@ -8,6 +8,7 @@ import jakarta.persistence.GenerationType; import jakarta.persistence.Id; import jakarta.persistence.Table; +import java.time.LocalDateTime; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -17,8 +18,6 @@ import page.clab.api.domain.auth.accountAccessLog.domain.AccountAccessResult; import page.clab.api.global.common.domain.BaseEntity; -import java.time.LocalDateTime; - @Entity @Table(name = "account_access_log") @Getter diff --git a/src/main/java/page/clab/api/domain/auth/accountAccessLog/adapter/out/persistence/AccountAccessLogPersistenceAdapter.java b/src/main/java/page/clab/api/domain/auth/accountAccessLog/adapter/out/persistence/AccountAccessLogPersistenceAdapter.java index 4220791df..7c427511c 100644 --- a/src/main/java/page/clab/api/domain/auth/accountAccessLog/adapter/out/persistence/AccountAccessLogPersistenceAdapter.java +++ b/src/main/java/page/clab/api/domain/auth/accountAccessLog/adapter/out/persistence/AccountAccessLogPersistenceAdapter.java @@ -8,7 +8,7 @@ @Component @RequiredArgsConstructor public class AccountAccessLogPersistenceAdapter implements - RegisterAccountAccessLogPort { + RegisterAccountAccessLogPort { private final AccountAccessLogRepository accountAccessLogRepository; private final AccountAccessLogMapper accountAccessLogMapper; diff --git a/src/main/java/page/clab/api/domain/auth/accountAccessLog/adapter/out/persistence/AccountAccessLogRepository.java b/src/main/java/page/clab/api/domain/auth/accountAccessLog/adapter/out/persistence/AccountAccessLogRepository.java index c84e09ddd..f7ca72b0f 100644 --- a/src/main/java/page/clab/api/domain/auth/accountAccessLog/adapter/out/persistence/AccountAccessLogRepository.java +++ b/src/main/java/page/clab/api/domain/auth/accountAccessLog/adapter/out/persistence/AccountAccessLogRepository.java @@ -7,5 +7,6 @@ @Repository public interface AccountAccessLogRepository extends JpaRepository { + Page findAllByMemberId(String memberId, Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/auth/accountAccessLog/application/port/out/RegisterAccountAccessLogPort.java b/src/main/java/page/clab/api/domain/auth/accountAccessLog/application/port/out/RegisterAccountAccessLogPort.java index 63df045e4..ffc642eb4 100644 --- a/src/main/java/page/clab/api/domain/auth/accountAccessLog/application/port/out/RegisterAccountAccessLogPort.java +++ b/src/main/java/page/clab/api/domain/auth/accountAccessLog/application/port/out/RegisterAccountAccessLogPort.java @@ -3,5 +3,6 @@ import page.clab.api.domain.auth.accountAccessLog.domain.AccountAccessLog; public interface RegisterAccountAccessLogPort { + AccountAccessLog save(AccountAccessLog accountAccessLog); } diff --git a/src/main/java/page/clab/api/domain/auth/accountAccessLog/domain/AccountAccessLog.java b/src/main/java/page/clab/api/domain/auth/accountAccessLog/domain/AccountAccessLog.java index 2932dc8bc..12150480e 100644 --- a/src/main/java/page/clab/api/domain/auth/accountAccessLog/domain/AccountAccessLog.java +++ b/src/main/java/page/clab/api/domain/auth/accountAccessLog/domain/AccountAccessLog.java @@ -2,14 +2,13 @@ import io.ipinfo.api.model.IPResponse; import jakarta.servlet.http.HttpServletRequest; +import java.time.LocalDateTime; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; -import java.time.LocalDateTime; - @Getter @Builder @NoArgsConstructor(access = AccessLevel.PROTECTED) @@ -24,14 +23,15 @@ public class AccountAccessLog { private AccountAccessResult accountAccessResult; private LocalDateTime accessTime; - public static AccountAccessLog create(String memberId, HttpServletRequest httpServletRequest, String ipAddress, IPResponse ipResponse, AccountAccessResult accountAccessResult) { + public static AccountAccessLog create(String memberId, HttpServletRequest httpServletRequest, String ipAddress, + IPResponse ipResponse, AccountAccessResult accountAccessResult) { return AccountAccessLog.builder() - .memberId(memberId) - .userAgent(httpServletRequest.getHeader("User-Agent")) - .ipAddress(ipAddress) - .location(ipResponse == null ? "Unknown" : ipResponse.getCountryName() + ", " + ipResponse.getCity()) - .accountAccessResult(accountAccessResult) - .accessTime(LocalDateTime.now()) - .build(); + .memberId(memberId) + .userAgent(httpServletRequest.getHeader("User-Agent")) + .ipAddress(ipAddress) + .location(ipResponse == null ? "Unknown" : ipResponse.getCountryName() + ", " + ipResponse.getCity()) + .accountAccessResult(accountAccessResult) + .accessTime(LocalDateTime.now()) + .build(); } } diff --git a/src/main/java/page/clab/api/domain/auth/accountLockInfo/adapter/in/web/BanMembersRetrievalController.java b/src/main/java/page/clab/api/domain/auth/accountLockInfo/adapter/in/web/BanMembersRetrievalController.java index fdc417826..f35df79f7 100644 --- a/src/main/java/page/clab/api/domain/auth/accountLockInfo/adapter/in/web/BanMembersRetrievalController.java +++ b/src/main/java/page/clab/api/domain/auth/accountLockInfo/adapter/in/web/BanMembersRetrievalController.java @@ -27,11 +27,12 @@ public class BanMembersRetrievalController { @PreAuthorize("hasRole('SUPER')") @GetMapping("") public ApiResponse> retrieveBanMembers( - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size ) { Pageable pageable = PageRequest.of(page, size); - PagedResponseDto banMembers = retrieveBannedMembersUseCase.retrieveBanMembers(pageable); + PagedResponseDto banMembers = retrieveBannedMembersUseCase.retrieveBanMembers( + pageable); return ApiResponse.success(banMembers); } } diff --git a/src/main/java/page/clab/api/domain/auth/accountLockInfo/adapter/in/web/MemberBanController.java b/src/main/java/page/clab/api/domain/auth/accountLockInfo/adapter/in/web/MemberBanController.java index 21b35804e..167c9ce3c 100644 --- a/src/main/java/page/clab/api/domain/auth/accountLockInfo/adapter/in/web/MemberBanController.java +++ b/src/main/java/page/clab/api/domain/auth/accountLockInfo/adapter/in/web/MemberBanController.java @@ -24,8 +24,8 @@ public class MemberBanController { @PreAuthorize("hasRole('SUPER')") @PostMapping("/ban/{memberId}") public ApiResponse banMember( - HttpServletRequest request, - @PathVariable(name = "memberId") String memberId + HttpServletRequest request, + @PathVariable(name = "memberId") String memberId ) { Long id = banMemberUseCase.banMember(request, memberId); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/auth/accountLockInfo/adapter/in/web/MemberUnbanController.java b/src/main/java/page/clab/api/domain/auth/accountLockInfo/adapter/in/web/MemberUnbanController.java index a9339d20c..38bfa43d2 100644 --- a/src/main/java/page/clab/api/domain/auth/accountLockInfo/adapter/in/web/MemberUnbanController.java +++ b/src/main/java/page/clab/api/domain/auth/accountLockInfo/adapter/in/web/MemberUnbanController.java @@ -24,8 +24,8 @@ public class MemberUnbanController { @PreAuthorize("hasRole('SUPER')") @PostMapping("/unban/{memberId}") public ApiResponse unbanMember( - HttpServletRequest request, - @PathVariable(name = "memberId") String memberId + HttpServletRequest request, + @PathVariable(name = "memberId") String memberId ) { Long id = unbanMemberUseCase.unbanMember(request, memberId); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/auth/accountLockInfo/adapter/out/persistence/AccountLockInfoJpaEntity.java b/src/main/java/page/clab/api/domain/auth/accountLockInfo/adapter/out/persistence/AccountLockInfoJpaEntity.java index 4353577bc..9679f899b 100644 --- a/src/main/java/page/clab/api/domain/auth/accountLockInfo/adapter/out/persistence/AccountLockInfoJpaEntity.java +++ b/src/main/java/page/clab/api/domain/auth/accountLockInfo/adapter/out/persistence/AccountLockInfoJpaEntity.java @@ -6,6 +6,7 @@ import jakarta.persistence.GenerationType; import jakarta.persistence.Id; import jakarta.persistence.Table; +import java.time.LocalDateTime; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -14,8 +15,6 @@ import lombok.Setter; import page.clab.api.global.common.domain.BaseEntity; -import java.time.LocalDateTime; - @Entity @Table(name = "account_lock_info") @Getter diff --git a/src/main/java/page/clab/api/domain/auth/accountLockInfo/adapter/out/persistence/AccountLockInfoPersistenceAdapter.java b/src/main/java/page/clab/api/domain/auth/accountLockInfo/adapter/out/persistence/AccountLockInfoPersistenceAdapter.java index 59691005a..771b38f16 100644 --- a/src/main/java/page/clab/api/domain/auth/accountLockInfo/adapter/out/persistence/AccountLockInfoPersistenceAdapter.java +++ b/src/main/java/page/clab/api/domain/auth/accountLockInfo/adapter/out/persistence/AccountLockInfoPersistenceAdapter.java @@ -1,5 +1,7 @@ package page.clab.api.domain.auth.accountLockInfo.adapter.out.persistence; +import java.time.LocalDateTime; +import java.util.Optional; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -9,15 +11,12 @@ import page.clab.api.domain.auth.accountLockInfo.application.port.out.RetrieveAccountLockInfoPort; import page.clab.api.domain.auth.accountLockInfo.domain.AccountLockInfo; -import java.time.LocalDateTime; -import java.util.Optional; - @Component @RequiredArgsConstructor public class AccountLockInfoPersistenceAdapter implements - RegisterAccountLockInfoPort, - RetrieveAccountLockInfoPort, - RemoveAccountLockInfoPort { + RegisterAccountLockInfoPort, + RetrieveAccountLockInfoPort, + RemoveAccountLockInfoPort { private final AccountLockInfoRepository accountLockInfoRepository; private final AccountLockInfoMapper accountLockInfoMapper; diff --git a/src/main/java/page/clab/api/domain/auth/accountLockInfo/adapter/out/persistence/AccountLockInfoRepository.java b/src/main/java/page/clab/api/domain/auth/accountLockInfo/adapter/out/persistence/AccountLockInfoRepository.java index a99a97287..a433b3ac7 100644 --- a/src/main/java/page/clab/api/domain/auth/accountLockInfo/adapter/out/persistence/AccountLockInfoRepository.java +++ b/src/main/java/page/clab/api/domain/auth/accountLockInfo/adapter/out/persistence/AccountLockInfoRepository.java @@ -1,13 +1,12 @@ package page.clab.api.domain.auth.accountLockInfo.adapter.out.persistence; +import java.time.LocalDateTime; +import java.util.Optional; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; -import java.time.LocalDateTime; -import java.util.Optional; - @Repository public interface AccountLockInfoRepository extends JpaRepository { diff --git a/src/main/java/page/clab/api/domain/auth/accountLockInfo/application/dto/mapper/AccountLockInfoDtoMapper.java b/src/main/java/page/clab/api/domain/auth/accountLockInfo/application/dto/mapper/AccountLockInfoDtoMapper.java index f96f7b5c2..fc8a21a26 100644 --- a/src/main/java/page/clab/api/domain/auth/accountLockInfo/application/dto/mapper/AccountLockInfoDtoMapper.java +++ b/src/main/java/page/clab/api/domain/auth/accountLockInfo/application/dto/mapper/AccountLockInfoDtoMapper.java @@ -9,8 +9,8 @@ public class AccountLockInfoDtoMapper { public AccountLockInfoResponseDto toDto(AccountLockInfo accountLockInfo, String memberName) { return AccountLockInfoResponseDto.builder() - .id(accountLockInfo.getMemberId()) - .name(memberName) - .build(); + .id(accountLockInfo.getMemberId()) + .name(memberName) + .build(); } } diff --git a/src/main/java/page/clab/api/domain/auth/accountLockInfo/application/port/in/BanMemberUseCase.java b/src/main/java/page/clab/api/domain/auth/accountLockInfo/application/port/in/BanMemberUseCase.java index 2cce13954..2c766f064 100644 --- a/src/main/java/page/clab/api/domain/auth/accountLockInfo/application/port/in/BanMemberUseCase.java +++ b/src/main/java/page/clab/api/domain/auth/accountLockInfo/application/port/in/BanMemberUseCase.java @@ -3,5 +3,6 @@ import jakarta.servlet.http.HttpServletRequest; public interface BanMemberUseCase { + Long banMember(HttpServletRequest request, String memberId); } diff --git a/src/main/java/page/clab/api/domain/auth/accountLockInfo/application/port/in/RetrieveBannedMembersUseCase.java b/src/main/java/page/clab/api/domain/auth/accountLockInfo/application/port/in/RetrieveBannedMembersUseCase.java index 5c17ce8b7..090a51e82 100644 --- a/src/main/java/page/clab/api/domain/auth/accountLockInfo/application/port/in/RetrieveBannedMembersUseCase.java +++ b/src/main/java/page/clab/api/domain/auth/accountLockInfo/application/port/in/RetrieveBannedMembersUseCase.java @@ -5,5 +5,6 @@ import page.clab.api.global.common.dto.PagedResponseDto; public interface RetrieveBannedMembersUseCase { + PagedResponseDto retrieveBanMembers(Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/auth/accountLockInfo/application/port/in/UnbanMemberUseCase.java b/src/main/java/page/clab/api/domain/auth/accountLockInfo/application/port/in/UnbanMemberUseCase.java index 77ba37bbd..577038038 100644 --- a/src/main/java/page/clab/api/domain/auth/accountLockInfo/application/port/in/UnbanMemberUseCase.java +++ b/src/main/java/page/clab/api/domain/auth/accountLockInfo/application/port/in/UnbanMemberUseCase.java @@ -3,5 +3,6 @@ import jakarta.servlet.http.HttpServletRequest; public interface UnbanMemberUseCase { + Long unbanMember(HttpServletRequest request, String memberId); } diff --git a/src/main/java/page/clab/api/domain/auth/accountLockInfo/application/port/out/RegisterAccountLockInfoPort.java b/src/main/java/page/clab/api/domain/auth/accountLockInfo/application/port/out/RegisterAccountLockInfoPort.java index 76044e234..f6fc57080 100644 --- a/src/main/java/page/clab/api/domain/auth/accountLockInfo/application/port/out/RegisterAccountLockInfoPort.java +++ b/src/main/java/page/clab/api/domain/auth/accountLockInfo/application/port/out/RegisterAccountLockInfoPort.java @@ -3,5 +3,6 @@ import page.clab.api.domain.auth.accountLockInfo.domain.AccountLockInfo; public interface RegisterAccountLockInfoPort { + AccountLockInfo save(AccountLockInfo accountLockInfo); } diff --git a/src/main/java/page/clab/api/domain/auth/accountLockInfo/application/port/out/RemoveAccountLockInfoPort.java b/src/main/java/page/clab/api/domain/auth/accountLockInfo/application/port/out/RemoveAccountLockInfoPort.java index f56bedbae..a32b8382a 100644 --- a/src/main/java/page/clab/api/domain/auth/accountLockInfo/application/port/out/RemoveAccountLockInfoPort.java +++ b/src/main/java/page/clab/api/domain/auth/accountLockInfo/application/port/out/RemoveAccountLockInfoPort.java @@ -3,5 +3,6 @@ import page.clab.api.domain.auth.accountLockInfo.domain.AccountLockInfo; public interface RemoveAccountLockInfoPort { + void delete(AccountLockInfo accountLockInfo); } diff --git a/src/main/java/page/clab/api/domain/auth/accountLockInfo/application/port/out/RetrieveAccountLockInfoPort.java b/src/main/java/page/clab/api/domain/auth/accountLockInfo/application/port/out/RetrieveAccountLockInfoPort.java index 142c8d48e..042517808 100644 --- a/src/main/java/page/clab/api/domain/auth/accountLockInfo/application/port/out/RetrieveAccountLockInfoPort.java +++ b/src/main/java/page/clab/api/domain/auth/accountLockInfo/application/port/out/RetrieveAccountLockInfoPort.java @@ -1,12 +1,11 @@ package page.clab.api.domain.auth.accountLockInfo.application.port.out; +import java.time.LocalDateTime; +import java.util.Optional; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import page.clab.api.domain.auth.accountLockInfo.domain.AccountLockInfo; -import java.time.LocalDateTime; -import java.util.Optional; - public interface RetrieveAccountLockInfoPort { Optional findByMemberId(String memberId); diff --git a/src/main/java/page/clab/api/domain/auth/accountLockInfo/application/service/BanMembersRetrievalService.java b/src/main/java/page/clab/api/domain/auth/accountLockInfo/application/service/BanMembersRetrievalService.java index cec3d1ca4..485cef7d7 100644 --- a/src/main/java/page/clab/api/domain/auth/accountLockInfo/application/service/BanMembersRetrievalService.java +++ b/src/main/java/page/clab/api/domain/auth/accountLockInfo/application/service/BanMembersRetrievalService.java @@ -1,5 +1,6 @@ package page.clab.api.domain.auth.accountLockInfo.application.service; +import java.time.LocalDateTime; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -13,8 +14,6 @@ import page.clab.api.external.memberManagement.member.application.port.ExternalRetrieveMemberUseCase; import page.clab.api.global.common.dto.PagedResponseDto; -import java.time.LocalDateTime; - @Service @RequiredArgsConstructor public class BanMembersRetrievalService implements RetrieveBannedMembersUseCase { @@ -29,7 +28,8 @@ public PagedResponseDto retrieveBanMembers(Pageable LocalDateTime banDate = LocalDateTime.of(9999, 12, 31, 23, 59); Page banMembers = retrieveAccountLockInfoPort.findByLockUntil(banDate, pageable); return new PagedResponseDto<>(banMembers.map(accountLockInfo -> { - String memberName = externalRetrieveMemberUseCase.getMemberBasicInfoById(accountLockInfo.getMemberId()).getMemberName(); + String memberName = externalRetrieveMemberUseCase.getMemberBasicInfoById(accountLockInfo.getMemberId()) + .getMemberName(); return mapper.toDto(accountLockInfo, memberName); })); } diff --git a/src/main/java/page/clab/api/domain/auth/accountLockInfo/application/service/MemberBanService.java b/src/main/java/page/clab/api/domain/auth/accountLockInfo/application/service/MemberBanService.java index a7ca3a616..8f7236a9d 100644 --- a/src/main/java/page/clab/api/domain/auth/accountLockInfo/application/service/MemberBanService.java +++ b/src/main/java/page/clab/api/domain/auth/accountLockInfo/application/service/MemberBanService.java @@ -48,7 +48,7 @@ public Long banMember(HttpServletRequest request, String memberId) { private AccountLockInfo ensureAccountLockInfo(String memberId) { return retrieveAccountLockInfoPort.findByMemberId(memberId) - .orElseGet(() -> createAccountLockInfo(memberId)); + .orElseGet(() -> createAccountLockInfo(memberId)); } private AccountLockInfo createAccountLockInfo(String memberId) { @@ -61,6 +61,6 @@ private void sendSlackBanNotification(HttpServletRequest request, String memberI String memberName = externalRetrieveMemberUseCase.getMemberBasicInfoById(memberId).getMemberName(); String memberBannedMessage = "ID: " + memberId + ", Name: " + memberName; eventPublisher.publishEvent( - new NotificationEvent(this, SecurityAlertType.MEMBER_BANNED, request, memberBannedMessage)); + new NotificationEvent(this, SecurityAlertType.MEMBER_BANNED, request, memberBannedMessage)); } } diff --git a/src/main/java/page/clab/api/domain/auth/accountLockInfo/application/service/MemberUnbanService.java b/src/main/java/page/clab/api/domain/auth/accountLockInfo/application/service/MemberUnbanService.java index 1aaf67e4d..0d2517129 100644 --- a/src/main/java/page/clab/api/domain/auth/accountLockInfo/application/service/MemberUnbanService.java +++ b/src/main/java/page/clab/api/domain/auth/accountLockInfo/application/service/MemberUnbanService.java @@ -45,7 +45,7 @@ public Long unbanMember(HttpServletRequest request, String memberId) { private AccountLockInfo ensureAccountLockInfo(String memberId) { return retrieveAccountLockInfoPort.findByMemberId(memberId) - .orElseGet(() -> createAccountLockInfo(memberId)); + .orElseGet(() -> createAccountLockInfo(memberId)); } private AccountLockInfo createAccountLockInfo(String memberId) { @@ -58,6 +58,6 @@ private void sendSlackUnbanNotification(HttpServletRequest request, String membe String memberName = externalRetrieveMemberUseCase.getMemberBasicInfoById(memberId).getMemberName(); String memberUnbannedMessage = "ID: " + memberId + ", Name: " + memberName; eventPublisher.publishEvent( - new NotificationEvent(this, SecurityAlertType.MEMBER_UNBANNED, request, memberUnbannedMessage)); + new NotificationEvent(this, SecurityAlertType.MEMBER_UNBANNED, request, memberUnbannedMessage)); } } diff --git a/src/main/java/page/clab/api/domain/auth/accountLockInfo/domain/AccountLockInfo.java b/src/main/java/page/clab/api/domain/auth/accountLockInfo/domain/AccountLockInfo.java index 022e7820c..bed8fb4df 100644 --- a/src/main/java/page/clab/api/domain/auth/accountLockInfo/domain/AccountLockInfo.java +++ b/src/main/java/page/clab/api/domain/auth/accountLockInfo/domain/AccountLockInfo.java @@ -1,5 +1,6 @@ package page.clab.api.domain.auth.accountLockInfo.domain; +import java.time.LocalDateTime; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -7,8 +8,6 @@ import lombok.NoArgsConstructor; import lombok.Setter; -import java.time.LocalDateTime; - @Getter @Setter @Builder @@ -24,11 +23,11 @@ public class AccountLockInfo { public static AccountLockInfo create(String memberId) { return AccountLockInfo.builder() - .memberId(memberId) - .loginFailCount(0L) - .isLock(false) - .lockUntil(null) - .build(); + .memberId(memberId) + .loginFailCount(0L) + .isLock(false) + .lockUntil(null) + .build(); } public void banPermanently() { diff --git a/src/main/java/page/clab/api/domain/auth/blacklistIp/adapter/in/web/BlacklistIpRegisterController.java b/src/main/java/page/clab/api/domain/auth/blacklistIp/adapter/in/web/BlacklistIpRegisterController.java index cf9aeef27..b740df599 100644 --- a/src/main/java/page/clab/api/domain/auth/blacklistIp/adapter/in/web/BlacklistIpRegisterController.java +++ b/src/main/java/page/clab/api/domain/auth/blacklistIp/adapter/in/web/BlacklistIpRegisterController.java @@ -26,8 +26,8 @@ public class BlacklistIpRegisterController { @PreAuthorize("hasRole('SUPER')") @PostMapping("") public ApiResponse registerBlacklistIp( - HttpServletRequest request, - @Valid @RequestBody BlacklistIpRequestDto requestDto + HttpServletRequest request, + @Valid @RequestBody BlacklistIpRequestDto requestDto ) { String addedIp = registerBlacklistIpUseCase.registerBlacklistIp(request, requestDto); return ApiResponse.success(addedIp); diff --git a/src/main/java/page/clab/api/domain/auth/blacklistIp/adapter/in/web/BlacklistIpRemoveController.java b/src/main/java/page/clab/api/domain/auth/blacklistIp/adapter/in/web/BlacklistIpRemoveController.java index f82205656..41b4140bd 100644 --- a/src/main/java/page/clab/api/domain/auth/blacklistIp/adapter/in/web/BlacklistIpRemoveController.java +++ b/src/main/java/page/clab/api/domain/auth/blacklistIp/adapter/in/web/BlacklistIpRemoveController.java @@ -24,8 +24,8 @@ public class BlacklistIpRemoveController { @PreAuthorize("hasRole('SUPER')") @DeleteMapping("") public ApiResponse removeBlacklistIp( - HttpServletRequest request, - @RequestParam(name = "ipAddress") String ipAddress + HttpServletRequest request, + @RequestParam(name = "ipAddress") String ipAddress ) { String deletedIp = removeBlacklistIpUseCase.removeBlacklistIp(request, ipAddress); return ApiResponse.success(deletedIp); diff --git a/src/main/java/page/clab/api/domain/auth/blacklistIp/adapter/in/web/BlacklistIpRetrievalController.java b/src/main/java/page/clab/api/domain/auth/blacklistIp/adapter/in/web/BlacklistIpRetrievalController.java index de1a8d351..0c37988ac 100644 --- a/src/main/java/page/clab/api/domain/auth/blacklistIp/adapter/in/web/BlacklistIpRetrievalController.java +++ b/src/main/java/page/clab/api/domain/auth/blacklistIp/adapter/in/web/BlacklistIpRetrievalController.java @@ -2,6 +2,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.security.access.prepost.PreAuthorize; @@ -17,8 +18,6 @@ import page.clab.api.global.exception.SortingArgumentException; import page.clab.api.global.util.PageableUtils; -import java.util.List; - @RestController @RequestMapping("/api/v1/blacklists") @RequiredArgsConstructor @@ -29,17 +28,19 @@ public class BlacklistIpRetrievalController { private final PageableUtils pageableUtils; @Operation(summary = "[A] 블랙리스트 IP 목록 조회", description = "ROLE_ADMIN 이상의 권한이 필요함
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") @PreAuthorize("hasRole('ADMIN')") @GetMapping("") public ApiResponse> retrieveBlacklistIps( - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection ) throws SortingArgumentException, InvalidColumnException { - Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, BlacklistIpResponseDto.class); - PagedResponseDto blacklistedIps = retrieveBlacklistIpsUseCase.retrieveBlacklistIps(pageable); + Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, + BlacklistIpResponseDto.class); + PagedResponseDto blacklistedIps = retrieveBlacklistIpsUseCase.retrieveBlacklistIps( + pageable); return ApiResponse.success(blacklistedIps); } } diff --git a/src/main/java/page/clab/api/domain/auth/blacklistIp/adapter/in/web/BlacklistResetController.java b/src/main/java/page/clab/api/domain/auth/blacklistIp/adapter/in/web/BlacklistResetController.java index ac7f6756f..4a5cadbcc 100644 --- a/src/main/java/page/clab/api/domain/auth/blacklistIp/adapter/in/web/BlacklistResetController.java +++ b/src/main/java/page/clab/api/domain/auth/blacklistIp/adapter/in/web/BlacklistResetController.java @@ -3,6 +3,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.servlet.http.HttpServletRequest; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.DeleteMapping; @@ -11,8 +12,6 @@ import page.clab.api.domain.auth.blacklistIp.application.port.in.ResetBlacklistIpsUseCase; import page.clab.api.global.common.dto.ApiResponse; -import java.util.List; - @RestController @RequestMapping("/api/v1/blacklists") @RequiredArgsConstructor @@ -25,7 +24,7 @@ public class BlacklistResetController { @PreAuthorize("hasRole('SUPER')") @DeleteMapping("/clear") public ApiResponse> resetBlacklistIps( - HttpServletRequest request + HttpServletRequest request ) { List blacklistIps = resetBlacklistIpsUseCase.resetBlacklistIps(request); return ApiResponse.success(blacklistIps); diff --git a/src/main/java/page/clab/api/domain/auth/blacklistIp/adapter/out/persistence/BlacklistIpJpaEntity.java b/src/main/java/page/clab/api/domain/auth/blacklistIp/adapter/out/persistence/BlacklistIpJpaEntity.java index 0b80db3c2..ca1cf3dac 100644 --- a/src/main/java/page/clab/api/domain/auth/blacklistIp/adapter/out/persistence/BlacklistIpJpaEntity.java +++ b/src/main/java/page/clab/api/domain/auth/blacklistIp/adapter/out/persistence/BlacklistIpJpaEntity.java @@ -34,8 +34,8 @@ public class BlacklistIpJpaEntity extends BaseEntity { public static BlacklistIpJpaEntity create(String ipAddress, String reason) { return BlacklistIpJpaEntity.builder() - .ipAddress(ipAddress) - .reason(reason) - .build(); + .ipAddress(ipAddress) + .reason(reason) + .build(); } } diff --git a/src/main/java/page/clab/api/domain/auth/blacklistIp/adapter/out/persistence/BlacklistIpPersistenceAdapter.java b/src/main/java/page/clab/api/domain/auth/blacklistIp/adapter/out/persistence/BlacklistIpPersistenceAdapter.java index cbafe18fe..efe11c213 100644 --- a/src/main/java/page/clab/api/domain/auth/blacklistIp/adapter/out/persistence/BlacklistIpPersistenceAdapter.java +++ b/src/main/java/page/clab/api/domain/auth/blacklistIp/adapter/out/persistence/BlacklistIpPersistenceAdapter.java @@ -1,5 +1,7 @@ package page.clab.api.domain.auth.blacklistIp.adapter.out.persistence; +import java.util.List; +import java.util.Optional; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -10,15 +12,12 @@ import page.clab.api.domain.auth.blacklistIp.domain.BlacklistIp; import page.clab.api.global.exception.NotFoundException; -import java.util.List; -import java.util.Optional; - @Component @RequiredArgsConstructor public class BlacklistIpPersistenceAdapter implements - RegisterBlacklistIpPort, - RetrieveBlacklistIpPort, - RemoveBlacklistIpPort { + RegisterBlacklistIpPort, + RetrieveBlacklistIpPort, + RemoveBlacklistIpPort { private final BlacklistIpRepository blacklistIpRepository; private final BlacklistIpMapper blacklistIpMapper; @@ -33,14 +32,14 @@ public BlacklistIp save(BlacklistIp blacklistIp) { @Override public Optional findByIpAddress(String ipAddress) { return blacklistIpRepository.findByIpAddress(ipAddress) - .map(blacklistIpMapper::toDomain); + .map(blacklistIpMapper::toDomain); } @Override public BlacklistIp getByIpAddress(String ipAddress) { return blacklistIpRepository.findByIpAddress(ipAddress) - .map(blacklistIpMapper::toDomain) - .orElseThrow(() -> new NotFoundException("[BlacklistIp] IP: " + ipAddress + "에 해당하는 블랙리스트 IP가 존재하지 않습니다.")); + .map(blacklistIpMapper::toDomain) + .orElseThrow(() -> new NotFoundException("[BlacklistIp] IP: " + ipAddress + "에 해당하는 블랙리스트 IP가 존재하지 않습니다.")); } @Override @@ -62,13 +61,13 @@ public void deleteAll() { @Override public List findAll() { return blacklistIpRepository.findAll().stream() - .map(blacklistIpMapper::toDomain) - .toList(); + .map(blacklistIpMapper::toDomain) + .toList(); } @Override public Page findAll(Pageable pageable) { return blacklistIpRepository.findAll(pageable) - .map(blacklistIpMapper::toDomain); + .map(blacklistIpMapper::toDomain); } } diff --git a/src/main/java/page/clab/api/domain/auth/blacklistIp/adapter/out/persistence/BlacklistIpRepository.java b/src/main/java/page/clab/api/domain/auth/blacklistIp/adapter/out/persistence/BlacklistIpRepository.java index 0fdc6e045..9742909f3 100644 --- a/src/main/java/page/clab/api/domain/auth/blacklistIp/adapter/out/persistence/BlacklistIpRepository.java +++ b/src/main/java/page/clab/api/domain/auth/blacklistIp/adapter/out/persistence/BlacklistIpRepository.java @@ -1,13 +1,12 @@ package page.clab.api.domain.auth.blacklistIp.adapter.out.persistence; +import java.util.Optional; import org.jetbrains.annotations.NotNull; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; -import java.util.Optional; - @Repository public interface BlacklistIpRepository extends JpaRepository { diff --git a/src/main/java/page/clab/api/domain/auth/blacklistIp/application/dto/mapper/BlacklistIpDtoMapper.java b/src/main/java/page/clab/api/domain/auth/blacklistIp/application/dto/mapper/BlacklistIpDtoMapper.java index e82607c2d..9cb585846 100644 --- a/src/main/java/page/clab/api/domain/auth/blacklistIp/application/dto/mapper/BlacklistIpDtoMapper.java +++ b/src/main/java/page/clab/api/domain/auth/blacklistIp/application/dto/mapper/BlacklistIpDtoMapper.java @@ -10,17 +10,17 @@ public class BlacklistIpDtoMapper { public BlacklistIp fromDto(BlacklistIpRequestDto requestDto) { return BlacklistIp.builder() - .ipAddress(requestDto.getIpAddress()) - .reason(requestDto.getReason()) - .build(); + .ipAddress(requestDto.getIpAddress()) + .reason(requestDto.getReason()) + .build(); } public BlacklistIpResponseDto toDto(BlacklistIp blacklistIp) { return BlacklistIpResponseDto.builder() - .id(blacklistIp.getId()) - .ipAddress(blacklistIp.getIpAddress()) - .reason(blacklistIp.getReason()) - .createdAt(blacklistIp.getCreatedAt()) - .build(); + .id(blacklistIp.getId()) + .ipAddress(blacklistIp.getIpAddress()) + .reason(blacklistIp.getReason()) + .createdAt(blacklistIp.getCreatedAt()) + .build(); } } diff --git a/src/main/java/page/clab/api/domain/auth/blacklistIp/application/dto/response/BlacklistIpResponseDto.java b/src/main/java/page/clab/api/domain/auth/blacklistIp/application/dto/response/BlacklistIpResponseDto.java index 2e712645f..fc3cce38e 100644 --- a/src/main/java/page/clab/api/domain/auth/blacklistIp/application/dto/response/BlacklistIpResponseDto.java +++ b/src/main/java/page/clab/api/domain/auth/blacklistIp/application/dto/response/BlacklistIpResponseDto.java @@ -1,10 +1,9 @@ package page.clab.api.domain.auth.blacklistIp.application.dto.response; +import java.time.LocalDateTime; import lombok.Builder; import lombok.Getter; -import java.time.LocalDateTime; - @Getter @Builder public class BlacklistIpResponseDto { diff --git a/src/main/java/page/clab/api/domain/auth/blacklistIp/application/port/in/RegisterBlacklistIpUseCase.java b/src/main/java/page/clab/api/domain/auth/blacklistIp/application/port/in/RegisterBlacklistIpUseCase.java index 73c550ac3..638b8c355 100644 --- a/src/main/java/page/clab/api/domain/auth/blacklistIp/application/port/in/RegisterBlacklistIpUseCase.java +++ b/src/main/java/page/clab/api/domain/auth/blacklistIp/application/port/in/RegisterBlacklistIpUseCase.java @@ -4,5 +4,6 @@ import page.clab.api.domain.auth.blacklistIp.application.dto.request.BlacklistIpRequestDto; public interface RegisterBlacklistIpUseCase { + String registerBlacklistIp(HttpServletRequest request, BlacklistIpRequestDto requestDto); } diff --git a/src/main/java/page/clab/api/domain/auth/blacklistIp/application/port/in/RemoveBlacklistIpUseCase.java b/src/main/java/page/clab/api/domain/auth/blacklistIp/application/port/in/RemoveBlacklistIpUseCase.java index 227e3fbf8..9628f40c7 100644 --- a/src/main/java/page/clab/api/domain/auth/blacklistIp/application/port/in/RemoveBlacklistIpUseCase.java +++ b/src/main/java/page/clab/api/domain/auth/blacklistIp/application/port/in/RemoveBlacklistIpUseCase.java @@ -3,5 +3,6 @@ import jakarta.servlet.http.HttpServletRequest; public interface RemoveBlacklistIpUseCase { + String removeBlacklistIp(HttpServletRequest request, String ipAddress); } diff --git a/src/main/java/page/clab/api/domain/auth/blacklistIp/application/port/in/ResetBlacklistIpsUseCase.java b/src/main/java/page/clab/api/domain/auth/blacklistIp/application/port/in/ResetBlacklistIpsUseCase.java index dcf1da738..f10a3a7d3 100644 --- a/src/main/java/page/clab/api/domain/auth/blacklistIp/application/port/in/ResetBlacklistIpsUseCase.java +++ b/src/main/java/page/clab/api/domain/auth/blacklistIp/application/port/in/ResetBlacklistIpsUseCase.java @@ -1,9 +1,9 @@ package page.clab.api.domain.auth.blacklistIp.application.port.in; import jakarta.servlet.http.HttpServletRequest; - import java.util.List; public interface ResetBlacklistIpsUseCase { + List resetBlacklistIps(HttpServletRequest request); } diff --git a/src/main/java/page/clab/api/domain/auth/blacklistIp/application/port/in/RetrieveBlacklistIpsUseCase.java b/src/main/java/page/clab/api/domain/auth/blacklistIp/application/port/in/RetrieveBlacklistIpsUseCase.java index d499a6ada..71e274634 100644 --- a/src/main/java/page/clab/api/domain/auth/blacklistIp/application/port/in/RetrieveBlacklistIpsUseCase.java +++ b/src/main/java/page/clab/api/domain/auth/blacklistIp/application/port/in/RetrieveBlacklistIpsUseCase.java @@ -5,5 +5,6 @@ import page.clab.api.global.common.dto.PagedResponseDto; public interface RetrieveBlacklistIpsUseCase { + PagedResponseDto retrieveBlacklistIps(Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/auth/blacklistIp/application/port/out/RegisterBlacklistIpPort.java b/src/main/java/page/clab/api/domain/auth/blacklistIp/application/port/out/RegisterBlacklistIpPort.java index 15b7d6138..e51864207 100644 --- a/src/main/java/page/clab/api/domain/auth/blacklistIp/application/port/out/RegisterBlacklistIpPort.java +++ b/src/main/java/page/clab/api/domain/auth/blacklistIp/application/port/out/RegisterBlacklistIpPort.java @@ -3,5 +3,6 @@ import page.clab.api.domain.auth.blacklistIp.domain.BlacklistIp; public interface RegisterBlacklistIpPort { + BlacklistIp save(BlacklistIp blacklistIp); } diff --git a/src/main/java/page/clab/api/domain/auth/blacklistIp/application/port/out/RetrieveBlacklistIpPort.java b/src/main/java/page/clab/api/domain/auth/blacklistIp/application/port/out/RetrieveBlacklistIpPort.java index 097ee7fea..ae2ca5304 100644 --- a/src/main/java/page/clab/api/domain/auth/blacklistIp/application/port/out/RetrieveBlacklistIpPort.java +++ b/src/main/java/page/clab/api/domain/auth/blacklistIp/application/port/out/RetrieveBlacklistIpPort.java @@ -1,12 +1,11 @@ package page.clab.api.domain.auth.blacklistIp.application.port.out; +import java.util.List; +import java.util.Optional; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import page.clab.api.domain.auth.blacklistIp.domain.BlacklistIp; -import java.util.List; -import java.util.Optional; - public interface RetrieveBlacklistIpPort { List findAll(); diff --git a/src/main/java/page/clab/api/domain/auth/blacklistIp/application/service/BlacklistIpRegisterService.java b/src/main/java/page/clab/api/domain/auth/blacklistIp/application/service/BlacklistIpRegisterService.java index 42bc014d8..99957b099 100644 --- a/src/main/java/page/clab/api/domain/auth/blacklistIp/application/service/BlacklistIpRegisterService.java +++ b/src/main/java/page/clab/api/domain/auth/blacklistIp/application/service/BlacklistIpRegisterService.java @@ -38,17 +38,17 @@ public class BlacklistIpRegisterService implements RegisterBlacklistIpUseCase { public String registerBlacklistIp(HttpServletRequest request, BlacklistIpRequestDto requestDto) { String ipAddress = requestDto.getIpAddress(); return retrieveBlacklistIpPort.findByIpAddress(ipAddress) - .map(BlacklistIp::getIpAddress) - .orElseGet(() -> { - BlacklistIp blacklistIp = mapper.fromDto(requestDto); - registerBlacklistIpPort.save(blacklistIp); + .map(BlacklistIp::getIpAddress) + .orElseGet(() -> { + BlacklistIp blacklistIp = mapper.fromDto(requestDto); + registerBlacklistIpPort.save(blacklistIp); - String blacklistAddedMessage = "Added IP: " + ipAddress; - eventPublisher.publishEvent( - new NotificationEvent(this, SecurityAlertType.BLACKLISTED_IP_ADDED, request, - blacklistAddedMessage)); + String blacklistAddedMessage = "Added IP: " + ipAddress; + eventPublisher.publishEvent( + new NotificationEvent(this, SecurityAlertType.BLACKLISTED_IP_ADDED, request, + blacklistAddedMessage)); - return ipAddress; - }); + return ipAddress; + }); } } diff --git a/src/main/java/page/clab/api/domain/auth/blacklistIp/application/service/BlacklistIpRemoveService.java b/src/main/java/page/clab/api/domain/auth/blacklistIp/application/service/BlacklistIpRemoveService.java index 26b558adc..1e7ca0b42 100644 --- a/src/main/java/page/clab/api/domain/auth/blacklistIp/application/service/BlacklistIpRemoveService.java +++ b/src/main/java/page/clab/api/domain/auth/blacklistIp/application/service/BlacklistIpRemoveService.java @@ -38,8 +38,8 @@ public String removeBlacklistIp(HttpServletRequest request, String ipAddress) { String blacklistRemovedMessage = "Deleted IP: " + ipAddress; eventPublisher.publishEvent( - new NotificationEvent(this, SecurityAlertType.BLACKLISTED_IP_REMOVED, request, - blacklistRemovedMessage)); + new NotificationEvent(this, SecurityAlertType.BLACKLISTED_IP_REMOVED, request, + blacklistRemovedMessage)); return blacklistIp.getIpAddress(); } diff --git a/src/main/java/page/clab/api/domain/auth/blacklistIp/application/service/BlacklistIpResetService.java b/src/main/java/page/clab/api/domain/auth/blacklistIp/application/service/BlacklistIpResetService.java index cdcf60021..634cae8b5 100644 --- a/src/main/java/page/clab/api/domain/auth/blacklistIp/application/service/BlacklistIpResetService.java +++ b/src/main/java/page/clab/api/domain/auth/blacklistIp/application/service/BlacklistIpResetService.java @@ -34,15 +34,15 @@ public class BlacklistIpResetService implements ResetBlacklistIpsUseCase { @Override public List resetBlacklistIps(HttpServletRequest request) { List blacklistedIps = retrieveBlacklistIpPort.findAll() - .stream() - .map(BlacklistIp::getIpAddress) - .toList(); + .stream() + .map(BlacklistIp::getIpAddress) + .toList(); removeBlacklistIpPort.deleteAll(); String blacklistRemovedMessage = "Deleted IP: ALL"; eventPublisher.publishEvent( - new NotificationEvent(this, SecurityAlertType.BLACKLISTED_IP_REMOVED, request, - blacklistRemovedMessage)); + new NotificationEvent(this, SecurityAlertType.BLACKLISTED_IP_REMOVED, request, + blacklistRemovedMessage)); return blacklistedIps; } diff --git a/src/main/java/page/clab/api/domain/auth/blacklistIp/domain/BlacklistIp.java b/src/main/java/page/clab/api/domain/auth/blacklistIp/domain/BlacklistIp.java index 5a83673ca..55eace952 100644 --- a/src/main/java/page/clab/api/domain/auth/blacklistIp/domain/BlacklistIp.java +++ b/src/main/java/page/clab/api/domain/auth/blacklistIp/domain/BlacklistIp.java @@ -1,5 +1,6 @@ package page.clab.api.domain.auth.blacklistIp.domain; +import java.time.LocalDateTime; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -7,8 +8,6 @@ import lombok.NoArgsConstructor; import lombok.Setter; -import java.time.LocalDateTime; - @Getter @Setter @Builder @@ -23,8 +22,8 @@ public class BlacklistIp { public static BlacklistIp create(String ipAddress, String reason) { return BlacklistIp.builder() - .ipAddress(ipAddress) - .reason(reason) - .build(); + .ipAddress(ipAddress) + .reason(reason) + .build(); } } diff --git a/src/main/java/page/clab/api/domain/auth/login/adapter/in/web/MemberLoginController.java b/src/main/java/page/clab/api/domain/auth/login/adapter/in/web/MemberLoginController.java index 900a1dace..83eaa502d 100644 --- a/src/main/java/page/clab/api/domain/auth/login/adapter/in/web/MemberLoginController.java +++ b/src/main/java/page/clab/api/domain/auth/login/adapter/in/web/MemberLoginController.java @@ -28,8 +28,8 @@ public class MemberLoginController { private final String authHeader; public MemberLoginController( - @Qualifier("userLoginService") ManageLoginUseCase manageLoginUseCase, - @Value("${security.auth.header}") String authHeader + @Qualifier("userLoginService") ManageLoginUseCase manageLoginUseCase, + @Value("${security.auth.header}") String authHeader ) { this.manageLoginUseCase = manageLoginUseCase; this.authHeader = authHeader; @@ -38,9 +38,9 @@ public MemberLoginController( @Operation(summary = "멤버 로그인", description = "ROLE_ANONYMOUS 권한이 필요함") @PostMapping("") public ApiResponse login( - HttpServletRequest request, - HttpServletResponse response, - @Valid @RequestBody LoginRequestDto requestDto + HttpServletRequest request, + HttpServletResponse response, + @Valid @RequestBody LoginRequestDto requestDto ) throws MemberLockedException, LoginFailedException { LoginResult result = manageLoginUseCase.login(request, requestDto); response.setHeader(authHeader, result.getHeader()); @@ -50,8 +50,8 @@ public ApiResponse login( @Operation(summary = "Guest 로그인", description = "ROLE_ANONYMOUS 권한이 필요함") @PostMapping("/guest") public ApiResponse guestLogin( - HttpServletRequest request, - HttpServletResponse response + HttpServletRequest request, + HttpServletResponse response ) { LoginResult result = manageLoginUseCase.guestLogin(request); response.setHeader(authHeader, result.getHeader()); diff --git a/src/main/java/page/clab/api/domain/auth/login/adapter/in/web/TokenManagementController.java b/src/main/java/page/clab/api/domain/auth/login/adapter/in/web/TokenManagementController.java index 87fb86d5e..2a5b7cfe2 100644 --- a/src/main/java/page/clab/api/domain/auth/login/adapter/in/web/TokenManagementController.java +++ b/src/main/java/page/clab/api/domain/auth/login/adapter/in/web/TokenManagementController.java @@ -4,6 +4,7 @@ import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import java.util.List; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; import org.springframework.security.access.prepost.PreAuthorize; @@ -15,8 +16,6 @@ import page.clab.api.domain.auth.login.application.port.in.ManageLoginUseCase; import page.clab.api.global.common.dto.ApiResponse; -import java.util.List; - @RestController @RequestMapping("/api/v1/login") @Tag(name = "Authentication - Token Management", description = "토큰 관리") @@ -27,8 +26,8 @@ public class TokenManagementController { private final String authHeader; public TokenManagementController( - @Qualifier("tokenManagementService") ManageLoginUseCase manageLoginUseCase, - @Value("${security.auth.header}") String authHeader + @Qualifier("tokenManagementService") ManageLoginUseCase manageLoginUseCase, + @Value("${security.auth.header}") String authHeader ) { this.manageLoginUseCase = manageLoginUseCase; this.authHeader = authHeader; @@ -38,8 +37,8 @@ public TokenManagementController( @PostMapping("/reissue") @PreAuthorize("hasRole('GUEST')") public ApiResponse reissueToken( - HttpServletRequest request, - HttpServletResponse response + HttpServletRequest request, + HttpServletResponse response ) { TokenHeader headerData = manageLoginUseCase.reissueToken(request); response.setHeader(authHeader, headerData.toJson()); @@ -47,7 +46,7 @@ public ApiResponse reissueToken( } @Operation(summary = "[S] 현재 로그인 중인 멤버 조회", description = "ROLE_SUPER 이상의 권한이 필요함
" + - "Redis에 저장된 토큰을 조회하여 현재 로그인 중인 멤버를 조회합니다.") + "Redis에 저장된 토큰을 조회하여 현재 로그인 중인 멤버를 조회합니다.") @GetMapping("/current") @PreAuthorize("hasRole('SUPER')") public ApiResponse> retrieveCurrentLoggedInUsers() { diff --git a/src/main/java/page/clab/api/domain/auth/login/adapter/in/web/TwoFactorAuthenticationController.java b/src/main/java/page/clab/api/domain/auth/login/adapter/in/web/TwoFactorAuthenticationController.java index 946e3e5a9..9a8f7fee4 100644 --- a/src/main/java/page/clab/api/domain/auth/login/adapter/in/web/TwoFactorAuthenticationController.java +++ b/src/main/java/page/clab/api/domain/auth/login/adapter/in/web/TwoFactorAuthenticationController.java @@ -31,8 +31,8 @@ public class TwoFactorAuthenticationController { private final String authHeader; public TwoFactorAuthenticationController( - @Qualifier("twoFactorAuthenticationService") ManageLoginUseCase manageLoginUseCase, - @Value("${security.auth.header}") String authHeader + @Qualifier("twoFactorAuthenticationService") ManageLoginUseCase manageLoginUseCase, + @Value("${security.auth.header}") String authHeader ) { this.manageLoginUseCase = manageLoginUseCase; this.authHeader = authHeader; @@ -41,9 +41,9 @@ public TwoFactorAuthenticationController( @Operation(summary = "TOTP 인증", description = "ROLE_ANONYMOUS 권한이 필요함") @PostMapping("") public ApiResponse authenticate( - HttpServletRequest request, - HttpServletResponse response, - @Valid @RequestBody TwoFactorAuthenticationRequestDto requestDto + HttpServletRequest request, + HttpServletResponse response, + @Valid @RequestBody TwoFactorAuthenticationRequestDto requestDto ) throws MemberLockedException, LoginFailedException { LoginResult result = manageLoginUseCase.authenticate(request, requestDto); response.setHeader(authHeader, result.getHeader()); @@ -54,7 +54,7 @@ public ApiResponse authenticate( @DeleteMapping("/{memberId}") @PreAuthorize("hasRole('SUPER')") public ApiResponse resetAuthenticator( - @PathVariable(name = "memberId") String memberId + @PathVariable(name = "memberId") String memberId ) { String id = manageLoginUseCase.resetAuthenticator(memberId); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/auth/login/adapter/out/persistence/AuthenticatorPersistenceAdapter.java b/src/main/java/page/clab/api/domain/auth/login/adapter/out/persistence/AuthenticatorPersistenceAdapter.java index 3fec2bad2..2bd6f5f90 100644 --- a/src/main/java/page/clab/api/domain/auth/login/adapter/out/persistence/AuthenticatorPersistenceAdapter.java +++ b/src/main/java/page/clab/api/domain/auth/login/adapter/out/persistence/AuthenticatorPersistenceAdapter.java @@ -1,5 +1,6 @@ package page.clab.api.domain.auth.login.adapter.out.persistence; +import java.util.Optional; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; import page.clab.api.domain.auth.login.application.port.out.RegisterAuthenticatorPort; @@ -8,14 +9,12 @@ import page.clab.api.domain.auth.login.domain.Authenticator; import page.clab.api.global.exception.NotFoundException; -import java.util.Optional; - @Component @RequiredArgsConstructor public class AuthenticatorPersistenceAdapter implements - RegisterAuthenticatorPort, - RetrieveAuthenticatorPort, - RemoveAuthenticatorPort { + RegisterAuthenticatorPort, + RetrieveAuthenticatorPort, + RemoveAuthenticatorPort { private final AuthenticatorRepository authenticatorRepository; private final AuthenticatorMapper authenticatorMapper; @@ -35,8 +34,9 @@ public Optional findById(String memberId) { @Override public Authenticator getById(String memberId) { return authenticatorRepository.findById(memberId) - .map(authenticatorMapper::toDomain) - .orElseThrow(() -> new NotFoundException("[Authenticator] memberId: " + memberId + "에 해당하는 Authenticator가 존재하지 않습니다.")); + .map(authenticatorMapper::toDomain) + .orElseThrow(() -> new NotFoundException( + "[Authenticator] memberId: " + memberId + "에 해당하는 Authenticator가 존재하지 않습니다.")); } @Override diff --git a/src/main/java/page/clab/api/domain/auth/login/adapter/out/persistence/AuthenticatorRepository.java b/src/main/java/page/clab/api/domain/auth/login/adapter/out/persistence/AuthenticatorRepository.java index d376a6517..3d0ccfbdd 100644 --- a/src/main/java/page/clab/api/domain/auth/login/adapter/out/persistence/AuthenticatorRepository.java +++ b/src/main/java/page/clab/api/domain/auth/login/adapter/out/persistence/AuthenticatorRepository.java @@ -5,4 +5,5 @@ @Repository public interface AuthenticatorRepository extends JpaRepository { + } diff --git a/src/main/java/page/clab/api/domain/auth/login/adapter/out/persistence/RedisTokenPersistenceAdapter.java b/src/main/java/page/clab/api/domain/auth/login/adapter/out/persistence/RedisTokenPersistenceAdapter.java index 18e6540cd..551bf7e42 100644 --- a/src/main/java/page/clab/api/domain/auth/login/adapter/out/persistence/RedisTokenPersistenceAdapter.java +++ b/src/main/java/page/clab/api/domain/auth/login/adapter/out/persistence/RedisTokenPersistenceAdapter.java @@ -1,5 +1,7 @@ package page.clab.api.domain.auth.login.adapter.out.persistence; +import java.util.List; +import java.util.Optional; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; import page.clab.api.domain.auth.login.application.port.out.RegisterRedisTokenPort; @@ -7,15 +9,12 @@ import page.clab.api.domain.auth.login.application.port.out.RetrieveRedisTokenPort; import page.clab.api.domain.auth.login.domain.RedisToken; -import java.util.List; -import java.util.Optional; - @Component @RequiredArgsConstructor public class RedisTokenPersistenceAdapter implements - RegisterRedisTokenPort, - RetrieveRedisTokenPort, - RemoveRedisTokenPort { + RegisterRedisTokenPort, + RetrieveRedisTokenPort, + RemoveRedisTokenPort { private final RedisTokenRepository redisTokenRepository; diff --git a/src/main/java/page/clab/api/domain/auth/login/adapter/out/persistence/RedisTokenRepository.java b/src/main/java/page/clab/api/domain/auth/login/adapter/out/persistence/RedisTokenRepository.java index c4b01a6ec..d3200775d 100644 --- a/src/main/java/page/clab/api/domain/auth/login/adapter/out/persistence/RedisTokenRepository.java +++ b/src/main/java/page/clab/api/domain/auth/login/adapter/out/persistence/RedisTokenRepository.java @@ -1,11 +1,10 @@ package page.clab.api.domain.auth.login.adapter.out.persistence; +import java.util.Optional; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; import page.clab.api.domain.auth.login.domain.RedisToken; -import java.util.Optional; - @Repository public interface RedisTokenRepository extends CrudRepository { diff --git a/src/main/java/page/clab/api/domain/auth/login/application/dto/response/TokenInfo.java b/src/main/java/page/clab/api/domain/auth/login/application/dto/response/TokenInfo.java index e2742e5a0..e9ce5b44a 100644 --- a/src/main/java/page/clab/api/domain/auth/login/application/dto/response/TokenInfo.java +++ b/src/main/java/page/clab/api/domain/auth/login/application/dto/response/TokenInfo.java @@ -15,8 +15,8 @@ public class TokenInfo { public static TokenInfo create(String accessToken, String refreshToken) { return TokenInfo.builder() - .accessToken(accessToken) - .refreshToken(refreshToken) - .build(); + .accessToken(accessToken) + .refreshToken(refreshToken) + .build(); } } diff --git a/src/main/java/page/clab/api/domain/auth/login/application/port/in/ManageLoginUseCase.java b/src/main/java/page/clab/api/domain/auth/login/application/port/in/ManageLoginUseCase.java index 86b562ec4..8b1ae49da 100644 --- a/src/main/java/page/clab/api/domain/auth/login/application/port/in/ManageLoginUseCase.java +++ b/src/main/java/page/clab/api/domain/auth/login/application/port/in/ManageLoginUseCase.java @@ -1,6 +1,7 @@ package page.clab.api.domain.auth.login.application.port.in; import jakarta.servlet.http.HttpServletRequest; +import java.util.List; import page.clab.api.domain.auth.login.application.dto.request.LoginRequestDto; import page.clab.api.domain.auth.login.application.dto.request.TwoFactorAuthenticationRequestDto; import page.clab.api.domain.auth.login.application.dto.response.LoginResult; @@ -8,13 +9,13 @@ import page.clab.api.domain.auth.login.application.exception.LoginFailedException; import page.clab.api.domain.auth.login.application.exception.MemberLockedException; -import java.util.List; - public interface ManageLoginUseCase { - LoginResult login(HttpServletRequest request, LoginRequestDto requestDto) throws LoginFailedException, MemberLockedException; + LoginResult login(HttpServletRequest request, LoginRequestDto requestDto) + throws LoginFailedException, MemberLockedException; - LoginResult authenticate(HttpServletRequest request, TwoFactorAuthenticationRequestDto requestDto) throws LoginFailedException, MemberLockedException; + LoginResult authenticate(HttpServletRequest request, TwoFactorAuthenticationRequestDto requestDto) + throws LoginFailedException, MemberLockedException; String resetAuthenticator(String memberId); diff --git a/src/main/java/page/clab/api/domain/auth/login/application/port/in/ManageRedisTokenUseCase.java b/src/main/java/page/clab/api/domain/auth/login/application/port/in/ManageRedisTokenUseCase.java index 4e008c8aa..1bea743d7 100644 --- a/src/main/java/page/clab/api/domain/auth/login/application/port/in/ManageRedisTokenUseCase.java +++ b/src/main/java/page/clab/api/domain/auth/login/application/port/in/ManageRedisTokenUseCase.java @@ -1,11 +1,10 @@ package page.clab.api.domain.auth.login.application.port.in; +import java.util.List; import page.clab.api.domain.auth.login.application.dto.response.TokenInfo; import page.clab.api.domain.auth.login.domain.RedisToken; import page.clab.api.domain.memberManagement.member.domain.Role; -import java.util.List; - public interface ManageRedisTokenUseCase { RedisToken findByAccessToken(String accessToken); diff --git a/src/main/java/page/clab/api/domain/auth/login/application/port/out/RegisterAuthenticatorPort.java b/src/main/java/page/clab/api/domain/auth/login/application/port/out/RegisterAuthenticatorPort.java index 0520da10c..e4ce921c6 100644 --- a/src/main/java/page/clab/api/domain/auth/login/application/port/out/RegisterAuthenticatorPort.java +++ b/src/main/java/page/clab/api/domain/auth/login/application/port/out/RegisterAuthenticatorPort.java @@ -3,5 +3,6 @@ import page.clab.api.domain.auth.login.domain.Authenticator; public interface RegisterAuthenticatorPort { + Authenticator save(Authenticator authenticator); } diff --git a/src/main/java/page/clab/api/domain/auth/login/application/port/out/RegisterRedisTokenPort.java b/src/main/java/page/clab/api/domain/auth/login/application/port/out/RegisterRedisTokenPort.java index 7ebefd085..4aed8d8dc 100644 --- a/src/main/java/page/clab/api/domain/auth/login/application/port/out/RegisterRedisTokenPort.java +++ b/src/main/java/page/clab/api/domain/auth/login/application/port/out/RegisterRedisTokenPort.java @@ -3,5 +3,6 @@ import page.clab.api.domain.auth.login.domain.RedisToken; public interface RegisterRedisTokenPort { + RedisToken save(RedisToken redisToken); } diff --git a/src/main/java/page/clab/api/domain/auth/login/application/port/out/RemoveAuthenticatorPort.java b/src/main/java/page/clab/api/domain/auth/login/application/port/out/RemoveAuthenticatorPort.java index 688a36979..f193e8453 100644 --- a/src/main/java/page/clab/api/domain/auth/login/application/port/out/RemoveAuthenticatorPort.java +++ b/src/main/java/page/clab/api/domain/auth/login/application/port/out/RemoveAuthenticatorPort.java @@ -3,5 +3,6 @@ import page.clab.api.domain.auth.login.domain.Authenticator; public interface RemoveAuthenticatorPort { + void delete(Authenticator authenticator); } diff --git a/src/main/java/page/clab/api/domain/auth/login/application/port/out/RetrieveAuthenticatorPort.java b/src/main/java/page/clab/api/domain/auth/login/application/port/out/RetrieveAuthenticatorPort.java index 988e37d88..57a662255 100644 --- a/src/main/java/page/clab/api/domain/auth/login/application/port/out/RetrieveAuthenticatorPort.java +++ b/src/main/java/page/clab/api/domain/auth/login/application/port/out/RetrieveAuthenticatorPort.java @@ -1,8 +1,7 @@ package page.clab.api.domain.auth.login.application.port.out; -import page.clab.api.domain.auth.login.domain.Authenticator; - import java.util.Optional; +import page.clab.api.domain.auth.login.domain.Authenticator; public interface RetrieveAuthenticatorPort { diff --git a/src/main/java/page/clab/api/domain/auth/login/application/port/out/RetrieveRedisTokenPort.java b/src/main/java/page/clab/api/domain/auth/login/application/port/out/RetrieveRedisTokenPort.java index cf83c4192..fdd7d36e9 100644 --- a/src/main/java/page/clab/api/domain/auth/login/application/port/out/RetrieveRedisTokenPort.java +++ b/src/main/java/page/clab/api/domain/auth/login/application/port/out/RetrieveRedisTokenPort.java @@ -1,9 +1,8 @@ package page.clab.api.domain.auth.login.application.port.out; -import page.clab.api.domain.auth.login.domain.RedisToken; - import java.util.List; import java.util.Optional; +import page.clab.api.domain.auth.login.domain.RedisToken; public interface RetrieveRedisTokenPort { diff --git a/src/main/java/page/clab/api/domain/auth/login/application/service/RedisTokenManagementService.java b/src/main/java/page/clab/api/domain/auth/login/application/service/RedisTokenManagementService.java index 7aeab8c8d..c188dd054 100644 --- a/src/main/java/page/clab/api/domain/auth/login/application/service/RedisTokenManagementService.java +++ b/src/main/java/page/clab/api/domain/auth/login/application/service/RedisTokenManagementService.java @@ -1,5 +1,9 @@ package page.clab.api.domain.auth.login.application.service; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; +import java.util.stream.StreamSupport; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import page.clab.api.domain.auth.login.application.dto.response.TokenInfo; @@ -12,11 +16,6 @@ import page.clab.api.global.auth.exception.TokenNotFoundException; import page.clab.api.global.auth.jwt.JwtTokenProvider; -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; -import java.util.stream.StreamSupport; - @Service @RequiredArgsConstructor public class RedisTokenManagementService implements ManageRedisTokenUseCase { @@ -28,22 +27,22 @@ public class RedisTokenManagementService implements ManageRedisTokenUseCase { public RedisToken findByAccessToken(String accessToken) { return retrieveRedisTokenPort.findByAccessToken(accessToken) - .orElseThrow(() -> new TokenNotFoundException("존재하지 않는 토큰입니다.")); + .orElseThrow(() -> new TokenNotFoundException("존재하지 않는 토큰입니다.")); } public RedisToken findByRefreshToken(String refreshToken) { return retrieveRedisTokenPort.findByRefreshToken(refreshToken) - .orElseThrow(() -> new TokenNotFoundException("존재하지 않는 토큰입니다.")); + .orElseThrow(() -> new TokenNotFoundException("존재하지 않는 토큰입니다.")); } public List getCurrentLoggedInUsers() { Iterable iterableTokens = retrieveRedisTokenPort.findAll(); return StreamSupport.stream(iterableTokens.spliterator(), false) - .filter(Objects::nonNull) - .filter(redisToken -> jwtTokenProvider.validateTokenSilently(redisToken.getAccessToken())) - .map(RedisToken::getMemberId) - .distinct() - .collect(Collectors.toList()); + .filter(Objects::nonNull) + .filter(redisToken -> jwtTokenProvider.validateTokenSilently(redisToken.getAccessToken())) + .map(RedisToken::getMemberId) + .distinct() + .collect(Collectors.toList()); } public void saveToken(String memberId, Role role, TokenInfo tokenInfo, String ip) { @@ -53,6 +52,6 @@ public void saveToken(String memberId, Role role, TokenInfo tokenInfo, String ip public void deleteByAccessToken(String accessToken) { retrieveRedisTokenPort.findByAccessToken(accessToken) - .ifPresent(removeRedisTokenPort::delete); + .ifPresent(removeRedisTokenPort::delete); } } diff --git a/src/main/java/page/clab/api/domain/auth/login/application/service/TokenManagementService.java b/src/main/java/page/clab/api/domain/auth/login/application/service/TokenManagementService.java index 631378efc..a8d57caa0 100644 --- a/src/main/java/page/clab/api/domain/auth/login/application/service/TokenManagementService.java +++ b/src/main/java/page/clab/api/domain/auth/login/application/service/TokenManagementService.java @@ -1,6 +1,7 @@ package page.clab.api.domain.auth.login.application.service; import jakarta.servlet.http.HttpServletRequest; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.security.core.Authentication; @@ -22,8 +23,6 @@ import page.clab.api.global.auth.jwt.JwtTokenProvider; import page.clab.api.global.util.HttpReqResUtil; -import java.util.List; - @Service @RequiredArgsConstructor @Qualifier("tokenManagementService") @@ -44,7 +43,8 @@ public TokenHeader reissueToken(HttpServletRequest request) { validateToken(redisToken); TokenInfo newTokenInfo = jwtTokenProvider.generateToken(redisToken.getMemberId(), redisToken.getRole()); - manageRedisTokenUseCase.saveToken(redisToken.getMemberId(), redisToken.getRole(), newTokenInfo, redisToken.getIp()); + manageRedisTokenUseCase.saveToken(redisToken.getMemberId(), redisToken.getRole(), newTokenInfo, + redisToken.getIp()); return TokenHeader.create(newTokenInfo); } @@ -74,12 +74,14 @@ private void validateToken(RedisToken redisToken) { } @Override - public LoginResult login(HttpServletRequest request, LoginRequestDto requestDto) throws LoginFailedException, MemberLockedException { + public LoginResult login(HttpServletRequest request, LoginRequestDto requestDto) + throws LoginFailedException, MemberLockedException { throw new UnsupportedOperationException("Method not implemented"); } @Override - public LoginResult authenticate(HttpServletRequest request, TwoFactorAuthenticationRequestDto requestDto) throws LoginFailedException, MemberLockedException { + public LoginResult authenticate(HttpServletRequest request, TwoFactorAuthenticationRequestDto requestDto) + throws LoginFailedException, MemberLockedException { throw new UnsupportedOperationException("Method not implemented"); } diff --git a/src/main/java/page/clab/api/domain/auth/login/application/service/TwoFactorAuthenticationService.java b/src/main/java/page/clab/api/domain/auth/login/application/service/TwoFactorAuthenticationService.java index 402cf4ee7..35df7605e 100644 --- a/src/main/java/page/clab/api/domain/auth/login/application/service/TwoFactorAuthenticationService.java +++ b/src/main/java/page/clab/api/domain/auth/login/application/service/TwoFactorAuthenticationService.java @@ -43,8 +43,8 @@ public class TwoFactorAuthenticationService implements ManageLoginUseCase { @Transactional @Override public LoginResult authenticate(HttpServletRequest request, - TwoFactorAuthenticationRequestDto twoFactorAuthenticationRequestDto) - throws LoginFailedException, MemberLockedException { + TwoFactorAuthenticationRequestDto twoFactorAuthenticationRequestDto) + throws LoginFailedException, MemberLockedException { String memberId = twoFactorAuthenticationRequestDto.getMemberId(); MemberLoginInfoDto loginMember = externalRetrieveMemberUseCase.getMemberLoginInfoById(memberId); String totp = twoFactorAuthenticationRequestDto.getTotp(); @@ -59,10 +59,10 @@ public LoginResult authenticate(HttpServletRequest request, } private void verifyTwoFactorAuthentication(String memberId, String totp, HttpServletRequest request) - throws MemberLockedException, LoginFailedException { + throws MemberLockedException, LoginFailedException { if (!manageAuthenticatorUseCase.isAuthenticatorValid(memberId, totp)) { externalRegisterAccountAccessLogUseCase.registerAccountAccessLog(request, memberId, - AccountAccessResult.FAILURE); + AccountAccessResult.FAILURE); externalManageAccountLockUseCase.handleLoginFailure(request, memberId); throw new LoginFailedException("잘못된 인증번호입니다."); } @@ -73,20 +73,20 @@ private TokenInfo generateAndSaveToken(MemberLoginInfoDto memberInfo) { TokenInfo tokenInfo = jwtTokenProvider.generateToken(memberInfo.getMemberId(), memberInfo.getRole()); String clientIpAddress = HttpReqResUtil.getClientIpAddressIfServletRequestExist(); externalManageRedisTokenUseCase.saveToken(memberInfo.getMemberId(), memberInfo.getRole(), tokenInfo, - clientIpAddress); + clientIpAddress); return tokenInfo; } private void sendAdminLoginNotification(HttpServletRequest request, MemberLoginInfoDto loginMember) { if (loginMember.isSuperAdminRole()) { eventPublisher.publishEvent( - new NotificationEvent(this, GeneralAlertType.ADMIN_LOGIN, request, loginMember)); + new NotificationEvent(this, GeneralAlertType.ADMIN_LOGIN, request, loginMember)); } } @Override public LoginResult login(HttpServletRequest request, LoginRequestDto requestDto) - throws LoginFailedException, MemberLockedException { + throws LoginFailedException, MemberLockedException { throw new UnsupportedOperationException("Method not implemented"); } diff --git a/src/main/java/page/clab/api/domain/auth/login/application/service/UserLoginService.java b/src/main/java/page/clab/api/domain/auth/login/application/service/UserLoginService.java index 5358b85ee..53c1d597c 100644 --- a/src/main/java/page/clab/api/domain/auth/login/application/service/UserLoginService.java +++ b/src/main/java/page/clab/api/domain/auth/login/application/service/UserLoginService.java @@ -1,6 +1,8 @@ package page.clab.api.domain.auth.login.application.service; import jakarta.servlet.http.HttpServletRequest; +import java.util.List; +import java.util.Optional; import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.security.authentication.AuthenticationManager; @@ -28,9 +30,6 @@ import page.clab.api.global.auth.jwt.JwtTokenProvider; import page.clab.api.global.util.HttpReqResUtil; -import java.util.List; -import java.util.Optional; - @Service @RequiredArgsConstructor @Qualifier("userLoginService") @@ -49,7 +48,8 @@ public class UserLoginService implements ManageLoginUseCase { @Transactional @Override - public LoginResult login(HttpServletRequest request, LoginRequestDto requestDto) throws LoginFailedException, MemberLockedException { + public LoginResult login(HttpServletRequest request, LoginRequestDto requestDto) + throws LoginFailedException, MemberLockedException { authenticateAndCheckStatus(request, requestDto); registerAccountAccessLog(request, requestDto.getId(), true); MemberLoginInfoDto loginMember = externalRetrieveMemberUseCase.getMemberLoginInfoById(requestDto.getId()); @@ -61,15 +61,17 @@ public LoginResult login(HttpServletRequest request, LoginRequestDto requestDto) @Override public LoginResult guestLogin(HttpServletRequest request) { MemberLoginInfoDto guestMember = externalRetrieveMemberUseCase.getGuestMemberLoginInfo(); - registerAccountAccessLogUseCase.registerAccountAccessLog(request, guestMember.getMemberId(), AccountAccessResult.SUCCESS); + registerAccountAccessLogUseCase.registerAccountAccessLog(request, guestMember.getMemberId(), + AccountAccessResult.SUCCESS); externalUpdateMemberUseCase.updateLastLoginTime(guestMember.getMemberId()); return generateLoginResult(guestMember); } - private void authenticateAndCheckStatus(HttpServletRequest httpServletRequest, LoginRequestDto loginRequestDto) throws LoginFailedException, MemberLockedException { + private void authenticateAndCheckStatus(HttpServletRequest httpServletRequest, LoginRequestDto loginRequestDto) + throws LoginFailedException, MemberLockedException { try { UsernamePasswordAuthenticationToken authenticationToken = - new UsernamePasswordAuthenticationToken(loginRequestDto.getId(), loginRequestDto.getPassword()); + new UsernamePasswordAuthenticationToken(loginRequestDto.getId(), loginRequestDto.getPassword()); loginAuthenticationManager.authenticate(authenticationToken); externalManageAccountLockUseCase.handleAccountLockInfo(loginRequestDto.getId()); } catch (BadCredentialsException e) { diff --git a/src/main/java/page/clab/api/domain/auth/login/domain/Authenticator.java b/src/main/java/page/clab/api/domain/auth/login/domain/Authenticator.java index 4e348e9d8..c867cf91c 100644 --- a/src/main/java/page/clab/api/domain/auth/login/domain/Authenticator.java +++ b/src/main/java/page/clab/api/domain/auth/login/domain/Authenticator.java @@ -17,8 +17,8 @@ public class Authenticator { public static Authenticator create(String memberId, String secretKey) { return Authenticator.builder() - .memberId(memberId) - .secretKey(secretKey) - .build(); + .memberId(memberId) + .secretKey(secretKey) + .build(); } } diff --git a/src/main/java/page/clab/api/domain/auth/login/domain/RedisToken.java b/src/main/java/page/clab/api/domain/auth/login/domain/RedisToken.java index 1c71e502a..dfc3aeb74 100644 --- a/src/main/java/page/clab/api/domain/auth/login/domain/RedisToken.java +++ b/src/main/java/page/clab/api/domain/auth/login/domain/RedisToken.java @@ -1,6 +1,7 @@ package page.clab.api.domain.auth.login.domain; import jakarta.persistence.Id; +import java.util.UUID; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -12,8 +13,6 @@ import page.clab.api.domain.auth.login.application.dto.response.TokenInfo; import page.clab.api.domain.memberManagement.member.domain.Role; -import java.util.UUID; - @Getter @Setter @Builder @@ -36,13 +35,13 @@ public class RedisToken { public static RedisToken create(String memberId, Role role, String ip, TokenInfo tokenInfo) { return RedisToken.builder() - .id(UUID.randomUUID()) - .memberId(memberId) - .role(role) - .ip(ip) - .accessToken(tokenInfo.getAccessToken()) - .refreshToken(tokenInfo.getRefreshToken()) - .build(); + .id(UUID.randomUUID()) + .memberId(memberId) + .role(role) + .ip(ip) + .accessToken(tokenInfo.getAccessToken()) + .refreshToken(tokenInfo.getRefreshToken()) + .build(); } public boolean isSameIp(String ip) { diff --git a/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/adapter/in/web/AbnormalAccessIpRemoveController.java b/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/adapter/in/web/AbnormalAccessIpRemoveController.java index 9759991e7..5b550c3a2 100644 --- a/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/adapter/in/web/AbnormalAccessIpRemoveController.java +++ b/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/adapter/in/web/AbnormalAccessIpRemoveController.java @@ -21,12 +21,12 @@ public class AbnormalAccessIpRemoveController { private final RemoveAbnormalAccessIpUseCase removeAbnormalAccessIpUseCase; @Operation(summary = "[S] 비정상 접근 IP 기록 삭제", description = "ROLE_SUPER 이상의 권한이 필요함
" + - "지속적인 비정상 접근으로 인해 차단된 IP를 삭제") + "지속적인 비정상 접근으로 인해 차단된 IP를 삭제") @PreAuthorize("hasRole('SUPER')") @DeleteMapping("/abnormal-access") public ApiResponse removeAbnormalAccessBlacklistIp( - HttpServletRequest request, - @RequestParam(name = "ipAddress") String ipAddress + HttpServletRequest request, + @RequestParam(name = "ipAddress") String ipAddress ) { String deletedIp = removeAbnormalAccessIpUseCase.removeAbnormalAccessIp(request, ipAddress); return ApiResponse.success(deletedIp); diff --git a/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/adapter/in/web/AbnormalAccessIpsClearController.java b/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/adapter/in/web/AbnormalAccessIpsClearController.java index ea7e8dd77..815d6123f 100644 --- a/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/adapter/in/web/AbnormalAccessIpsClearController.java +++ b/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/adapter/in/web/AbnormalAccessIpsClearController.java @@ -3,6 +3,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.servlet.http.HttpServletRequest; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.DeleteMapping; @@ -12,8 +13,6 @@ import page.clab.api.domain.auth.redisIpAccessMonitor.domain.RedisIpAccessMonitor; import page.clab.api.global.common.dto.ApiResponse; -import java.util.List; - @RestController @RequestMapping("/api/v1/ip-access-monitor") @RequiredArgsConstructor @@ -23,11 +22,11 @@ public class AbnormalAccessIpsClearController { private final ClearAbnormalAccessIpsUseCase clearAbnormalAccessIpsUseCase; @Operation(summary = "[S] 비정상 접근 IP 기록 초기화", description = "ROLE_SUPER 이상의 권한이 필요함
" + - "지속적인 비정상 접근으로 인해 차단된 IP를 모두 삭제") + "지속적인 비정상 접근으로 인해 차단된 IP를 모두 삭제") @PreAuthorize("hasRole('SUPER')") @DeleteMapping("/abnormal-access/clear") public ApiResponse> clearAbnormalAccessBlacklist( - HttpServletRequest request + HttpServletRequest request ) { List ipAccessMonitors = clearAbnormalAccessIpsUseCase.clearAbnormalAccessIps(request); return ApiResponse.success(ipAccessMonitors); diff --git a/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/adapter/in/web/AbnormalAccessIpsRetrieveController.java b/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/adapter/in/web/AbnormalAccessIpsRetrieveController.java index 2cf1b453f..702e75667 100644 --- a/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/adapter/in/web/AbnormalAccessIpsRetrieveController.java +++ b/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/adapter/in/web/AbnormalAccessIpsRetrieveController.java @@ -24,15 +24,16 @@ public class AbnormalAccessIpsRetrieveController { private final RetrieveAbnormalAccessIpsUseCase retrieveAbnormalAccessIpsUseCase; @Operation(summary = "[S] 비정상 접근으로 인한 차단 IP 목록 조회", description = "ROLE_SUPER 이상의 권한이 필요함
" + - "지속적인 비정상 접근으로 인해 Redis에 추가된 IP를 조회") + "지속적인 비정상 접근으로 인해 Redis에 추가된 IP를 조회") @PreAuthorize("hasRole('SUPER')") @GetMapping("/abnormal-access") public ApiResponse> retrieveAbnormalAccessBlacklistIps( - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size ) { Pageable pageable = PageRequest.of(page, size); - PagedResponseDto abnormalAccessBlacklistIps = retrieveAbnormalAccessIpsUseCase.retrieveAbnormalAccessIps(pageable); + PagedResponseDto abnormalAccessBlacklistIps = retrieveAbnormalAccessIpsUseCase.retrieveAbnormalAccessIps( + pageable); return ApiResponse.success(abnormalAccessBlacklistIps); } } diff --git a/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/adapter/out/persistence/RedisIpAccessMonitorAdapter.java b/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/adapter/out/persistence/RedisIpAccessMonitorAdapter.java index 9b9222008..caeef134b 100644 --- a/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/adapter/out/persistence/RedisIpAccessMonitorAdapter.java +++ b/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/adapter/out/persistence/RedisIpAccessMonitorAdapter.java @@ -1,5 +1,8 @@ package page.clab.api.domain.auth.redisIpAccessMonitor.adapter.out.persistence; +import java.util.List; +import java.util.Optional; +import java.util.stream.StreamSupport; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; import page.clab.api.domain.auth.redisIpAccessMonitor.application.port.out.ClearIpAccessMonitorPort; @@ -8,17 +11,13 @@ import page.clab.api.domain.auth.redisIpAccessMonitor.application.port.out.RetrieveIpAccessMonitorPort; import page.clab.api.domain.auth.redisIpAccessMonitor.domain.RedisIpAccessMonitor; -import java.util.List; -import java.util.Optional; -import java.util.stream.StreamSupport; - @Component @RequiredArgsConstructor public class RedisIpAccessMonitorAdapter implements - RegisterIpAccessMonitorPort, - RetrieveIpAccessMonitorPort, - RemoveIpAccessMonitorPort, - ClearIpAccessMonitorPort { + RegisterIpAccessMonitorPort, + RetrieveIpAccessMonitorPort, + RemoveIpAccessMonitorPort, + ClearIpAccessMonitorPort { private final RedisIpAccessMonitorRepository repository; @@ -30,7 +29,7 @@ public Optional findById(String ipAddress) { @Override public void deleteById(String ipAddress) { repository.findById(ipAddress) - .ifPresent(repository::delete); + .ifPresent(repository::delete); } @Override @@ -40,8 +39,8 @@ public void deleteAll() { public List findAll() { return StreamSupport - .stream(repository.findAll().spliterator(), false) - .toList(); + .stream(repository.findAll().spliterator(), false) + .toList(); } @Override diff --git a/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/adapter/out/persistence/RedisIpAccessMonitorRepository.java b/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/adapter/out/persistence/RedisIpAccessMonitorRepository.java index f9652abf7..0bd8172dc 100644 --- a/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/adapter/out/persistence/RedisIpAccessMonitorRepository.java +++ b/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/adapter/out/persistence/RedisIpAccessMonitorRepository.java @@ -6,4 +6,5 @@ @Repository public interface RedisIpAccessMonitorRepository extends CrudRepository { + } diff --git a/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/application/port/in/ClearAbnormalAccessIpsUseCase.java b/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/application/port/in/ClearAbnormalAccessIpsUseCase.java index 9caa1407c..c4dc825a6 100644 --- a/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/application/port/in/ClearAbnormalAccessIpsUseCase.java +++ b/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/application/port/in/ClearAbnormalAccessIpsUseCase.java @@ -1,10 +1,10 @@ package page.clab.api.domain.auth.redisIpAccessMonitor.application.port.in; import jakarta.servlet.http.HttpServletRequest; -import page.clab.api.domain.auth.redisIpAccessMonitor.domain.RedisIpAccessMonitor; - import java.util.List; +import page.clab.api.domain.auth.redisIpAccessMonitor.domain.RedisIpAccessMonitor; public interface ClearAbnormalAccessIpsUseCase { + List clearAbnormalAccessIps(HttpServletRequest request); } diff --git a/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/application/port/in/RemoveAbnormalAccessIpUseCase.java b/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/application/port/in/RemoveAbnormalAccessIpUseCase.java index f0ac753d4..ed7ad12f0 100644 --- a/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/application/port/in/RemoveAbnormalAccessIpUseCase.java +++ b/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/application/port/in/RemoveAbnormalAccessIpUseCase.java @@ -3,5 +3,6 @@ import jakarta.servlet.http.HttpServletRequest; public interface RemoveAbnormalAccessIpUseCase { + String removeAbnormalAccessIp(HttpServletRequest request, String ipAddress); } diff --git a/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/application/port/in/RetrieveAbnormalAccessIpsUseCase.java b/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/application/port/in/RetrieveAbnormalAccessIpsUseCase.java index a5a9f5e6a..c2201d6ea 100644 --- a/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/application/port/in/RetrieveAbnormalAccessIpsUseCase.java +++ b/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/application/port/in/RetrieveAbnormalAccessIpsUseCase.java @@ -5,5 +5,6 @@ import page.clab.api.global.common.dto.PagedResponseDto; public interface RetrieveAbnormalAccessIpsUseCase { + PagedResponseDto retrieveAbnormalAccessIps(Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/application/port/out/ClearIpAccessMonitorPort.java b/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/application/port/out/ClearIpAccessMonitorPort.java index a0397a9a9..f51b5bafd 100644 --- a/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/application/port/out/ClearIpAccessMonitorPort.java +++ b/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/application/port/out/ClearIpAccessMonitorPort.java @@ -1,5 +1,6 @@ package page.clab.api.domain.auth.redisIpAccessMonitor.application.port.out; public interface ClearIpAccessMonitorPort { + void deleteAll(); } diff --git a/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/application/port/out/RegisterIpAccessMonitorPort.java b/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/application/port/out/RegisterIpAccessMonitorPort.java index cff2bdb3d..13721f3c5 100644 --- a/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/application/port/out/RegisterIpAccessMonitorPort.java +++ b/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/application/port/out/RegisterIpAccessMonitorPort.java @@ -3,5 +3,6 @@ import page.clab.api.domain.auth.redisIpAccessMonitor.domain.RedisIpAccessMonitor; public interface RegisterIpAccessMonitorPort { + void save(RedisIpAccessMonitor redisIpAccessMonitor); } diff --git a/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/application/port/out/RemoveIpAccessMonitorPort.java b/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/application/port/out/RemoveIpAccessMonitorPort.java index 226fa293f..b960f80c4 100644 --- a/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/application/port/out/RemoveIpAccessMonitorPort.java +++ b/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/application/port/out/RemoveIpAccessMonitorPort.java @@ -1,5 +1,6 @@ package page.clab.api.domain.auth.redisIpAccessMonitor.application.port.out; public interface RemoveIpAccessMonitorPort { + void deleteById(String ipAddress); } diff --git a/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/application/port/out/RetrieveIpAccessMonitorPort.java b/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/application/port/out/RetrieveIpAccessMonitorPort.java index 877213369..f2a54347a 100644 --- a/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/application/port/out/RetrieveIpAccessMonitorPort.java +++ b/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/application/port/out/RetrieveIpAccessMonitorPort.java @@ -1,9 +1,8 @@ package page.clab.api.domain.auth.redisIpAccessMonitor.application.port.out; -import page.clab.api.domain.auth.redisIpAccessMonitor.domain.RedisIpAccessMonitor; - import java.util.List; import java.util.Optional; +import page.clab.api.domain.auth.redisIpAccessMonitor.domain.RedisIpAccessMonitor; public interface RetrieveIpAccessMonitorPort { diff --git a/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/application/service/AbnormalAccessIpRemoveService.java b/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/application/service/AbnormalAccessIpRemoveService.java index a31e7ee8a..37ef0d425 100644 --- a/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/application/service/AbnormalAccessIpRemoveService.java +++ b/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/application/service/AbnormalAccessIpRemoveService.java @@ -23,8 +23,8 @@ public String removeAbnormalAccessIp(HttpServletRequest request, String ipAddres removeIpAccessMonitorPort.deleteById(ipAddress); String abnormalAccessIpDeletedMessage = "Deleted IP: " + ipAddress; eventPublisher.publishEvent( - new NotificationEvent(this, SecurityAlertType.ABNORMAL_ACCESS_IP_DELETED, request, - abnormalAccessIpDeletedMessage)); + new NotificationEvent(this, SecurityAlertType.ABNORMAL_ACCESS_IP_DELETED, request, + abnormalAccessIpDeletedMessage)); return ipAddress; } } diff --git a/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/application/service/AbnormalAccessIpsClearService.java b/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/application/service/AbnormalAccessIpsClearService.java index f347f2644..84e3877b3 100644 --- a/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/application/service/AbnormalAccessIpsClearService.java +++ b/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/application/service/AbnormalAccessIpsClearService.java @@ -29,8 +29,8 @@ public List clearAbnormalAccessIps(HttpServletRequest requ String abnormalAccessIpClearedMessage = "Deleted IP: ALL"; eventPublisher.publishEvent( - new NotificationEvent(this, SecurityAlertType.ABNORMAL_ACCESS_IP_DELETED, request, - abnormalAccessIpClearedMessage)); + new NotificationEvent(this, SecurityAlertType.ABNORMAL_ACCESS_IP_DELETED, request, + abnormalAccessIpClearedMessage)); return ipAccessMonitors; } diff --git a/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/application/service/AbnormalAccessIpsRetrieveService.java b/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/application/service/AbnormalAccessIpsRetrieveService.java index 923e354cc..5f4a32416 100644 --- a/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/application/service/AbnormalAccessIpsRetrieveService.java +++ b/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/application/service/AbnormalAccessIpsRetrieveService.java @@ -1,5 +1,8 @@ package page.clab.api.domain.auth.redisIpAccessMonitor.application.service; +import java.util.Comparator; +import java.util.List; +import java.util.Objects; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; @@ -9,10 +12,6 @@ import page.clab.api.domain.auth.redisIpAccessMonitor.domain.RedisIpAccessMonitor; import page.clab.api.global.common.dto.PagedResponseDto; -import java.util.Comparator; -import java.util.List; -import java.util.Objects; - @Service @RequiredArgsConstructor public class AbnormalAccessIpsRetrieveService implements RetrieveAbnormalAccessIpsUseCase { @@ -24,10 +23,10 @@ public class AbnormalAccessIpsRetrieveService implements RetrieveAbnormalAccessI public PagedResponseDto retrieveAbnormalAccessIps(Pageable pageable) { List allMonitors = retrieveIpAccessMonitorPort.findAll(); List filteredMonitors = allMonitors.stream() - .filter(Objects::nonNull) - .filter(RedisIpAccessMonitor::isBlocked) - .sorted(Comparator.comparing(RedisIpAccessMonitor::getLastAttempt).reversed()) - .toList(); + .filter(Objects::nonNull) + .filter(RedisIpAccessMonitor::isBlocked) + .sorted(Comparator.comparing(RedisIpAccessMonitor::getLastAttempt).reversed()) + .toList(); return new PagedResponseDto<>(filteredMonitors, pageable, filteredMonitors.size()); } } diff --git a/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/domain/RedisIpAccessMonitor.java b/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/domain/RedisIpAccessMonitor.java index 984c301fa..66f31efb5 100644 --- a/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/domain/RedisIpAccessMonitor.java +++ b/src/main/java/page/clab/api/domain/auth/redisIpAccessMonitor/domain/RedisIpAccessMonitor.java @@ -1,6 +1,7 @@ package page.clab.api.domain.auth.redisIpAccessMonitor.domain; import jakarta.persistence.Column; +import java.time.LocalDateTime; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -11,8 +12,6 @@ import org.springframework.data.redis.core.RedisHash; import org.springframework.data.redis.core.index.Indexed; -import java.time.LocalDateTime; - @Getter @Setter @Builder diff --git a/src/main/java/page/clab/api/domain/community/accuse/adapter/in/web/AccusationReportController.java b/src/main/java/page/clab/api/domain/community/accuse/adapter/in/web/AccusationReportController.java index 256716c3b..d780d5860 100644 --- a/src/main/java/page/clab/api/domain/community/accuse/adapter/in/web/AccusationReportController.java +++ b/src/main/java/page/clab/api/domain/community/accuse/adapter/in/web/AccusationReportController.java @@ -25,7 +25,7 @@ public class AccusationReportController { @PreAuthorize("hasRole('USER')") @PostMapping("") public ApiResponse reportIncident( - @Valid @RequestBody AccuseRequestDto requestDto + @Valid @RequestBody AccuseRequestDto requestDto ) { Long id = reportAccusationUsecase.reportAccusation(requestDto); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/community/accuse/adapter/in/web/AccusationRetrievalController.java b/src/main/java/page/clab/api/domain/community/accuse/adapter/in/web/AccusationRetrievalController.java index b453db63f..7087dbea9 100644 --- a/src/main/java/page/clab/api/domain/community/accuse/adapter/in/web/AccusationRetrievalController.java +++ b/src/main/java/page/clab/api/domain/community/accuse/adapter/in/web/AccusationRetrievalController.java @@ -2,6 +2,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.security.access.prepost.PreAuthorize; @@ -19,8 +20,6 @@ import page.clab.api.global.exception.SortingArgumentException; import page.clab.api.global.util.PageableUtils; -import java.util.List; - @RestController @RequestMapping("/api/v1/accusations") @RequiredArgsConstructor @@ -31,23 +30,24 @@ public class AccusationRetrievalController { private final PageableUtils pageableUtils; @Operation(summary = "[A] 신고 내역 조회(신고 대상, 처리 상태 기준)", description = "ROLE_ADMIN 이상의 권한이 필요함
" + - "2개의 파라미터를 자유롭게 조합하여 필터링 가능
" + - "신고 대상, 처리 상태 중 하나라도 입력하지 않으면 전체 조회됨
" + - "누적 횟수 기준으로 정렬할지 여부를 선택할 수 있음
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") + "2개의 파라미터를 자유롭게 조합하여 필터링 가능
" + + "신고 대상, 처리 상태 중 하나라도 입력하지 않으면 전체 조회됨
" + + "누적 횟수 기준으로 정렬할지 여부를 선택할 수 있음
" + + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") @PreAuthorize("hasRole('ADMIN')") @GetMapping("") public ApiResponse> retrieveAccusations( - @RequestParam(name = "targetType", required = false) TargetType type, - @RequestParam(name = "accuseStatus", required = false) AccuseStatus status, - @RequestParam(name = "countOrder", defaultValue = "false") boolean countOrder, - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection + @RequestParam(name = "targetType", required = false) TargetType type, + @RequestParam(name = "accuseStatus", required = false) AccuseStatus status, + @RequestParam(name = "countOrder", defaultValue = "false") boolean countOrder, + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection ) throws SortingArgumentException, InvalidColumnException { Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, AccuseResponseDto.class); - PagedResponseDto accuses = retrieveAccusationUsecase.retrieveAccusations(type, status, countOrder, pageable); + PagedResponseDto accuses = retrieveAccusationUsecase.retrieveAccusations(type, status, + countOrder, pageable); return ApiResponse.success(accuses); } } diff --git a/src/main/java/page/clab/api/domain/community/accuse/adapter/in/web/AccusationStatusController.java b/src/main/java/page/clab/api/domain/community/accuse/adapter/in/web/AccusationStatusController.java index 27decb97e..ed1c28ee9 100644 --- a/src/main/java/page/clab/api/domain/community/accuse/adapter/in/web/AccusationStatusController.java +++ b/src/main/java/page/clab/api/domain/community/accuse/adapter/in/web/AccusationStatusController.java @@ -26,9 +26,9 @@ public class AccusationStatusController { @PreAuthorize("hasRole('ADMIN')") @PatchMapping("/{targetType}/{targetId}") public ApiResponse changeAccusationStatus( - @PathVariable(name = "targetType") TargetType type, - @PathVariable(name = "targetId") Long targetId, - @RequestParam(name = "accuseStatus") AccuseStatus status + @PathVariable(name = "targetType") TargetType type, + @PathVariable(name = "targetId") Long targetId, + @RequestParam(name = "accuseStatus") AccuseStatus status ) { Long id = changeAccusationStatusUsecase.changeAccusationStatus(type, targetId, status); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/community/accuse/adapter/in/web/MyAccusationsController.java b/src/main/java/page/clab/api/domain/community/accuse/adapter/in/web/MyAccusationsController.java index 64dbb295e..03669b75a 100644 --- a/src/main/java/page/clab/api/domain/community/accuse/adapter/in/web/MyAccusationsController.java +++ b/src/main/java/page/clab/api/domain/community/accuse/adapter/in/web/MyAccusationsController.java @@ -2,6 +2,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.security.access.prepost.PreAuthorize; @@ -17,8 +18,6 @@ import page.clab.api.global.exception.SortingArgumentException; import page.clab.api.global.util.PageableUtils; -import java.util.List; - @RestController @RequestMapping("/api/v1/accusations") @RequiredArgsConstructor @@ -29,14 +28,14 @@ public class MyAccusationsController { private final PageableUtils pageableUtils; @Operation(summary = "[G] 나의 신고 내역 조회", description = "ROLE_GUEST 이상의 권한이 필요함
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") @PreAuthorize("hasRole('GUEST')") @GetMapping("/my") public ApiResponse> retrieveMyAccusations( - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection ) throws SortingArgumentException, InvalidColumnException { Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, AccuseMyResponseDto.class); PagedResponseDto accuses = retrieveMyAccusationsUsecase.retrieveMyAccusations(pageable); diff --git a/src/main/java/page/clab/api/domain/community/accuse/adapter/out/persistence/AccuseJpaEntity.java b/src/main/java/page/clab/api/domain/community/accuse/adapter/out/persistence/AccuseJpaEntity.java index 55822887a..a6faca8ca 100644 --- a/src/main/java/page/clab/api/domain/community/accuse/adapter/out/persistence/AccuseJpaEntity.java +++ b/src/main/java/page/clab/api/domain/community/accuse/adapter/out/persistence/AccuseJpaEntity.java @@ -42,8 +42,8 @@ public class AccuseJpaEntity extends BaseEntity { @ManyToOne @JoinColumns({ - @JoinColumn(name = "target_type", nullable = false), - @JoinColumn(name = "target_reference_id", nullable = false) + @JoinColumn(name = "target_type", nullable = false), + @JoinColumn(name = "target_reference_id", nullable = false) }) private AccuseTargetJpaEntity target; diff --git a/src/main/java/page/clab/api/domain/community/accuse/adapter/out/persistence/AccusePersistenceAdapter.java b/src/main/java/page/clab/api/domain/community/accuse/adapter/out/persistence/AccusePersistenceAdapter.java index 57e17ca20..aef9a124e 100644 --- a/src/main/java/page/clab/api/domain/community/accuse/adapter/out/persistence/AccusePersistenceAdapter.java +++ b/src/main/java/page/clab/api/domain/community/accuse/adapter/out/persistence/AccusePersistenceAdapter.java @@ -1,5 +1,7 @@ package page.clab.api.domain.community.accuse.adapter.out.persistence; +import java.util.List; +import java.util.Optional; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -9,14 +11,11 @@ import page.clab.api.domain.community.accuse.domain.Accuse; import page.clab.api.domain.community.accuse.domain.TargetType; -import java.util.List; -import java.util.Optional; - @Component @RequiredArgsConstructor public class AccusePersistenceAdapter implements - RegisterAccusePort, - RetrieveAccusePort { + RegisterAccusePort, + RetrieveAccusePort { private final AccuseRepository accuseRepository; private final AccuseMapper accuseMapper; @@ -31,41 +30,41 @@ public Accuse save(Accuse accuse) { @Override public void saveAll(List accuses) { List entities = accuses.stream() - .map(accuseMapper::toEntity) - .toList(); + .map(accuseMapper::toEntity) + .toList(); accuseRepository.saveAll(entities); } @Override public Optional findByMemberIdAndTarget(String memberId, TargetType targetType, Long targetReferenceId) { return accuseRepository.findByMemberIdAndTarget(memberId, targetType, targetReferenceId) - .map(accuseMapper::toDomain); + .map(accuseMapper::toDomain); } @Override public List findByTargetOrderByCreatedAtDesc(TargetType targetType, Long targetReferenceId) { return accuseRepository.findByTargetOrderByCreatedAtDesc(targetType, targetReferenceId).stream() - .map(accuseMapper::toDomain) - .toList(); + .map(accuseMapper::toDomain) + .toList(); } @Override public List findByTarget(TargetType targetType, Long targetReferenceId) { return accuseRepository.findByTarget(targetType, targetReferenceId).stream() - .map(accuseMapper::toDomain) - .toList(); + .map(accuseMapper::toDomain) + .toList(); } @Override public Page findByMemberId(String memberId, Pageable pageable) { return accuseRepository.findByMemberId(memberId, pageable) - .map(accuseMapper::toDomain); + .map(accuseMapper::toDomain); } @Override public List findByMemberId(String memberId) { return accuseRepository.findByMemberId(memberId).stream() - .map(accuseMapper::toDomain) - .toList(); + .map(accuseMapper::toDomain) + .toList(); } } diff --git a/src/main/java/page/clab/api/domain/community/accuse/adapter/out/persistence/AccuseRepository.java b/src/main/java/page/clab/api/domain/community/accuse/adapter/out/persistence/AccuseRepository.java index ddec89df1..0f46adc77 100644 --- a/src/main/java/page/clab/api/domain/community/accuse/adapter/out/persistence/AccuseRepository.java +++ b/src/main/java/page/clab/api/domain/community/accuse/adapter/out/persistence/AccuseRepository.java @@ -1,5 +1,7 @@ package page.clab.api.domain.community.accuse.adapter.out.persistence; +import java.util.List; +import java.util.Optional; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; @@ -7,9 +9,6 @@ import org.springframework.stereotype.Repository; import page.clab.api.domain.community.accuse.domain.TargetType; -import java.util.List; -import java.util.Optional; - @Repository public interface AccuseRepository extends JpaRepository { diff --git a/src/main/java/page/clab/api/domain/community/accuse/adapter/out/persistence/AccuseTargetId.java b/src/main/java/page/clab/api/domain/community/accuse/adapter/out/persistence/AccuseTargetId.java index acc15cd5d..abd1b1de6 100644 --- a/src/main/java/page/clab/api/domain/community/accuse/adapter/out/persistence/AccuseTargetId.java +++ b/src/main/java/page/clab/api/domain/community/accuse/adapter/out/persistence/AccuseTargetId.java @@ -1,14 +1,13 @@ package page.clab.api.domain.community.accuse.adapter.out.persistence; import jakarta.persistence.Embeddable; +import java.io.Serializable; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import page.clab.api.domain.community.accuse.domain.TargetType; -import java.io.Serializable; - @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor(access = AccessLevel.PRIVATE) @EqualsAndHashCode(onlyExplicitlyIncluded = true) diff --git a/src/main/java/page/clab/api/domain/community/accuse/adapter/out/persistence/AccuseTargetPersistenceAdapter.java b/src/main/java/page/clab/api/domain/community/accuse/adapter/out/persistence/AccuseTargetPersistenceAdapter.java index a31d0c96c..afcb35977 100644 --- a/src/main/java/page/clab/api/domain/community/accuse/adapter/out/persistence/AccuseTargetPersistenceAdapter.java +++ b/src/main/java/page/clab/api/domain/community/accuse/adapter/out/persistence/AccuseTargetPersistenceAdapter.java @@ -1,5 +1,6 @@ package page.clab.api.domain.community.accuse.adapter.out.persistence; +import java.util.Optional; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -11,13 +12,11 @@ import page.clab.api.domain.community.accuse.domain.TargetType; import page.clab.api.global.exception.NotFoundException; -import java.util.Optional; - @Component @RequiredArgsConstructor public class AccuseTargetPersistenceAdapter implements - RegisterAccuseTargetPort, - RetrieveAccuseTargetPort { + RegisterAccuseTargetPort, + RetrieveAccuseTargetPort { private final AccuseTargetRepository accuseTargetRepository; private final AccuseTargetMapper accuseTargetMapper; @@ -32,19 +31,21 @@ public AccuseTarget save(AccuseTarget accuseTarget) { @Override public Optional findById(AccuseTargetId accuseTargetId) { return accuseTargetRepository.findById(accuseTargetId) - .map(accuseTargetMapper::toDomain); + .map(accuseTargetMapper::toDomain); } @Override public AccuseTarget getById(AccuseTargetId accuseTargetId) { return accuseTargetRepository.findById(accuseTargetId) - .map(accuseTargetMapper::toDomain) - .orElseThrow(() -> new NotFoundException("[AccuseTarget] id: " + accuseTargetId + "에 해당하는 신고 대상이 존재하지 않습니다.")); + .map(accuseTargetMapper::toDomain) + .orElseThrow( + () -> new NotFoundException("[AccuseTarget] id: " + accuseTargetId + "에 해당하는 신고 대상이 존재하지 않습니다.")); } @Override - public Page findByConditions(TargetType type, AccuseStatus status, boolean countOrder, Pageable pageable) { + public Page findByConditions(TargetType type, AccuseStatus status, boolean countOrder, + Pageable pageable) { return accuseTargetRepository.findByConditions(type, status, countOrder, pageable) - .map(accuseTargetMapper::toDomain); + .map(accuseTargetMapper::toDomain); } } diff --git a/src/main/java/page/clab/api/domain/community/accuse/adapter/out/persistence/AccuseTargetRepository.java b/src/main/java/page/clab/api/domain/community/accuse/adapter/out/persistence/AccuseTargetRepository.java index 9567cb196..d92662204 100644 --- a/src/main/java/page/clab/api/domain/community/accuse/adapter/out/persistence/AccuseTargetRepository.java +++ b/src/main/java/page/clab/api/domain/community/accuse/adapter/out/persistence/AccuseTargetRepository.java @@ -4,5 +4,6 @@ import org.springframework.data.querydsl.QuerydslPredicateExecutor; public interface AccuseTargetRepository extends JpaRepository, - AccuseTargetRepositoryCustom, QuerydslPredicateExecutor { + AccuseTargetRepositoryCustom, QuerydslPredicateExecutor { + } diff --git a/src/main/java/page/clab/api/domain/community/accuse/adapter/out/persistence/AccuseTargetRepositoryCustom.java b/src/main/java/page/clab/api/domain/community/accuse/adapter/out/persistence/AccuseTargetRepositoryCustom.java index 9d0fb5294..abf5f2421 100644 --- a/src/main/java/page/clab/api/domain/community/accuse/adapter/out/persistence/AccuseTargetRepositoryCustom.java +++ b/src/main/java/page/clab/api/domain/community/accuse/adapter/out/persistence/AccuseTargetRepositoryCustom.java @@ -6,5 +6,7 @@ import page.clab.api.domain.community.accuse.domain.TargetType; public interface AccuseTargetRepositoryCustom { - Page findByConditions(TargetType type, AccuseStatus status, boolean countOrder, Pageable pageable); + + Page findByConditions(TargetType type, AccuseStatus status, boolean countOrder, + Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/community/accuse/adapter/out/persistence/AccuseTargetRepositoryImpl.java b/src/main/java/page/clab/api/domain/community/accuse/adapter/out/persistence/AccuseTargetRepositoryImpl.java index e61df087f..b2d248991 100644 --- a/src/main/java/page/clab/api/domain/community/accuse/adapter/out/persistence/AccuseTargetRepositoryImpl.java +++ b/src/main/java/page/clab/api/domain/community/accuse/adapter/out/persistence/AccuseTargetRepositoryImpl.java @@ -2,6 +2,7 @@ import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.jpa.impl.JPAQueryFactory; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; @@ -11,8 +12,6 @@ import page.clab.api.domain.community.accuse.domain.TargetType; import page.clab.api.global.util.OrderSpecifierUtil; -import java.util.List; - @Repository @RequiredArgsConstructor public class AccuseTargetRepositoryImpl implements AccuseTargetRepositoryCustom { @@ -20,7 +19,8 @@ public class AccuseTargetRepositoryImpl implements AccuseTargetRepositoryCustom private final JPAQueryFactory queryFactory; @Override - public Page findByConditions(TargetType type, AccuseStatus status, boolean countOrder, Pageable pageable) { + public Page findByConditions(TargetType type, AccuseStatus status, boolean countOrder, + Pageable pageable) { QAccuseTargetJpaEntity accuseTarget = QAccuseTargetJpaEntity.accuseTargetJpaEntity; BooleanExpression predicate = accuseTarget.isNotNull(); @@ -32,15 +32,15 @@ public Page findByConditions(TargetType type, AccuseStatu } List accuseTargets = queryFactory.selectFrom(accuseTarget) - .where(predicate) - .orderBy(OrderSpecifierUtil.getOrderSpecifiers(pageable, accuseTarget)) - .offset(pageable.getOffset()) - .limit(pageable.getPageSize()) - .fetch(); + .where(predicate) + .orderBy(OrderSpecifierUtil.getOrderSpecifiers(pageable, accuseTarget)) + .offset(pageable.getOffset()) + .limit(pageable.getPageSize()) + .fetch(); long total = queryFactory.selectFrom(accuseTarget) - .where(predicate) - .fetchCount(); + .where(predicate) + .fetchCount(); return new PageImpl<>(accuseTargets, pageable, total); } diff --git a/src/main/java/page/clab/api/domain/community/accuse/application/dto/mapper/AccuseDtoMapper.java b/src/main/java/page/clab/api/domain/community/accuse/application/dto/mapper/AccuseDtoMapper.java index 92303c4e0..77ae22caf 100644 --- a/src/main/java/page/clab/api/domain/community/accuse/application/dto/mapper/AccuseDtoMapper.java +++ b/src/main/java/page/clab/api/domain/community/accuse/application/dto/mapper/AccuseDtoMapper.java @@ -1,5 +1,6 @@ package page.clab.api.domain.community.accuse.application.dto.mapper; +import java.util.List; import org.springframework.stereotype.Component; import page.clab.api.domain.community.accuse.application.dto.request.AccuseRequestDto; import page.clab.api.domain.community.accuse.application.dto.response.AccuseMyResponseDto; @@ -9,48 +10,46 @@ import page.clab.api.domain.community.accuse.domain.AccuseTarget; import page.clab.api.domain.memberManagement.member.application.dto.shared.MemberBasicInfoDto; -import java.util.List; - @Component public class AccuseDtoMapper { public Accuse fromDto(AccuseRequestDto requestDto, String memberId, AccuseTarget target) { return Accuse.builder() - .memberId(memberId) - .target(target) - .reason(requestDto.getReason()) - .isDeleted(false) - .build(); + .memberId(memberId) + .target(target) + .reason(requestDto.getReason()) + .isDeleted(false) + .build(); } public AccuseTarget fromDto(AccuseRequestDto requestDto) { return AccuseTarget.builder() - .targetType(requestDto.getTargetType()) - .targetReferenceId(requestDto.getTargetId()) - .accuseCount(1L) - .accuseStatus(AccuseStatus.PENDING) - .build(); + .targetType(requestDto.getTargetType()) + .targetReferenceId(requestDto.getTargetId()) + .accuseCount(1L) + .accuseStatus(AccuseStatus.PENDING) + .build(); } public AccuseMyResponseDto toDto(Accuse accuse) { return AccuseMyResponseDto.builder() - .targetType(accuse.getTarget().getTargetType()) - .targetId(accuse.getTarget().getTargetReferenceId()) - .reason(accuse.getReason()) - .accuseStatus(accuse.getTarget().getAccuseStatus()) - .createdAt(accuse.getTarget().getCreatedAt()) - .build(); + .targetType(accuse.getTarget().getTargetType()) + .targetId(accuse.getTarget().getTargetReferenceId()) + .reason(accuse.getReason()) + .accuseStatus(accuse.getTarget().getAccuseStatus()) + .createdAt(accuse.getTarget().getCreatedAt()) + .build(); } public AccuseResponseDto toDto(Accuse accuse, List members) { return AccuseResponseDto.builder() - .members(members) - .targetType(accuse.getTarget().getTargetType()) - .targetId(accuse.getTarget().getTargetReferenceId()) - .reason(accuse.getReason()) - .accuseStatus(accuse.getTarget().getAccuseStatus()) - .accuseCount(accuse.getTarget().getAccuseCount()) - .createdAt(accuse.getCreatedAt()) - .build(); + .members(members) + .targetType(accuse.getTarget().getTargetType()) + .targetId(accuse.getTarget().getTargetReferenceId()) + .reason(accuse.getReason()) + .accuseStatus(accuse.getTarget().getAccuseStatus()) + .accuseCount(accuse.getTarget().getAccuseCount()) + .createdAt(accuse.getCreatedAt()) + .build(); } } diff --git a/src/main/java/page/clab/api/domain/community/accuse/application/dto/response/AccuseMyResponseDto.java b/src/main/java/page/clab/api/domain/community/accuse/application/dto/response/AccuseMyResponseDto.java index aeef85115..435ccfc91 100644 --- a/src/main/java/page/clab/api/domain/community/accuse/application/dto/response/AccuseMyResponseDto.java +++ b/src/main/java/page/clab/api/domain/community/accuse/application/dto/response/AccuseMyResponseDto.java @@ -1,12 +1,11 @@ package page.clab.api.domain.community.accuse.application.dto.response; +import java.time.LocalDateTime; import lombok.Builder; import lombok.Getter; import page.clab.api.domain.community.accuse.domain.AccuseStatus; import page.clab.api.domain.community.accuse.domain.TargetType; -import java.time.LocalDateTime; - @Getter @Builder public class AccuseMyResponseDto { diff --git a/src/main/java/page/clab/api/domain/community/accuse/application/dto/response/AccuseResponseDto.java b/src/main/java/page/clab/api/domain/community/accuse/application/dto/response/AccuseResponseDto.java index 8db8d5faf..aa54073e9 100644 --- a/src/main/java/page/clab/api/domain/community/accuse/application/dto/response/AccuseResponseDto.java +++ b/src/main/java/page/clab/api/domain/community/accuse/application/dto/response/AccuseResponseDto.java @@ -1,14 +1,13 @@ package page.clab.api.domain.community.accuse.application.dto.response; +import java.time.LocalDateTime; +import java.util.List; import lombok.Builder; import lombok.Getter; import page.clab.api.domain.community.accuse.domain.AccuseStatus; import page.clab.api.domain.community.accuse.domain.TargetType; import page.clab.api.domain.memberManagement.member.application.dto.shared.MemberBasicInfoDto; -import java.time.LocalDateTime; -import java.util.List; - @Getter @Builder public class AccuseResponseDto { diff --git a/src/main/java/page/clab/api/domain/community/accuse/application/event/AccuseEventProcessor.java b/src/main/java/page/clab/api/domain/community/accuse/application/event/AccuseEventProcessor.java index 105af881c..020b1839a 100644 --- a/src/main/java/page/clab/api/domain/community/accuse/application/event/AccuseEventProcessor.java +++ b/src/main/java/page/clab/api/domain/community/accuse/application/event/AccuseEventProcessor.java @@ -1,6 +1,7 @@ package page.clab.api.domain.community.accuse.application.event; import jakarta.annotation.PostConstruct; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; @@ -10,8 +11,6 @@ import page.clab.api.domain.memberManagement.member.application.event.MemberEventProcessor; import page.clab.api.domain.memberManagement.member.application.event.MemberEventProcessorRegistry; -import java.util.List; - @Component @RequiredArgsConstructor public class AccuseEventProcessor implements MemberEventProcessor { diff --git a/src/main/java/page/clab/api/domain/community/accuse/application/port/in/ChangeAccusationStatusUseCase.java b/src/main/java/page/clab/api/domain/community/accuse/application/port/in/ChangeAccusationStatusUseCase.java index 29757a1ea..9f1cdcb50 100644 --- a/src/main/java/page/clab/api/domain/community/accuse/application/port/in/ChangeAccusationStatusUseCase.java +++ b/src/main/java/page/clab/api/domain/community/accuse/application/port/in/ChangeAccusationStatusUseCase.java @@ -5,5 +5,6 @@ import page.clab.api.domain.community.accuse.domain.TargetType; public interface ChangeAccusationStatusUseCase { + Long changeAccusationStatus(TargetType type, Long targetId, AccuseStatus status); } diff --git a/src/main/java/page/clab/api/domain/community/accuse/application/port/in/ReportAccusationUseCase.java b/src/main/java/page/clab/api/domain/community/accuse/application/port/in/ReportAccusationUseCase.java index 1e90b7deb..bcffefd6f 100644 --- a/src/main/java/page/clab/api/domain/community/accuse/application/port/in/ReportAccusationUseCase.java +++ b/src/main/java/page/clab/api/domain/community/accuse/application/port/in/ReportAccusationUseCase.java @@ -4,5 +4,6 @@ import page.clab.api.domain.community.accuse.application.dto.request.AccuseRequestDto; public interface ReportAccusationUseCase { + Long reportAccusation(AccuseRequestDto requestDto); } diff --git a/src/main/java/page/clab/api/domain/community/accuse/application/port/in/RetrieveAccusationUseCase.java b/src/main/java/page/clab/api/domain/community/accuse/application/port/in/RetrieveAccusationUseCase.java index 66b50ec92..034d8ddf5 100644 --- a/src/main/java/page/clab/api/domain/community/accuse/application/port/in/RetrieveAccusationUseCase.java +++ b/src/main/java/page/clab/api/domain/community/accuse/application/port/in/RetrieveAccusationUseCase.java @@ -7,5 +7,7 @@ import page.clab.api.global.common.dto.PagedResponseDto; public interface RetrieveAccusationUseCase { - PagedResponseDto retrieveAccusations(TargetType type, AccuseStatus status, boolean countOrder, Pageable pageable); + + PagedResponseDto retrieveAccusations(TargetType type, AccuseStatus status, boolean countOrder, + Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/community/accuse/application/port/in/RetrieveMyAccusationsUseCase.java b/src/main/java/page/clab/api/domain/community/accuse/application/port/in/RetrieveMyAccusationsUseCase.java index 39f0d23e7..661d1d0c2 100644 --- a/src/main/java/page/clab/api/domain/community/accuse/application/port/in/RetrieveMyAccusationsUseCase.java +++ b/src/main/java/page/clab/api/domain/community/accuse/application/port/in/RetrieveMyAccusationsUseCase.java @@ -5,5 +5,6 @@ import page.clab.api.global.common.dto.PagedResponseDto; public interface RetrieveMyAccusationsUseCase { + PagedResponseDto retrieveMyAccusations(Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/community/accuse/application/port/out/RegisterAccusePort.java b/src/main/java/page/clab/api/domain/community/accuse/application/port/out/RegisterAccusePort.java index 6dcbdcba2..df67e2004 100644 --- a/src/main/java/page/clab/api/domain/community/accuse/application/port/out/RegisterAccusePort.java +++ b/src/main/java/page/clab/api/domain/community/accuse/application/port/out/RegisterAccusePort.java @@ -1,8 +1,7 @@ package page.clab.api.domain.community.accuse.application.port.out; -import page.clab.api.domain.community.accuse.domain.Accuse; - import java.util.List; +import page.clab.api.domain.community.accuse.domain.Accuse; public interface RegisterAccusePort { diff --git a/src/main/java/page/clab/api/domain/community/accuse/application/port/out/RegisterAccuseTargetPort.java b/src/main/java/page/clab/api/domain/community/accuse/application/port/out/RegisterAccuseTargetPort.java index 5e4e5ef03..f53af0868 100644 --- a/src/main/java/page/clab/api/domain/community/accuse/application/port/out/RegisterAccuseTargetPort.java +++ b/src/main/java/page/clab/api/domain/community/accuse/application/port/out/RegisterAccuseTargetPort.java @@ -3,5 +3,6 @@ import page.clab.api.domain.community.accuse.domain.AccuseTarget; public interface RegisterAccuseTargetPort { + AccuseTarget save(AccuseTarget accuseTarget); } diff --git a/src/main/java/page/clab/api/domain/community/accuse/application/port/out/RetrieveAccusePort.java b/src/main/java/page/clab/api/domain/community/accuse/application/port/out/RetrieveAccusePort.java index e2df901d6..b60791e4e 100644 --- a/src/main/java/page/clab/api/domain/community/accuse/application/port/out/RetrieveAccusePort.java +++ b/src/main/java/page/clab/api/domain/community/accuse/application/port/out/RetrieveAccusePort.java @@ -1,13 +1,12 @@ package page.clab.api.domain.community.accuse.application.port.out; +import java.util.List; +import java.util.Optional; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import page.clab.api.domain.community.accuse.domain.Accuse; import page.clab.api.domain.community.accuse.domain.TargetType; -import java.util.List; -import java.util.Optional; - public interface RetrieveAccusePort { Optional findByMemberIdAndTarget(String memberId, TargetType targetType, Long targetReferenceId); diff --git a/src/main/java/page/clab/api/domain/community/accuse/application/port/out/RetrieveAccuseTargetPort.java b/src/main/java/page/clab/api/domain/community/accuse/application/port/out/RetrieveAccuseTargetPort.java index a9379be78..5d73f85b9 100644 --- a/src/main/java/page/clab/api/domain/community/accuse/application/port/out/RetrieveAccuseTargetPort.java +++ b/src/main/java/page/clab/api/domain/community/accuse/application/port/out/RetrieveAccuseTargetPort.java @@ -1,5 +1,6 @@ package page.clab.api.domain.community.accuse.application.port.out; +import java.util.Optional; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import page.clab.api.domain.community.accuse.adapter.out.persistence.AccuseTargetId; @@ -7,8 +8,6 @@ import page.clab.api.domain.community.accuse.domain.AccuseTarget; import page.clab.api.domain.community.accuse.domain.TargetType; -import java.util.Optional; - public interface RetrieveAccuseTargetPort { Optional findById(AccuseTargetId accuseTargetId); diff --git a/src/main/java/page/clab/api/domain/community/accuse/application/service/AccusationReportService.java b/src/main/java/page/clab/api/domain/community/accuse/application/service/AccusationReportService.java index 114bf45ae..1e93d4f49 100644 --- a/src/main/java/page/clab/api/domain/community/accuse/application/service/AccusationReportService.java +++ b/src/main/java/page/clab/api/domain/community/accuse/application/service/AccusationReportService.java @@ -85,18 +85,19 @@ private void validateAccusationRequest(TargetType type, Long targetId, String cu private AccuseTarget getOrCreateAccuseTarget(AccuseRequestDto requestDto, TargetType type, Long targetId) { return retrieveAccuseTargetPort.findById(AccuseTargetId.create(type, targetId)) - .orElseGet(() -> mapper.fromDto(requestDto)); + .orElseGet(() -> mapper.fromDto(requestDto)); } private Accuse findOrCreateAccusation(AccuseRequestDto requestDto, String memberId, AccuseTarget target) { - return retrieveAccusePort.findByMemberIdAndTarget(memberId, target.getTargetType(), target.getTargetReferenceId()) - .map(existingAccuse -> { - existingAccuse.updateReason(requestDto.getReason()); - return existingAccuse; - }) - .orElseGet(() -> { - target.increaseAccuseCount(); - return mapper.fromDto(requestDto, memberId, target); - }); + return retrieveAccusePort.findByMemberIdAndTarget(memberId, target.getTargetType(), + target.getTargetReferenceId()) + .map(existingAccuse -> { + existingAccuse.updateReason(requestDto.getReason()); + return existingAccuse; + }) + .orElseGet(() -> { + target.increaseAccuseCount(); + return mapper.fromDto(requestDto, memberId, target); + }); } } diff --git a/src/main/java/page/clab/api/domain/community/accuse/application/service/AccusationRetrievalService.java b/src/main/java/page/clab/api/domain/community/accuse/application/service/AccusationRetrievalService.java index ef1f7fc50..44c984647 100644 --- a/src/main/java/page/clab/api/domain/community/accuse/application/service/AccusationRetrievalService.java +++ b/src/main/java/page/clab/api/domain/community/accuse/application/service/AccusationRetrievalService.java @@ -1,5 +1,7 @@ package page.clab.api.domain.community.accuse.application.service; +import java.util.List; +import java.util.Objects; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -18,9 +20,6 @@ import page.clab.api.external.memberManagement.member.application.port.ExternalRetrieveMemberUseCase; import page.clab.api.global.common.dto.PagedResponseDto; -import java.util.List; -import java.util.Objects; - @Service @RequiredArgsConstructor public class AccusationRetrievalService implements RetrieveAccusationUseCase { @@ -32,25 +31,28 @@ public class AccusationRetrievalService implements RetrieveAccusationUseCase { @Transactional(readOnly = true) @Override - public PagedResponseDto retrieveAccusations(TargetType type, AccuseStatus status, boolean countOrder, Pageable pageable) { - Page accuseTargets = retrieveAccuseByTargetPort.findByConditions(type, status, countOrder, pageable); + public PagedResponseDto retrieveAccusations(TargetType type, AccuseStatus status, + boolean countOrder, Pageable pageable) { + Page accuseTargets = retrieveAccuseByTargetPort.findByConditions(type, status, countOrder, + pageable); List responseDtos = convertTargetsToResponseDtos(accuseTargets); return new PagedResponseDto<>(responseDtos, pageable, responseDtos.size()); } private List convertTargetsToResponseDtos(Page accuseTargets) { return accuseTargets.stream() - .map(accuseTarget -> { - List accuses = retrieveAccusePort.findByTargetOrderByCreatedAtDesc(accuseTarget.getTargetType(), accuseTarget.getTargetReferenceId()); - if (accuses.isEmpty()) { - return null; - } - List members = accuses.stream() - .map(accuse -> externalRetrieveMemberUseCase.getMemberBasicInfoById(accuse.getMemberId())) - .toList(); - return mapper.toDto(accuses.getFirst(), members); - }) - .filter(Objects::nonNull) - .toList(); + .map(accuseTarget -> { + List accuses = retrieveAccusePort.findByTargetOrderByCreatedAtDesc(accuseTarget.getTargetType(), + accuseTarget.getTargetReferenceId()); + if (accuses.isEmpty()) { + return null; + } + List members = accuses.stream() + .map(accuse -> externalRetrieveMemberUseCase.getMemberBasicInfoById(accuse.getMemberId())) + .toList(); + return mapper.toDto(accuses.getFirst(), members); + }) + .filter(Objects::nonNull) + .toList(); } } diff --git a/src/main/java/page/clab/api/domain/community/accuse/application/service/AccusationStatusService.java b/src/main/java/page/clab/api/domain/community/accuse/application/service/AccusationStatusService.java index 5ad496c62..19d1bb12b 100644 --- a/src/main/java/page/clab/api/domain/community/accuse/application/service/AccusationStatusService.java +++ b/src/main/java/page/clab/api/domain/community/accuse/application/service/AccusationStatusService.java @@ -1,5 +1,7 @@ package page.clab.api.domain.community.accuse.application.service; +import java.util.List; +import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -14,9 +16,6 @@ import page.clab.api.domain.community.accuse.domain.TargetType; import page.clab.api.external.memberManagement.notification.application.port.ExternalSendNotificationUseCase; -import java.util.List; -import java.util.stream.Collectors; - @Service @RequiredArgsConstructor public class AccusationStatusService implements ChangeAccusationStatusUseCase { @@ -36,9 +35,11 @@ public Long changeAccusationStatus(TargetType type, Long targetId, AccuseStatus } private void sendStatusUpdateNotifications(AccuseStatus status, AccuseTarget target) { - List memberIds = retrieveAccusePort.findByTarget(target.getTargetType(), target.getTargetReferenceId()).stream() - .map(Accuse::getMemberId) - .collect(Collectors.toList()); - externalSendNotificationUseCase.sendNotificationToMembers(memberIds, "신고 상태가 " + status.getDescription() + "(으)로 변경되었습니다."); + List memberIds = retrieveAccusePort.findByTarget(target.getTargetType(), target.getTargetReferenceId()) + .stream() + .map(Accuse::getMemberId) + .collect(Collectors.toList()); + externalSendNotificationUseCase.sendNotificationToMembers(memberIds, + "신고 상태가 " + status.getDescription() + "(으)로 변경되었습니다."); } } diff --git a/src/main/java/page/clab/api/domain/community/accuse/domain/Accuse.java b/src/main/java/page/clab/api/domain/community/accuse/domain/Accuse.java index 9d1800262..cb932dc61 100644 --- a/src/main/java/page/clab/api/domain/community/accuse/domain/Accuse.java +++ b/src/main/java/page/clab/api/domain/community/accuse/domain/Accuse.java @@ -1,5 +1,6 @@ package page.clab.api.domain.community.accuse.domain; +import java.time.LocalDateTime; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -8,8 +9,6 @@ import lombok.NoArgsConstructor; import lombok.Setter; -import java.time.LocalDateTime; - @Getter @Setter @Builder diff --git a/src/main/java/page/clab/api/domain/community/accuse/domain/AccuseTarget.java b/src/main/java/page/clab/api/domain/community/accuse/domain/AccuseTarget.java index 299ceaf05..b3b5abdf9 100644 --- a/src/main/java/page/clab/api/domain/community/accuse/domain/AccuseTarget.java +++ b/src/main/java/page/clab/api/domain/community/accuse/domain/AccuseTarget.java @@ -1,5 +1,6 @@ package page.clab.api.domain.community.accuse.domain; +import java.time.LocalDateTime; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -7,8 +8,6 @@ import lombok.NoArgsConstructor; import lombok.Setter; -import java.time.LocalDateTime; - @Getter @Setter @Builder diff --git a/src/main/java/page/clab/api/domain/community/board/adapter/in/web/BoardDetailsRetrievalController.java b/src/main/java/page/clab/api/domain/community/board/adapter/in/web/BoardDetailsRetrievalController.java index 6c15232d1..30d614d29 100644 --- a/src/main/java/page/clab/api/domain/community/board/adapter/in/web/BoardDetailsRetrievalController.java +++ b/src/main/java/page/clab/api/domain/community/board/adapter/in/web/BoardDetailsRetrievalController.java @@ -24,7 +24,7 @@ public class BoardDetailsRetrievalController { @PreAuthorize("hasRole('USER')") @GetMapping("/{boardId}") public ApiResponse retrieveBoardDetails( - @PathVariable(name = "boardId") Long boardId + @PathVariable(name = "boardId") Long boardId ) { BoardDetailsResponseDto board = retrieveBoardDetailsUseCase.retrieveBoardDetails(boardId); return ApiResponse.success(board); diff --git a/src/main/java/page/clab/api/domain/community/board/adapter/in/web/BoardEmojiToggleController.java b/src/main/java/page/clab/api/domain/community/board/adapter/in/web/BoardEmojiToggleController.java index 3d77c9ba6..c3e322c5c 100644 --- a/src/main/java/page/clab/api/domain/community/board/adapter/in/web/BoardEmojiToggleController.java +++ b/src/main/java/page/clab/api/domain/community/board/adapter/in/web/BoardEmojiToggleController.java @@ -23,8 +23,8 @@ public class BoardEmojiToggleController { @PreAuthorize("hasRole('USER')") @PostMapping("/{boardId}/react/{emoji}") public ApiResponse toggleEmojiStatus( - @PathVariable(name = "boardId") Long boardId, - @PathVariable(name = "emoji") String emoji + @PathVariable(name = "boardId") Long boardId, + @PathVariable(name = "emoji") String emoji ) { String id = toggleBoardEmojiUseCase.toggleEmojiStatus(boardId, emoji); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/community/board/adapter/in/web/BoardRegisterController.java b/src/main/java/page/clab/api/domain/community/board/adapter/in/web/BoardRegisterController.java index 114b06266..90f11d722 100644 --- a/src/main/java/page/clab/api/domain/community/board/adapter/in/web/BoardRegisterController.java +++ b/src/main/java/page/clab/api/domain/community/board/adapter/in/web/BoardRegisterController.java @@ -4,7 +4,6 @@ import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; -import org.apache.coyote.BadRequestException; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -27,7 +26,7 @@ public class BoardRegisterController { @PreAuthorize("hasRole('USER')") @PostMapping("") public ApiResponse registerBoard( - @Valid @RequestBody BoardRequestDto requestDto + @Valid @RequestBody BoardRequestDto requestDto ) throws PermissionDeniedException { String id = registerBoardUseCase.registerBoard(requestDto); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/community/board/adapter/in/web/BoardRemoveController.java b/src/main/java/page/clab/api/domain/community/board/adapter/in/web/BoardRemoveController.java index 72cb128d7..98f32cd35 100644 --- a/src/main/java/page/clab/api/domain/community/board/adapter/in/web/BoardRemoveController.java +++ b/src/main/java/page/clab/api/domain/community/board/adapter/in/web/BoardRemoveController.java @@ -24,7 +24,7 @@ public class BoardRemoveController { @PreAuthorize("hasRole('USER')") @DeleteMapping("/{boardId}") public ApiResponse removeBoard( - @PathVariable(name = "boardId") Long boardId + @PathVariable(name = "boardId") Long boardId ) throws PermissionDeniedException { String id = removeBoardUseCase.removeBoard(boardId); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/community/board/adapter/in/web/BoardUpdateController.java b/src/main/java/page/clab/api/domain/community/board/adapter/in/web/BoardUpdateController.java index f147bd2d2..9d1eee36c 100644 --- a/src/main/java/page/clab/api/domain/community/board/adapter/in/web/BoardUpdateController.java +++ b/src/main/java/page/clab/api/domain/community/board/adapter/in/web/BoardUpdateController.java @@ -27,8 +27,8 @@ public class BoardUpdateController { @PreAuthorize("hasRole('USER')") @PatchMapping("/{boardId}") public ApiResponse updateBoard( - @PathVariable(name = "boardId") Long boardId, - @Valid @RequestBody BoardUpdateRequestDto requestDto + @PathVariable(name = "boardId") Long boardId, + @Valid @RequestBody BoardUpdateRequestDto requestDto ) throws PermissionDeniedException { String id = updateBoardUseCase.updateBoard(boardId, requestDto); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/community/board/adapter/in/web/BoardsByCategoryRetrievalController.java b/src/main/java/page/clab/api/domain/community/board/adapter/in/web/BoardsByCategoryRetrievalController.java index ff9f50427..11e113106 100644 --- a/src/main/java/page/clab/api/domain/community/board/adapter/in/web/BoardsByCategoryRetrievalController.java +++ b/src/main/java/page/clab/api/domain/community/board/adapter/in/web/BoardsByCategoryRetrievalController.java @@ -2,6 +2,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.security.access.prepost.PreAuthorize; @@ -18,8 +19,6 @@ import page.clab.api.global.exception.SortingArgumentException; import page.clab.api.global.util.PageableUtils; -import java.util.List; - @RestController @RequestMapping("/api/v1/boards") @RequiredArgsConstructor @@ -30,18 +29,20 @@ public class BoardsByCategoryRetrievalController { private final PageableUtils pageableUtils; @Operation(summary = "[G] 커뮤니티 게시글 카테고리별 조회", description = "ROLE_GUEST 이상의 권한이 필요함
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") @PreAuthorize("hasRole('GUEST')") @GetMapping("/category") public ApiResponse> retrieveBoardsByCategory( - @RequestParam(name = "category") BoardCategory category, - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection + @RequestParam(name = "category") BoardCategory category, + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection ) throws SortingArgumentException, InvalidColumnException { - Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, BoardOverviewResponseDto.class); - PagedResponseDto boards = retrieveBoardsByCategoryUseCase.retrieveBoardsByCategory(category, pageable); + Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, + BoardOverviewResponseDto.class); + PagedResponseDto boards = retrieveBoardsByCategoryUseCase.retrieveBoardsByCategory( + category, pageable); return ApiResponse.success(boards); } } diff --git a/src/main/java/page/clab/api/domain/community/board/adapter/in/web/BoardsByHashtagRetrievalController.java b/src/main/java/page/clab/api/domain/community/board/adapter/in/web/BoardsByHashtagRetrievalController.java index 80a73b2d4..24fe8ee03 100644 --- a/src/main/java/page/clab/api/domain/community/board/adapter/in/web/BoardsByHashtagRetrievalController.java +++ b/src/main/java/page/clab/api/domain/community/board/adapter/in/web/BoardsByHashtagRetrievalController.java @@ -28,19 +28,21 @@ public class BoardsByHashtagRetrievalController { private final PageableUtils pageableUtils; @Operation(summary = "[G] 커뮤니티 게시글 해시태그로 조회", description = "ROLE_GUEST 이상의 권한이 필요함
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함
" + - "현재는 카테고리가 개발질문인 게시글만 해시태그가 적용되어 있어서 해당 API의 응답으로 개발질문 게시판만 반환됨") + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함
" + + "현재는 카테고리가 개발질문인 게시글만 해시태그가 적용되어 있어서 해당 API의 응답으로 개발질문 게시판만 반환됨") @PreAuthorize("hasRole('GUEST')") @GetMapping("/hashtag") public ApiResponse> retrieveBoardsByHashtag( - @RequestParam(name = "hashtags") List hashtags, - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection + @RequestParam(name = "hashtags") List hashtags, + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection ) throws SortingArgumentException, InvalidColumnException { - Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, BoardOverviewResponseDto.class); - PagedResponseDto boards = retrieveBoardsByHashtagUseCase.retrieveBoardsByHashtag(hashtags, pageable); + Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, + BoardOverviewResponseDto.class); + PagedResponseDto boards = retrieveBoardsByHashtagUseCase.retrieveBoardsByHashtag( + hashtags, pageable); return ApiResponse.success(boards); } } diff --git a/src/main/java/page/clab/api/domain/community/board/adapter/in/web/BoardsRetrievalController.java b/src/main/java/page/clab/api/domain/community/board/adapter/in/web/BoardsRetrievalController.java index 0bc2f6248..fcddfeef2 100644 --- a/src/main/java/page/clab/api/domain/community/board/adapter/in/web/BoardsRetrievalController.java +++ b/src/main/java/page/clab/api/domain/community/board/adapter/in/web/BoardsRetrievalController.java @@ -2,6 +2,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.security.access.prepost.PreAuthorize; @@ -17,8 +18,6 @@ import page.clab.api.global.exception.SortingArgumentException; import page.clab.api.global.util.PageableUtils; -import java.util.List; - @RestController @RequestMapping("/api/v1/boards") @RequiredArgsConstructor @@ -29,14 +28,14 @@ public class BoardsRetrievalController { private final PageableUtils pageableUtils; @Operation(summary = "[G] 커뮤니티 게시글 목록 조회", description = "ROLE_GUEST 이상의 권한이 필요함
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") @PreAuthorize("hasRole('GUEST')") @GetMapping("") public ApiResponse> retrieveBoards( - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection ) throws SortingArgumentException, InvalidColumnException { Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, BoardListResponseDto.class); PagedResponseDto boards = retrieveBoardUseCase.retrieveBoards(pageable); diff --git a/src/main/java/page/clab/api/domain/community/board/adapter/in/web/DeletedBoardsRetrievalController.java b/src/main/java/page/clab/api/domain/community/board/adapter/in/web/DeletedBoardsRetrievalController.java index 020e749af..0e2994234 100644 --- a/src/main/java/page/clab/api/domain/community/board/adapter/in/web/DeletedBoardsRetrievalController.java +++ b/src/main/java/page/clab/api/domain/community/board/adapter/in/web/DeletedBoardsRetrievalController.java @@ -27,8 +27,8 @@ public class DeletedBoardsRetrievalController { @PreAuthorize("hasRole('SUPER')") @GetMapping("/deleted") public ApiResponse> retrieveDeletedBoards( - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size ) { Pageable pageable = PageRequest.of(page, size); PagedResponseDto boards = retrieveDeletedBoardsUseCase.retrieveDeletedBoards(pageable); diff --git a/src/main/java/page/clab/api/domain/community/board/adapter/in/web/MyBoardsRetrievalController.java b/src/main/java/page/clab/api/domain/community/board/adapter/in/web/MyBoardsRetrievalController.java index c322fe6a7..34c259abe 100644 --- a/src/main/java/page/clab/api/domain/community/board/adapter/in/web/MyBoardsRetrievalController.java +++ b/src/main/java/page/clab/api/domain/community/board/adapter/in/web/MyBoardsRetrievalController.java @@ -2,6 +2,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.security.access.prepost.PreAuthorize; @@ -17,8 +18,6 @@ import page.clab.api.global.exception.SortingArgumentException; import page.clab.api.global.util.PageableUtils; -import java.util.List; - @RestController @RequestMapping("/api/v1/boards") @RequiredArgsConstructor @@ -29,14 +28,14 @@ public class MyBoardsRetrievalController { private final PageableUtils pageableUtils; @Operation(summary = "[G] 내가 쓴 커뮤니티 게시글 조회", description = "ROLE_GUEST 이상의 권한이 필요함
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") @PreAuthorize("hasRole('GUEST')") @GetMapping("/my-boards") public ApiResponse> retrieveMyBoards( - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection ) throws SortingArgumentException, InvalidColumnException { Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, BoardMyResponseDto.class); PagedResponseDto board = retrieveMyBoardsUseCase.retrieveMyBoards(pageable); diff --git a/src/main/java/page/clab/api/domain/community/board/adapter/out/persistence/BoardEmojiJpaEntity.java b/src/main/java/page/clab/api/domain/community/board/adapter/out/persistence/BoardEmojiJpaEntity.java index 7b8b8ad15..0e988068c 100644 --- a/src/main/java/page/clab/api/domain/community/board/adapter/out/persistence/BoardEmojiJpaEntity.java +++ b/src/main/java/page/clab/api/domain/community/board/adapter/out/persistence/BoardEmojiJpaEntity.java @@ -7,6 +7,7 @@ import jakarta.persistence.Id; import jakarta.persistence.Index; import jakarta.persistence.Table; +import java.time.LocalDateTime; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -17,8 +18,6 @@ import org.hibernate.annotations.SQLRestriction; import page.clab.api.global.common.domain.BaseEntity; -import java.time.LocalDateTime; - @Entity @Getter @Setter @@ -28,8 +27,8 @@ @SQLDelete(sql = "UPDATE board_emoji SET is_deleted = true WHERE id = ?") @SQLRestriction("is_deleted = false") @Table(name = "board_emoji", indexes = { - @Index(name = "idx_board_emoji_board_id_emoji", columnList = "board_id, emoji"), - @Index(name = "idx_board_emoji_board_id_emoji_member_id", columnList = "board_id, emoji, member_id") + @Index(name = "idx_board_emoji_board_id_emoji", columnList = "board_id, emoji"), + @Index(name = "idx_board_emoji_board_id_emoji_member_id", columnList = "board_id, emoji, member_id") }) public class BoardEmojiJpaEntity extends BaseEntity { diff --git a/src/main/java/page/clab/api/domain/community/board/adapter/out/persistence/BoardEmojiPersistenceAdapter.java b/src/main/java/page/clab/api/domain/community/board/adapter/out/persistence/BoardEmojiPersistenceAdapter.java index c55110eee..22d1b8e68 100644 --- a/src/main/java/page/clab/api/domain/community/board/adapter/out/persistence/BoardEmojiPersistenceAdapter.java +++ b/src/main/java/page/clab/api/domain/community/board/adapter/out/persistence/BoardEmojiPersistenceAdapter.java @@ -1,20 +1,19 @@ package page.clab.api.domain.community.board.adapter.out.persistence; import jakarta.persistence.Tuple; +import java.util.List; +import java.util.Optional; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; import page.clab.api.domain.community.board.application.port.out.RegisterBoardEmojiPort; import page.clab.api.domain.community.board.application.port.out.RetrieveBoardEmojiPort; import page.clab.api.domain.community.board.domain.BoardEmoji; -import java.util.List; -import java.util.Optional; - @Component @RequiredArgsConstructor public class BoardEmojiPersistenceAdapter implements - RetrieveBoardEmojiPort, - RegisterBoardEmojiPort { + RetrieveBoardEmojiPort, + RegisterBoardEmojiPort { private final BoardEmojiRepository boardEmojiRepository; private final BoardEmojiMapper boardEmojiMapper; @@ -27,7 +26,7 @@ public List findEmojiClickCountsByBoardId(Long boardId, String memberId) @Override public Optional findByBoardIdAndMemberIdAndEmoji(Long boardId, String memberId, String emoji) { return boardEmojiRepository.findByBoardIdAndMemberIdAndEmoji(boardId, memberId, emoji) - .map(boardEmojiMapper::toDomain); + .map(boardEmojiMapper::toDomain); } @Override diff --git a/src/main/java/page/clab/api/domain/community/board/adapter/out/persistence/BoardEmojiRepository.java b/src/main/java/page/clab/api/domain/community/board/adapter/out/persistence/BoardEmojiRepository.java index 009767719..9fa5a20e7 100644 --- a/src/main/java/page/clab/api/domain/community/board/adapter/out/persistence/BoardEmojiRepository.java +++ b/src/main/java/page/clab/api/domain/community/board/adapter/out/persistence/BoardEmojiRepository.java @@ -1,6 +1,9 @@ package page.clab.api.domain.community.board.adapter.out.persistence; import jakarta.persistence.Tuple; +import java.time.LocalDateTime; +import java.util.List; +import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; @@ -8,21 +11,18 @@ import org.springframework.stereotype.Repository; import org.springframework.transaction.annotation.Transactional; -import java.time.LocalDateTime; -import java.util.List; -import java.util.Optional; - @Repository public interface BoardEmojiRepository extends JpaRepository { @Query(value = "SELECT b.* FROM board_emoji b WHERE b.board_id = :boardId AND b.member_id = :memberId AND b.emoji = :emoji", nativeQuery = true) - Optional findByBoardIdAndMemberIdAndEmoji(@Param("boardId") Long boardId, @Param("memberId") String memberId, @Param("emoji") String emoji); + Optional findByBoardIdAndMemberIdAndEmoji(@Param("boardId") Long boardId, + @Param("memberId") String memberId, @Param("emoji") String emoji); @Query("SELECT b.emoji as emoji, COUNT(b) as count, " + - "CASE WHEN SUM(CASE WHEN b.memberId = :memberId THEN 1 ELSE 0 END) > 0 THEN true ELSE false END as isClicked " + - "FROM BoardEmojiJpaEntity b " + - "WHERE b.boardId = :boardId " + - "GROUP BY b.emoji") + "CASE WHEN SUM(CASE WHEN b.memberId = :memberId THEN 1 ELSE 0 END) > 0 THEN true ELSE false END as isClicked " + + "FROM BoardEmojiJpaEntity b " + + "WHERE b.boardId = :boardId " + + "GROUP BY b.emoji") List findEmojiClickCountsByBoardId(@Param("boardId") Long boardId, @Param("memberId") String memberId); @Transactional diff --git a/src/main/java/page/clab/api/domain/community/board/adapter/out/persistence/BoardHashtagPersistenceAdapter.java b/src/main/java/page/clab/api/domain/community/board/adapter/out/persistence/BoardHashtagPersistenceAdapter.java index 965490578..77cf72ee6 100644 --- a/src/main/java/page/clab/api/domain/community/board/adapter/out/persistence/BoardHashtagPersistenceAdapter.java +++ b/src/main/java/page/clab/api/domain/community/board/adapter/out/persistence/BoardHashtagPersistenceAdapter.java @@ -3,8 +3,6 @@ import java.util.List; import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Component; import page.clab.api.domain.community.board.application.port.out.RegisterBoardHashtagPort; import page.clab.api.domain.community.board.application.port.out.RetrieveBoardHashtagPort; @@ -13,10 +11,11 @@ @Component @RequiredArgsConstructor public class BoardHashtagPersistenceAdapter implements - RegisterBoardHashtagPort, RetrieveBoardHashtagPort { + RegisterBoardHashtagPort, RetrieveBoardHashtagPort { private final BoardHashtagRepository repository; private final BoardHashtagMapper mapper; + @Override public BoardHashtag save(BoardHashtag boardHashtag) { BoardHashtagJpaEntity entity = mapper.toEntity(boardHashtag); @@ -27,18 +26,18 @@ public BoardHashtag save(BoardHashtag boardHashtag) { @Override public List findAllByBoardId(Long boardId) { return repository.findAllByBoardId(boardId).stream() - .map(mapper::toDomain) - .collect(Collectors.toList()); + .map(mapper::toDomain) + .collect(Collectors.toList()); } @Override public List findAllIncludingDeletedByBoardId(Long boardId) { return repository.findAllIncludingDeletedByBoardId(boardId).stream() - .map(mapper::toDomain) - .collect(Collectors.toList()); + .map(mapper::toDomain) + .collect(Collectors.toList()); } public List findBoardIdsByHashTagId(List hashtagIds) { - return repository.getBoardIdsByHashTagId(hashtagIds, (long)hashtagIds.size()); + return repository.getBoardIdsByHashTagId(hashtagIds, (long) hashtagIds.size()); } } diff --git a/src/main/java/page/clab/api/domain/community/board/adapter/out/persistence/BoardHashtagRepository.java b/src/main/java/page/clab/api/domain/community/board/adapter/out/persistence/BoardHashtagRepository.java index 84ee1ca14..8526d3964 100644 --- a/src/main/java/page/clab/api/domain/community/board/adapter/out/persistence/BoardHashtagRepository.java +++ b/src/main/java/page/clab/api/domain/community/board/adapter/out/persistence/BoardHashtagRepository.java @@ -1,29 +1,27 @@ package page.clab.api.domain.community.board.adapter.out.persistence; import java.util.List; -import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; -import org.springframework.data.querydsl.QuerydslPredicateExecutor; import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; @Repository -public interface BoardHashtagRepository extends JpaRepository{ +public interface BoardHashtagRepository extends JpaRepository { List findAllByBoardId(Long boardId); @Query(value = "SELECT b.* " + - "FROM board_hashtag b " + - "WHERE b.board_id = :boardId", - nativeQuery = true) + "FROM board_hashtag b " + + "WHERE b.board_id = :boardId", + nativeQuery = true) List findAllIncludingDeletedByBoardId(Long boardId); @Query("SELECT DISTINCT b.boardId " + - "FROM BoardHashtagJpaEntity b " + - "WHERE b.hashtagId IN :hashtagIds " + - "AND b.isDeleted = false " + - "GROUP BY b.boardId " + - "HAVING COUNT(b.hashtagId) = :size") + "FROM BoardHashtagJpaEntity b " + + "WHERE b.hashtagId IN :hashtagIds " + + "AND b.isDeleted = false " + + "GROUP BY b.boardId " + + "HAVING COUNT(b.hashtagId) = :size") List getBoardIdsByHashTagId(@Param("hashtagIds") List hashtagIds, @Param("size") Long size); } diff --git a/src/main/java/page/clab/api/domain/community/board/adapter/out/persistence/BoardJpaEntity.java b/src/main/java/page/clab/api/domain/community/board/adapter/out/persistence/BoardJpaEntity.java index 473a2092f..43ab073c1 100644 --- a/src/main/java/page/clab/api/domain/community/board/adapter/out/persistence/BoardJpaEntity.java +++ b/src/main/java/page/clab/api/domain/community/board/adapter/out/persistence/BoardJpaEntity.java @@ -12,6 +12,7 @@ import jakarta.persistence.OneToMany; import jakarta.persistence.Table; import jakarta.validation.constraints.Size; +import java.util.List; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -24,8 +25,6 @@ import page.clab.api.global.common.domain.BaseEntity; import page.clab.api.global.common.file.domain.UploadedFile; -import java.util.List; - @Entity @Table(name = "board") @Getter diff --git a/src/main/java/page/clab/api/domain/community/board/adapter/out/persistence/BoardPersistenceAdapter.java b/src/main/java/page/clab/api/domain/community/board/adapter/out/persistence/BoardPersistenceAdapter.java index 6752552c3..142661091 100644 --- a/src/main/java/page/clab/api/domain/community/board/adapter/out/persistence/BoardPersistenceAdapter.java +++ b/src/main/java/page/clab/api/domain/community/board/adapter/out/persistence/BoardPersistenceAdapter.java @@ -13,8 +13,8 @@ @Component @RequiredArgsConstructor public class BoardPersistenceAdapter implements - RegisterBoardPort, - RetrieveBoardPort { + RegisterBoardPort, + RetrieveBoardPort { private final BoardRepository boardRepository; private final BoardMapper boardMapper; @@ -29,38 +29,38 @@ public Board save(Board board) { @Override public Board getById(Long boardId) { return boardRepository.findById(boardId) - .map(boardMapper::toDomain) - .orElseThrow(() -> new NotFoundException("[Board] id: " + boardId + "에 해당하는 게시글이 존재하지 않습니다.")); + .map(boardMapper::toDomain) + .orElseThrow(() -> new NotFoundException("[Board] id: " + boardId + "에 해당하는 게시글이 존재하지 않습니다.")); } @Override public Board findByIdRegardlessOfDeletion(Long boardId) { return boardRepository.findByIdRegardlessOfDeletion(boardId) - .map(boardMapper::toDomain) - .orElseThrow(() -> new NotFoundException("[Board] id: " + boardId + "에 해당하는 게시글이 존재하지 않습니다.")); + .map(boardMapper::toDomain) + .orElseThrow(() -> new NotFoundException("[Board] id: " + boardId + "에 해당하는 게시글이 존재하지 않습니다.")); } @Override public Page findAllByCategory(BoardCategory category, Pageable pageable) { return boardRepository.findAllByCategory(category, pageable) - .map(boardMapper::toDomain); + .map(boardMapper::toDomain); } @Override public Page findAllByIsDeletedTrue(Pageable pageable) { return boardRepository.findAllByIsDeletedTrue(pageable) - .map(boardMapper::toDomain); + .map(boardMapper::toDomain); } @Override public Page findAllByMemberId(String memberId, Pageable pageable) { return boardRepository.findAllByMemberIdAndIsDeletedFalse(memberId, pageable) - .map(boardMapper::toDomain); + .map(boardMapper::toDomain); } @Override public Page findAll(Pageable pageable) { return boardRepository.findAll(pageable) - .map(boardMapper::toDomain); + .map(boardMapper::toDomain); } } diff --git a/src/main/java/page/clab/api/domain/community/board/application/dto/mapper/BoardDtoMapper.java b/src/main/java/page/clab/api/domain/community/board/application/dto/mapper/BoardDtoMapper.java index 214a032c3..33a546928 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/dto/mapper/BoardDtoMapper.java +++ b/src/main/java/page/clab/api/domain/community/board/application/dto/mapper/BoardDtoMapper.java @@ -1,14 +1,15 @@ package page.clab.api.domain.community.board.application.dto.mapper; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; import page.clab.api.domain.community.board.application.dto.request.BoardRequestDto; -import page.clab.api.domain.community.board.application.dto.response.BoardOverviewResponseDto; import page.clab.api.domain.community.board.application.dto.response.BoardDetailsResponseDto; import page.clab.api.domain.community.board.application.dto.response.BoardEmojiCountResponseDto; import page.clab.api.domain.community.board.application.dto.response.BoardHashtagResponseDto; import page.clab.api.domain.community.board.application.dto.response.BoardListResponseDto; import page.clab.api.domain.community.board.application.dto.response.BoardMyResponseDto; +import page.clab.api.domain.community.board.application.dto.response.BoardOverviewResponseDto; import page.clab.api.domain.community.board.application.dto.response.WriterInfo; import page.clab.api.domain.community.board.application.dto.shared.BoardCommentInfoDto; import page.clab.api.domain.community.board.domain.Board; @@ -18,8 +19,6 @@ import page.clab.api.global.common.file.dto.mapper.FileDtoMapper; import page.clab.api.global.util.RandomNicknameUtil; -import java.util.List; - @Component @RequiredArgsConstructor public class BoardDtoMapper { @@ -28,88 +27,92 @@ public class BoardDtoMapper { public Board fromDto(BoardRequestDto requestDto, String memberId, List uploadedFiles) { return Board.builder() - .memberId(memberId) - .nickname(RandomNicknameUtil.makeRandomNickname()) - .category(requestDto.getCategory()) - .title(requestDto.getTitle()) - .content(requestDto.getContent()) - .uploadedFiles(uploadedFiles) - .imageUrl(requestDto.getImageUrl()) - .wantAnonymous(requestDto.isWantAnonymous()) - .isDeleted(false) - .build(); + .memberId(memberId) + .nickname(RandomNicknameUtil.makeRandomNickname()) + .category(requestDto.getCategory()) + .title(requestDto.getTitle()) + .content(requestDto.getContent()) + .uploadedFiles(uploadedFiles) + .imageUrl(requestDto.getImageUrl()) + .wantAnonymous(requestDto.isWantAnonymous()) + .isDeleted(false) + .build(); } - public BoardDetailsResponseDto toDto(Board board, MemberDetailedInfoDto memberInfo, boolean isOwner, List emojiInfos, List boardHashtagInfos) { + public BoardDetailsResponseDto toDto(Board board, MemberDetailedInfoDto memberInfo, boolean isOwner, + List emojiInfos, List boardHashtagInfos) { WriterInfo writerInfo = createDetail(board, memberInfo); return BoardDetailsResponseDto.builder() - .id(board.getId()) - .writerId(writerInfo.getId()) - .writerName(writerInfo.getName()) - .writerRoleLevel(writerInfo.getRoleLevel()) - .writerImageUrl(writerInfo.getImageUrl()) - .category(board.getCategory().getKey()) - .title(board.getTitle()) - .content(board.getContent()) - .files(mapper.toDto(board.getUploadedFiles())) - .imageUrl(board.getImageUrl()) - .isOwner(isOwner) - .emojiInfos(emojiInfos) - .boardHashtagInfos(boardHashtagInfos) - .createdAt(board.getCreatedAt()) - .build(); + .id(board.getId()) + .writerId(writerInfo.getId()) + .writerName(writerInfo.getName()) + .writerRoleLevel(writerInfo.getRoleLevel()) + .writerImageUrl(writerInfo.getImageUrl()) + .category(board.getCategory().getKey()) + .title(board.getTitle()) + .content(board.getContent()) + .files(mapper.toDto(board.getUploadedFiles())) + .imageUrl(board.getImageUrl()) + .isOwner(isOwner) + .emojiInfos(emojiInfos) + .boardHashtagInfos(boardHashtagInfos) + .createdAt(board.getCreatedAt()) + .build(); } - public BoardMyResponseDto toDto(Board board, MemberBasicInfoDto memberInfo, List boardHashtagInfos) { + public BoardMyResponseDto toDto(Board board, MemberBasicInfoDto memberInfo, + List boardHashtagInfos) { return BoardMyResponseDto.builder() - .id(board.getId()) - .category(board.getCategory().getKey()) - .writerName(board.isWantAnonymous() ? board.getNickname() : memberInfo.getMemberName()) - .title(board.getTitle()) - .imageUrl(board.getImageUrl()) - .boardHashtagInfos(boardHashtagInfos) - .createdAt(board.getCreatedAt()) - .build(); + .id(board.getId()) + .category(board.getCategory().getKey()) + .writerName(board.isWantAnonymous() ? board.getNickname() : memberInfo.getMemberName()) + .title(board.getTitle()) + .imageUrl(board.getImageUrl()) + .boardHashtagInfos(boardHashtagInfos) + .createdAt(board.getCreatedAt()) + .build(); } public BoardCommentInfoDto toDto(Board board) { return BoardCommentInfoDto.builder() - .boardId(board.getId()) - .memberId(board.getMemberId()) - .title(board.getTitle()) - .category(board.getCategory()) - .build(); + .boardId(board.getId()) + .memberId(board.getMemberId()) + .title(board.getTitle()) + .category(board.getCategory()) + .build(); } - public BoardOverviewResponseDto toCategoryDto(Board board, MemberDetailedInfoDto memberInfo, Long commentCount, List boardHashtagInfos) { + public BoardOverviewResponseDto toCategoryDto(Board board, MemberDetailedInfoDto memberInfo, Long commentCount, + List boardHashtagInfos) { WriterInfo writerInfo = create(board, memberInfo); return BoardOverviewResponseDto.builder() - .id(board.getId()) - .category(board.getCategory().getKey()) - .writerId(writerInfo.getId()) - .writerName(writerInfo.getName()) - .title(board.getTitle()) - .commentCount(commentCount) - .imageUrl(board.getImageUrl()) - .boardHashtagInfos(boardHashtagInfos) - .createdAt(board.getCreatedAt()) - .build(); + .id(board.getId()) + .category(board.getCategory().getKey()) + .writerId(writerInfo.getId()) + .writerName(writerInfo.getName()) + .title(board.getTitle()) + .commentCount(commentCount) + .imageUrl(board.getImageUrl()) + .boardHashtagInfos(boardHashtagInfos) + .createdAt(board.getCreatedAt()) + .build(); } - public BoardListResponseDto toListDto(Board board, MemberDetailedInfoDto memberInfo, Long commentCount, List boardHashtagInfos) { + public BoardListResponseDto toListDto(Board board, MemberDetailedInfoDto memberInfo, Long commentCount, + List boardHashtagInfos) { WriterInfo writerInfo = create(board, memberInfo); return BoardListResponseDto.builder() - .id(board.getId()) - .writerId(writerInfo.getId()) - .writerName(writerInfo.getName()) - .category(board.getCategory().getKey()) - .title(board.getTitle()) - .content(board.getContent()) - .commentCount(commentCount) - .imageUrl(board.getImageUrl()) - .boardHashtagInfos(boardHashtagInfos) - .createdAt(board.getCreatedAt()) - .build(); + .id(board.getId()) + .writerId(writerInfo.getId()) + .writerName(writerInfo.getName()) + .category(board.getCategory().getKey()) + .title(board.getTitle()) + .content(board.getContent()) + .commentCount(commentCount) + .imageUrl(board.getImageUrl()) + .boardHashtagInfos(boardHashtagInfos) + .createdAt(board.getCreatedAt()) + .build(); } public WriterInfo create(Board board, MemberDetailedInfoDto memberInfo) { @@ -127,6 +130,7 @@ public WriterInfo createDetail(Board board, MemberDetailedInfoDto memberInfo) { } else if (board.isWantAnonymous()) { return new WriterInfo(null, board.getNickname(), null, null); } - return new WriterInfo(memberInfo.getMemberId(), memberInfo.getMemberName(), memberInfo.getRoleLevel(), memberInfo.getImageUrl()); + return new WriterInfo(memberInfo.getMemberId(), memberInfo.getMemberName(), memberInfo.getRoleLevel(), + memberInfo.getImageUrl()); } } diff --git a/src/main/java/page/clab/api/domain/community/board/application/dto/mapper/BoardHashtagDtoMapper.java b/src/main/java/page/clab/api/domain/community/board/application/dto/mapper/BoardHashtagDtoMapper.java index a510337ee..7853abcfd 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/dto/mapper/BoardHashtagDtoMapper.java +++ b/src/main/java/page/clab/api/domain/community/board/application/dto/mapper/BoardHashtagDtoMapper.java @@ -13,25 +13,25 @@ public class BoardHashtagDtoMapper { public BoardHashtag fromDto(Long boardId, Long hashtagId) { return BoardHashtag.builder() - .boardId(boardId) - .hashtagId(hashtagId) - .isDeleted(false) - .build(); + .boardId(boardId) + .hashtagId(hashtagId) + .isDeleted(false) + .build(); } public BoardHashtagRequestDto toDto(Long boardId, List hashtagIdList) { return BoardHashtagRequestDto.builder() - .boardId(boardId) - .hashtagIds(hashtagIdList) - .build(); + .boardId(boardId) + .hashtagIds(hashtagIdList) + .build(); } public BoardHashtagResponseDto toDto(BoardHashtag boardHashtag, String name) { return BoardHashtagResponseDto.builder() - .id(boardHashtag.getId()) - .boardId(boardHashtag.getBoardId()) - .name(name) - .hashtagId(boardHashtag.getHashtagId()) - .build(); + .id(boardHashtag.getId()) + .boardId(boardHashtag.getBoardId()) + .name(name) + .hashtagId(boardHashtag.getHashtagId()) + .build(); } } diff --git a/src/main/java/page/clab/api/domain/community/board/application/dto/request/BoardRequestDto.java b/src/main/java/page/clab/api/domain/community/board/application/dto/request/BoardRequestDto.java index e9fcdf2fc..b8b933fd6 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/dto/request/BoardRequestDto.java +++ b/src/main/java/page/clab/api/domain/community/board/application/dto/request/BoardRequestDto.java @@ -2,12 +2,11 @@ import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotNull; +import java.util.List; import lombok.Getter; import lombok.Setter; import page.clab.api.domain.community.board.domain.BoardCategory; -import java.util.List; - @Getter @Setter public class BoardRequestDto { diff --git a/src/main/java/page/clab/api/domain/community/board/application/dto/response/BoardDetailsResponseDto.java b/src/main/java/page/clab/api/domain/community/board/application/dto/response/BoardDetailsResponseDto.java index 3b93eee28..c2d8fcdf8 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/dto/response/BoardDetailsResponseDto.java +++ b/src/main/java/page/clab/api/domain/community/board/application/dto/response/BoardDetailsResponseDto.java @@ -1,13 +1,12 @@ package page.clab.api.domain.community.board.application.dto.response; import com.fasterxml.jackson.annotation.JsonProperty; +import java.time.LocalDateTime; +import java.util.List; import lombok.Builder; import lombok.Getter; import page.clab.api.global.common.file.dto.response.UploadedFileResponseDto; -import java.time.LocalDateTime; -import java.util.List; - @Getter @Builder public class BoardDetailsResponseDto { diff --git a/src/main/java/page/clab/api/domain/community/board/application/dto/response/BoardListResponseDto.java b/src/main/java/page/clab/api/domain/community/board/application/dto/response/BoardListResponseDto.java index e62042092..f1f1e700a 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/dto/response/BoardListResponseDto.java +++ b/src/main/java/page/clab/api/domain/community/board/application/dto/response/BoardListResponseDto.java @@ -1,11 +1,10 @@ package page.clab.api.domain.community.board.application.dto.response; +import java.time.LocalDateTime; import java.util.List; import lombok.Builder; import lombok.Getter; -import java.time.LocalDateTime; - @Getter @Builder public class BoardListResponseDto { diff --git a/src/main/java/page/clab/api/domain/community/board/application/dto/response/BoardMyResponseDto.java b/src/main/java/page/clab/api/domain/community/board/application/dto/response/BoardMyResponseDto.java index 8675ad49e..382ef8bc5 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/dto/response/BoardMyResponseDto.java +++ b/src/main/java/page/clab/api/domain/community/board/application/dto/response/BoardMyResponseDto.java @@ -1,11 +1,10 @@ package page.clab.api.domain.community.board.application.dto.response; +import java.time.LocalDateTime; import java.util.List; import lombok.Builder; import lombok.Getter; -import java.time.LocalDateTime; - @Getter @Builder public class BoardMyResponseDto { diff --git a/src/main/java/page/clab/api/domain/community/board/application/dto/response/BoardOverviewResponseDto.java b/src/main/java/page/clab/api/domain/community/board/application/dto/response/BoardOverviewResponseDto.java index bbaba7afe..7ed9b4ec9 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/dto/response/BoardOverviewResponseDto.java +++ b/src/main/java/page/clab/api/domain/community/board/application/dto/response/BoardOverviewResponseDto.java @@ -1,11 +1,10 @@ package page.clab.api.domain.community.board.application.dto.response; +import java.time.LocalDateTime; import java.util.List; import lombok.Builder; import lombok.Getter; -import java.time.LocalDateTime; - @Getter @Builder public class BoardOverviewResponseDto { diff --git a/src/main/java/page/clab/api/domain/community/board/application/event/BoardEventDispatcher.java b/src/main/java/page/clab/api/domain/community/board/application/event/BoardEventDispatcher.java index f25e4b159..93b6662c4 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/event/BoardEventDispatcher.java +++ b/src/main/java/page/clab/api/domain/community/board/application/event/BoardEventDispatcher.java @@ -1,11 +1,10 @@ package page.clab.api.domain.community.board.application.event; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.context.event.EventListener; import org.springframework.stereotype.Component; -import java.util.List; - @Component @RequiredArgsConstructor public class BoardEventDispatcher { diff --git a/src/main/java/page/clab/api/domain/community/board/application/event/BoardEventProcessorRegistry.java b/src/main/java/page/clab/api/domain/community/board/application/event/BoardEventProcessorRegistry.java index cec59dfb4..bcba16e28 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/event/BoardEventProcessorRegistry.java +++ b/src/main/java/page/clab/api/domain/community/board/application/event/BoardEventProcessorRegistry.java @@ -1,11 +1,10 @@ package page.clab.api.domain.community.board.application.event; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Component; - import java.util.ArrayList; import java.util.Collections; import java.util.List; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; @Component @RequiredArgsConstructor diff --git a/src/main/java/page/clab/api/domain/community/board/application/port/in/RegisterBoardHashtagUseCase.java b/src/main/java/page/clab/api/domain/community/board/application/port/in/RegisterBoardHashtagUseCase.java index 91b847645..6ef97cffb 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/port/in/RegisterBoardHashtagUseCase.java +++ b/src/main/java/page/clab/api/domain/community/board/application/port/in/RegisterBoardHashtagUseCase.java @@ -3,5 +3,6 @@ import page.clab.api.domain.community.board.application.dto.request.BoardHashtagRequestDto; public interface RegisterBoardHashtagUseCase { + Long registerBoardHashtag(BoardHashtagRequestDto requestDto); } diff --git a/src/main/java/page/clab/api/domain/community/board/application/port/in/RegisterBoardUseCase.java b/src/main/java/page/clab/api/domain/community/board/application/port/in/RegisterBoardUseCase.java index 4f49dd60b..13df9823b 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/port/in/RegisterBoardUseCase.java +++ b/src/main/java/page/clab/api/domain/community/board/application/port/in/RegisterBoardUseCase.java @@ -1,9 +1,9 @@ package page.clab.api.domain.community.board.application.port.in; -import org.apache.coyote.BadRequestException; import page.clab.api.domain.community.board.application.dto.request.BoardRequestDto; import page.clab.api.global.exception.PermissionDeniedException; public interface RegisterBoardUseCase { + String registerBoard(BoardRequestDto requestDto) throws PermissionDeniedException; } diff --git a/src/main/java/page/clab/api/domain/community/board/application/port/in/RemoveBoardUseCase.java b/src/main/java/page/clab/api/domain/community/board/application/port/in/RemoveBoardUseCase.java index ddd9ad2c6..ffbfe27c7 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/port/in/RemoveBoardUseCase.java +++ b/src/main/java/page/clab/api/domain/community/board/application/port/in/RemoveBoardUseCase.java @@ -3,5 +3,6 @@ import page.clab.api.global.exception.PermissionDeniedException; public interface RemoveBoardUseCase { + String removeBoard(Long boardId) throws PermissionDeniedException; } diff --git a/src/main/java/page/clab/api/domain/community/board/application/port/in/RetrieveBoardDetailsUseCase.java b/src/main/java/page/clab/api/domain/community/board/application/port/in/RetrieveBoardDetailsUseCase.java index 4719edbb0..5cdff3e87 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/port/in/RetrieveBoardDetailsUseCase.java +++ b/src/main/java/page/clab/api/domain/community/board/application/port/in/RetrieveBoardDetailsUseCase.java @@ -3,5 +3,6 @@ import page.clab.api.domain.community.board.application.dto.response.BoardDetailsResponseDto; public interface RetrieveBoardDetailsUseCase { + BoardDetailsResponseDto retrieveBoardDetails(Long boardId); } diff --git a/src/main/java/page/clab/api/domain/community/board/application/port/in/RetrieveBoardsByCategoryUseCase.java b/src/main/java/page/clab/api/domain/community/board/application/port/in/RetrieveBoardsByCategoryUseCase.java index 1693bb27e..7b7646682 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/port/in/RetrieveBoardsByCategoryUseCase.java +++ b/src/main/java/page/clab/api/domain/community/board/application/port/in/RetrieveBoardsByCategoryUseCase.java @@ -6,5 +6,6 @@ import page.clab.api.global.common.dto.PagedResponseDto; public interface RetrieveBoardsByCategoryUseCase { + PagedResponseDto retrieveBoardsByCategory(BoardCategory category, Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/community/board/application/port/in/RetrieveBoardsByHashtagUseCase.java b/src/main/java/page/clab/api/domain/community/board/application/port/in/RetrieveBoardsByHashtagUseCase.java index 5038be794..3f8d644d1 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/port/in/RetrieveBoardsByHashtagUseCase.java +++ b/src/main/java/page/clab/api/domain/community/board/application/port/in/RetrieveBoardsByHashtagUseCase.java @@ -6,5 +6,6 @@ import page.clab.api.global.common.dto.PagedResponseDto; public interface RetrieveBoardsByHashtagUseCase { + PagedResponseDto retrieveBoardsByHashtag(List hashtags, Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/community/board/application/port/in/RetrieveDeletedBoardsUseCase.java b/src/main/java/page/clab/api/domain/community/board/application/port/in/RetrieveDeletedBoardsUseCase.java index 8987f372c..243c896b4 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/port/in/RetrieveDeletedBoardsUseCase.java +++ b/src/main/java/page/clab/api/domain/community/board/application/port/in/RetrieveDeletedBoardsUseCase.java @@ -5,5 +5,6 @@ import page.clab.api.global.common.dto.PagedResponseDto; public interface RetrieveDeletedBoardsUseCase { + PagedResponseDto retrieveDeletedBoards(Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/community/board/application/port/in/RetrieveMyBoardsUseCase.java b/src/main/java/page/clab/api/domain/community/board/application/port/in/RetrieveMyBoardsUseCase.java index 7c0b4ea00..c823ad4df 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/port/in/RetrieveMyBoardsUseCase.java +++ b/src/main/java/page/clab/api/domain/community/board/application/port/in/RetrieveMyBoardsUseCase.java @@ -5,5 +5,6 @@ import page.clab.api.global.common.dto.PagedResponseDto; public interface RetrieveMyBoardsUseCase { + PagedResponseDto retrieveMyBoards(Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/community/board/application/port/in/ToggleBoardEmojiUseCase.java b/src/main/java/page/clab/api/domain/community/board/application/port/in/ToggleBoardEmojiUseCase.java index 84ad15d47..0b6a0a062 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/port/in/ToggleBoardEmojiUseCase.java +++ b/src/main/java/page/clab/api/domain/community/board/application/port/in/ToggleBoardEmojiUseCase.java @@ -1,5 +1,6 @@ package page.clab.api.domain.community.board.application.port.in; public interface ToggleBoardEmojiUseCase { + String toggleEmojiStatus(Long boardId, String emoji); } diff --git a/src/main/java/page/clab/api/domain/community/board/application/port/in/UpdateBoardUseCase.java b/src/main/java/page/clab/api/domain/community/board/application/port/in/UpdateBoardUseCase.java index b1d3c183b..3876ef0e9 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/port/in/UpdateBoardUseCase.java +++ b/src/main/java/page/clab/api/domain/community/board/application/port/in/UpdateBoardUseCase.java @@ -4,5 +4,6 @@ import page.clab.api.global.exception.PermissionDeniedException; public interface UpdateBoardUseCase { + String updateBoard(Long boardId, BoardUpdateRequestDto requestDto) throws PermissionDeniedException; } diff --git a/src/main/java/page/clab/api/domain/community/board/application/port/out/RegisterBoardEmojiPort.java b/src/main/java/page/clab/api/domain/community/board/application/port/out/RegisterBoardEmojiPort.java index 22c0bdfb9..c701f8c5e 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/port/out/RegisterBoardEmojiPort.java +++ b/src/main/java/page/clab/api/domain/community/board/application/port/out/RegisterBoardEmojiPort.java @@ -4,5 +4,6 @@ import page.clab.api.domain.community.board.domain.BoardEmoji; public interface RegisterBoardEmojiPort { + BoardEmoji save(BoardEmoji boardEmoji); } diff --git a/src/main/java/page/clab/api/domain/community/board/application/port/out/RegisterBoardHashtagPort.java b/src/main/java/page/clab/api/domain/community/board/application/port/out/RegisterBoardHashtagPort.java index 840200b6e..7981523ec 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/port/out/RegisterBoardHashtagPort.java +++ b/src/main/java/page/clab/api/domain/community/board/application/port/out/RegisterBoardHashtagPort.java @@ -3,5 +3,6 @@ import page.clab.api.domain.community.board.domain.BoardHashtag; public interface RegisterBoardHashtagPort { + BoardHashtag save(BoardHashtag boardHashtag); } diff --git a/src/main/java/page/clab/api/domain/community/board/application/port/out/RegisterBoardPort.java b/src/main/java/page/clab/api/domain/community/board/application/port/out/RegisterBoardPort.java index 568c5be82..785f0a102 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/port/out/RegisterBoardPort.java +++ b/src/main/java/page/clab/api/domain/community/board/application/port/out/RegisterBoardPort.java @@ -3,5 +3,6 @@ import page.clab.api.domain.community.board.domain.Board; public interface RegisterBoardPort { + Board save(Board board); } diff --git a/src/main/java/page/clab/api/domain/community/board/application/port/out/RetrieveBoardEmojiPort.java b/src/main/java/page/clab/api/domain/community/board/application/port/out/RetrieveBoardEmojiPort.java index cdd1d2e9c..10f972056 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/port/out/RetrieveBoardEmojiPort.java +++ b/src/main/java/page/clab/api/domain/community/board/application/port/out/RetrieveBoardEmojiPort.java @@ -1,10 +1,9 @@ package page.clab.api.domain.community.board.application.port.out; import jakarta.persistence.Tuple; -import page.clab.api.domain.community.board.domain.BoardEmoji; - import java.util.List; import java.util.Optional; +import page.clab.api.domain.community.board.domain.BoardEmoji; public interface RetrieveBoardEmojiPort { diff --git a/src/main/java/page/clab/api/domain/community/board/application/port/out/RetrieveBoardHashtagPort.java b/src/main/java/page/clab/api/domain/community/board/application/port/out/RetrieveBoardHashtagPort.java index e1859f44b..8ae24d462 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/port/out/RetrieveBoardHashtagPort.java +++ b/src/main/java/page/clab/api/domain/community/board/application/port/out/RetrieveBoardHashtagPort.java @@ -1,8 +1,6 @@ package page.clab.api.domain.community.board.application.port.out; import java.util.List; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; import page.clab.api.domain.community.board.domain.BoardHashtag; public interface RetrieveBoardHashtagPort { diff --git a/src/main/java/page/clab/api/domain/community/board/application/service/BoardDetailsRetrievalService.java b/src/main/java/page/clab/api/domain/community/board/application/service/BoardDetailsRetrievalService.java index 45fe333d1..6fe3b1399 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/service/BoardDetailsRetrievalService.java +++ b/src/main/java/page/clab/api/domain/community/board/application/service/BoardDetailsRetrievalService.java @@ -1,6 +1,8 @@ package page.clab.api.domain.community.board.application.service; import jakarta.persistence.Tuple; +import java.util.List; +import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -15,9 +17,6 @@ import page.clab.api.domain.memberManagement.member.application.dto.shared.MemberDetailedInfoDto; import page.clab.api.external.memberManagement.member.application.port.ExternalRetrieveMemberUseCase; -import java.util.List; -import java.util.stream.Collectors; - @Service @RequiredArgsConstructor public class BoardDetailsRetrievalService implements RetrieveBoardDetailsUseCase { @@ -35,8 +34,10 @@ public BoardDetailsResponseDto retrieveBoardDetails(Long boardId) { Board board = retrieveBoardPort.getById(boardId); MemberDetailedInfoDto memberInfo = externalRetrieveMemberUseCase.getMemberDetailedInfoById(board.getMemberId()); boolean isOwner = board.isOwner(currentMemberInfo.getMemberId()); - List emojiInfos = getBoardEmojiCountResponseDtoList(boardId, currentMemberInfo.getMemberId()); - List boardHashtagInfos = boardHashtagRetrieveService.getBoardHashtagInfoByBoardId(boardId); + List emojiInfos = getBoardEmojiCountResponseDtoList(boardId, + currentMemberInfo.getMemberId()); + List boardHashtagInfos = boardHashtagRetrieveService.getBoardHashtagInfoByBoardId( + boardId); return boardDtoMapper.toDto(board, memberInfo, isOwner, emojiInfos, boardHashtagInfos); } @@ -44,10 +45,10 @@ public BoardDetailsResponseDto retrieveBoardDetails(Long boardId) { public List getBoardEmojiCountResponseDtoList(Long boardId, String memberId) { List results = retrieveBoardEmojiPort.findEmojiClickCountsByBoardId(boardId, memberId); return results.stream() - .map(result -> new BoardEmojiCountResponseDto( - result.get("emoji", String.class), - result.get("count", Long.class), - result.get("isClicked", Boolean.class))) - .collect(Collectors.toList()); + .map(result -> new BoardEmojiCountResponseDto( + result.get("emoji", String.class), + result.get("count", Long.class), + result.get("isClicked", Boolean.class))) + .collect(Collectors.toList()); } } diff --git a/src/main/java/page/clab/api/domain/community/board/application/service/BoardEmojiToggleService.java b/src/main/java/page/clab/api/domain/community/board/application/service/BoardEmojiToggleService.java index fbd38c661..5ad4c5aa3 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/service/BoardEmojiToggleService.java +++ b/src/main/java/page/clab/api/domain/community/board/application/service/BoardEmojiToggleService.java @@ -30,7 +30,7 @@ public class BoardEmojiToggleService implements ToggleBoardEmojiUseCase { * 이모지가 없으면 새로 생성하여 저장합니다.

* * @param boardId 이모지를 추가하거나 토글할 게시글의 ID - * @param emoji 추가할 이모지 + * @param emoji 추가할 이모지 * @return 게시글의 카테고리 키 * @throws InvalidEmojiException 지원하지 않는 이모지를 사용할 경우 예외 발생 */ @@ -44,11 +44,11 @@ public String toggleEmojiStatus(Long boardId, String emoji) { String memberId = currentMemberInfo.getMemberId(); Board board = retrieveBoardPort.getById(boardId); BoardEmoji boardEmoji = retrieveBoardEmojiPort.findByBoardIdAndMemberIdAndEmoji(boardId, memberId, emoji) - .map(existingEmoji -> { - existingEmoji.toggleIsDeletedStatus(); - return existingEmoji; - }) - .orElseGet(() -> BoardEmoji.create(memberId, boardId, emoji)); + .map(existingEmoji -> { + existingEmoji.toggleIsDeletedStatus(); + return existingEmoji; + }) + .orElseGet(() -> BoardEmoji.create(memberId, boardId, emoji)); registerBoardEmojiPort.save(boardEmoji); return board.getCategory().getKey(); } diff --git a/src/main/java/page/clab/api/domain/community/board/application/service/BoardHashtagRegisterService.java b/src/main/java/page/clab/api/domain/community/board/application/service/BoardHashtagRegisterService.java index e3e0e9095..d6384fd96 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/service/BoardHashtagRegisterService.java +++ b/src/main/java/page/clab/api/domain/community/board/application/service/BoardHashtagRegisterService.java @@ -11,7 +11,6 @@ import page.clab.api.domain.community.hashtag.domain.Hashtag; import page.clab.api.external.hashtag.application.port.ExternalRegisterHashtagUseCase; import page.clab.api.external.hashtag.application.port.ExternalRetrieveHashtagUseCase; -import page.clab.api.global.exception.NotFoundException; @Service @RequiredArgsConstructor diff --git a/src/main/java/page/clab/api/domain/community/board/application/service/BoardHashtagRetrieveService.java b/src/main/java/page/clab/api/domain/community/board/application/service/BoardHashtagRetrieveService.java index 83873c7be..1cfeed429 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/service/BoardHashtagRetrieveService.java +++ b/src/main/java/page/clab/api/domain/community/board/application/service/BoardHashtagRetrieveService.java @@ -6,9 +6,9 @@ import org.springframework.stereotype.Service; import page.clab.api.domain.community.board.application.dto.mapper.BoardHashtagDtoMapper; import page.clab.api.domain.community.board.application.dto.response.BoardHashtagResponseDto; +import page.clab.api.domain.community.board.application.port.in.RetrieveBoardHashtagUseCase; import page.clab.api.domain.community.board.application.port.out.RetrieveBoardHashtagPort; import page.clab.api.domain.community.board.domain.BoardHashtag; -import page.clab.api.domain.community.board.application.port.in.RetrieveBoardHashtagUseCase; import page.clab.api.external.hashtag.application.port.ExternalRetrieveHashtagUseCase; @Service @@ -23,11 +23,11 @@ public class BoardHashtagRetrieveService implements RetrieveBoardHashtagUseCase public List getBoardHashtagInfoByBoardId(Long boardId) { List boardHashtagList = getAllByBoardId(boardId); return boardHashtagList.stream() - .map(entity -> { - String name = externalRetrieveHashtagUseCase.getById(entity.getHashtagId()).getName(); - return boardHashtagDtoMapper.toDto(entity, name); - }) - .collect(Collectors.toList()); + .map(entity -> { + String name = externalRetrieveHashtagUseCase.getById(entity.getHashtagId()).getName(); + return boardHashtagDtoMapper.toDto(entity, name); + }) + .collect(Collectors.toList()); } @Override @@ -38,8 +38,8 @@ public List getAllByBoardId(Long boardId) { @Override public List extractAllHashtagId(List boardHashtagList) { return boardHashtagList.stream() - .map(BoardHashtag::getHashtagId) - .collect(Collectors.toList()); + .map(BoardHashtag::getHashtagId) + .collect(Collectors.toList()); } @Override diff --git a/src/main/java/page/clab/api/domain/community/board/application/service/BoardRegisterService.java b/src/main/java/page/clab/api/domain/community/board/application/service/BoardRegisterService.java index 95b095ea2..307ad19f6 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/service/BoardRegisterService.java +++ b/src/main/java/page/clab/api/domain/community/board/application/service/BoardRegisterService.java @@ -8,12 +8,11 @@ import page.clab.api.domain.community.board.application.dto.mapper.BoardDtoMapper; import page.clab.api.domain.community.board.application.dto.mapper.BoardHashtagDtoMapper; import page.clab.api.domain.community.board.application.dto.request.BoardRequestDto; -import page.clab.api.domain.community.board.application.exception.InvalidBoardCategoryHashtagException; +import page.clab.api.domain.community.board.application.port.in.RegisterBoardHashtagUseCase; import page.clab.api.domain.community.board.application.port.in.RegisterBoardUseCase; import page.clab.api.domain.community.board.application.port.out.RegisterBoardPort; import page.clab.api.domain.community.board.domain.Board; import page.clab.api.domain.memberManagement.member.application.dto.shared.MemberDetailedInfoDto; -import page.clab.api.domain.community.board.application.port.in.RegisterBoardHashtagUseCase; import page.clab.api.external.memberManagement.member.application.port.ExternalRetrieveMemberUseCase; import page.clab.api.external.memberManagement.notification.application.port.ExternalSendNotificationUseCase; import page.clab.api.global.common.file.application.UploadedFileService; @@ -40,8 +39,7 @@ public class BoardRegisterService implements RegisterBoardUseCase { * 새로운 게시글을 등록합니다. * *

현재 로그인한 멤버의 정보를 가져와 게시글을 생성하고, 필요한 경우 알림을 전송합니다. - * 게시글 작성 권한을 검증하며, 공지사항일 경우 Slack과 사용자에게 알림을 보냅니다. - * 개발 질문일 경우 해시태그의 유무를 확인해 등록합니다. + * 게시글 작성 권한을 검증하며, 공지사항일 경우 Slack과 사용자에게 알림을 보냅니다. 개발 질문일 경우 해시태그의 유무를 확인해 등록합니다. *

* * @param requestDto 게시글 요청 정보 DTO @@ -59,16 +57,17 @@ public String registerBoard(BoardRequestDto requestDto) throws PermissionDeniedE if (board.shouldNotifyForNewBoard(currentMemberInfo)) { externalSendNotificationUseCase.sendNotificationToMember(currentMemberInfo.getMemberId(), - "[" + board.getTitle() + "] 새로운 공지사항이 등록되었습니다."); + "[" + board.getTitle() + "] 새로운 공지사항이 등록되었습니다."); } BoardNotificationInfo boardInfo = BoardNotificationInfo.create(board, currentMemberInfo); eventPublisher.publishEvent(new NotificationEvent(this, ExecutivesAlertType.NEW_BOARD, null, - boardInfo)); + boardInfo)); Board savedBoard = registerBoardPort.save(board); if (savedBoard.isDevelopmentQna() && requestDto.getHashtagIdList() != null) { - registerBoardHashtagUseCase.registerBoardHashtag(boardHashtagDtoMapper.toDto(savedBoard.getId(), requestDto.getHashtagIdList())); + registerBoardHashtagUseCase.registerBoardHashtag( + boardHashtagDtoMapper.toDto(savedBoard.getId(), requestDto.getHashtagIdList())); } return savedBoard.getCategory().getKey(); } diff --git a/src/main/java/page/clab/api/domain/community/board/application/service/BoardRetrievalService.java b/src/main/java/page/clab/api/domain/community/board/application/service/BoardRetrievalService.java index 15a198eb2..1411e1794 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/service/BoardRetrievalService.java +++ b/src/main/java/page/clab/api/domain/community/board/application/service/BoardRetrievalService.java @@ -10,11 +10,11 @@ import page.clab.api.domain.community.board.application.dto.mapper.BoardDtoMapper; import page.clab.api.domain.community.board.application.dto.response.BoardHashtagResponseDto; import page.clab.api.domain.community.board.application.dto.response.BoardListResponseDto; +import page.clab.api.domain.community.board.application.port.in.RetrieveBoardHashtagUseCase; import page.clab.api.domain.community.board.application.port.in.RetrieveBoardUseCase; import page.clab.api.domain.community.board.application.port.out.RetrieveBoardPort; import page.clab.api.domain.community.board.domain.Board; import page.clab.api.domain.memberManagement.member.application.dto.shared.MemberDetailedInfoDto; -import page.clab.api.domain.community.board.application.port.in.RetrieveBoardHashtagUseCase; import page.clab.api.external.community.comment.application.port.ExternalRetrieveCommentUseCase; import page.clab.api.external.memberManagement.member.application.port.ExternalRetrieveMemberUseCase; import page.clab.api.global.common.dto.PagedResponseDto; @@ -34,7 +34,7 @@ public class BoardRetrievalService implements RetrieveBoardUseCase { public PagedResponseDto retrieveBoards(Pageable pageable) { Page boards = retrieveBoardPort.findAll(pageable); return new PagedResponseDto<>(boards.map(board -> - mapToBoardListResponseDto(board, getMemberDetailedInfoByBoard(board)))); + mapToBoardListResponseDto(board, getMemberDetailedInfoByBoard(board)))); } @Override @@ -49,7 +49,8 @@ private MemberDetailedInfoDto getMemberDetailedInfoByBoard(Board board) { @NotNull private BoardListResponseDto mapToBoardListResponseDto(Board board, MemberDetailedInfoDto memberInfo) { Long commentCount = externalRetrieveCommentUseCase.countByBoardId(board.getId()); - List boardHashtagInfos = retrieveBoardHashtagUseCase.getBoardHashtagInfoByBoardId(board.getId()); + List boardHashtagInfos = retrieveBoardHashtagUseCase.getBoardHashtagInfoByBoardId( + board.getId()); return mapper.toListDto(board, memberInfo, commentCount, boardHashtagInfos); } } diff --git a/src/main/java/page/clab/api/domain/community/board/application/service/BoardUpdateService.java b/src/main/java/page/clab/api/domain/community/board/application/service/BoardUpdateService.java index ccc276e0a..e640fcce4 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/service/BoardUpdateService.java +++ b/src/main/java/page/clab/api/domain/community/board/application/service/BoardUpdateService.java @@ -1,28 +1,23 @@ package page.clab.api.domain.community.board.application.service; -import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; import org.springframework.context.ApplicationEventPublisher; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import page.clab.api.domain.community.board.application.dto.mapper.BoardHashtagDtoMapper; import page.clab.api.domain.community.board.application.dto.request.BoardUpdateRequestDto; import page.clab.api.domain.community.board.application.event.BoardUpdatedEvent; -import page.clab.api.domain.community.board.application.exception.InvalidBoardCategoryHashtagException; +import page.clab.api.domain.community.board.application.port.in.RegisterBoardHashtagUseCase; +import page.clab.api.domain.community.board.application.port.in.RetrieveBoardHashtagUseCase; import page.clab.api.domain.community.board.application.port.in.UpdateBoardUseCase; import page.clab.api.domain.community.board.application.port.out.RegisterBoardHashtagPort; import page.clab.api.domain.community.board.application.port.out.RegisterBoardPort; import page.clab.api.domain.community.board.application.port.out.RetrieveBoardPort; import page.clab.api.domain.community.board.domain.Board; -import page.clab.api.domain.community.board.domain.BoardCategory; import page.clab.api.domain.community.board.domain.BoardHashtag; import page.clab.api.domain.community.hashtag.domain.Hashtag; import page.clab.api.domain.memberManagement.member.application.dto.shared.MemberDetailedInfoDto; -import page.clab.api.domain.community.board.application.port.in.RegisterBoardHashtagUseCase; -import page.clab.api.domain.community.board.application.port.in.RetrieveBoardHashtagUseCase; import page.clab.api.external.hashtag.application.port.ExternalRegisterHashtagUseCase; import page.clab.api.external.hashtag.application.port.ExternalRetrieveHashtagUseCase; import page.clab.api.external.memberManagement.member.application.port.ExternalRetrieveMemberUseCase; @@ -63,7 +58,8 @@ public String updateBoard(Long boardId, BoardUpdateRequestDto requestDto) throws private void handleBoardHashtagUpdate(Long boardId, Board board, List hashtagIdList) { if (hashtagIdList != null && !hashtagIdList.isEmpty()) { board.validateBoardHashtagUpdate(); - updateBoardHashtag(board, hashtagIdList, retrieveBoardHashtagUseCase.getAllIncludingDeletedByBoardId(boardId)); + updateBoardHashtag(board, hashtagIdList, + retrieveBoardHashtagUseCase.getAllIncludingDeletedByBoardId(boardId)); } else { deleteAllHashtagsForBoard(boardId); } @@ -101,38 +97,39 @@ private List getCurrentHashtagIds(List currentBoardHashtags) private List findHashtagsToRemove(List currentHashtagIds, List newHashtagIds) { return currentHashtagIds.stream() - .filter(id -> !newHashtagIds.contains(id)) - .toList(); + .filter(id -> !newHashtagIds.contains(id)) + .toList(); } - private List findHashtagsToAdd(List newHashtagIds, List currentHashtagIds, List currentBoardHashtags) { + private List findHashtagsToAdd(List newHashtagIds, List currentHashtagIds, + List currentBoardHashtags) { return newHashtagIds.stream() - .filter(id -> { - if (!currentHashtagIds.contains(id)) { - return true; - } - return currentBoardHashtags.stream() - .anyMatch(boardHashtag -> - boardHashtag.getHashtagId().equals(id) && - boardHashtag.getIsDeleted() - ); - }) - .toList(); + .filter(id -> { + if (!currentHashtagIds.contains(id)) { + return true; + } + return currentBoardHashtags.stream() + .anyMatch(boardHashtag -> + boardHashtag.getHashtagId().equals(id) && + boardHashtag.getIsDeleted() + ); + }) + .toList(); } private void removeHashtags(List hashtagsToRemove, List currentBoardHashtags) { hashtagsToRemove.forEach(idToRemove -> { currentBoardHashtags.stream() - .filter(boardHashtag -> boardHashtag.getHashtagId().equals(idToRemove)) - .forEach(boardHashtag -> { - if (!boardHashtag.getIsDeleted()) { - boardHashtag.toggleIsDeletedStatus(); - } - registerBoardHashtagPort.save(boardHashtag); - Hashtag hashtag = externalRetrieveHashtagUseCase.getById(boardHashtag.getHashtagId()); - hashtag.decreaseBoardUsage(); - externalRegisterHashtagUseCase.save(hashtag); - }); + .filter(boardHashtag -> boardHashtag.getHashtagId().equals(idToRemove)) + .forEach(boardHashtag -> { + if (!boardHashtag.getIsDeleted()) { + boardHashtag.toggleIsDeletedStatus(); + } + registerBoardHashtagPort.save(boardHashtag); + Hashtag hashtag = externalRetrieveHashtagUseCase.getById(boardHashtag.getHashtagId()); + hashtag.decreaseBoardUsage(); + externalRegisterHashtagUseCase.save(hashtag); + }); }); } @@ -142,21 +139,21 @@ private void addHashtags(Long boardId, List hashtagsToAdd, List currentBoardHashtags) { currentBoardHashtags.stream() - .filter(boardHashtag -> boardHashtag.getHashtagId().equals(hashtagId) && boardHashtag.getIsDeleted()) - .findFirst() - .ifPresentOrElse( - boardHashtag -> { - Hashtag hashtag = externalRetrieveHashtagUseCase.getById(boardHashtag.getHashtagId()); - boardHashtag.toggleIsDeletedStatus(); - registerBoardHashtagPort.save(boardHashtag); - hashtag.incrementBoardUsage(); - externalRegisterHashtagUseCase.save(hashtag); - }, - () -> { - registerBoardHashtagUseCase.registerBoardHashtag( - boardHashtagDtoMapper.toDto(boardId, List.of(hashtagId)) - ); - } - ); + .filter(boardHashtag -> boardHashtag.getHashtagId().equals(hashtagId) && boardHashtag.getIsDeleted()) + .findFirst() + .ifPresentOrElse( + boardHashtag -> { + Hashtag hashtag = externalRetrieveHashtagUseCase.getById(boardHashtag.getHashtagId()); + boardHashtag.toggleIsDeletedStatus(); + registerBoardHashtagPort.save(boardHashtag); + hashtag.incrementBoardUsage(); + externalRegisterHashtagUseCase.save(hashtag); + }, + () -> { + registerBoardHashtagUseCase.registerBoardHashtag( + boardHashtagDtoMapper.toDto(boardId, List.of(hashtagId)) + ); + } + ); } } diff --git a/src/main/java/page/clab/api/domain/community/board/application/service/BoardsByCategoryRetrievalService.java b/src/main/java/page/clab/api/domain/community/board/application/service/BoardsByCategoryRetrievalService.java index ce066bd0a..b47b4e733 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/service/BoardsByCategoryRetrievalService.java +++ b/src/main/java/page/clab/api/domain/community/board/application/service/BoardsByCategoryRetrievalService.java @@ -7,14 +7,14 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import page.clab.api.domain.community.board.application.dto.mapper.BoardDtoMapper; -import page.clab.api.domain.community.board.application.dto.response.BoardOverviewResponseDto; import page.clab.api.domain.community.board.application.dto.response.BoardHashtagResponseDto; +import page.clab.api.domain.community.board.application.dto.response.BoardOverviewResponseDto; +import page.clab.api.domain.community.board.application.port.in.RetrieveBoardHashtagUseCase; import page.clab.api.domain.community.board.application.port.in.RetrieveBoardsByCategoryUseCase; import page.clab.api.domain.community.board.application.port.out.RetrieveBoardPort; import page.clab.api.domain.community.board.domain.Board; import page.clab.api.domain.community.board.domain.BoardCategory; import page.clab.api.domain.memberManagement.member.application.dto.shared.MemberDetailedInfoDto; -import page.clab.api.domain.community.board.application.port.in.RetrieveBoardHashtagUseCase; import page.clab.api.external.community.comment.application.port.ExternalRetrieveCommentUseCase; import page.clab.api.external.memberManagement.member.application.port.ExternalRetrieveMemberUseCase; import page.clab.api.global.common.dto.PagedResponseDto; @@ -31,11 +31,13 @@ public class BoardsByCategoryRetrievalService implements RetrieveBoardsByCategor @Transactional @Override - public PagedResponseDto retrieveBoardsByCategory(BoardCategory category, Pageable pageable) { + public PagedResponseDto retrieveBoardsByCategory(BoardCategory category, + Pageable pageable) { Page boards = retrieveBoardPort.findAllByCategory(category, pageable); return new PagedResponseDto<>(boards.map(board -> { long commentCount = externalRetrieveCommentUseCase.countByBoardId(board.getId()); - List boardHashtagInfos = retrieveBoardHashtagUseCase.getBoardHashtagInfoByBoardId(board.getId()); + List boardHashtagInfos = retrieveBoardHashtagUseCase.getBoardHashtagInfoByBoardId( + board.getId()); return mapper.toCategoryDto(board, getMemberDetailedInfoByBoard(board), commentCount, boardHashtagInfos); })); } diff --git a/src/main/java/page/clab/api/domain/community/board/application/service/BoardsByHashtagRetrievalService.java b/src/main/java/page/clab/api/domain/community/board/application/service/BoardsByHashtagRetrievalService.java index 80a05fdd7..9ea88e90d 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/service/BoardsByHashtagRetrievalService.java +++ b/src/main/java/page/clab/api/domain/community/board/application/service/BoardsByHashtagRetrievalService.java @@ -1,6 +1,5 @@ package page.clab.api.domain.community.board.application.service; -import java.util.ArrayList; import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; @@ -8,10 +7,10 @@ import page.clab.api.domain.community.board.application.dto.mapper.BoardDtoMapper; import page.clab.api.domain.community.board.application.dto.response.BoardHashtagResponseDto; import page.clab.api.domain.community.board.application.dto.response.BoardOverviewResponseDto; +import page.clab.api.domain.community.board.application.port.in.RetrieveBoardHashtagUseCase; import page.clab.api.domain.community.board.application.port.in.RetrieveBoardsByHashtagUseCase; import page.clab.api.domain.community.board.domain.Board; import page.clab.api.domain.memberManagement.member.application.dto.shared.MemberDetailedInfoDto; -import page.clab.api.domain.community.board.application.port.in.RetrieveBoardHashtagUseCase; import page.clab.api.external.community.board.application.port.ExternalRetrieveBoardUseCase; import page.clab.api.external.community.comment.application.port.ExternalRetrieveCommentUseCase; import page.clab.api.external.hashtag.application.port.ExternalRetrieveHashtagUseCase; @@ -31,35 +30,36 @@ public class BoardsByHashtagRetrievalService implements RetrieveBoardsByHashtagU private final BoardDtoMapper mapper; @Override - public PagedResponseDto retrieveBoardsByHashtag(List hashtags, Pageable pageable) { + public PagedResponseDto retrieveBoardsByHashtag(List hashtags, + Pageable pageable) { List hashtagIds = getHashtagIdsByNames(hashtags); List boardIds = retrieveBoardHashtagUseCase.getBoardIdsByHashTagId(hashtagIds); List boards = getBoardsByIds(boardIds); List boardOverviewResponseDtos = toBoardOverviewResponseDtos(boards); List paginatedBoardOverviewDtos = - PaginationUtils.applySortingAndSlicing(boardOverviewResponseDtos, pageable); + PaginationUtils.applySortingAndSlicing(boardOverviewResponseDtos, pageable); return new PagedResponseDto<>(paginatedBoardOverviewDtos, boardIds.size(), pageable); } private List getHashtagIdsByNames(List hashtags) { return hashtags.stream() - .map(hashtag -> externalRetrieveHashtagUseCase.getByName(hashtag).getId()) - .toList(); + .map(hashtag -> externalRetrieveHashtagUseCase.getByName(hashtag).getId()) + .toList(); } private List getBoardsByIds(List boardIds) { return boardIds.stream() - .map(externalRetrieveBoardUseCase::getById) - .toList(); + .map(externalRetrieveBoardUseCase::getById) + .toList(); } private List toBoardOverviewResponseDtos(List boards) { return boards.stream().map(board -> { long commentCount = externalRetrieveCommentUseCase.countByBoardId(board.getId()); List boardHashtagInfos = - retrieveBoardHashtagUseCase.getBoardHashtagInfoByBoardId(board.getId()); + retrieveBoardHashtagUseCase.getBoardHashtagInfoByBoardId(board.getId()); return mapper.toCategoryDto(board, getMemberDetailedInfoByBoard(board), commentCount, boardHashtagInfos); }).toList(); } diff --git a/src/main/java/page/clab/api/domain/community/board/application/service/DeletedBoardsRetrievalService.java b/src/main/java/page/clab/api/domain/community/board/application/service/DeletedBoardsRetrievalService.java index eeb960593..2de8d8f8c 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/service/DeletedBoardsRetrievalService.java +++ b/src/main/java/page/clab/api/domain/community/board/application/service/DeletedBoardsRetrievalService.java @@ -33,7 +33,7 @@ public class DeletedBoardsRetrievalService implements RetrieveDeletedBoardsUseCa public PagedResponseDto retrieveDeletedBoards(Pageable pageable) { Page boards = retrieveBoardPort.findAllByIsDeletedTrue(pageable); return new PagedResponseDto<>(boards.map(board -> - mapToBoardListResponseDto(board, getMemberDetailedInfoByBoard(board)))); + mapToBoardListResponseDto(board, getMemberDetailedInfoByBoard(board)))); } private MemberDetailedInfoDto getMemberDetailedInfoByBoard(Board board) { @@ -43,7 +43,8 @@ private MemberDetailedInfoDto getMemberDetailedInfoByBoard(Board board) { @NotNull private BoardListResponseDto mapToBoardListResponseDto(Board board, MemberDetailedInfoDto memberInfo) { Long commentCount = externalRetrieveCommentUseCase.countByBoardId(board.getId()); - List boardHashtagInfos = boardHashtagRetrieveService.getBoardHashtagInfoByBoardId(board.getId()); + List boardHashtagInfos = boardHashtagRetrieveService.getBoardHashtagInfoByBoardId( + board.getId()); return mapper.toListDto(board, memberInfo, commentCount, boardHashtagInfos); } } diff --git a/src/main/java/page/clab/api/domain/community/board/application/service/MyBoardsRetrievalService.java b/src/main/java/page/clab/api/domain/community/board/application/service/MyBoardsRetrievalService.java index 1490d99be..16cc2fe75 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/service/MyBoardsRetrievalService.java +++ b/src/main/java/page/clab/api/domain/community/board/application/service/MyBoardsRetrievalService.java @@ -9,11 +9,11 @@ import page.clab.api.domain.community.board.application.dto.mapper.BoardDtoMapper; import page.clab.api.domain.community.board.application.dto.response.BoardHashtagResponseDto; import page.clab.api.domain.community.board.application.dto.response.BoardMyResponseDto; +import page.clab.api.domain.community.board.application.port.in.RetrieveBoardHashtagUseCase; import page.clab.api.domain.community.board.application.port.in.RetrieveMyBoardsUseCase; import page.clab.api.domain.community.board.application.port.out.RetrieveBoardPort; import page.clab.api.domain.community.board.domain.Board; import page.clab.api.domain.memberManagement.member.application.dto.shared.MemberBasicInfoDto; -import page.clab.api.domain.community.board.application.port.in.RetrieveBoardHashtagUseCase; import page.clab.api.external.memberManagement.member.application.port.ExternalRetrieveMemberUseCase; import page.clab.api.global.common.dto.PagedResponseDto; @@ -32,7 +32,8 @@ public PagedResponseDto retrieveMyBoards(Pageable pageable) MemberBasicInfoDto currentMemberInfo = externalRetrieveMemberUseCase.getCurrentMemberBasicInfo(); Page boards = retrieveBoardPort.findAllByMemberId(currentMemberInfo.getMemberId(), pageable); return new PagedResponseDto<>(boards.map(board -> { - List boardHashtagInfos = retrieveBoardHashtagUseCase.getBoardHashtagInfoByBoardId(board.getId()); + List boardHashtagInfos = retrieveBoardHashtagUseCase.getBoardHashtagInfoByBoardId( + board.getId()); return mapper.toDto(board, currentMemberInfo, boardHashtagInfos); })); } diff --git a/src/main/java/page/clab/api/domain/community/board/domain/Board.java b/src/main/java/page/clab/api/domain/community/board/domain/Board.java index 0337932d3..089795c91 100644 --- a/src/main/java/page/clab/api/domain/community/board/domain/Board.java +++ b/src/main/java/page/clab/api/domain/community/board/domain/Board.java @@ -1,6 +1,8 @@ package page.clab.api.domain.community.board.domain; -import java.util.stream.Collectors; +import java.time.LocalDateTime; +import java.util.List; +import java.util.Optional; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -13,10 +15,6 @@ import page.clab.api.global.common.file.domain.UploadedFile; import page.clab.api.global.exception.PermissionDeniedException; -import java.time.LocalDateTime; -import java.util.List; -import java.util.Optional; - @Getter @Setter @Builder @@ -70,7 +68,8 @@ public void validateAccessPermission(MemberDetailedInfoDto memberInfo) throws Pe } } - public void validateAccessPermissionForCreation(MemberDetailedInfoDto currentMemberInfo) throws PermissionDeniedException { + public void validateAccessPermissionForCreation(MemberDetailedInfoDto currentMemberInfo) + throws PermissionDeniedException { if (this.isNotice() && !currentMemberInfo.isAdminRole()) { throw new PermissionDeniedException("공지사항은 관리자만 작성할 수 있습니다."); } diff --git a/src/main/java/page/clab/api/domain/community/board/domain/BoardEmoji.java b/src/main/java/page/clab/api/domain/community/board/domain/BoardEmoji.java index 3add32b60..cba0b09eb 100644 --- a/src/main/java/page/clab/api/domain/community/board/domain/BoardEmoji.java +++ b/src/main/java/page/clab/api/domain/community/board/domain/BoardEmoji.java @@ -1,5 +1,6 @@ package page.clab.api.domain.community.board.domain; +import java.time.LocalDateTime; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -7,8 +8,6 @@ import lombok.NoArgsConstructor; import lombok.Setter; -import java.time.LocalDateTime; - @Getter @Setter @Builder @@ -25,11 +24,11 @@ public class BoardEmoji { public static BoardEmoji create(String memberId, Long boardId, String emoji) { return BoardEmoji.builder() - .memberId(memberId) - .boardId(boardId) - .emoji(emoji) - .isDeleted(false) - .build(); + .memberId(memberId) + .boardId(boardId) + .emoji(emoji) + .isDeleted(false) + .build(); } public void toggleIsDeletedStatus() { diff --git a/src/main/java/page/clab/api/domain/community/board/domain/BoardHashtag.java b/src/main/java/page/clab/api/domain/community/board/domain/BoardHashtag.java index 8430fb257..3119f70c6 100644 --- a/src/main/java/page/clab/api/domain/community/board/domain/BoardHashtag.java +++ b/src/main/java/page/clab/api/domain/community/board/domain/BoardHashtag.java @@ -2,7 +2,6 @@ import jakarta.persistence.Index; import jakarta.persistence.Table; -import java.time.LocalDateTime; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -16,8 +15,8 @@ @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor(access = AccessLevel.PRIVATE) @Table(name = "board_hashtag", indexes = { - @Index(name = "idx_board_hashtag_board_id", columnList = "boardId"), - @Index(name = "idx_board_hashtag_hashtag_id", columnList = "hashtagId"), + @Index(name = "idx_board_hashtag_board_id", columnList = "boardId"), + @Index(name = "idx_board_hashtag_hashtag_id", columnList = "hashtagId"), }) public class BoardHashtag { diff --git a/src/main/java/page/clab/api/domain/community/comment/adapter/in/web/CommentLikeToggleController.java b/src/main/java/page/clab/api/domain/community/comment/adapter/in/web/CommentLikeToggleController.java index a6ac318c9..69e840726 100644 --- a/src/main/java/page/clab/api/domain/community/comment/adapter/in/web/CommentLikeToggleController.java +++ b/src/main/java/page/clab/api/domain/community/comment/adapter/in/web/CommentLikeToggleController.java @@ -23,7 +23,7 @@ public class CommentLikeToggleController { @PreAuthorize("hasRole('USER')") @PostMapping("/likes/{commentId}") public ApiResponse toggleLikeStatus( - @PathVariable(name = "commentId") Long commentId + @PathVariable(name = "commentId") Long commentId ) { Long id = toggleCommentLikeUseCase.toggleLikeStatus(commentId); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/community/comment/adapter/in/web/CommentRegisterController.java b/src/main/java/page/clab/api/domain/community/comment/adapter/in/web/CommentRegisterController.java index 22f24f9ca..fe5dbfcf8 100644 --- a/src/main/java/page/clab/api/domain/community/comment/adapter/in/web/CommentRegisterController.java +++ b/src/main/java/page/clab/api/domain/community/comment/adapter/in/web/CommentRegisterController.java @@ -27,9 +27,9 @@ public class CommentRegisterController { @PreAuthorize("hasRole('USER')") @PostMapping("/{boardId}") public ApiResponse registerComment( - @RequestParam(name = "parentId", required = false) Long parentId, - @PathVariable(name = "boardId") Long boardId, - @Valid @RequestBody CommentRequestDto requestDto + @RequestParam(name = "parentId", required = false) Long parentId, + @PathVariable(name = "boardId") Long boardId, + @Valid @RequestBody CommentRequestDto requestDto ) { Long id = registerCommentUseCase.registerComment(parentId, boardId, requestDto); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/community/comment/adapter/in/web/CommentRemoveController.java b/src/main/java/page/clab/api/domain/community/comment/adapter/in/web/CommentRemoveController.java index 7af5eb320..89191e000 100644 --- a/src/main/java/page/clab/api/domain/community/comment/adapter/in/web/CommentRemoveController.java +++ b/src/main/java/page/clab/api/domain/community/comment/adapter/in/web/CommentRemoveController.java @@ -24,7 +24,7 @@ public class CommentRemoveController { @PreAuthorize("hasRole('USER')") @DeleteMapping("/{commentId}") public ApiResponse removeComment( - @PathVariable(name = "commentId") Long commentId + @PathVariable(name = "commentId") Long commentId ) throws PermissionDeniedException { Long id = removeCommentUseCase.removeComment(commentId); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/community/comment/adapter/in/web/CommentRetrievalController.java b/src/main/java/page/clab/api/domain/community/comment/adapter/in/web/CommentRetrievalController.java index 489c0a5ad..d149cb30a 100644 --- a/src/main/java/page/clab/api/domain/community/comment/adapter/in/web/CommentRetrievalController.java +++ b/src/main/java/page/clab/api/domain/community/comment/adapter/in/web/CommentRetrievalController.java @@ -2,6 +2,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.security.access.prepost.PreAuthorize; @@ -18,8 +19,6 @@ import page.clab.api.global.exception.SortingArgumentException; import page.clab.api.global.util.PageableUtils; -import java.util.List; - @RestController @RequestMapping("/api/v1/comments") @RequiredArgsConstructor @@ -30,15 +29,15 @@ public class CommentRetrievalController { private final PageableUtils pageableUtils; @Operation(summary = "[U] 댓글 목록 조회", description = "ROLE_USER 이상의 권한이 필요함
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") @PreAuthorize("hasRole('USER')") @GetMapping("/{boardId}") public ApiResponse> retrieveComments( - @PathVariable(name = "boardId") Long boardId, - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection + @PathVariable(name = "boardId") Long boardId, + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection ) throws SortingArgumentException, InvalidColumnException { Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, CommentResponseDto.class); PagedResponseDto comments = retrieveCommentUseCase.retrieveComments(boardId, pageable); diff --git a/src/main/java/page/clab/api/domain/community/comment/adapter/in/web/CommentUpdateController.java b/src/main/java/page/clab/api/domain/community/comment/adapter/in/web/CommentUpdateController.java index b219191fc..bfa4e7fc9 100644 --- a/src/main/java/page/clab/api/domain/community/comment/adapter/in/web/CommentUpdateController.java +++ b/src/main/java/page/clab/api/domain/community/comment/adapter/in/web/CommentUpdateController.java @@ -27,8 +27,8 @@ public class CommentUpdateController { @PreAuthorize("hasRole('USER')") @PatchMapping("/{commentId}") public ApiResponse updateComment( - @PathVariable(name = "commentId") Long commentId, - @Valid @RequestBody CommentUpdateRequestDto requestDto + @PathVariable(name = "commentId") Long commentId, + @Valid @RequestBody CommentUpdateRequestDto requestDto ) throws PermissionDeniedException { Long id = updateCommentUseCase.updateComment(commentId, requestDto); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/community/comment/adapter/in/web/DeletedCommentsRetrievalController.java b/src/main/java/page/clab/api/domain/community/comment/adapter/in/web/DeletedCommentsRetrievalController.java index 1e8e1af2b..bec0406f9 100644 --- a/src/main/java/page/clab/api/domain/community/comment/adapter/in/web/DeletedCommentsRetrievalController.java +++ b/src/main/java/page/clab/api/domain/community/comment/adapter/in/web/DeletedCommentsRetrievalController.java @@ -28,12 +28,13 @@ public class DeletedCommentsRetrievalController { @PreAuthorize("hasRole('SUPER')") @GetMapping("/deleted/{boardId}") public ApiResponse> retrieveDeletedComments( - @PathVariable(name = "boardId") Long boardId, - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size + @PathVariable(name = "boardId") Long boardId, + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size ) { Pageable pageable = PageRequest.of(page, size); - PagedResponseDto comments = retrieveDeletedCommentsUseCase.retrieveDeletedComments(boardId, pageable); + PagedResponseDto comments = retrieveDeletedCommentsUseCase.retrieveDeletedComments( + boardId, pageable); return ApiResponse.success(comments); } } diff --git a/src/main/java/page/clab/api/domain/community/comment/adapter/in/web/MyCommentsRetrievalController.java b/src/main/java/page/clab/api/domain/community/comment/adapter/in/web/MyCommentsRetrievalController.java index 42d340991..a9c368e23 100644 --- a/src/main/java/page/clab/api/domain/community/comment/adapter/in/web/MyCommentsRetrievalController.java +++ b/src/main/java/page/clab/api/domain/community/comment/adapter/in/web/MyCommentsRetrievalController.java @@ -2,6 +2,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.security.access.prepost.PreAuthorize; @@ -17,8 +18,6 @@ import page.clab.api.global.exception.SortingArgumentException; import page.clab.api.global.util.PageableUtils; -import java.util.List; - @RestController @RequestMapping("/api/v1/comments") @RequiredArgsConstructor @@ -29,14 +28,14 @@ public class MyCommentsRetrievalController { private final PageableUtils pageableUtils; @Operation(summary = "[G] 나의 댓글 조회", description = "ROLE_GUEST 이상의 권한이 필요함
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") @PreAuthorize("hasRole('GUEST')") @GetMapping("/my-comments") public ApiResponse> retrieveMyComments( - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection ) throws SortingArgumentException, InvalidColumnException { Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, CommentMyResponseDto.class); PagedResponseDto comments = retrieveMyCommentsUseCase.retrieveMyComments(pageable); diff --git a/src/main/java/page/clab/api/domain/community/comment/adapter/out/persistence/CommentJpaEntity.java b/src/main/java/page/clab/api/domain/community/comment/adapter/out/persistence/CommentJpaEntity.java index 46c8b0a55..f3211bb0d 100644 --- a/src/main/java/page/clab/api/domain/community/comment/adapter/out/persistence/CommentJpaEntity.java +++ b/src/main/java/page/clab/api/domain/community/comment/adapter/out/persistence/CommentJpaEntity.java @@ -12,6 +12,8 @@ import jakarta.persistence.OneToMany; import jakarta.persistence.Table; import jakarta.validation.constraints.Size; +import java.util.ArrayList; +import java.util.List; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -21,9 +23,6 @@ import org.hibernate.annotations.SQLDelete; import page.clab.api.global.common.domain.BaseEntity; -import java.util.ArrayList; -import java.util.List; - @Entity @Getter @Setter diff --git a/src/main/java/page/clab/api/domain/community/comment/adapter/out/persistence/CommentLikePersistenceAdapter.java b/src/main/java/page/clab/api/domain/community/comment/adapter/out/persistence/CommentLikePersistenceAdapter.java index 67e5ace4c..3dd6e6ed1 100644 --- a/src/main/java/page/clab/api/domain/community/comment/adapter/out/persistence/CommentLikePersistenceAdapter.java +++ b/src/main/java/page/clab/api/domain/community/comment/adapter/out/persistence/CommentLikePersistenceAdapter.java @@ -1,5 +1,6 @@ package page.clab.api.domain.community.comment.adapter.out.persistence; +import java.util.Optional; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; import page.clab.api.domain.community.comment.application.port.out.RegisterCommentLikePort; @@ -7,14 +8,12 @@ import page.clab.api.domain.community.comment.application.port.out.RetrieveCommentLikePort; import page.clab.api.domain.community.comment.domain.CommentLike; -import java.util.Optional; - @Component @RequiredArgsConstructor public class CommentLikePersistenceAdapter implements - RegisterCommentLikePort, - RemoveCommentLikePort, - RetrieveCommentLikePort { + RegisterCommentLikePort, + RemoveCommentLikePort, + RetrieveCommentLikePort { private final CommentLikeRepository commentLikeRepository; private final CommentLikeMapper commentLikeMapper; @@ -34,6 +33,6 @@ public void delete(CommentLike commentLike) { @Override public Optional findByCommentIdAndMemberId(Long commentId, String memberId) { return commentLikeRepository.findByCommentIdAndMemberId(commentId, memberId) - .map(commentLikeMapper::toDomain); + .map(commentLikeMapper::toDomain); } } diff --git a/src/main/java/page/clab/api/domain/community/comment/adapter/out/persistence/CommentLikeRepository.java b/src/main/java/page/clab/api/domain/community/comment/adapter/out/persistence/CommentLikeRepository.java index bbfb37918..7fa6ba541 100644 --- a/src/main/java/page/clab/api/domain/community/comment/adapter/out/persistence/CommentLikeRepository.java +++ b/src/main/java/page/clab/api/domain/community/comment/adapter/out/persistence/CommentLikeRepository.java @@ -1,12 +1,11 @@ package page.clab.api.domain.community.comment.adapter.out.persistence; import jakarta.persistence.LockModeType; +import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Lock; import org.springframework.stereotype.Repository; -import java.util.Optional; - @Repository public interface CommentLikeRepository extends JpaRepository { diff --git a/src/main/java/page/clab/api/domain/community/comment/adapter/out/persistence/CommentMapper.java b/src/main/java/page/clab/api/domain/community/comment/adapter/out/persistence/CommentMapper.java index ec26beffa..c10072b0d 100644 --- a/src/main/java/page/clab/api/domain/community/comment/adapter/out/persistence/CommentMapper.java +++ b/src/main/java/page/clab/api/domain/community/comment/adapter/out/persistence/CommentMapper.java @@ -1,11 +1,10 @@ package page.clab.api.domain.community.comment.adapter.out.persistence; -import org.springframework.stereotype.Component; -import page.clab.api.domain.community.comment.domain.Comment; - import java.util.ArrayList; import java.util.HashMap; import java.util.Map; +import org.springframework.stereotype.Component; +import page.clab.api.domain.community.comment.domain.Comment; @Component public class CommentMapper { @@ -16,24 +15,26 @@ public CommentJpaEntity toEntity(Comment comment) { } private CommentJpaEntity toEntity(Comment comment, Map mappedEntities) { - if (comment == null) return null; + if (comment == null) { + return null; + } if (mappedEntities.containsKey(comment.getId())) { return mappedEntities.get(comment.getId()); } CommentJpaEntity parentEntity = toEntity(comment.getParent(), mappedEntities); CommentJpaEntity entity = CommentJpaEntity.builder() - .id(comment.getId()) - .boardId(comment.getBoardId()) - .writerId(comment.getWriterId()) - .nickname(comment.getNickname()) - .content(comment.getContent()) - .parent(parentEntity) - .children(new ArrayList<>()) - .wantAnonymous(comment.isWantAnonymous()) - .likes(comment.getLikes()) - .isDeleted(comment.getIsDeleted()) - .build(); + .id(comment.getId()) + .boardId(comment.getBoardId()) + .writerId(comment.getWriterId()) + .nickname(comment.getNickname()) + .content(comment.getContent()) + .parent(parentEntity) + .children(new ArrayList<>()) + .wantAnonymous(comment.isWantAnonymous()) + .likes(comment.getLikes()) + .isDeleted(comment.getIsDeleted()) + .build(); mappedEntities.put(comment.getId(), entity); for (Comment child : comment.getChildren()) { @@ -48,25 +49,27 @@ public Comment toDomain(CommentJpaEntity entity) { } private Comment toDomain(CommentJpaEntity entity, Map mappedDomains) { - if (entity == null) return null; + if (entity == null) { + return null; + } if (mappedDomains.containsKey(entity.getId())) { return mappedDomains.get(entity.getId()); } Comment parentDomain = toDomain(entity.getParent(), mappedDomains); Comment domain = Comment.builder() - .id(entity.getId()) - .boardId(entity.getBoardId()) - .writerId(entity.getWriterId()) - .nickname(entity.getNickname()) - .content(entity.getContent()) - .parent(parentDomain) - .children(new ArrayList<>()) - .wantAnonymous(entity.isWantAnonymous()) - .likes(entity.getLikes()) - .isDeleted(entity.getIsDeleted()) - .createdAt(entity.getCreatedAt()) - .build(); + .id(entity.getId()) + .boardId(entity.getBoardId()) + .writerId(entity.getWriterId()) + .nickname(entity.getNickname()) + .content(entity.getContent()) + .parent(parentDomain) + .children(new ArrayList<>()) + .wantAnonymous(entity.isWantAnonymous()) + .likes(entity.getLikes()) + .isDeleted(entity.getIsDeleted()) + .createdAt(entity.getCreatedAt()) + .build(); mappedDomains.put(entity.getId(), domain); for (CommentJpaEntity child : entity.getChildren()) { diff --git a/src/main/java/page/clab/api/domain/community/comment/adapter/out/persistence/CommentPersistenceAdapter.java b/src/main/java/page/clab/api/domain/community/comment/adapter/out/persistence/CommentPersistenceAdapter.java index 8e4e41b67..bb417fe99 100644 --- a/src/main/java/page/clab/api/domain/community/comment/adapter/out/persistence/CommentPersistenceAdapter.java +++ b/src/main/java/page/clab/api/domain/community/comment/adapter/out/persistence/CommentPersistenceAdapter.java @@ -1,5 +1,7 @@ package page.clab.api.domain.community.comment.adapter.out.persistence; +import java.util.List; +import java.util.Optional; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -9,14 +11,11 @@ import page.clab.api.domain.community.comment.domain.Comment; import page.clab.api.global.exception.NotFoundException; -import java.util.List; -import java.util.Optional; - @Component @RequiredArgsConstructor public class CommentPersistenceAdapter implements - RegisterCommentPort, - RetrieveCommentPort { + RegisterCommentPort, + RetrieveCommentPort { private final CommentRepository commentRepository; private final CommentMapper commentMapper; @@ -31,40 +30,40 @@ public Comment save(Comment comment) { @Override public void saveAll(List comments) { List entities = comments.stream() - .map(commentMapper::toEntity) - .toList(); + .map(commentMapper::toEntity) + .toList(); commentRepository.saveAll(entities); } @Override public Optional findById(Long commentId) { return commentRepository.findById(commentId) - .map(commentMapper::toDomain); + .map(commentMapper::toDomain); } @Override public Comment getById(Long commentId) { return commentRepository.findById(commentId) - .map(commentMapper::toDomain) - .orElseThrow(() -> new NotFoundException("[Comment] id: " + commentId + "에 해당하는 댓글이 존재하지 않습니다.")); + .map(commentMapper::toDomain) + .orElseThrow(() -> new NotFoundException("[Comment] id: " + commentId + "에 해당하는 댓글이 존재하지 않습니다.")); } @Override public Page findAllByIsDeletedTrueAndBoardId(Long boardId, Pageable pageable) { return commentRepository.findAllByIsDeletedTrueAndBoardId(boardId, pageable) - .map(commentMapper::toDomain); + .map(commentMapper::toDomain); } @Override public Page findAllByBoardIdAndParentIsNull(Long boardId, Pageable pageable) { return commentRepository.findAllByBoardIdAndParentIsNull(boardId, pageable) - .map(commentMapper::toDomain); + .map(commentMapper::toDomain); } @Override public Page findAllByWriterId(String memberId, Pageable pageable) { return commentRepository.findAllByWriterId(memberId, pageable) - .map(commentMapper::toDomain); + .map(commentMapper::toDomain); } @Override @@ -75,8 +74,8 @@ public Long countByBoardId(Long boardId) { @Override public List findByBoardId(Long boardId) { return commentRepository.findByBoardId(boardId) - .stream() - .map(commentMapper::toDomain) - .toList(); + .stream() + .map(commentMapper::toDomain) + .toList(); } } diff --git a/src/main/java/page/clab/api/domain/community/comment/adapter/out/persistence/CommentRepository.java b/src/main/java/page/clab/api/domain/community/comment/adapter/out/persistence/CommentRepository.java index ef222d95b..9fad2194d 100644 --- a/src/main/java/page/clab/api/domain/community/comment/adapter/out/persistence/CommentRepository.java +++ b/src/main/java/page/clab/api/domain/community/comment/adapter/out/persistence/CommentRepository.java @@ -1,14 +1,13 @@ package page.clab.api.domain.community.comment.adapter.out.persistence; +import java.util.List; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; -import java.util.List; - @Repository public interface CommentRepository extends JpaRepository { diff --git a/src/main/java/page/clab/api/domain/community/comment/application/dto/mapper/CommentDtoMapper.java b/src/main/java/page/clab/api/domain/community/comment/application/dto/mapper/CommentDtoMapper.java index 6b4912af3..fbe2196f4 100644 --- a/src/main/java/page/clab/api/domain/community/comment/application/dto/mapper/CommentDtoMapper.java +++ b/src/main/java/page/clab/api/domain/community/comment/application/dto/mapper/CommentDtoMapper.java @@ -1,5 +1,6 @@ package page.clab.api.domain.community.comment.application.dto.mapper; +import java.util.List; import org.springframework.stereotype.Component; import page.clab.api.domain.community.board.application.dto.shared.BoardCommentInfoDto; import page.clab.api.domain.community.comment.application.dto.request.CommentRequestDto; @@ -10,77 +11,77 @@ import page.clab.api.domain.memberManagement.member.application.dto.shared.MemberDetailedInfoDto; import page.clab.api.global.util.RandomNicknameUtil; -import java.util.List; - @Component public class CommentDtoMapper { public Comment fromDto(CommentRequestDto requestDto, Long boardId, String writerId, Comment parent) { return Comment.builder() - .boardId(boardId) - .writerId(writerId) - .nickname(RandomNicknameUtil.makeRandomNickname()) - .content(requestDto.getContent()) - .parent(parent) - .wantAnonymous(requestDto.isWantAnonymous()) - .likes(0L) - .isDeleted(false) - .build(); + .boardId(boardId) + .writerId(writerId) + .nickname(RandomNicknameUtil.makeRandomNickname()) + .content(requestDto.getContent()) + .parent(parent) + .wantAnonymous(requestDto.isWantAnonymous()) + .likes(0L) + .isDeleted(false) + .build(); } - public CommentMyResponseDto toDto(Comment comment, MemberDetailedInfoDto memberInfo, BoardCommentInfoDto boardInfo, boolean hasLikeByMe) { + public CommentMyResponseDto toDto(Comment comment, MemberDetailedInfoDto memberInfo, BoardCommentInfoDto boardInfo, + boolean hasLikeByMe) { if (comment.getBoardId() == null || comment.getIsDeleted()) { return null; } return CommentMyResponseDto.builder() - .id(comment.getId()) - .boardId(boardInfo.getBoardId()) - .boardCategory(boardInfo.getCategory().getKey()) - .writer(comment.isWantAnonymous() ? comment.getNickname() : memberInfo.getMemberName()) - .writerImageUrl(comment.isWantAnonymous() ? null : memberInfo.getImageUrl()) - .content(comment.getContent()) - .likes(comment.getLikes()) - .hasLikeByMe(hasLikeByMe) - .createdAt(comment.getCreatedAt()) - .build(); + .id(comment.getId()) + .boardId(boardInfo.getBoardId()) + .boardCategory(boardInfo.getCategory().getKey()) + .writer(comment.isWantAnonymous() ? comment.getNickname() : memberInfo.getMemberName()) + .writerImageUrl(comment.isWantAnonymous() ? null : memberInfo.getImageUrl()) + .content(comment.getContent()) + .likes(comment.getLikes()) + .hasLikeByMe(hasLikeByMe) + .createdAt(comment.getCreatedAt()) + .build(); } - public CommentResponseDto toDto(Comment comment, MemberDetailedInfoDto memberInfo, boolean isOwner, List children) { + public CommentResponseDto toDto(Comment comment, MemberDetailedInfoDto memberInfo, boolean isOwner, + List children) { if (comment.getIsDeleted()) { return CommentResponseDto.builder() - .id(comment.getId()) - .isDeleted(true) - .children(children) - .likes(comment.getLikes()) - .createdAt(comment.getCreatedAt()) - .build(); - } - return CommentResponseDto.builder() .id(comment.getId()) - .isDeleted(false) - .writerId(comment.isWantAnonymous() ? null : comment.getWriterId()) - .writerName(comment.isWantAnonymous() ? comment.getNickname() : memberInfo.getMemberName()) - .writerImageUrl(comment.isWantAnonymous() ? null : memberInfo.getImageUrl()) - .writerRoleLevel(comment.isWantAnonymous() ? null : memberInfo.getRoleLevel()) - .content(comment.getContent()) + .isDeleted(true) .children(children) .likes(comment.getLikes()) - .isOwner(isOwner) .createdAt(comment.getCreatedAt()) .build(); + } + return CommentResponseDto.builder() + .id(comment.getId()) + .isDeleted(false) + .writerId(comment.isWantAnonymous() ? null : comment.getWriterId()) + .writerName(comment.isWantAnonymous() ? comment.getNickname() : memberInfo.getMemberName()) + .writerImageUrl(comment.isWantAnonymous() ? null : memberInfo.getImageUrl()) + .writerRoleLevel(comment.isWantAnonymous() ? null : memberInfo.getRoleLevel()) + .content(comment.getContent()) + .children(children) + .likes(comment.getLikes()) + .isOwner(isOwner) + .createdAt(comment.getCreatedAt()) + .build(); } public DeletedCommentResponseDto toDto(Comment comment, MemberDetailedInfoDto memberInfo, boolean isOwner) { return DeletedCommentResponseDto.builder() - .id(comment.getId()) - .writerId(comment.isWantAnonymous() ? null : memberInfo.getMemberId()) - .writerName(comment.isWantAnonymous() ? comment.getNickname() : memberInfo.getMemberName()) - .writerImageUrl(comment.isWantAnonymous() ? null : memberInfo.getImageUrl()) - .writerRoleLevel(comment.isWantAnonymous() ? null : memberInfo.getRoleLevel()) - .content(comment.getContent()) - .likes(comment.getLikes()) - .isOwner(isOwner) - .createdAt(comment.getCreatedAt()) - .build(); + .id(comment.getId()) + .writerId(comment.isWantAnonymous() ? null : memberInfo.getMemberId()) + .writerName(comment.isWantAnonymous() ? comment.getNickname() : memberInfo.getMemberName()) + .writerImageUrl(comment.isWantAnonymous() ? null : memberInfo.getImageUrl()) + .writerRoleLevel(comment.isWantAnonymous() ? null : memberInfo.getRoleLevel()) + .content(comment.getContent()) + .likes(comment.getLikes()) + .isOwner(isOwner) + .createdAt(comment.getCreatedAt()) + .build(); } } diff --git a/src/main/java/page/clab/api/domain/community/comment/application/dto/response/CommentMyResponseDto.java b/src/main/java/page/clab/api/domain/community/comment/application/dto/response/CommentMyResponseDto.java index 584f76725..b238394f8 100644 --- a/src/main/java/page/clab/api/domain/community/comment/application/dto/response/CommentMyResponseDto.java +++ b/src/main/java/page/clab/api/domain/community/comment/application/dto/response/CommentMyResponseDto.java @@ -1,10 +1,9 @@ package page.clab.api.domain.community.comment.application.dto.response; +import java.time.LocalDateTime; import lombok.Builder; import lombok.Getter; -import java.time.LocalDateTime; - @Getter @Builder public class CommentMyResponseDto { diff --git a/src/main/java/page/clab/api/domain/community/comment/application/dto/response/CommentResponseDto.java b/src/main/java/page/clab/api/domain/community/comment/application/dto/response/CommentResponseDto.java index a2c1b2034..d2c1d3a83 100644 --- a/src/main/java/page/clab/api/domain/community/comment/application/dto/response/CommentResponseDto.java +++ b/src/main/java/page/clab/api/domain/community/comment/application/dto/response/CommentResponseDto.java @@ -1,13 +1,12 @@ package page.clab.api.domain.community.comment.application.dto.response; import com.fasterxml.jackson.annotation.JsonProperty; +import java.time.LocalDateTime; +import java.util.List; import lombok.Builder; import lombok.Getter; import lombok.Setter; -import java.time.LocalDateTime; -import java.util.List; - @Getter @Setter @Builder diff --git a/src/main/java/page/clab/api/domain/community/comment/application/dto/response/DeletedCommentResponseDto.java b/src/main/java/page/clab/api/domain/community/comment/application/dto/response/DeletedCommentResponseDto.java index 536c9b021..d07e7d824 100644 --- a/src/main/java/page/clab/api/domain/community/comment/application/dto/response/DeletedCommentResponseDto.java +++ b/src/main/java/page/clab/api/domain/community/comment/application/dto/response/DeletedCommentResponseDto.java @@ -1,12 +1,11 @@ package page.clab.api.domain.community.comment.application.dto.response; import com.fasterxml.jackson.annotation.JsonProperty; +import java.time.LocalDateTime; import lombok.Builder; import lombok.Getter; import lombok.Setter; -import java.time.LocalDateTime; - @Getter @Setter @Builder diff --git a/src/main/java/page/clab/api/domain/community/comment/application/event/CommentEventProcessor.java b/src/main/java/page/clab/api/domain/community/comment/application/event/CommentEventProcessor.java index 5b24053d4..9d565a9c4 100644 --- a/src/main/java/page/clab/api/domain/community/comment/application/event/CommentEventProcessor.java +++ b/src/main/java/page/clab/api/domain/community/comment/application/event/CommentEventProcessor.java @@ -1,6 +1,7 @@ package page.clab.api.domain.community.comment.application.event; import jakarta.annotation.PostConstruct; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; import page.clab.api.domain.community.board.application.event.BoardEventProcessor; @@ -9,8 +10,6 @@ import page.clab.api.domain.community.comment.application.port.out.RetrieveCommentPort; import page.clab.api.domain.community.comment.domain.Comment; -import java.util.List; - @Component @RequiredArgsConstructor public class CommentEventProcessor implements BoardEventProcessor { diff --git a/src/main/java/page/clab/api/domain/community/comment/application/port/in/RegisterCommentUseCase.java b/src/main/java/page/clab/api/domain/community/comment/application/port/in/RegisterCommentUseCase.java index 0ee9c7758..35c061e4f 100644 --- a/src/main/java/page/clab/api/domain/community/comment/application/port/in/RegisterCommentUseCase.java +++ b/src/main/java/page/clab/api/domain/community/comment/application/port/in/RegisterCommentUseCase.java @@ -3,5 +3,6 @@ import page.clab.api.domain.community.comment.application.dto.request.CommentRequestDto; public interface RegisterCommentUseCase { + Long registerComment(Long parentId, Long boardId, CommentRequestDto requestDto); } diff --git a/src/main/java/page/clab/api/domain/community/comment/application/port/in/RemoveCommentUseCase.java b/src/main/java/page/clab/api/domain/community/comment/application/port/in/RemoveCommentUseCase.java index 9dc1dcd06..fd8563dd5 100644 --- a/src/main/java/page/clab/api/domain/community/comment/application/port/in/RemoveCommentUseCase.java +++ b/src/main/java/page/clab/api/domain/community/comment/application/port/in/RemoveCommentUseCase.java @@ -3,5 +3,6 @@ import page.clab.api.global.exception.PermissionDeniedException; public interface RemoveCommentUseCase { + Long removeComment(Long commentId) throws PermissionDeniedException; } diff --git a/src/main/java/page/clab/api/domain/community/comment/application/port/in/RetrieveDeletedCommentsUseCase.java b/src/main/java/page/clab/api/domain/community/comment/application/port/in/RetrieveDeletedCommentsUseCase.java index 9d5b0db4e..5f13e2fa4 100644 --- a/src/main/java/page/clab/api/domain/community/comment/application/port/in/RetrieveDeletedCommentsUseCase.java +++ b/src/main/java/page/clab/api/domain/community/comment/application/port/in/RetrieveDeletedCommentsUseCase.java @@ -5,5 +5,6 @@ import page.clab.api.global.common.dto.PagedResponseDto; public interface RetrieveDeletedCommentsUseCase { + PagedResponseDto retrieveDeletedComments(Long boardId, Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/community/comment/application/port/in/RetrieveMyCommentsUseCase.java b/src/main/java/page/clab/api/domain/community/comment/application/port/in/RetrieveMyCommentsUseCase.java index bc2aa7cac..9ee922a8e 100644 --- a/src/main/java/page/clab/api/domain/community/comment/application/port/in/RetrieveMyCommentsUseCase.java +++ b/src/main/java/page/clab/api/domain/community/comment/application/port/in/RetrieveMyCommentsUseCase.java @@ -5,5 +5,6 @@ import page.clab.api.global.common.dto.PagedResponseDto; public interface RetrieveMyCommentsUseCase { + PagedResponseDto retrieveMyComments(Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/community/comment/application/port/in/ToggleCommentLikeUseCase.java b/src/main/java/page/clab/api/domain/community/comment/application/port/in/ToggleCommentLikeUseCase.java index 387c2e94b..d39e73af1 100644 --- a/src/main/java/page/clab/api/domain/community/comment/application/port/in/ToggleCommentLikeUseCase.java +++ b/src/main/java/page/clab/api/domain/community/comment/application/port/in/ToggleCommentLikeUseCase.java @@ -1,5 +1,6 @@ package page.clab.api.domain.community.comment.application.port.in; public interface ToggleCommentLikeUseCase { + Long toggleLikeStatus(Long commentId); } diff --git a/src/main/java/page/clab/api/domain/community/comment/application/port/in/UpdateCommentUseCase.java b/src/main/java/page/clab/api/domain/community/comment/application/port/in/UpdateCommentUseCase.java index 3835f5a4c..fda4ccd33 100644 --- a/src/main/java/page/clab/api/domain/community/comment/application/port/in/UpdateCommentUseCase.java +++ b/src/main/java/page/clab/api/domain/community/comment/application/port/in/UpdateCommentUseCase.java @@ -4,5 +4,6 @@ import page.clab.api.global.exception.PermissionDeniedException; public interface UpdateCommentUseCase { + Long updateComment(Long commentId, CommentUpdateRequestDto requestDto) throws PermissionDeniedException; } diff --git a/src/main/java/page/clab/api/domain/community/comment/application/port/out/RegisterCommentLikePort.java b/src/main/java/page/clab/api/domain/community/comment/application/port/out/RegisterCommentLikePort.java index 766a0353d..a4f8b7fea 100644 --- a/src/main/java/page/clab/api/domain/community/comment/application/port/out/RegisterCommentLikePort.java +++ b/src/main/java/page/clab/api/domain/community/comment/application/port/out/RegisterCommentLikePort.java @@ -3,5 +3,6 @@ import page.clab.api.domain.community.comment.domain.CommentLike; public interface RegisterCommentLikePort { + CommentLike save(CommentLike commentLike); } diff --git a/src/main/java/page/clab/api/domain/community/comment/application/port/out/RegisterCommentPort.java b/src/main/java/page/clab/api/domain/community/comment/application/port/out/RegisterCommentPort.java index 3205295b1..30bcba159 100644 --- a/src/main/java/page/clab/api/domain/community/comment/application/port/out/RegisterCommentPort.java +++ b/src/main/java/page/clab/api/domain/community/comment/application/port/out/RegisterCommentPort.java @@ -1,8 +1,7 @@ package page.clab.api.domain.community.comment.application.port.out; -import page.clab.api.domain.community.comment.domain.Comment; - import java.util.List; +import page.clab.api.domain.community.comment.domain.Comment; public interface RegisterCommentPort { diff --git a/src/main/java/page/clab/api/domain/community/comment/application/port/out/RemoveCommentLikePort.java b/src/main/java/page/clab/api/domain/community/comment/application/port/out/RemoveCommentLikePort.java index 91fd7df79..47f651983 100644 --- a/src/main/java/page/clab/api/domain/community/comment/application/port/out/RemoveCommentLikePort.java +++ b/src/main/java/page/clab/api/domain/community/comment/application/port/out/RemoveCommentLikePort.java @@ -3,5 +3,6 @@ import page.clab.api.domain.community.comment.domain.CommentLike; public interface RemoveCommentLikePort { + void delete(CommentLike commentLike); } diff --git a/src/main/java/page/clab/api/domain/community/comment/application/port/out/RetrieveCommentLikePort.java b/src/main/java/page/clab/api/domain/community/comment/application/port/out/RetrieveCommentLikePort.java index b706b38c6..cfd779b3b 100644 --- a/src/main/java/page/clab/api/domain/community/comment/application/port/out/RetrieveCommentLikePort.java +++ b/src/main/java/page/clab/api/domain/community/comment/application/port/out/RetrieveCommentLikePort.java @@ -1,9 +1,9 @@ package page.clab.api.domain.community.comment.application.port.out; -import page.clab.api.domain.community.comment.domain.CommentLike; - import java.util.Optional; +import page.clab.api.domain.community.comment.domain.CommentLike; public interface RetrieveCommentLikePort { + Optional findByCommentIdAndMemberId(Long commentId, String memberId); } diff --git a/src/main/java/page/clab/api/domain/community/comment/application/port/out/RetrieveCommentPort.java b/src/main/java/page/clab/api/domain/community/comment/application/port/out/RetrieveCommentPort.java index c649f55d1..24ac56169 100644 --- a/src/main/java/page/clab/api/domain/community/comment/application/port/out/RetrieveCommentPort.java +++ b/src/main/java/page/clab/api/domain/community/comment/application/port/out/RetrieveCommentPort.java @@ -1,12 +1,11 @@ package page.clab.api.domain.community.comment.application.port.out; +import java.util.List; +import java.util.Optional; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import page.clab.api.domain.community.comment.domain.Comment; -import java.util.List; -import java.util.Optional; - public interface RetrieveCommentPort { Optional findById(Long commentId); diff --git a/src/main/java/page/clab/api/domain/community/comment/application/service/CommentLikeToggleService.java b/src/main/java/page/clab/api/domain/community/comment/application/service/CommentLikeToggleService.java index 58f1877ee..32b4edaed 100644 --- a/src/main/java/page/clab/api/domain/community/comment/application/service/CommentLikeToggleService.java +++ b/src/main/java/page/clab/api/domain/community/comment/application/service/CommentLikeToggleService.java @@ -28,8 +28,7 @@ public class CommentLikeToggleService implements ToggleCommentLikeUseCase { * 댓글의 좋아요 상태를 토글합니다. * *

현재 사용자가 해당 댓글에 좋아요를 누른 상태인 경우 좋아요를 취소하고, - * 그렇지 않은 경우 새롭게 좋아요를 추가합니다. - * 댓글의 좋아요 수를 업데이트한 후 해당 수를 반환합니다.

+ * 그렇지 않은 경우 새롭게 좋아요를 추가합니다. 댓글의 좋아요 수를 업데이트한 후 해당 수를 반환합니다.

* * @param commentId 좋아요를 토글할 댓글의 ID * @return 업데이트된 댓글의 좋아요 수 @@ -40,16 +39,16 @@ public Long toggleLikeStatus(Long commentId) { String currentMemberId = externalRetrieveMemberUseCase.getCurrentMemberId(); Comment comment = externalRetrieveCommentUseCase.getById(commentId); return retrieveCommentLikePort.findByCommentIdAndMemberId(comment.getId(), currentMemberId) - .map(commentLike -> { - removeCommentLikePort.delete(commentLike); - comment.decrementLikes(); - return externalRegisterCommentUseCase.save(comment).getLikes(); - }) - .orElseGet(() -> { - CommentLike newLike = CommentLike.create(currentMemberId, comment.getId()); - registerCommentLikePort.save(newLike); - comment.incrementLikes(); - return externalRegisterCommentUseCase.save(comment).getLikes(); - }); + .map(commentLike -> { + removeCommentLikePort.delete(commentLike); + comment.decrementLikes(); + return externalRegisterCommentUseCase.save(comment).getLikes(); + }) + .orElseGet(() -> { + CommentLike newLike = CommentLike.create(currentMemberId, comment.getId()); + registerCommentLikePort.save(newLike); + comment.incrementLikes(); + return externalRegisterCommentUseCase.save(comment).getLikes(); + }); } } diff --git a/src/main/java/page/clab/api/domain/community/comment/application/service/CommentRetrievalService.java b/src/main/java/page/clab/api/domain/community/comment/application/service/CommentRetrievalService.java index 1764c07ee..3c251ef53 100644 --- a/src/main/java/page/clab/api/domain/community/comment/application/service/CommentRetrievalService.java +++ b/src/main/java/page/clab/api/domain/community/comment/application/service/CommentRetrievalService.java @@ -1,5 +1,6 @@ package page.clab.api.domain.community.comment.application.service; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; @@ -15,8 +16,6 @@ import page.clab.api.external.memberManagement.member.application.port.ExternalRetrieveMemberUseCase; import page.clab.api.global.common.dto.PagedResponseDto; -import java.util.List; - @Service @RequiredArgsConstructor public class CommentRetrievalService implements RetrieveCommentUseCase { @@ -41,26 +40,28 @@ public PagedResponseDto getAllComments(Long boardId, Pageabl String currentMemberId = externalRetrieveMemberUseCase.getCurrentMemberId(); Page comments = retrieveCommentPort.findAllByBoardIdAndParentIsNull(boardId, pageable); List commentDtos = comments.stream() - .map(comment -> toCommentResponseDtoWithMemberInfo(comment, currentMemberId)) - .toList(); + .map(comment -> toCommentResponseDtoWithMemberInfo(comment, currentMemberId)) + .toList(); Long totalElements = retrieveCommentPort.countByBoardId(boardId); Page commentDtoPage = new PageImpl<>(commentDtos, pageable, comments.getTotalElements()); - return new PagedResponseDto<>(commentDtoPage, totalElements, getNumberOfCurrentPageComments(comments, commentDtos)); + return new PagedResponseDto<>(commentDtoPage, totalElements, + getNumberOfCurrentPageComments(comments, commentDtos)); } private CommentResponseDto toCommentResponseDtoWithMemberInfo(Comment comment, String currentMemberId) { - MemberDetailedInfoDto memberInfo = externalRetrieveMemberUseCase.getMemberDetailedInfoById(comment.getWriterId()); + MemberDetailedInfoDto memberInfo = externalRetrieveMemberUseCase.getMemberDetailedInfoById( + comment.getWriterId()); List childrenDtos = comment.getChildren().stream() - .map(child -> toCommentResponseDtoWithMemberInfo(child, currentMemberId)) - .toList(); + .map(child -> toCommentResponseDtoWithMemberInfo(child, currentMemberId)) + .toList(); boolean isOwner = comment.isOwner(currentMemberId); return mapper.toDto(comment, memberInfo, isOwner, childrenDtos); } private int getNumberOfCurrentPageComments(Page comments, List commentDtos) { return comments.getNumberOfElements() + - commentDtos.stream() - .mapToInt(comment -> comment.getChildren().size()) - .sum(); + commentDtos.stream() + .mapToInt(comment -> comment.getChildren().size()) + .sum(); } } diff --git a/src/main/java/page/clab/api/domain/community/comment/application/service/DeletedCommentsRetrievalService.java b/src/main/java/page/clab/api/domain/community/comment/application/service/DeletedCommentsRetrievalService.java index d2a3f6709..e66045764 100644 --- a/src/main/java/page/clab/api/domain/community/comment/application/service/DeletedCommentsRetrievalService.java +++ b/src/main/java/page/clab/api/domain/community/comment/application/service/DeletedCommentsRetrievalService.java @@ -1,5 +1,6 @@ package page.clab.api.domain.community.comment.application.service; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; @@ -15,8 +16,6 @@ import page.clab.api.external.memberManagement.member.application.port.ExternalRetrieveMemberUseCase; import page.clab.api.global.common.dto.PagedResponseDto; -import java.util.List; - @Service @RequiredArgsConstructor public class DeletedCommentsRetrievalService implements RetrieveDeletedCommentsUseCase { @@ -31,11 +30,12 @@ public PagedResponseDto retrieveDeletedComments(Long String currentMemberId = externalRetrieveMemberUseCase.getCurrentMemberId(); Page comments = retrieveCommentPort.findAllByIsDeletedTrueAndBoardId(boardId, pageable); List deletedCommentDtos = comments.stream() - .map(comment -> { - MemberDetailedInfoDto memberInfo = externalRetrieveMemberUseCase.getMemberDetailedInfoById(comment.getWriterId()); - return mapper.toDto(comment, memberInfo, comment.isOwner(currentMemberId)); - }) - .toList(); + .map(comment -> { + MemberDetailedInfoDto memberInfo = externalRetrieveMemberUseCase.getMemberDetailedInfoById( + comment.getWriterId()); + return mapper.toDto(comment, memberInfo, comment.isOwner(currentMemberId)); + }) + .toList(); return new PagedResponseDto<>(new PageImpl<>(deletedCommentDtos, pageable, comments.getTotalElements())); } } diff --git a/src/main/java/page/clab/api/domain/community/comment/application/service/MyCommentsRetrievalService.java b/src/main/java/page/clab/api/domain/community/comment/application/service/MyCommentsRetrievalService.java index fd383622e..1b6d41b48 100644 --- a/src/main/java/page/clab/api/domain/community/comment/application/service/MyCommentsRetrievalService.java +++ b/src/main/java/page/clab/api/domain/community/comment/application/service/MyCommentsRetrievalService.java @@ -1,5 +1,7 @@ package page.clab.api.domain.community.comment.application.service; +import java.util.List; +import java.util.Objects; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; @@ -17,9 +19,6 @@ import page.clab.api.external.memberManagement.member.application.port.ExternalRetrieveMemberUseCase; import page.clab.api.global.common.dto.PagedResponseDto; -import java.util.List; -import java.util.Objects; - @Service @RequiredArgsConstructor public class MyCommentsRetrievalService implements RetrieveMyCommentsUseCase { @@ -35,14 +34,15 @@ public PagedResponseDto retrieveMyComments(Pageable pageab String currentMemberId = externalRetrieveMemberUseCase.getCurrentMemberId(); Page comments = retrieveCommentPort.findAllByWriterId(currentMemberId, pageable); List dtos = comments.stream() - .map(this::toCommentMyResponseDto) - .filter(Objects::nonNull) - .toList(); + .map(this::toCommentMyResponseDto) + .filter(Objects::nonNull) + .toList(); return new PagedResponseDto<>(new PageImpl<>(dtos, pageable, comments.getTotalElements())); } private CommentMyResponseDto toCommentMyResponseDto(Comment comment) { - MemberDetailedInfoDto memberInfo = externalRetrieveMemberUseCase.getMemberDetailedInfoById(comment.getWriterId()); + MemberDetailedInfoDto memberInfo = externalRetrieveMemberUseCase.getMemberDetailedInfoById( + comment.getWriterId()); BoardCommentInfoDto boardInfo = externalRetrieveBoardUseCase.getBoardCommentInfoById(comment.getBoardId()); return mapper.toDto(comment, memberInfo, boardInfo, false); } diff --git a/src/main/java/page/clab/api/domain/community/comment/domain/Comment.java b/src/main/java/page/clab/api/domain/community/comment/domain/Comment.java index 97ce0b2b9..da54f1623 100644 --- a/src/main/java/page/clab/api/domain/community/comment/domain/Comment.java +++ b/src/main/java/page/clab/api/domain/community/comment/domain/Comment.java @@ -1,5 +1,9 @@ package page.clab.api.domain.community.comment.domain; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -10,11 +14,6 @@ import page.clab.api.domain.memberManagement.member.application.dto.shared.MemberDetailedInfoDto; import page.clab.api.global.exception.PermissionDeniedException; -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - @Getter @Setter @Builder diff --git a/src/main/java/page/clab/api/domain/community/comment/domain/CommentLike.java b/src/main/java/page/clab/api/domain/community/comment/domain/CommentLike.java index be07cdd41..8a9b7a8b4 100644 --- a/src/main/java/page/clab/api/domain/community/comment/domain/CommentLike.java +++ b/src/main/java/page/clab/api/domain/community/comment/domain/CommentLike.java @@ -20,8 +20,8 @@ public class CommentLike { public static CommentLike create(String memberId, Long commentId) { return CommentLike.builder() - .memberId(memberId) - .commentId(commentId) - .build(); + .memberId(memberId) + .commentId(commentId) + .build(); } } diff --git a/src/main/java/page/clab/api/domain/community/hashtag/adapter/in/web/HashtagRegisterController.java b/src/main/java/page/clab/api/domain/community/hashtag/adapter/in/web/HashtagRegisterController.java index cdd351242..c878d0cfa 100644 --- a/src/main/java/page/clab/api/domain/community/hashtag/adapter/in/web/HashtagRegisterController.java +++ b/src/main/java/page/clab/api/domain/community/hashtag/adapter/in/web/HashtagRegisterController.java @@ -27,7 +27,7 @@ public class HashtagRegisterController { @PreAuthorize("hasRole('ADMIN')") @PostMapping("") public ApiResponse> registerHashtag( - @Valid @RequestBody HashtagRequestDto requestDto + @Valid @RequestBody HashtagRequestDto requestDto ) { List hashTags = registerHashtagUseCase.registerHashtag(requestDto); return ApiResponse.success(hashTags); diff --git a/src/main/java/page/clab/api/domain/community/hashtag/adapter/out/persistence/HashtagJpaEntity.java b/src/main/java/page/clab/api/domain/community/hashtag/adapter/out/persistence/HashtagJpaEntity.java index b8e6d181c..62721ab11 100644 --- a/src/main/java/page/clab/api/domain/community/hashtag/adapter/out/persistence/HashtagJpaEntity.java +++ b/src/main/java/page/clab/api/domain/community/hashtag/adapter/out/persistence/HashtagJpaEntity.java @@ -5,7 +5,6 @@ import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; -import jakarta.persistence.Index; import jakarta.persistence.Table; import lombok.AccessLevel; import lombok.AllArgsConstructor; diff --git a/src/main/java/page/clab/api/domain/community/hashtag/adapter/out/persistence/HashtagPersistenceAdapter.java b/src/main/java/page/clab/api/domain/community/hashtag/adapter/out/persistence/HashtagPersistenceAdapter.java index 7d199e240..a4f0b9538 100644 --- a/src/main/java/page/clab/api/domain/community/hashtag/adapter/out/persistence/HashtagPersistenceAdapter.java +++ b/src/main/java/page/clab/api/domain/community/hashtag/adapter/out/persistence/HashtagPersistenceAdapter.java @@ -11,8 +11,8 @@ @Component @RequiredArgsConstructor public class HashtagPersistenceAdapter implements - RegisterHashtagPort, - RetrieveHashtagPort { + RegisterHashtagPort, + RetrieveHashtagPort { private final HashtagRepository hashtagRepository; private final HashtagMapper hashtagMapper; @@ -41,8 +41,8 @@ public Hashtag getByName(String name) { @Override public Hashtag getById(Long id) { return hashtagRepository.findById(id) - .map(hashtagMapper::toDomain) - .orElseThrow(() -> new NotFoundException("[Hashtag] id: " + id + "에 해당하는 해시태그가 존재하지 않습니다.")); + .map(hashtagMapper::toDomain) + .orElseThrow(() -> new NotFoundException("[Hashtag] id: " + id + "에 해당하는 해시태그가 존재하지 않습니다.")); } @@ -54,7 +54,7 @@ public Boolean existsById(Long id) { @Override public List findAllByOrderById() { return hashtagRepository.findAllByOrderById() - .stream().map(hashtagMapper::toDomain) - .toList(); + .stream().map(hashtagMapper::toDomain) + .toList(); } } diff --git a/src/main/java/page/clab/api/domain/community/hashtag/application/dto/mapper/HashtagDtoMapper.java b/src/main/java/page/clab/api/domain/community/hashtag/application/dto/mapper/HashtagDtoMapper.java index 560bce231..e9797bba7 100644 --- a/src/main/java/page/clab/api/domain/community/hashtag/application/dto/mapper/HashtagDtoMapper.java +++ b/src/main/java/page/clab/api/domain/community/hashtag/application/dto/mapper/HashtagDtoMapper.java @@ -11,17 +11,17 @@ public class HashtagDtoMapper { public Hashtag of(String name) { return Hashtag.builder() - .name(name) - .boardUsage(0L) - .isDeleted(false) - .build(); + .name(name) + .boardUsage(0L) + .isDeleted(false) + .build(); } public HashtagResponseDto toDto(Hashtag hashtag) { return HashtagResponseDto.builder() - .id(hashtag.getId()) - .name(hashtag.getName()) - .boardUsageCount(hashtag.getBoardUsage()) - .build(); + .id(hashtag.getId()) + .name(hashtag.getName()) + .boardUsageCount(hashtag.getBoardUsage()) + .build(); } } diff --git a/src/main/java/page/clab/api/domain/community/hashtag/application/port/in/RegisterHashtagUseCase.java b/src/main/java/page/clab/api/domain/community/hashtag/application/port/in/RegisterHashtagUseCase.java index ae424bb7e..508a49b73 100644 --- a/src/main/java/page/clab/api/domain/community/hashtag/application/port/in/RegisterHashtagUseCase.java +++ b/src/main/java/page/clab/api/domain/community/hashtag/application/port/in/RegisterHashtagUseCase.java @@ -5,5 +5,6 @@ import page.clab.api.domain.community.hashtag.application.dto.response.HashtagResponseDto; public interface RegisterHashtagUseCase { + List registerHashtag(HashtagRequestDto requestDto); } diff --git a/src/main/java/page/clab/api/domain/community/hashtag/application/port/out/RegisterHashtagPort.java b/src/main/java/page/clab/api/domain/community/hashtag/application/port/out/RegisterHashtagPort.java index 0e52e1146..2f0f5678a 100644 --- a/src/main/java/page/clab/api/domain/community/hashtag/application/port/out/RegisterHashtagPort.java +++ b/src/main/java/page/clab/api/domain/community/hashtag/application/port/out/RegisterHashtagPort.java @@ -3,5 +3,6 @@ import page.clab.api.domain.community.hashtag.domain.Hashtag; public interface RegisterHashtagPort { + Hashtag save(Hashtag hashtag); } diff --git a/src/main/java/page/clab/api/domain/community/hashtag/application/service/HashtagRetrieveService.java b/src/main/java/page/clab/api/domain/community/hashtag/application/service/HashtagRetrieveService.java index 7a53e1a20..4b6e2e456 100644 --- a/src/main/java/page/clab/api/domain/community/hashtag/application/service/HashtagRetrieveService.java +++ b/src/main/java/page/clab/api/domain/community/hashtag/application/service/HashtagRetrieveService.java @@ -3,7 +3,6 @@ import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; -import page.clab.api.domain.community.hashtag.adapter.out.persistence.HashtagMapper; import page.clab.api.domain.community.hashtag.application.dto.mapper.HashtagDtoMapper; import page.clab.api.domain.community.hashtag.application.dto.response.HashtagResponseDto; import page.clab.api.domain.community.hashtag.application.port.in.RetrieveHashtagUseCase; @@ -31,7 +30,7 @@ public Hashtag getByName(String name) { public List retrieveHashtagWithUsedBoardCount() { List hashtags = retrieveHashtagPort.findAllByOrderById(); return hashtags.stream() - .map(mapper::toDto) - .toList(); + .map(mapper::toDto) + .toList(); } } diff --git a/src/main/java/page/clab/api/domain/community/hashtag/domain/Hashtag.java b/src/main/java/page/clab/api/domain/community/hashtag/domain/Hashtag.java index 9284fcd1e..a320679ad 100644 --- a/src/main/java/page/clab/api/domain/community/hashtag/domain/Hashtag.java +++ b/src/main/java/page/clab/api/domain/community/hashtag/domain/Hashtag.java @@ -1,6 +1,5 @@ package page.clab.api.domain.community.hashtag.domain; -import jakarta.persistence.Column; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/src/main/java/page/clab/api/domain/community/jobPosting/adapter/in/web/JobPostingDetailsRetrievalController.java b/src/main/java/page/clab/api/domain/community/jobPosting/adapter/in/web/JobPostingDetailsRetrievalController.java index 5e6e9047d..b2ab1177f 100644 --- a/src/main/java/page/clab/api/domain/community/jobPosting/adapter/in/web/JobPostingDetailsRetrievalController.java +++ b/src/main/java/page/clab/api/domain/community/jobPosting/adapter/in/web/JobPostingDetailsRetrievalController.java @@ -24,9 +24,10 @@ public class JobPostingDetailsRetrievalController { @PreAuthorize("hasRole('GUEST')") @GetMapping("/{jobPostingId}") public ApiResponse retrieveJobPostingDetails( - @PathVariable(name = "jobPostingId") Long jobPostingId + @PathVariable(name = "jobPostingId") Long jobPostingId ) { - JobPostingDetailsResponseDto jobPosting = retrieveJobPostingDetailsUseCase.retrieveJobPostingDetails(jobPostingId); + JobPostingDetailsResponseDto jobPosting = retrieveJobPostingDetailsUseCase.retrieveJobPostingDetails( + jobPostingId); return ApiResponse.success(jobPosting); } } diff --git a/src/main/java/page/clab/api/domain/community/jobPosting/adapter/in/web/JobPostingsByConditionsRetrievalController.java b/src/main/java/page/clab/api/domain/community/jobPosting/adapter/in/web/JobPostingsByConditionsRetrievalController.java index 65edd56d5..04fb0be59 100644 --- a/src/main/java/page/clab/api/domain/community/jobPosting/adapter/in/web/JobPostingsByConditionsRetrievalController.java +++ b/src/main/java/page/clab/api/domain/community/jobPosting/adapter/in/web/JobPostingsByConditionsRetrievalController.java @@ -2,6 +2,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.security.access.prepost.PreAuthorize; @@ -19,8 +20,6 @@ import page.clab.api.global.exception.SortingArgumentException; import page.clab.api.global.util.PageableUtils; -import java.util.List; - @RestController @RequestMapping("/api/v1/job-postings") @RequiredArgsConstructor @@ -31,23 +30,25 @@ public class JobPostingsByConditionsRetrievalController { private final PageableUtils pageableUtils; @Operation(summary = "[G] 채용 공고 목록 조회(공고명, 기업명, 경력, 근로 조건 기준)", description = "ROLE_GUEST 이상의 권한이 필요함
" + - "4개의 파라미터를 자유롭게 조합하여 필터링 가능
" + - "공고명, 기업명, 경력, 근로 조건 중 하나라도 입력하지 않으면 전체 조회됨
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") + "4개의 파라미터를 자유롭게 조합하여 필터링 가능
" + + "공고명, 기업명, 경력, 근로 조건 중 하나라도 입력하지 않으면 전체 조회됨
" + + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") @PreAuthorize("hasRole('GUEST')") @GetMapping("") public ApiResponse> retrieveJobPostingsByConditions( - @RequestParam(name = "title", required = false) String title, - @RequestParam(name = "companyName", required = false) String companyName, - @RequestParam(name = "careerLevel", required = false) CareerLevel careerLevel, - @RequestParam(name = "employmentType", required = false) EmploymentType employmentType, - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection + @RequestParam(name = "title", required = false) String title, + @RequestParam(name = "companyName", required = false) String companyName, + @RequestParam(name = "careerLevel", required = false) CareerLevel careerLevel, + @RequestParam(name = "employmentType", required = false) EmploymentType employmentType, + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection ) throws SortingArgumentException, InvalidColumnException { - Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, JobPostingResponseDto.class); - PagedResponseDto jobPostings = retrieveJobPostingsByConditionsUseCase.retrieveJobPostings(title, companyName, careerLevel, employmentType, pageable); + Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, + JobPostingResponseDto.class); + PagedResponseDto jobPostings = retrieveJobPostingsByConditionsUseCase.retrieveJobPostings( + title, companyName, careerLevel, employmentType, pageable); return ApiResponse.success(jobPostings); } } diff --git a/src/main/java/page/clab/api/domain/community/jobPosting/adapter/out/persistence/JobPostingPersistenceAdapter.java b/src/main/java/page/clab/api/domain/community/jobPosting/adapter/out/persistence/JobPostingPersistenceAdapter.java index e4702e5fe..e2ae75ceb 100644 --- a/src/main/java/page/clab/api/domain/community/jobPosting/adapter/out/persistence/JobPostingPersistenceAdapter.java +++ b/src/main/java/page/clab/api/domain/community/jobPosting/adapter/out/persistence/JobPostingPersistenceAdapter.java @@ -13,7 +13,7 @@ @Component @RequiredArgsConstructor public class JobPostingPersistenceAdapter implements - RetrieveJobPostingPort { + RetrieveJobPostingPort { private final JobPostingRepository repository; private final JobPostingMapper jobPostingMapper; @@ -21,12 +21,14 @@ public class JobPostingPersistenceAdapter implements @Override public JobPosting getById(Long jobPostingId) { return repository.findById(jobPostingId) - .map(jobPostingMapper::toDomain) - .orElseThrow(() -> new NotFoundException("[JobPosting] id: " + jobPostingId + "에 해당하는 채용 공고가 존재하지 않습니다.")); + .map(jobPostingMapper::toDomain) + .orElseThrow(() -> new NotFoundException("[JobPosting] id: " + jobPostingId + "에 해당하는 채용 공고가 존재하지 않습니다.")); } @Override - public Page findByConditions(String title, String companyName, CareerLevel careerLevel, EmploymentType employmentType, Pageable pageable) { - return repository.findByConditions(title, companyName, careerLevel, employmentType, pageable).map(jobPostingMapper::toDomain); + public Page findByConditions(String title, String companyName, CareerLevel careerLevel, + EmploymentType employmentType, Pageable pageable) { + return repository.findByConditions(title, companyName, careerLevel, employmentType, pageable) + .map(jobPostingMapper::toDomain); } } diff --git a/src/main/java/page/clab/api/domain/community/jobPosting/adapter/out/persistence/JobPostingRepository.java b/src/main/java/page/clab/api/domain/community/jobPosting/adapter/out/persistence/JobPostingRepository.java index fe8b52dab..8e14cd7c8 100644 --- a/src/main/java/page/clab/api/domain/community/jobPosting/adapter/out/persistence/JobPostingRepository.java +++ b/src/main/java/page/clab/api/domain/community/jobPosting/adapter/out/persistence/JobPostingRepository.java @@ -5,5 +5,7 @@ import org.springframework.stereotype.Repository; @Repository -public interface JobPostingRepository extends JpaRepository, JobPostingRepositoryCustom, QuerydslPredicateExecutor { +public interface JobPostingRepository extends JpaRepository, JobPostingRepositoryCustom, + QuerydslPredicateExecutor { + } diff --git a/src/main/java/page/clab/api/domain/community/jobPosting/adapter/out/persistence/JobPostingRepositoryCustom.java b/src/main/java/page/clab/api/domain/community/jobPosting/adapter/out/persistence/JobPostingRepositoryCustom.java index 31c234e32..7d21d49ac 100644 --- a/src/main/java/page/clab/api/domain/community/jobPosting/adapter/out/persistence/JobPostingRepositoryCustom.java +++ b/src/main/java/page/clab/api/domain/community/jobPosting/adapter/out/persistence/JobPostingRepositoryCustom.java @@ -6,5 +6,7 @@ import page.clab.api.domain.community.jobPosting.domain.EmploymentType; public interface JobPostingRepositoryCustom { - Page findByConditions(String title, String companyName, CareerLevel careerLevel, EmploymentType employmentType, Pageable pageable); + + Page findByConditions(String title, String companyName, CareerLevel careerLevel, + EmploymentType employmentType, Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/community/jobPosting/adapter/out/persistence/JobPostingRepositoryImpl.java b/src/main/java/page/clab/api/domain/community/jobPosting/adapter/out/persistence/JobPostingRepositoryImpl.java index a6871bb1a..bdc7550d1 100644 --- a/src/main/java/page/clab/api/domain/community/jobPosting/adapter/out/persistence/JobPostingRepositoryImpl.java +++ b/src/main/java/page/clab/api/domain/community/jobPosting/adapter/out/persistence/JobPostingRepositoryImpl.java @@ -2,6 +2,7 @@ import com.querydsl.core.BooleanBuilder; import com.querydsl.jpa.impl.JPAQueryFactory; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; @@ -11,8 +12,6 @@ import page.clab.api.domain.community.jobPosting.domain.EmploymentType; import page.clab.api.global.util.OrderSpecifierUtil; -import java.util.List; - @Repository @RequiredArgsConstructor public class JobPostingRepositoryImpl implements JobPostingRepositoryCustom { @@ -20,26 +19,34 @@ public class JobPostingRepositoryImpl implements JobPostingRepositoryCustom { private final JPAQueryFactory queryFactory; @Override - public Page findByConditions(String title, String companyName, CareerLevel careerLevel, EmploymentType employmentType, Pageable pageable) { + public Page findByConditions(String title, String companyName, CareerLevel careerLevel, + EmploymentType employmentType, Pageable pageable) { QJobPostingJpaEntity jobPosting = QJobPostingJpaEntity.jobPostingJpaEntity; BooleanBuilder builder = new BooleanBuilder(); - if (title != null && !title.isEmpty()) builder.and(jobPosting.title.containsIgnoreCase(title)); - if (companyName != null && !companyName.isEmpty()) + if (title != null && !title.isEmpty()) { + builder.and(jobPosting.title.containsIgnoreCase(title)); + } + if (companyName != null && !companyName.isEmpty()) { builder.and(jobPosting.companyName.containsIgnoreCase(companyName)); - if (careerLevel != null) builder.and(jobPosting.careerLevel.eq(careerLevel)); - if (employmentType != null) builder.and(jobPosting.employmentType.eq(employmentType)); + } + if (careerLevel != null) { + builder.and(jobPosting.careerLevel.eq(careerLevel)); + } + if (employmentType != null) { + builder.and(jobPosting.employmentType.eq(employmentType)); + } List jobPostings = queryFactory.selectFrom(jobPosting) - .where(builder) - .orderBy(OrderSpecifierUtil.getOrderSpecifiers(pageable, jobPosting)) - .offset(pageable.getOffset()) - .limit(pageable.getPageSize()) - .fetch(); + .where(builder) + .orderBy(OrderSpecifierUtil.getOrderSpecifiers(pageable, jobPosting)) + .offset(pageable.getOffset()) + .limit(pageable.getPageSize()) + .fetch(); long total = queryFactory.query().from(jobPosting) - .where(builder) - .fetchCount(); + .where(builder) + .fetchCount(); return new PageImpl<>(jobPostings, pageable, total); } diff --git a/src/main/java/page/clab/api/domain/community/jobPosting/application/dto/mapper/JobPostingDtoMapper.java b/src/main/java/page/clab/api/domain/community/jobPosting/application/dto/mapper/JobPostingDtoMapper.java index 5ac936bb9..3cc5ed0ef 100644 --- a/src/main/java/page/clab/api/domain/community/jobPosting/application/dto/mapper/JobPostingDtoMapper.java +++ b/src/main/java/page/clab/api/domain/community/jobPosting/application/dto/mapper/JobPostingDtoMapper.java @@ -10,24 +10,24 @@ public class JobPostingDtoMapper { public JobPostingResponseDto toDto(JobPosting jobPosting) { return JobPostingResponseDto.builder() - .id(jobPosting.getId()) - .title(jobPosting.getTitle()) - .recruitmentPeriod(jobPosting.getRecruitmentPeriod()) - .jobPostingUrl(jobPosting.getJobPostingUrl()) - .createdAt(jobPosting.getCreatedAt()) - .build(); + .id(jobPosting.getId()) + .title(jobPosting.getTitle()) + .recruitmentPeriod(jobPosting.getRecruitmentPeriod()) + .jobPostingUrl(jobPosting.getJobPostingUrl()) + .createdAt(jobPosting.getCreatedAt()) + .build(); } public JobPostingDetailsResponseDto toDetailsDto(JobPosting jobPosting) { return JobPostingDetailsResponseDto.builder() - .id(jobPosting.getId()) - .title(jobPosting.getTitle()) - .careerLevel(jobPosting.getCareerLevel()) - .employmentType(jobPosting.getEmploymentType()) - .companyName(jobPosting.getCompanyName()) - .recruitmentPeriod(jobPosting.getRecruitmentPeriod()) - .jobPostingUrl(jobPosting.getJobPostingUrl()) - .createdAt(jobPosting.getCreatedAt()) - .build(); + .id(jobPosting.getId()) + .title(jobPosting.getTitle()) + .careerLevel(jobPosting.getCareerLevel()) + .employmentType(jobPosting.getEmploymentType()) + .companyName(jobPosting.getCompanyName()) + .recruitmentPeriod(jobPosting.getRecruitmentPeriod()) + .jobPostingUrl(jobPosting.getJobPostingUrl()) + .createdAt(jobPosting.getCreatedAt()) + .build(); } } diff --git a/src/main/java/page/clab/api/domain/community/jobPosting/application/dto/response/JobPostingDetailsResponseDto.java b/src/main/java/page/clab/api/domain/community/jobPosting/application/dto/response/JobPostingDetailsResponseDto.java index 4d96d9991..35d8bb2c2 100644 --- a/src/main/java/page/clab/api/domain/community/jobPosting/application/dto/response/JobPostingDetailsResponseDto.java +++ b/src/main/java/page/clab/api/domain/community/jobPosting/application/dto/response/JobPostingDetailsResponseDto.java @@ -1,12 +1,11 @@ package page.clab.api.domain.community.jobPosting.application.dto.response; +import java.time.LocalDateTime; import lombok.Builder; import lombok.Getter; import page.clab.api.domain.community.jobPosting.domain.CareerLevel; import page.clab.api.domain.community.jobPosting.domain.EmploymentType; -import java.time.LocalDateTime; - @Getter @Builder public class JobPostingDetailsResponseDto { diff --git a/src/main/java/page/clab/api/domain/community/jobPosting/application/dto/response/JobPostingResponseDto.java b/src/main/java/page/clab/api/domain/community/jobPosting/application/dto/response/JobPostingResponseDto.java index a2ae73a86..aaa47a1d5 100644 --- a/src/main/java/page/clab/api/domain/community/jobPosting/application/dto/response/JobPostingResponseDto.java +++ b/src/main/java/page/clab/api/domain/community/jobPosting/application/dto/response/JobPostingResponseDto.java @@ -1,10 +1,9 @@ package page.clab.api.domain.community.jobPosting.application.dto.response; +import java.time.LocalDateTime; import lombok.Builder; import lombok.Getter; -import java.time.LocalDateTime; - @Getter @Builder public class JobPostingResponseDto { diff --git a/src/main/java/page/clab/api/domain/community/jobPosting/application/port/in/RetrieveJobPostingDetailsUseCase.java b/src/main/java/page/clab/api/domain/community/jobPosting/application/port/in/RetrieveJobPostingDetailsUseCase.java index 27164ba0d..186234e0b 100644 --- a/src/main/java/page/clab/api/domain/community/jobPosting/application/port/in/RetrieveJobPostingDetailsUseCase.java +++ b/src/main/java/page/clab/api/domain/community/jobPosting/application/port/in/RetrieveJobPostingDetailsUseCase.java @@ -3,5 +3,6 @@ import page.clab.api.domain.community.jobPosting.application.dto.response.JobPostingDetailsResponseDto; public interface RetrieveJobPostingDetailsUseCase { + JobPostingDetailsResponseDto retrieveJobPostingDetails(Long jobPostingId); } diff --git a/src/main/java/page/clab/api/domain/community/jobPosting/application/port/in/RetrieveJobPostingsByConditionsUseCase.java b/src/main/java/page/clab/api/domain/community/jobPosting/application/port/in/RetrieveJobPostingsByConditionsUseCase.java index 386b452c0..f27a2f154 100644 --- a/src/main/java/page/clab/api/domain/community/jobPosting/application/port/in/RetrieveJobPostingsByConditionsUseCase.java +++ b/src/main/java/page/clab/api/domain/community/jobPosting/application/port/in/RetrieveJobPostingsByConditionsUseCase.java @@ -7,5 +7,7 @@ import page.clab.api.global.common.dto.PagedResponseDto; public interface RetrieveJobPostingsByConditionsUseCase { - PagedResponseDto retrieveJobPostings(String title, String companyName, CareerLevel careerLevel, EmploymentType employmentType, Pageable pageable); + + PagedResponseDto retrieveJobPostings(String title, String companyName, + CareerLevel careerLevel, EmploymentType employmentType, Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/community/jobPosting/application/port/out/RetrieveJobPostingPort.java b/src/main/java/page/clab/api/domain/community/jobPosting/application/port/out/RetrieveJobPostingPort.java index d75173d61..8480f4551 100644 --- a/src/main/java/page/clab/api/domain/community/jobPosting/application/port/out/RetrieveJobPostingPort.java +++ b/src/main/java/page/clab/api/domain/community/jobPosting/application/port/out/RetrieveJobPostingPort.java @@ -10,5 +10,6 @@ public interface RetrieveJobPostingPort { JobPosting getById(Long jobPostingId); - Page findByConditions(String title, String companyName, CareerLevel careerLevel, EmploymentType employmentType, Pageable pageable); + Page findByConditions(String title, String companyName, CareerLevel careerLevel, + EmploymentType employmentType, Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/community/jobPosting/application/service/JobPostingsByConditionsRetrievalService.java b/src/main/java/page/clab/api/domain/community/jobPosting/application/service/JobPostingsByConditionsRetrievalService.java index 2c92c3072..94c973043 100644 --- a/src/main/java/page/clab/api/domain/community/jobPosting/application/service/JobPostingsByConditionsRetrievalService.java +++ b/src/main/java/page/clab/api/domain/community/jobPosting/application/service/JobPostingsByConditionsRetrievalService.java @@ -23,8 +23,10 @@ public class JobPostingsByConditionsRetrievalService implements RetrieveJobPosti @Transactional(readOnly = true) @Override - public PagedResponseDto retrieveJobPostings(String title, String companyName, CareerLevel careerLevel, EmploymentType employmentType, Pageable pageable) { - Page jobPostings = retrieveJobPostingPort.findByConditions(title, companyName, careerLevel, employmentType, pageable); + public PagedResponseDto retrieveJobPostings(String title, String companyName, + CareerLevel careerLevel, EmploymentType employmentType, Pageable pageable) { + Page jobPostings = retrieveJobPostingPort.findByConditions(title, companyName, careerLevel, + employmentType, pageable); return new PagedResponseDto<>(jobPostings.map(mapper::toDto)); } } diff --git a/src/main/java/page/clab/api/domain/community/jobPosting/domain/JobPosting.java b/src/main/java/page/clab/api/domain/community/jobPosting/domain/JobPosting.java index caf2813ce..47debf9bb 100644 --- a/src/main/java/page/clab/api/domain/community/jobPosting/domain/JobPosting.java +++ b/src/main/java/page/clab/api/domain/community/jobPosting/domain/JobPosting.java @@ -1,5 +1,6 @@ package page.clab.api.domain.community.jobPosting.domain; +import java.time.LocalDateTime; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -7,8 +8,6 @@ import lombok.NoArgsConstructor; import lombok.Setter; -import java.time.LocalDateTime; - @Getter @Setter @Builder diff --git a/src/main/java/page/clab/api/domain/community/news/adapter/in/web/NewsByConditionsRetrievalController.java b/src/main/java/page/clab/api/domain/community/news/adapter/in/web/NewsByConditionsRetrievalController.java index 6ee2706f5..76b66d395 100644 --- a/src/main/java/page/clab/api/domain/community/news/adapter/in/web/NewsByConditionsRetrievalController.java +++ b/src/main/java/page/clab/api/domain/community/news/adapter/in/web/NewsByConditionsRetrievalController.java @@ -2,6 +2,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.security.access.prepost.PreAuthorize; @@ -17,8 +18,6 @@ import page.clab.api.global.exception.SortingArgumentException; import page.clab.api.global.util.PageableUtils; -import java.util.List; - @RestController @RequestMapping("/api/v1/news") @RequiredArgsConstructor @@ -29,21 +28,22 @@ public class NewsByConditionsRetrievalController { private final PageableUtils pageableUtils; @Operation(summary = "[G] 뉴스 목록 조회(제목, 카테고리 기준)", description = "ROLE_GUEST 이상의 권한이 필요함
" + - "2개의 파라미터를 자유롭게 조합하여 필터링 가능
" + - "제목, 카테고리 중 하나라도 입력하지 않으면 전체 조회됨
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") + "2개의 파라미터를 자유롭게 조합하여 필터링 가능
" + + "제목, 카테고리 중 하나라도 입력하지 않으면 전체 조회됨
" + + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") @PreAuthorize("hasRole('GUEST')") @GetMapping("") public ApiResponse> retrieveNewsByConditions( - @RequestParam(name = "title", required = false) String title, - @RequestParam(name = "category", required = false) String category, - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection + @RequestParam(name = "title", required = false) String title, + @RequestParam(name = "category", required = false) String category, + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection ) throws SortingArgumentException, InvalidColumnException { Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, NewsResponseDto.class); - PagedResponseDto news = retrieveNewsByConditionsUseCase.retrieveNews(title, category, pageable); + PagedResponseDto news = retrieveNewsByConditionsUseCase.retrieveNews(title, category, + pageable); return ApiResponse.success(news); } } diff --git a/src/main/java/page/clab/api/domain/community/news/adapter/in/web/NewsDetailsRetrievalController.java b/src/main/java/page/clab/api/domain/community/news/adapter/in/web/NewsDetailsRetrievalController.java index 34773a926..1aab62588 100644 --- a/src/main/java/page/clab/api/domain/community/news/adapter/in/web/NewsDetailsRetrievalController.java +++ b/src/main/java/page/clab/api/domain/community/news/adapter/in/web/NewsDetailsRetrievalController.java @@ -24,7 +24,7 @@ public class NewsDetailsRetrievalController { @PreAuthorize("hasRole('GUEST')") @GetMapping("/{newsId}") public ApiResponse retrieveNewsDetails( - @PathVariable(name = "newsId") Long newsId + @PathVariable(name = "newsId") Long newsId ) { NewsDetailsResponseDto news = retrieveNewsDetailsUseCase.retrieveNewsDetails(newsId); return ApiResponse.success(news); diff --git a/src/main/java/page/clab/api/domain/community/news/adapter/out/persistence/NewsJpaEntity.java b/src/main/java/page/clab/api/domain/community/news/adapter/out/persistence/NewsJpaEntity.java index 927ca3533..18a4600aa 100644 --- a/src/main/java/page/clab/api/domain/community/news/adapter/out/persistence/NewsJpaEntity.java +++ b/src/main/java/page/clab/api/domain/community/news/adapter/out/persistence/NewsJpaEntity.java @@ -8,6 +8,7 @@ import jakarta.persistence.Index; import jakarta.persistence.Table; import jakarta.validation.constraints.Size; +import java.time.LocalDate; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -19,8 +20,6 @@ import org.hibernate.validator.constraints.URL; import page.clab.api.global.common.domain.BaseEntity; -import java.time.LocalDate; - @Entity @Getter @Setter @@ -29,7 +28,7 @@ @AllArgsConstructor(access = AccessLevel.PRIVATE) @SQLDelete(sql = "UPDATE news SET is_deleted = true WHERE id = ?") @SQLRestriction("is_deleted = false") -@Table(name = "news", indexes = { @Index(name = "idx_article_url", columnList = "articleUrl") }) +@Table(name = "news", indexes = {@Index(name = "idx_article_url", columnList = "articleUrl")}) public class NewsJpaEntity extends BaseEntity { @Id diff --git a/src/main/java/page/clab/api/domain/community/news/adapter/out/persistence/NewsPersistenceAdapter.java b/src/main/java/page/clab/api/domain/community/news/adapter/out/persistence/NewsPersistenceAdapter.java index 8e02d0b09..17be4ca63 100644 --- a/src/main/java/page/clab/api/domain/community/news/adapter/out/persistence/NewsPersistenceAdapter.java +++ b/src/main/java/page/clab/api/domain/community/news/adapter/out/persistence/NewsPersistenceAdapter.java @@ -11,7 +11,7 @@ @Component @RequiredArgsConstructor public class NewsPersistenceAdapter implements - RetrieveNewsPort { + RetrieveNewsPort { private final NewsRepository repository; private final NewsMapper mapper; @@ -19,13 +19,13 @@ public class NewsPersistenceAdapter implements @Override public News getById(Long id) { return repository.findById(id) - .map(mapper::toDomain) - .orElseThrow(() -> new NotFoundException("[News] id: " + id + "에 해당하는 뉴스가 존재하지 않습니다.")); + .map(mapper::toDomain) + .orElseThrow(() -> new NotFoundException("[News] id: " + id + "에 해당하는 뉴스가 존재하지 않습니다.")); } @Override public Page findByConditions(String title, String category, Pageable pageable) { return repository.findByConditions(title, category, pageable) - .map(mapper::toDomain); + .map(mapper::toDomain); } } diff --git a/src/main/java/page/clab/api/domain/community/news/adapter/out/persistence/NewsRepository.java b/src/main/java/page/clab/api/domain/community/news/adapter/out/persistence/NewsRepository.java index 5c6983c75..47a72d54e 100644 --- a/src/main/java/page/clab/api/domain/community/news/adapter/out/persistence/NewsRepository.java +++ b/src/main/java/page/clab/api/domain/community/news/adapter/out/persistence/NewsRepository.java @@ -5,5 +5,7 @@ import org.springframework.stereotype.Repository; @Repository -public interface NewsRepository extends JpaRepository, NewsRepositoryCustom, QuerydslPredicateExecutor { +public interface NewsRepository extends JpaRepository, NewsRepositoryCustom, + QuerydslPredicateExecutor { + } diff --git a/src/main/java/page/clab/api/domain/community/news/adapter/out/persistence/NewsRepositoryCustom.java b/src/main/java/page/clab/api/domain/community/news/adapter/out/persistence/NewsRepositoryCustom.java index c75aab4c3..07562f424 100644 --- a/src/main/java/page/clab/api/domain/community/news/adapter/out/persistence/NewsRepositoryCustom.java +++ b/src/main/java/page/clab/api/domain/community/news/adapter/out/persistence/NewsRepositoryCustom.java @@ -4,5 +4,6 @@ import org.springframework.data.domain.Pageable; public interface NewsRepositoryCustom { + Page findByConditions(String title, String category, Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/community/news/adapter/out/persistence/NewsRepositoryImpl.java b/src/main/java/page/clab/api/domain/community/news/adapter/out/persistence/NewsRepositoryImpl.java index 10d6e98ca..ce9fc1822 100644 --- a/src/main/java/page/clab/api/domain/community/news/adapter/out/persistence/NewsRepositoryImpl.java +++ b/src/main/java/page/clab/api/domain/community/news/adapter/out/persistence/NewsRepositoryImpl.java @@ -2,6 +2,7 @@ import com.querydsl.core.BooleanBuilder; import com.querydsl.jpa.impl.JPAQueryFactory; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; @@ -9,8 +10,6 @@ import org.springframework.stereotype.Repository; import page.clab.api.global.util.OrderSpecifierUtil; -import java.util.List; - @Repository @RequiredArgsConstructor public class NewsRepositoryImpl implements NewsRepositoryCustom { @@ -22,19 +21,23 @@ public Page findByConditions(String title, String category, Pagea QNewsJpaEntity news = QNewsJpaEntity.newsJpaEntity; BooleanBuilder builder = new BooleanBuilder(); - if (title != null && !title.isEmpty()) builder.and(news.title.containsIgnoreCase(title)); - if (category != null && !category.isEmpty()) builder.and(news.category.eq(category)); + if (title != null && !title.isEmpty()) { + builder.and(news.title.containsIgnoreCase(title)); + } + if (category != null && !category.isEmpty()) { + builder.and(news.category.eq(category)); + } List newsList = queryFactory.selectFrom(news) - .where(builder) - .orderBy(OrderSpecifierUtil.getOrderSpecifiers(pageable, news)) - .offset(pageable.getOffset()) - .limit(pageable.getPageSize()) - .fetch(); + .where(builder) + .orderBy(OrderSpecifierUtil.getOrderSpecifiers(pageable, news)) + .offset(pageable.getOffset()) + .limit(pageable.getPageSize()) + .fetch(); long count = queryFactory.selectFrom(news) - .where(builder) - .fetchCount(); + .where(builder) + .fetchCount(); return new PageImpl<>(newsList, pageable, count); } diff --git a/src/main/java/page/clab/api/domain/community/news/application/dto/mapper/NewsDtoMapper.java b/src/main/java/page/clab/api/domain/community/news/application/dto/mapper/NewsDtoMapper.java index d13414b9c..7e60b2b3e 100644 --- a/src/main/java/page/clab/api/domain/community/news/application/dto/mapper/NewsDtoMapper.java +++ b/src/main/java/page/clab/api/domain/community/news/application/dto/mapper/NewsDtoMapper.java @@ -10,25 +10,25 @@ public class NewsDtoMapper { public NewsResponseDto toDto(News news) { return NewsResponseDto.builder() - .id(news.getId()) - .title(news.getTitle()) - .category(news.getCategory()) - .articleUrl(news.getArticleUrl()) - .date(news.getDate()) - .createdAt(news.getCreatedAt()) - .build(); + .id(news.getId()) + .title(news.getTitle()) + .category(news.getCategory()) + .articleUrl(news.getArticleUrl()) + .date(news.getDate()) + .createdAt(news.getCreatedAt()) + .build(); } public NewsDetailsResponseDto toDetailsDto(News news) { return NewsDetailsResponseDto.builder() - .id(news.getId()) - .title(news.getTitle()) - .category(news.getCategory()) - .content(news.getContent()) - .articleUrl(news.getArticleUrl()) - .source(news.getSource()) - .date(news.getDate()) - .createdAt(news.getCreatedAt()) - .build(); + .id(news.getId()) + .title(news.getTitle()) + .category(news.getCategory()) + .content(news.getContent()) + .articleUrl(news.getArticleUrl()) + .source(news.getSource()) + .date(news.getDate()) + .createdAt(news.getCreatedAt()) + .build(); } } diff --git a/src/main/java/page/clab/api/domain/community/news/application/dto/response/NewsDetailsResponseDto.java b/src/main/java/page/clab/api/domain/community/news/application/dto/response/NewsDetailsResponseDto.java index 81caef81d..f101815b8 100644 --- a/src/main/java/page/clab/api/domain/community/news/application/dto/response/NewsDetailsResponseDto.java +++ b/src/main/java/page/clab/api/domain/community/news/application/dto/response/NewsDetailsResponseDto.java @@ -1,12 +1,11 @@ package page.clab.api.domain.community.news.application.dto.response; -import lombok.Builder; -import lombok.Getter; -import page.clab.api.global.common.file.dto.response.UploadedFileResponseDto; - import java.time.LocalDate; import java.time.LocalDateTime; import java.util.List; +import lombok.Builder; +import lombok.Getter; +import page.clab.api.global.common.file.dto.response.UploadedFileResponseDto; @Getter @Builder diff --git a/src/main/java/page/clab/api/domain/community/news/application/dto/response/NewsResponseDto.java b/src/main/java/page/clab/api/domain/community/news/application/dto/response/NewsResponseDto.java index 11612a5f2..0023c56a4 100644 --- a/src/main/java/page/clab/api/domain/community/news/application/dto/response/NewsResponseDto.java +++ b/src/main/java/page/clab/api/domain/community/news/application/dto/response/NewsResponseDto.java @@ -1,10 +1,9 @@ package page.clab.api.domain.community.news.application.dto.response; -import lombok.Builder; -import lombok.Getter; - import java.time.LocalDate; import java.time.LocalDateTime; +import lombok.Builder; +import lombok.Getter; @Getter @Builder diff --git a/src/main/java/page/clab/api/domain/community/news/application/port/in/RetrieveNewsByConditionsUseCase.java b/src/main/java/page/clab/api/domain/community/news/application/port/in/RetrieveNewsByConditionsUseCase.java index 9dd8c8a2a..bdd488175 100644 --- a/src/main/java/page/clab/api/domain/community/news/application/port/in/RetrieveNewsByConditionsUseCase.java +++ b/src/main/java/page/clab/api/domain/community/news/application/port/in/RetrieveNewsByConditionsUseCase.java @@ -5,5 +5,6 @@ import page.clab.api.global.common.dto.PagedResponseDto; public interface RetrieveNewsByConditionsUseCase { + PagedResponseDto retrieveNews(String title, String category, Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/community/news/application/port/in/RetrieveNewsDetailsUseCase.java b/src/main/java/page/clab/api/domain/community/news/application/port/in/RetrieveNewsDetailsUseCase.java index ec23ec150..48c25ae81 100644 --- a/src/main/java/page/clab/api/domain/community/news/application/port/in/RetrieveNewsDetailsUseCase.java +++ b/src/main/java/page/clab/api/domain/community/news/application/port/in/RetrieveNewsDetailsUseCase.java @@ -3,5 +3,6 @@ import page.clab.api.domain.community.news.application.dto.response.NewsDetailsResponseDto; public interface RetrieveNewsDetailsUseCase { + NewsDetailsResponseDto retrieveNewsDetails(Long newsId); } diff --git a/src/main/java/page/clab/api/domain/community/news/domain/News.java b/src/main/java/page/clab/api/domain/community/news/domain/News.java index 94b817859..17204c607 100644 --- a/src/main/java/page/clab/api/domain/community/news/domain/News.java +++ b/src/main/java/page/clab/api/domain/community/news/domain/News.java @@ -1,5 +1,7 @@ package page.clab.api.domain.community.news.domain; +import java.time.LocalDate; +import java.time.LocalDateTime; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -7,9 +9,6 @@ import lombok.NoArgsConstructor; import lombok.Setter; -import java.time.LocalDate; -import java.time.LocalDateTime; - @Getter @Setter @Builder diff --git a/src/main/java/page/clab/api/domain/hiring/application/adapter/in/web/ApplicationApplyController.java b/src/main/java/page/clab/api/domain/hiring/application/adapter/in/web/ApplicationApplyController.java index ac2003846..2807e74d9 100644 --- a/src/main/java/page/clab/api/domain/hiring/application/adapter/in/web/ApplicationApplyController.java +++ b/src/main/java/page/clab/api/domain/hiring/application/adapter/in/web/ApplicationApplyController.java @@ -23,7 +23,7 @@ public class ApplicationApplyController { @Operation(summary = "동아리 지원", description = "ROLE_ANONYMOUS 이상의 권한이 필요함") @PostMapping("") public ApiResponse applyForClub( - @Valid @RequestBody ApplicationRequestDto requestDto + @Valid @RequestBody ApplicationRequestDto requestDto ) { String id = applyForApplicationUseCase.applyForClub(requestDto); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/hiring/application/adapter/in/web/ApplicationApprovalController.java b/src/main/java/page/clab/api/domain/hiring/application/adapter/in/web/ApplicationApprovalController.java index 5c00d0776..91404796f 100644 --- a/src/main/java/page/clab/api/domain/hiring/application/adapter/in/web/ApplicationApprovalController.java +++ b/src/main/java/page/clab/api/domain/hiring/application/adapter/in/web/ApplicationApprovalController.java @@ -22,24 +22,24 @@ public class ApplicationApprovalController { private final RejectApplicationUseCase rejectApplicationUseCase; @Operation(summary = "[S] 지원 합격 처리", description = "ROLE_SUPER 이상의 권한이 필요함
" + - "지원자의 상태를 합격으로 변경") + "지원자의 상태를 합격으로 변경") @PreAuthorize("hasRole('SUPER')") @PatchMapping("/approve/{recruitmentId}/{studentId}") public ApiResponse approveApplication( - @PathVariable(name = "recruitmentId") Long recruitmentId, - @PathVariable(name = "studentId") String studentId + @PathVariable(name = "recruitmentId") Long recruitmentId, + @PathVariable(name = "studentId") String studentId ) { Long recruitmentID = approveApplicationUseCase.approveApplication(recruitmentId, studentId); return ApiResponse.success(recruitmentID); } @Operation(summary = "[S] 지원 불합격 처리", description = "ROLE_SUPER 이상의 권한이 필요함
" + - "지원자의 상태를 불합격으로 변경") + "지원자의 상태를 불합격으로 변경") @PreAuthorize("hasRole('SUPER')") @PatchMapping("/reject/{recruitmentId}/{studentId}") public ApiResponse rejectApplication( - @PathVariable(name = "recruitmentId") Long recruitmentId, - @PathVariable(name = "studentId") String studentId + @PathVariable(name = "recruitmentId") Long recruitmentId, + @PathVariable(name = "studentId") String studentId ) { Long recruitmentID = rejectApplicationUseCase.rejectApplication(recruitmentId, studentId); return ApiResponse.success(recruitmentID); diff --git a/src/main/java/page/clab/api/domain/hiring/application/adapter/in/web/ApplicationMemberRegisterController.java b/src/main/java/page/clab/api/domain/hiring/application/adapter/in/web/ApplicationMemberRegisterController.java index 0cb2fba63..e9c3ca407 100644 --- a/src/main/java/page/clab/api/domain/hiring/application/adapter/in/web/ApplicationMemberRegisterController.java +++ b/src/main/java/page/clab/api/domain/hiring/application/adapter/in/web/ApplicationMemberRegisterController.java @@ -2,6 +2,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.PathVariable; @@ -11,8 +12,6 @@ import page.clab.api.domain.hiring.application.application.port.in.RegisterMembersByRecruitmentUseCase; import page.clab.api.global.common.dto.ApiResponse; -import java.util.List; - @RestController @RequestMapping("/api/v1/applications") @RequiredArgsConstructor @@ -25,7 +24,7 @@ public class ApplicationMemberRegisterController { @PreAuthorize("hasRole('SUPER')") @PostMapping("/{recruitmentId}") public ApiResponse> registerMembersByRecruitment( - @PathVariable(name = "recruitmentId") Long recruitmentId + @PathVariable(name = "recruitmentId") Long recruitmentId ) { List ids = registerMembersByRecruitmentUseCase.registerMembersByRecruitment(recruitmentId); return ApiResponse.success(ids); @@ -35,8 +34,8 @@ public ApiResponse> registerMembersByRecruitment( @PreAuthorize("hasRole('SUPER')") @PostMapping("/{recruitmentId}/{studentId}") public ApiResponse registerMembersByRecruitment( - @PathVariable(name = "recruitmentId") Long recruitmentId, - @PathVariable(name = "studentId") String studentId + @PathVariable(name = "recruitmentId") Long recruitmentId, + @PathVariable(name = "studentId") String studentId ) { String id = registerMembersByRecruitmentUseCase.registerMembersByRecruitment(recruitmentId, studentId); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/hiring/application/adapter/in/web/ApplicationPassCheckController.java b/src/main/java/page/clab/api/domain/hiring/application/adapter/in/web/ApplicationPassCheckController.java index c7b0f1d70..805966c18 100644 --- a/src/main/java/page/clab/api/domain/hiring/application/adapter/in/web/ApplicationPassCheckController.java +++ b/src/main/java/page/clab/api/domain/hiring/application/adapter/in/web/ApplicationPassCheckController.java @@ -22,8 +22,8 @@ public class ApplicationPassCheckController { @Operation(summary = "합격 여부 조회", description = "ROLE_ANONYMOUS 이상의 권한이 필요함") @GetMapping("/{recruitmentId}/{studentId}") public ApiResponse checkApplicationPass( - @PathVariable(name = "recruitmentId") Long recruitmentId, - @PathVariable(name = "studentId") String studentId + @PathVariable(name = "recruitmentId") Long recruitmentId, + @PathVariable(name = "studentId") String studentId ) { ApplicationPassResponseDto pass = checkApplicationPassStatusUseCase.checkPassStatus(recruitmentId, studentId); return ApiResponse.success(pass); diff --git a/src/main/java/page/clab/api/domain/hiring/application/adapter/in/web/ApplicationRetrievalController.java b/src/main/java/page/clab/api/domain/hiring/application/adapter/in/web/ApplicationRetrievalController.java index c5e65eb53..c70453f2d 100644 --- a/src/main/java/page/clab/api/domain/hiring/application/adapter/in/web/ApplicationRetrievalController.java +++ b/src/main/java/page/clab/api/domain/hiring/application/adapter/in/web/ApplicationRetrievalController.java @@ -2,6 +2,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.security.access.prepost.PreAuthorize; @@ -17,8 +18,6 @@ import page.clab.api.global.exception.SortingArgumentException; import page.clab.api.global.util.PageableUtils; -import java.util.List; - @RestController @RequestMapping("/api/v1/applications") @RequiredArgsConstructor @@ -29,22 +28,24 @@ public class ApplicationRetrievalController { private final PageableUtils pageableUtils; @Operation(summary = "[A] 지원자 목록 조회(모집 일정 ID, 지원자 ID, 합격 여부 기준)", description = "ROLE_ADMIN 이상의 권한이 필요함
" + - "3개의 파라미터를 자유롭게 조합하여 필터링 가능
" + - "모집 일정 ID, 지원자 ID, 합격 여부 중 하나라도 입력하지 않으면 전체 조회됨
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") + "3개의 파라미터를 자유롭게 조합하여 필터링 가능
" + + "모집 일정 ID, 지원자 ID, 합격 여부 중 하나라도 입력하지 않으면 전체 조회됨
" + + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") @PreAuthorize("hasRole('ADMIN')") @GetMapping("/conditions") public ApiResponse> retrieveApplicationsByConditions( - @RequestParam(name = "recruitmentId", required = false) Long recruitmentId, - @RequestParam(name = "studentId", required = false) String studentId, - @RequestParam(name = "isPass", required = false) Boolean isPass, - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection + @RequestParam(name = "recruitmentId", required = false) Long recruitmentId, + @RequestParam(name = "studentId", required = false) String studentId, + @RequestParam(name = "isPass", required = false) Boolean isPass, + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection ) throws SortingArgumentException, InvalidColumnException { - Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, ApplicationResponseDto.class); - PagedResponseDto applications = retrieveApplicationsUseCase.retrieveApplications(recruitmentId, studentId, isPass, pageable); + Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, + ApplicationResponseDto.class); + PagedResponseDto applications = retrieveApplicationsUseCase.retrieveApplications( + recruitmentId, studentId, isPass, pageable); return ApiResponse.success(applications); } } diff --git a/src/main/java/page/clab/api/domain/hiring/application/adapter/out/persistence/ApplicationId.java b/src/main/java/page/clab/api/domain/hiring/application/adapter/out/persistence/ApplicationId.java index b654bdb8b..d966a2806 100644 --- a/src/main/java/page/clab/api/domain/hiring/application/adapter/out/persistence/ApplicationId.java +++ b/src/main/java/page/clab/api/domain/hiring/application/adapter/out/persistence/ApplicationId.java @@ -1,13 +1,12 @@ package page.clab.api.domain.hiring.application.adapter.out.persistence; import jakarta.persistence.Embeddable; +import java.io.Serializable; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; -import java.io.Serializable; - @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor(access = AccessLevel.PRIVATE) @EqualsAndHashCode(onlyExplicitlyIncluded = true) diff --git a/src/main/java/page/clab/api/domain/hiring/application/adapter/out/persistence/ApplicationJpaEntity.java b/src/main/java/page/clab/api/domain/hiring/application/adapter/out/persistence/ApplicationJpaEntity.java index d862c1c15..1fe35d389 100644 --- a/src/main/java/page/clab/api/domain/hiring/application/adapter/out/persistence/ApplicationJpaEntity.java +++ b/src/main/java/page/clab/api/domain/hiring/application/adapter/out/persistence/ApplicationJpaEntity.java @@ -12,6 +12,7 @@ import jakarta.validation.constraints.Min; import jakarta.validation.constraints.Pattern; import jakarta.validation.constraints.Size; +import java.time.LocalDate; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -24,8 +25,6 @@ import page.clab.api.domain.hiring.application.domain.ApplicationType; import page.clab.api.global.common.domain.BaseEntity; -import java.time.LocalDate; - @Entity @Table(name = "application") @Getter diff --git a/src/main/java/page/clab/api/domain/hiring/application/adapter/out/persistence/ApplicationPersistenceAdapter.java b/src/main/java/page/clab/api/domain/hiring/application/adapter/out/persistence/ApplicationPersistenceAdapter.java index 679532cdf..c6fd8273d 100644 --- a/src/main/java/page/clab/api/domain/hiring/application/adapter/out/persistence/ApplicationPersistenceAdapter.java +++ b/src/main/java/page/clab/api/domain/hiring/application/adapter/out/persistence/ApplicationPersistenceAdapter.java @@ -1,5 +1,7 @@ package page.clab.api.domain.hiring.application.adapter.out.persistence; +import java.util.List; +import java.util.Optional; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -9,14 +11,11 @@ import page.clab.api.domain.hiring.application.domain.Application; import page.clab.api.global.exception.NotFoundException; -import java.util.List; -import java.util.Optional; - @Component @RequiredArgsConstructor public class ApplicationPersistenceAdapter implements - RegisterApplicationPort, - RetrieveApplicationPort { + RegisterApplicationPort, + RetrieveApplicationPort { private final ApplicationRepository applicationRepository; private final ApplicationMapper applicationMapper; @@ -31,33 +30,35 @@ public Application save(Application application) { @Override public Optional findById(ApplicationId applicationId) { return applicationRepository.findById(applicationId) - .map(applicationMapper::toDomain); + .map(applicationMapper::toDomain); } @Override public Application getById(ApplicationId applicationId) { return applicationRepository.findById(applicationId) - .map(applicationMapper::toDomain) - .orElseThrow(() -> new NotFoundException("[Application] id: " + applicationId + "에 해당하는 지원서가 존재하지 않습니다.")); + .map(applicationMapper::toDomain) + .orElseThrow(() -> new NotFoundException("[Application] id: " + applicationId + "에 해당하는 지원서가 존재하지 않습니다.")); } @Override public Page findByConditions(Long recruitmentId, String studentId, Boolean isPass, Pageable pageable) { return applicationRepository.findByConditions(recruitmentId, studentId, isPass, pageable) - .map(applicationMapper::toDomain); + .map(applicationMapper::toDomain); } @Override public List findByRecruitmentIdAndIsPass(Long recruitmentId, boolean isPass) { return applicationRepository.findByRecruitmentIdAndIsPass(recruitmentId, isPass).stream() - .map(applicationMapper::toDomain) - .toList(); + .map(applicationMapper::toDomain) + .toList(); } @Override public Application getByRecruitmentIdAndStudentId(Long recruitmentId, String studentId) { return applicationRepository.findByRecruitmentIdAndStudentId(recruitmentId, studentId) - .map(applicationMapper::toDomain) - .orElseThrow(() -> new NotFoundException("[Application] recruitmentId: " + recruitmentId + ", studentId: " + studentId + "에 해당하는 지원서가 존재하지 않습니다.")); + .map(applicationMapper::toDomain) + .orElseThrow(() -> new NotFoundException( + "[Application] recruitmentId: " + recruitmentId + ", studentId: " + studentId + + "에 해당하는 지원서가 존재하지 않습니다.")); } } diff --git a/src/main/java/page/clab/api/domain/hiring/application/adapter/out/persistence/ApplicationRepository.java b/src/main/java/page/clab/api/domain/hiring/application/adapter/out/persistence/ApplicationRepository.java index 1fabe96fc..252b21e83 100644 --- a/src/main/java/page/clab/api/domain/hiring/application/adapter/out/persistence/ApplicationRepository.java +++ b/src/main/java/page/clab/api/domain/hiring/application/adapter/out/persistence/ApplicationRepository.java @@ -1,13 +1,13 @@ package page.clab.api.domain.hiring.application.adapter.out.persistence; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - import java.util.List; import java.util.Optional; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; @Repository -public interface ApplicationRepository extends JpaRepository, ApplicationRepositoryCustom { +public interface ApplicationRepository extends JpaRepository, + ApplicationRepositoryCustom { List findByRecruitmentIdAndIsPass(Long recruitmentId, Boolean isPass); diff --git a/src/main/java/page/clab/api/domain/hiring/application/adapter/out/persistence/ApplicationRepositoryCustom.java b/src/main/java/page/clab/api/domain/hiring/application/adapter/out/persistence/ApplicationRepositoryCustom.java index 88b434f4f..c67962ef8 100644 --- a/src/main/java/page/clab/api/domain/hiring/application/adapter/out/persistence/ApplicationRepositoryCustom.java +++ b/src/main/java/page/clab/api/domain/hiring/application/adapter/out/persistence/ApplicationRepositoryCustom.java @@ -4,5 +4,7 @@ import org.springframework.data.domain.Pageable; public interface ApplicationRepositoryCustom { - Page findByConditions(Long recruitmentId, String studentId, Boolean isPass, Pageable pageable); + + Page findByConditions(Long recruitmentId, String studentId, Boolean isPass, + Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/hiring/application/adapter/out/persistence/ApplicationRepositoryImpl.java b/src/main/java/page/clab/api/domain/hiring/application/adapter/out/persistence/ApplicationRepositoryImpl.java index 1e60336a5..1c2d285f7 100644 --- a/src/main/java/page/clab/api/domain/hiring/application/adapter/out/persistence/ApplicationRepositoryImpl.java +++ b/src/main/java/page/clab/api/domain/hiring/application/adapter/out/persistence/ApplicationRepositoryImpl.java @@ -2,6 +2,7 @@ import com.querydsl.core.BooleanBuilder; import com.querydsl.jpa.impl.JPAQueryFactory; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; @@ -9,8 +10,6 @@ import org.springframework.stereotype.Repository; import page.clab.api.global.util.OrderSpecifierUtil; -import java.util.List; - @Repository @RequiredArgsConstructor public class ApplicationRepositoryImpl implements ApplicationRepositoryCustom { @@ -18,24 +17,31 @@ public class ApplicationRepositoryImpl implements ApplicationRepositoryCustom { private final JPAQueryFactory queryFactory; @Override - public Page findByConditions(Long recruitmentId, String studentId, Boolean isPass, Pageable pageable) { + public Page findByConditions(Long recruitmentId, String studentId, Boolean isPass, + Pageable pageable) { QApplicationJpaEntity application = QApplicationJpaEntity.applicationJpaEntity; BooleanBuilder builder = new BooleanBuilder(); - if (recruitmentId != null) builder.and(application.recruitmentId.eq(recruitmentId)); - if (studentId != null && !studentId.isEmpty()) builder.and(application.studentId.eq(studentId)); - if (isPass != null) builder.and(application.isPass.eq(isPass)); + if (recruitmentId != null) { + builder.and(application.recruitmentId.eq(recruitmentId)); + } + if (studentId != null && !studentId.isEmpty()) { + builder.and(application.studentId.eq(studentId)); + } + if (isPass != null) { + builder.and(application.isPass.eq(isPass)); + } List applications = queryFactory.selectFrom(application) - .where(builder.getValue()) - .orderBy(OrderSpecifierUtil.getOrderSpecifiers(pageable, application)) - .offset(pageable.getOffset()) - .limit(pageable.getPageSize()) - .fetch(); + .where(builder.getValue()) + .orderBy(OrderSpecifierUtil.getOrderSpecifiers(pageable, application)) + .offset(pageable.getOffset()) + .limit(pageable.getPageSize()) + .fetch(); long count = queryFactory.from(application) - .where(builder) - .fetchCount(); + .where(builder) + .fetchCount(); return new PageImpl<>(applications, pageable, count); } diff --git a/src/main/java/page/clab/api/domain/hiring/application/application/dto/mapper/ApplicationDtoMapper.java b/src/main/java/page/clab/api/domain/hiring/application/application/dto/mapper/ApplicationDtoMapper.java index 3ebd8f89d..c37dff1c5 100644 --- a/src/main/java/page/clab/api/domain/hiring/application/application/dto/mapper/ApplicationDtoMapper.java +++ b/src/main/java/page/clab/api/domain/hiring/application/application/dto/mapper/ApplicationDtoMapper.java @@ -13,66 +13,66 @@ public class ApplicationDtoMapper { public Application fromDto(ApplicationRequestDto requestDto) { return Application.builder() - .studentId(requestDto.getStudentId()) - .recruitmentId(requestDto.getRecruitmentId()) - .name(requestDto.getName()) - .contact(Contact.of(requestDto.getContact()).getValue()) - .email(requestDto.getEmail()) - .department(requestDto.getDepartment()) - .grade(requestDto.getGrade()) - .birth(requestDto.getBirth()) - .address(requestDto.getAddress()) - .interests(requestDto.getInterests()) - .otherActivities(requestDto.getOtherActivities()) - .githubUrl(requestDto.getGithubUrl()) - .applicationType(requestDto.getApplicationType()) - .isPass(false) - .isDeleted(false) - .build(); + .studentId(requestDto.getStudentId()) + .recruitmentId(requestDto.getRecruitmentId()) + .name(requestDto.getName()) + .contact(Contact.of(requestDto.getContact()).getValue()) + .email(requestDto.getEmail()) + .department(requestDto.getDepartment()) + .grade(requestDto.getGrade()) + .birth(requestDto.getBirth()) + .address(requestDto.getAddress()) + .interests(requestDto.getInterests()) + .otherActivities(requestDto.getOtherActivities()) + .githubUrl(requestDto.getGithubUrl()) + .applicationType(requestDto.getApplicationType()) + .isPass(false) + .isDeleted(false) + .build(); } public ApplicationResponseDto toDto(Application application) { return ApplicationResponseDto.builder() - .studentId(application.getStudentId()) - .recruitmentId(application.getRecruitmentId()) - .name(application.getName()) - .contact(application.getContact()) - .email(application.getEmail()) - .department(application.getDepartment()) - .grade(application.getGrade()) - .birth(application.getBirth()) - .address(application.getAddress()) - .interests(application.getInterests()) - .otherActivities(application.getOtherActivities()) - .githubUrl(application.getGithubUrl()) - .applicationType(application.getApplicationType()) - .isPass(application.getIsPass()) - .updatedAt(application.getUpdatedAt()) - .createdAt(application.getCreatedAt()) - .build(); + .studentId(application.getStudentId()) + .recruitmentId(application.getRecruitmentId()) + .name(application.getName()) + .contact(application.getContact()) + .email(application.getEmail()) + .department(application.getDepartment()) + .grade(application.getGrade()) + .birth(application.getBirth()) + .address(application.getAddress()) + .interests(application.getInterests()) + .otherActivities(application.getOtherActivities()) + .githubUrl(application.getGithubUrl()) + .applicationType(application.getApplicationType()) + .isPass(application.getIsPass()) + .updatedAt(application.getUpdatedAt()) + .createdAt(application.getCreatedAt()) + .build(); } public ApplicationMemberCreationDto toCreationDto(Application application) { return ApplicationMemberCreationDto.builder() - .studentId(application.getStudentId()) - .name(application.getName()) - .contact(application.getContact()) - .email(application.getEmail()) - .department(application.getDepartment()) - .grade(application.getGrade()) - .birth(application.getBirth()) - .address(application.getAddress()) - .interests(application.getInterests()) - .githubUrl(application.getGithubUrl()) - .build(); + .studentId(application.getStudentId()) + .name(application.getName()) + .contact(application.getContact()) + .email(application.getEmail()) + .department(application.getDepartment()) + .grade(application.getGrade()) + .birth(application.getBirth()) + .address(application.getAddress()) + .interests(application.getInterests()) + .githubUrl(application.getGithubUrl()) + .build(); } public ApplicationPassResponseDto toPassDto(Application application) { return ApplicationPassResponseDto.builder() - .recruitmentId(application.getRecruitmentId()) - .name(application.getName()) - .applicationType(application.getApplicationType()) - .isPass(application.getIsPass()) - .build(); + .recruitmentId(application.getRecruitmentId()) + .name(application.getName()) + .applicationType(application.getApplicationType()) + .isPass(application.getIsPass()) + .build(); } } diff --git a/src/main/java/page/clab/api/domain/hiring/application/application/dto/request/ApplicationMemberCreationDto.java b/src/main/java/page/clab/api/domain/hiring/application/application/dto/request/ApplicationMemberCreationDto.java index 44a44ec4d..fcab74a2c 100644 --- a/src/main/java/page/clab/api/domain/hiring/application/application/dto/request/ApplicationMemberCreationDto.java +++ b/src/main/java/page/clab/api/domain/hiring/application/application/dto/request/ApplicationMemberCreationDto.java @@ -1,10 +1,9 @@ package page.clab.api.domain.hiring.application.application.dto.request; +import java.time.LocalDate; import lombok.Builder; import lombok.Getter; -import java.time.LocalDate; - @Getter @Builder public class ApplicationMemberCreationDto { diff --git a/src/main/java/page/clab/api/domain/hiring/application/application/dto/request/ApplicationRequestDto.java b/src/main/java/page/clab/api/domain/hiring/application/application/dto/request/ApplicationRequestDto.java index ec9f61197..a595cb8fd 100644 --- a/src/main/java/page/clab/api/domain/hiring/application/application/dto/request/ApplicationRequestDto.java +++ b/src/main/java/page/clab/api/domain/hiring/application/application/dto/request/ApplicationRequestDto.java @@ -2,12 +2,11 @@ import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotNull; +import java.time.LocalDate; import lombok.Getter; import lombok.Setter; import page.clab.api.domain.hiring.application.domain.ApplicationType; -import java.time.LocalDate; - @Getter @Setter public class ApplicationRequestDto { diff --git a/src/main/java/page/clab/api/domain/hiring/application/application/dto/response/ApplicationPassResponseDto.java b/src/main/java/page/clab/api/domain/hiring/application/application/dto/response/ApplicationPassResponseDto.java index c5d264021..f362f6979 100644 --- a/src/main/java/page/clab/api/domain/hiring/application/application/dto/response/ApplicationPassResponseDto.java +++ b/src/main/java/page/clab/api/domain/hiring/application/application/dto/response/ApplicationPassResponseDto.java @@ -15,7 +15,7 @@ public class ApplicationPassResponseDto { public static ApplicationPassResponseDto defaultResponse() { return ApplicationPassResponseDto.builder() - .isPass(false) - .build(); + .isPass(false) + .build(); } } diff --git a/src/main/java/page/clab/api/domain/hiring/application/application/dto/response/ApplicationResponseDto.java b/src/main/java/page/clab/api/domain/hiring/application/application/dto/response/ApplicationResponseDto.java index 9a0693de3..119d23772 100644 --- a/src/main/java/page/clab/api/domain/hiring/application/application/dto/response/ApplicationResponseDto.java +++ b/src/main/java/page/clab/api/domain/hiring/application/application/dto/response/ApplicationResponseDto.java @@ -1,12 +1,11 @@ package page.clab.api.domain.hiring.application.application.dto.response; +import java.time.LocalDate; +import java.time.LocalDateTime; import lombok.Builder; import lombok.Getter; import page.clab.api.domain.hiring.application.domain.ApplicationType; -import java.time.LocalDate; -import java.time.LocalDateTime; - @Getter @Builder public class ApplicationResponseDto { diff --git a/src/main/java/page/clab/api/domain/hiring/application/application/event/ApplicationEventDispatcher.java b/src/main/java/page/clab/api/domain/hiring/application/application/event/ApplicationEventDispatcher.java index e598e9af6..9fa61fd2b 100644 --- a/src/main/java/page/clab/api/domain/hiring/application/application/event/ApplicationEventDispatcher.java +++ b/src/main/java/page/clab/api/domain/hiring/application/application/event/ApplicationEventDispatcher.java @@ -1,11 +1,10 @@ package page.clab.api.domain.hiring.application.application.event; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.context.event.EventListener; import org.springframework.stereotype.Component; -import java.util.List; - @Component @RequiredArgsConstructor public class ApplicationEventDispatcher { diff --git a/src/main/java/page/clab/api/domain/hiring/application/application/event/ApplicationEventProcessorRegistry.java b/src/main/java/page/clab/api/domain/hiring/application/application/event/ApplicationEventProcessorRegistry.java index 0eb70cb8d..64d180257 100644 --- a/src/main/java/page/clab/api/domain/hiring/application/application/event/ApplicationEventProcessorRegistry.java +++ b/src/main/java/page/clab/api/domain/hiring/application/application/event/ApplicationEventProcessorRegistry.java @@ -1,11 +1,10 @@ package page.clab.api.domain.hiring.application.application.event; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Component; - import java.util.ArrayList; import java.util.Collections; import java.util.List; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; @Component @RequiredArgsConstructor diff --git a/src/main/java/page/clab/api/domain/hiring/application/application/port/in/ApplyForApplicationUseCase.java b/src/main/java/page/clab/api/domain/hiring/application/application/port/in/ApplyForApplicationUseCase.java index db8dfc6aa..61a77107c 100644 --- a/src/main/java/page/clab/api/domain/hiring/application/application/port/in/ApplyForApplicationUseCase.java +++ b/src/main/java/page/clab/api/domain/hiring/application/application/port/in/ApplyForApplicationUseCase.java @@ -3,5 +3,6 @@ import page.clab.api.domain.hiring.application.application.dto.request.ApplicationRequestDto; public interface ApplyForApplicationUseCase { + String applyForClub(ApplicationRequestDto requestDto); } diff --git a/src/main/java/page/clab/api/domain/hiring/application/application/port/in/ApproveApplicationUseCase.java b/src/main/java/page/clab/api/domain/hiring/application/application/port/in/ApproveApplicationUseCase.java index 1bc005daa..06a997e63 100644 --- a/src/main/java/page/clab/api/domain/hiring/application/application/port/in/ApproveApplicationUseCase.java +++ b/src/main/java/page/clab/api/domain/hiring/application/application/port/in/ApproveApplicationUseCase.java @@ -1,5 +1,6 @@ package page.clab.api.domain.hiring.application.application.port.in; public interface ApproveApplicationUseCase { + Long approveApplication(Long recruitmentId, String studentId); } diff --git a/src/main/java/page/clab/api/domain/hiring/application/application/port/in/CheckApplicationPassStatusUseCase.java b/src/main/java/page/clab/api/domain/hiring/application/application/port/in/CheckApplicationPassStatusUseCase.java index 188459b0b..b3a25552a 100644 --- a/src/main/java/page/clab/api/domain/hiring/application/application/port/in/CheckApplicationPassStatusUseCase.java +++ b/src/main/java/page/clab/api/domain/hiring/application/application/port/in/CheckApplicationPassStatusUseCase.java @@ -3,5 +3,6 @@ import page.clab.api.domain.hiring.application.application.dto.response.ApplicationPassResponseDto; public interface CheckApplicationPassStatusUseCase { + ApplicationPassResponseDto checkPassStatus(Long recruitmentId, String studentId); } diff --git a/src/main/java/page/clab/api/domain/hiring/application/application/port/in/RejectApplicationUseCase.java b/src/main/java/page/clab/api/domain/hiring/application/application/port/in/RejectApplicationUseCase.java index 569c649b0..afa5ae1e1 100644 --- a/src/main/java/page/clab/api/domain/hiring/application/application/port/in/RejectApplicationUseCase.java +++ b/src/main/java/page/clab/api/domain/hiring/application/application/port/in/RejectApplicationUseCase.java @@ -1,5 +1,6 @@ package page.clab.api.domain.hiring.application.application.port.in; public interface RejectApplicationUseCase { + Long rejectApplication(Long recruitmentId, String studentId); } diff --git a/src/main/java/page/clab/api/domain/hiring/application/application/port/in/RetrieveApplicationsUseCase.java b/src/main/java/page/clab/api/domain/hiring/application/application/port/in/RetrieveApplicationsUseCase.java index 5fb619a31..170135486 100644 --- a/src/main/java/page/clab/api/domain/hiring/application/application/port/in/RetrieveApplicationsUseCase.java +++ b/src/main/java/page/clab/api/domain/hiring/application/application/port/in/RetrieveApplicationsUseCase.java @@ -5,5 +5,7 @@ import page.clab.api.global.common.dto.PagedResponseDto; public interface RetrieveApplicationsUseCase { - PagedResponseDto retrieveApplications(Long recruitmentId, String studentId, Boolean isPass, Pageable pageable); + + PagedResponseDto retrieveApplications(Long recruitmentId, String studentId, Boolean isPass, + Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/hiring/application/application/port/out/RegisterApplicationPort.java b/src/main/java/page/clab/api/domain/hiring/application/application/port/out/RegisterApplicationPort.java index 953959b56..7e8d184b1 100644 --- a/src/main/java/page/clab/api/domain/hiring/application/application/port/out/RegisterApplicationPort.java +++ b/src/main/java/page/clab/api/domain/hiring/application/application/port/out/RegisterApplicationPort.java @@ -3,5 +3,6 @@ import page.clab.api.domain.hiring.application.domain.Application; public interface RegisterApplicationPort { + Application save(Application application); } diff --git a/src/main/java/page/clab/api/domain/hiring/application/application/port/out/RetrieveApplicationPort.java b/src/main/java/page/clab/api/domain/hiring/application/application/port/out/RetrieveApplicationPort.java index 130e0e034..e44e686f2 100644 --- a/src/main/java/page/clab/api/domain/hiring/application/application/port/out/RetrieveApplicationPort.java +++ b/src/main/java/page/clab/api/domain/hiring/application/application/port/out/RetrieveApplicationPort.java @@ -1,13 +1,12 @@ package page.clab.api.domain.hiring.application.application.port.out; +import java.util.List; +import java.util.Optional; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import page.clab.api.domain.hiring.application.adapter.out.persistence.ApplicationId; import page.clab.api.domain.hiring.application.domain.Application; -import java.util.List; -import java.util.Optional; - public interface RetrieveApplicationPort { Optional findById(ApplicationId applicationId); diff --git a/src/main/java/page/clab/api/domain/hiring/application/application/service/ApplicationApplyService.java b/src/main/java/page/clab/api/domain/hiring/application/application/service/ApplicationApplyService.java index 357a59cde..d50c1d00d 100644 --- a/src/main/java/page/clab/api/domain/hiring/application/application/service/ApplicationApplyService.java +++ b/src/main/java/page/clab/api/domain/hiring/application/application/service/ApplicationApplyService.java @@ -31,10 +31,10 @@ public String applyForClub(ApplicationRequestDto requestDto) { Application application = mapper.fromDto(requestDto); String applicationType = application.getApplicationTypeForNotificationPrefix(); externalSendNotificationUseCase.sendNotificationToAdmins(applicationType + requestDto.getStudentId() + " " + - requestDto.getName() + "님이 지원하였습니다."); + requestDto.getName() + "님이 지원하였습니다."); eventPublisher.publishEvent(new NotificationEvent(this, ExecutivesAlertType.NEW_APPLICATION, null, - requestDto)); + requestDto)); return registerApplicationPort.save(application).getStudentId(); } diff --git a/src/main/java/page/clab/api/domain/hiring/application/application/service/ApplicationMemberRegisterService.java b/src/main/java/page/clab/api/domain/hiring/application/application/service/ApplicationMemberRegisterService.java index 5051d6b0f..bb593e1e4 100644 --- a/src/main/java/page/clab/api/domain/hiring/application/application/service/ApplicationMemberRegisterService.java +++ b/src/main/java/page/clab/api/domain/hiring/application/application/service/ApplicationMemberRegisterService.java @@ -1,5 +1,7 @@ package page.clab.api.domain.hiring.application.application.service; +import java.time.LocalDate; +import java.util.List; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.context.ApplicationEventPublisher; @@ -18,9 +20,6 @@ import page.clab.api.external.memberManagement.member.application.port.ExternalRetrieveMemberUseCase; import page.clab.api.external.memberManagement.position.application.port.ExternalRetrievePositionUseCase; -import java.time.LocalDate; -import java.util.List; - @Service @RequiredArgsConstructor @Slf4j @@ -38,8 +37,8 @@ public class ApplicationMemberRegisterService implements RegisterMembersByRecrui public List registerMembersByRecruitment(Long recruitmentId) { List applications = retrieveApplicationPort.findByRecruitmentIdAndIsPass(recruitmentId, true); return applications.stream() - .map(this::createMemberFromApplication) - .toList(); + .map(this::createMemberFromApplication) + .toList(); } // 해당 모집에서 합격한 특정 지원자의 계정을 생성합니다. @@ -52,7 +51,7 @@ public String registerMembersByRecruitment(Long recruitmentId, String studentId) } private void validateApplicationIsPass(Application application) { - if(!application.getIsPass()) { + if (!application.getIsPass()) { throw new NotApprovedApplicationException("승인되지 않은 지원서입니다."); } } @@ -65,15 +64,15 @@ private String createMemberFromApplication(Application application) { private Member createMemberByApplication(Application application) { return externalRetrieveMemberUseCase.findById(application.getStudentId()) - .orElseGet(() -> { - ApplicationMemberCreationDto dto = mapper.toCreationDto(application); - eventPublisher.publishEvent(new ApplicationMemberCreatedEvent(this, dto)); - return externalRetrieveMemberUseCase.getById(application.getStudentId()); - }); + .orElseGet(() -> { + ApplicationMemberCreationDto dto = mapper.toCreationDto(application); + eventPublisher.publishEvent(new ApplicationMemberCreatedEvent(this, dto)); + return externalRetrieveMemberUseCase.getById(application.getStudentId()); + }); } public void createPositionByMember(Member member) { - if(isMemberPositionRegistered(member)) { + if (isMemberPositionRegistered(member)) { log.warn("이미 직책이 있는 회원입니다: {}", member.getId()); return; } @@ -82,7 +81,8 @@ public void createPositionByMember(Member member) { private boolean isMemberPositionRegistered(Member member) { return externalRetrievePositionUseCase - .findByMemberIdAndYearAndPositionType(member.getId(), String.valueOf(LocalDate.now().getYear()), PositionType.MEMBER) - .isPresent(); + .findByMemberIdAndYearAndPositionType(member.getId(), String.valueOf(LocalDate.now().getYear()), + PositionType.MEMBER) + .isPresent(); } } diff --git a/src/main/java/page/clab/api/domain/hiring/application/application/service/ApplicationPassCheckService.java b/src/main/java/page/clab/api/domain/hiring/application/application/service/ApplicationPassCheckService.java index 168c5007e..4c8ffdfef 100644 --- a/src/main/java/page/clab/api/domain/hiring/application/application/service/ApplicationPassCheckService.java +++ b/src/main/java/page/clab/api/domain/hiring/application/application/service/ApplicationPassCheckService.java @@ -28,7 +28,7 @@ public ApplicationPassResponseDto checkPassStatus(Long recruitmentId, String stu recruitment.validateEndDateWithin7Days(); return retrieveApplicationPort.findById(id) - .map(mapper::toPassDto) - .orElseGet(ApplicationPassResponseDto::defaultResponse); + .map(mapper::toPassDto) + .orElseGet(ApplicationPassResponseDto::defaultResponse); } } diff --git a/src/main/java/page/clab/api/domain/hiring/application/application/service/ApplicationRetrievalService.java b/src/main/java/page/clab/api/domain/hiring/application/application/service/ApplicationRetrievalService.java index a6ea0306b..e97ea1505 100644 --- a/src/main/java/page/clab/api/domain/hiring/application/application/service/ApplicationRetrievalService.java +++ b/src/main/java/page/clab/api/domain/hiring/application/application/service/ApplicationRetrievalService.java @@ -21,8 +21,10 @@ public class ApplicationRetrievalService implements RetrieveApplicationsUseCase @Transactional(readOnly = true) @Override - public PagedResponseDto retrieveApplications(Long recruitmentId, String studentId, Boolean isPass, Pageable pageable) { - Page applications = retrieveApplicationPort.findByConditions(recruitmentId, studentId, isPass, pageable); + public PagedResponseDto retrieveApplications(Long recruitmentId, String studentId, + Boolean isPass, Pageable pageable) { + Page applications = retrieveApplicationPort.findByConditions(recruitmentId, studentId, isPass, + pageable); return new PagedResponseDto<>(applications.map(mapper::toDto)); } } diff --git a/src/main/java/page/clab/api/domain/hiring/application/domain/Application.java b/src/main/java/page/clab/api/domain/hiring/application/domain/Application.java index 56121e70a..6e9fe7055 100644 --- a/src/main/java/page/clab/api/domain/hiring/application/domain/Application.java +++ b/src/main/java/page/clab/api/domain/hiring/application/domain/Application.java @@ -1,5 +1,7 @@ package page.clab.api.domain.hiring.application.domain; +import java.time.LocalDate; +import java.time.LocalDateTime; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -7,9 +9,6 @@ import lombok.NoArgsConstructor; import lombok.Setter; -import java.time.LocalDate; -import java.time.LocalDateTime; - @Getter @Setter @Builder diff --git a/src/main/java/page/clab/api/domain/hiring/recruitment/adapter/in/web/RecentRecruitmentsRetrievalController.java b/src/main/java/page/clab/api/domain/hiring/recruitment/adapter/in/web/RecentRecruitmentsRetrievalController.java index b7609def2..a4802e3c1 100644 --- a/src/main/java/page/clab/api/domain/hiring/recruitment/adapter/in/web/RecentRecruitmentsRetrievalController.java +++ b/src/main/java/page/clab/api/domain/hiring/recruitment/adapter/in/web/RecentRecruitmentsRetrievalController.java @@ -2,6 +2,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -11,8 +12,6 @@ import page.clab.api.domain.hiring.recruitment.application.port.in.RetrieveRecentRecruitmentsUseCase; import page.clab.api.global.common.dto.ApiResponse; -import java.util.List; - @RestController @RequestMapping("/api/v1/recruitments") @RequiredArgsConstructor @@ -22,13 +21,13 @@ public class RecentRecruitmentsRetrievalController { private final RetrieveRecentRecruitmentsUseCase retrieveRecentRecruitmentsUseCase; @Operation(summary = "모집 공고 목록(최근 5건)", description = "ROLE_ANONYMOUS 이상의 권한이 필요함
" + - "최근 5건의 모집 공고를 조회") + "최근 5건의 모집 공고를 조회") @GetMapping("") public ApiResponse> retrieveRecentRecruitments() { List recruitments = retrieveRecentRecruitmentsUseCase.retrieveRecentRecruitments(); return ApiResponse.success(recruitments); } - + @Operation(summary = "모집 종료 기간 기준 최신 일주일 모집 공고 목록", description = "ROLE_ANONYMOUS 이상의 권한이 필요함") @GetMapping("/recent-week") public ApiResponse> retrieveRecruitmentsByEndDate() { diff --git a/src/main/java/page/clab/api/domain/hiring/recruitment/adapter/in/web/RecruitmentRegisterController.java b/src/main/java/page/clab/api/domain/hiring/recruitment/adapter/in/web/RecruitmentRegisterController.java index 5343865b3..e62443e62 100644 --- a/src/main/java/page/clab/api/domain/hiring/recruitment/adapter/in/web/RecruitmentRegisterController.java +++ b/src/main/java/page/clab/api/domain/hiring/recruitment/adapter/in/web/RecruitmentRegisterController.java @@ -25,7 +25,7 @@ public class RecruitmentRegisterController { @PreAuthorize("hasRole('SUPER')") @PostMapping("") public ApiResponse registerRecruitment( - @Valid @RequestBody RecruitmentRequestDto requestDto + @Valid @RequestBody RecruitmentRequestDto requestDto ) { Long id = registerRecruitmentUseCase.registerRecruitment(requestDto); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/hiring/recruitment/adapter/in/web/RecruitmentUpdateController.java b/src/main/java/page/clab/api/domain/hiring/recruitment/adapter/in/web/RecruitmentUpdateController.java index 879cb5857..c05d342ce 100644 --- a/src/main/java/page/clab/api/domain/hiring/recruitment/adapter/in/web/RecruitmentUpdateController.java +++ b/src/main/java/page/clab/api/domain/hiring/recruitment/adapter/in/web/RecruitmentUpdateController.java @@ -26,8 +26,8 @@ public class RecruitmentUpdateController { @PreAuthorize("hasRole('SUPER')") @PatchMapping("/{recruitmentId}") public ApiResponse updateRecruitment( - @PathVariable(name = "recruitmentId") Long recruitmentId, - @Valid @RequestBody RecruitmentUpdateRequestDto requestDto + @PathVariable(name = "recruitmentId") Long recruitmentId, + @Valid @RequestBody RecruitmentUpdateRequestDto requestDto ) { Long id = updateRecruitmentUseCase.updateRecruitment(recruitmentId, requestDto); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/hiring/recruitment/adapter/out/persistence/RecruitmentJpaEntity.java b/src/main/java/page/clab/api/domain/hiring/recruitment/adapter/out/persistence/RecruitmentJpaEntity.java index bf53085c4..15a3dda80 100644 --- a/src/main/java/page/clab/api/domain/hiring/recruitment/adapter/out/persistence/RecruitmentJpaEntity.java +++ b/src/main/java/page/clab/api/domain/hiring/recruitment/adapter/out/persistence/RecruitmentJpaEntity.java @@ -9,6 +9,7 @@ import jakarta.persistence.Id; import jakarta.persistence.Table; import jakarta.validation.constraints.Size; +import java.time.LocalDateTime; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -21,8 +22,6 @@ import page.clab.api.domain.hiring.recruitment.domain.RecruitmentStatus; import page.clab.api.global.common.domain.BaseEntity; -import java.time.LocalDateTime; - @Entity @Table(name = "recruitment") @Getter diff --git a/src/main/java/page/clab/api/domain/hiring/recruitment/adapter/out/persistence/RecruitmentPersistenceAdapter.java b/src/main/java/page/clab/api/domain/hiring/recruitment/adapter/out/persistence/RecruitmentPersistenceAdapter.java index 8d32312db..913b980ca 100644 --- a/src/main/java/page/clab/api/domain/hiring/recruitment/adapter/out/persistence/RecruitmentPersistenceAdapter.java +++ b/src/main/java/page/clab/api/domain/hiring/recruitment/adapter/out/persistence/RecruitmentPersistenceAdapter.java @@ -1,5 +1,7 @@ package page.clab.api.domain.hiring.recruitment.adapter.out.persistence; +import java.time.LocalDateTime; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; import page.clab.api.domain.hiring.recruitment.application.port.out.RegisterRecruitmentPort; @@ -8,15 +10,12 @@ import page.clab.api.domain.hiring.recruitment.domain.Recruitment; import page.clab.api.global.exception.NotFoundException; -import java.time.LocalDateTime; -import java.util.List; - @Component @RequiredArgsConstructor public class RecruitmentPersistenceAdapter implements - RegisterRecruitmentPort, - UpdateRecruitmentPort, - RetrieveRecruitmentPort { + RegisterRecruitmentPort, + UpdateRecruitmentPort, + RetrieveRecruitmentPort { private final RecruitmentRepository repository; private final RecruitmentMapper mapper; @@ -38,28 +37,29 @@ public Recruitment update(Recruitment recruitment) { @Override public Recruitment getById(Long recruitmentId) { return repository.findById(recruitmentId) - .map(mapper::toDomain) - .orElseThrow(() -> new NotFoundException("[Recruitment] id: " + recruitmentId + "에 해당하는 모집 공고가 존재하지 않습니다.")); + .map(mapper::toDomain) + .orElseThrow( + () -> new NotFoundException("[Recruitment] id: " + recruitmentId + "에 해당하는 모집 공고가 존재하지 않습니다.")); } @Override public List findAll() { return repository.findAll().stream() - .map(mapper::toDomain) - .toList(); + .map(mapper::toDomain) + .toList(); } @Override public List findTop5ByOrderByCreatedAtDesc() { return repository.findTop5ByOrderByCreatedAtDesc().stream() - .map(mapper::toDomain) - .toList(); + .map(mapper::toDomain) + .toList(); } @Override public List findByEndDateBetween(LocalDateTime weekAgo, LocalDateTime now) { return repository.findByEndDateBetween(weekAgo, now).stream() - .map(mapper::toDomain) - .toList(); + .map(mapper::toDomain) + .toList(); } } diff --git a/src/main/java/page/clab/api/domain/hiring/recruitment/adapter/out/persistence/RecruitmentRepository.java b/src/main/java/page/clab/api/domain/hiring/recruitment/adapter/out/persistence/RecruitmentRepository.java index 0ceb88bd7..171e9fb9d 100644 --- a/src/main/java/page/clab/api/domain/hiring/recruitment/adapter/out/persistence/RecruitmentRepository.java +++ b/src/main/java/page/clab/api/domain/hiring/recruitment/adapter/out/persistence/RecruitmentRepository.java @@ -1,10 +1,9 @@ package page.clab.api.domain.hiring.recruitment.adapter.out.persistence; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - import java.time.LocalDateTime; import java.util.List; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; @Repository public interface RecruitmentRepository extends JpaRepository { diff --git a/src/main/java/page/clab/api/domain/hiring/recruitment/application/dto/mapper/RecruitmentDtoMapper.java b/src/main/java/page/clab/api/domain/hiring/recruitment/application/dto/mapper/RecruitmentDtoMapper.java index 3e6627583..1a2fe6c85 100644 --- a/src/main/java/page/clab/api/domain/hiring/recruitment/application/dto/mapper/RecruitmentDtoMapper.java +++ b/src/main/java/page/clab/api/domain/hiring/recruitment/application/dto/mapper/RecruitmentDtoMapper.java @@ -11,30 +11,30 @@ public class RecruitmentDtoMapper { public Recruitment fromDto(RecruitmentRequestDto requestDto) { return Recruitment.builder() - .startDate(requestDto.getStartDate()) - .endDate(requestDto.getEndDate()) - .applicationType(requestDto.getApplicationType()) - .target(requestDto.getTarget()) - .isDeleted(false) - .build(); + .startDate(requestDto.getStartDate()) + .endDate(requestDto.getEndDate()) + .applicationType(requestDto.getApplicationType()) + .target(requestDto.getTarget()) + .isDeleted(false) + .build(); } public RecruitmentResponseDto toDto(Recruitment recruitment) { return RecruitmentResponseDto.builder() - .id(recruitment.getId()) - .startDate(recruitment.getStartDate()) - .endDate(recruitment.getEndDate()) - .applicationType(recruitment.getApplicationType()) - .target(recruitment.getTarget()) - .status(recruitment.getStatus().getDescription()) - .updatedAt(recruitment.getUpdatedAt()) - .build(); + .id(recruitment.getId()) + .startDate(recruitment.getStartDate()) + .endDate(recruitment.getEndDate()) + .applicationType(recruitment.getApplicationType()) + .target(recruitment.getTarget()) + .status(recruitment.getStatus().getDescription()) + .updatedAt(recruitment.getUpdatedAt()) + .build(); } public RecruitmentEndDateResponseDto toEndDateDto(Recruitment recruitment) { return RecruitmentEndDateResponseDto.builder() - .id(recruitment.getId()) - .applicationType(recruitment.getApplicationType()) - .build(); + .id(recruitment.getId()) + .applicationType(recruitment.getApplicationType()) + .build(); } } diff --git a/src/main/java/page/clab/api/domain/hiring/recruitment/application/dto/request/RecruitmentRequestDto.java b/src/main/java/page/clab/api/domain/hiring/recruitment/application/dto/request/RecruitmentRequestDto.java index 87b32e0b4..dc2618dbe 100644 --- a/src/main/java/page/clab/api/domain/hiring/recruitment/application/dto/request/RecruitmentRequestDto.java +++ b/src/main/java/page/clab/api/domain/hiring/recruitment/application/dto/request/RecruitmentRequestDto.java @@ -2,12 +2,11 @@ import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotNull; +import java.time.LocalDateTime; import lombok.Getter; import lombok.Setter; import page.clab.api.domain.hiring.application.domain.ApplicationType; -import java.time.LocalDateTime; - @Getter @Setter public class RecruitmentRequestDto { diff --git a/src/main/java/page/clab/api/domain/hiring/recruitment/application/dto/request/RecruitmentUpdateRequestDto.java b/src/main/java/page/clab/api/domain/hiring/recruitment/application/dto/request/RecruitmentUpdateRequestDto.java index 246603b68..8bcede1bb 100644 --- a/src/main/java/page/clab/api/domain/hiring/recruitment/application/dto/request/RecruitmentUpdateRequestDto.java +++ b/src/main/java/page/clab/api/domain/hiring/recruitment/application/dto/request/RecruitmentUpdateRequestDto.java @@ -1,12 +1,11 @@ package page.clab.api.domain.hiring.recruitment.application.dto.request; import io.swagger.v3.oas.annotations.media.Schema; +import java.time.LocalDateTime; import lombok.Getter; import lombok.Setter; import page.clab.api.domain.hiring.application.domain.ApplicationType; -import java.time.LocalDateTime; - @Getter @Setter public class RecruitmentUpdateRequestDto { diff --git a/src/main/java/page/clab/api/domain/hiring/recruitment/application/dto/response/RecruitmentResponseDto.java b/src/main/java/page/clab/api/domain/hiring/recruitment/application/dto/response/RecruitmentResponseDto.java index a7234bd8f..10dc5d9cd 100644 --- a/src/main/java/page/clab/api/domain/hiring/recruitment/application/dto/response/RecruitmentResponseDto.java +++ b/src/main/java/page/clab/api/domain/hiring/recruitment/application/dto/response/RecruitmentResponseDto.java @@ -1,11 +1,10 @@ package page.clab.api.domain.hiring.recruitment.application.dto.response; +import java.time.LocalDateTime; import lombok.Builder; import lombok.Getter; import page.clab.api.domain.hiring.application.domain.ApplicationType; -import java.time.LocalDateTime; - @Getter @Builder public class RecruitmentResponseDto { diff --git a/src/main/java/page/clab/api/domain/hiring/recruitment/application/port/in/RegisterRecruitmentUseCase.java b/src/main/java/page/clab/api/domain/hiring/recruitment/application/port/in/RegisterRecruitmentUseCase.java index 133b8a429..0935cfa13 100644 --- a/src/main/java/page/clab/api/domain/hiring/recruitment/application/port/in/RegisterRecruitmentUseCase.java +++ b/src/main/java/page/clab/api/domain/hiring/recruitment/application/port/in/RegisterRecruitmentUseCase.java @@ -3,5 +3,6 @@ import page.clab.api.domain.hiring.recruitment.application.dto.request.RecruitmentRequestDto; public interface RegisterRecruitmentUseCase { + Long registerRecruitment(RecruitmentRequestDto requestDto); } diff --git a/src/main/java/page/clab/api/domain/hiring/recruitment/application/port/in/RetrieveRecentRecruitmentsUseCase.java b/src/main/java/page/clab/api/domain/hiring/recruitment/application/port/in/RetrieveRecentRecruitmentsUseCase.java index a55ed8275..38823faec 100644 --- a/src/main/java/page/clab/api/domain/hiring/recruitment/application/port/in/RetrieveRecentRecruitmentsUseCase.java +++ b/src/main/java/page/clab/api/domain/hiring/recruitment/application/port/in/RetrieveRecentRecruitmentsUseCase.java @@ -1,10 +1,9 @@ package page.clab.api.domain.hiring.recruitment.application.port.in; +import java.util.List; import page.clab.api.domain.hiring.recruitment.application.dto.response.RecruitmentEndDateResponseDto; import page.clab.api.domain.hiring.recruitment.application.dto.response.RecruitmentResponseDto; -import java.util.List; - public interface RetrieveRecentRecruitmentsUseCase { List retrieveRecentRecruitments(); diff --git a/src/main/java/page/clab/api/domain/hiring/recruitment/application/port/in/RetrieveRecruitmentUseCase.java b/src/main/java/page/clab/api/domain/hiring/recruitment/application/port/in/RetrieveRecruitmentUseCase.java index fdfaa40c9..e3ab1d8d7 100644 --- a/src/main/java/page/clab/api/domain/hiring/recruitment/application/port/in/RetrieveRecruitmentUseCase.java +++ b/src/main/java/page/clab/api/domain/hiring/recruitment/application/port/in/RetrieveRecruitmentUseCase.java @@ -4,5 +4,6 @@ import page.clab.api.domain.hiring.recruitment.domain.Recruitment; public interface RetrieveRecruitmentUseCase { + Recruitment getById(Long recruitmentId); } diff --git a/src/main/java/page/clab/api/domain/hiring/recruitment/application/port/in/UpdateRecruitmentUseCase.java b/src/main/java/page/clab/api/domain/hiring/recruitment/application/port/in/UpdateRecruitmentUseCase.java index e4e4f7852..f83c72bad 100644 --- a/src/main/java/page/clab/api/domain/hiring/recruitment/application/port/in/UpdateRecruitmentUseCase.java +++ b/src/main/java/page/clab/api/domain/hiring/recruitment/application/port/in/UpdateRecruitmentUseCase.java @@ -3,5 +3,6 @@ import page.clab.api.domain.hiring.recruitment.application.dto.request.RecruitmentUpdateRequestDto; public interface UpdateRecruitmentUseCase { + Long updateRecruitment(Long recruitmentId, RecruitmentUpdateRequestDto requestDto); } diff --git a/src/main/java/page/clab/api/domain/hiring/recruitment/application/port/out/RegisterRecruitmentPort.java b/src/main/java/page/clab/api/domain/hiring/recruitment/application/port/out/RegisterRecruitmentPort.java index 6b6384502..642a2969e 100644 --- a/src/main/java/page/clab/api/domain/hiring/recruitment/application/port/out/RegisterRecruitmentPort.java +++ b/src/main/java/page/clab/api/domain/hiring/recruitment/application/port/out/RegisterRecruitmentPort.java @@ -4,5 +4,6 @@ import page.clab.api.domain.hiring.recruitment.domain.Recruitment; public interface RegisterRecruitmentPort { + Recruitment save(Recruitment recruitment); } diff --git a/src/main/java/page/clab/api/domain/hiring/recruitment/application/port/out/RetrieveRecruitmentPort.java b/src/main/java/page/clab/api/domain/hiring/recruitment/application/port/out/RetrieveRecruitmentPort.java index 36d5057e5..ab19aa86f 100644 --- a/src/main/java/page/clab/api/domain/hiring/recruitment/application/port/out/RetrieveRecruitmentPort.java +++ b/src/main/java/page/clab/api/domain/hiring/recruitment/application/port/out/RetrieveRecruitmentPort.java @@ -1,9 +1,8 @@ package page.clab.api.domain.hiring.recruitment.application.port.out; -import page.clab.api.domain.hiring.recruitment.domain.Recruitment; - import java.time.LocalDateTime; import java.util.List; +import page.clab.api.domain.hiring.recruitment.domain.Recruitment; public interface RetrieveRecruitmentPort { diff --git a/src/main/java/page/clab/api/domain/hiring/recruitment/application/port/out/UpdateRecruitmentPort.java b/src/main/java/page/clab/api/domain/hiring/recruitment/application/port/out/UpdateRecruitmentPort.java index 7e4fc4dec..d017da909 100644 --- a/src/main/java/page/clab/api/domain/hiring/recruitment/application/port/out/UpdateRecruitmentPort.java +++ b/src/main/java/page/clab/api/domain/hiring/recruitment/application/port/out/UpdateRecruitmentPort.java @@ -4,5 +4,6 @@ import page.clab.api.domain.hiring.recruitment.domain.Recruitment; public interface UpdateRecruitmentPort { + Recruitment update(Recruitment recruitment); } diff --git a/src/main/java/page/clab/api/domain/hiring/recruitment/application/service/RecentRecruitmentsRetrievalService.java b/src/main/java/page/clab/api/domain/hiring/recruitment/application/service/RecentRecruitmentsRetrievalService.java index 3f9d86892..433c791e9 100644 --- a/src/main/java/page/clab/api/domain/hiring/recruitment/application/service/RecentRecruitmentsRetrievalService.java +++ b/src/main/java/page/clab/api/domain/hiring/recruitment/application/service/RecentRecruitmentsRetrievalService.java @@ -1,5 +1,8 @@ package page.clab.api.domain.hiring.recruitment.application.service; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -9,10 +12,6 @@ import page.clab.api.domain.hiring.recruitment.application.port.in.RetrieveRecentRecruitmentsUseCase; import page.clab.api.domain.hiring.recruitment.application.port.out.RetrieveRecruitmentPort; -import java.time.LocalDateTime; -import java.time.LocalTime; -import java.util.List; - @Service @RequiredArgsConstructor public class RecentRecruitmentsRetrievalService implements RetrieveRecentRecruitmentsUseCase { @@ -24,8 +23,8 @@ public class RecentRecruitmentsRetrievalService implements RetrieveRecentRecruit @Override public List retrieveRecentRecruitments() { return retrieveRecruitmentPort.findTop5ByOrderByCreatedAtDesc().stream() - .map(mapper::toDto) - .toList(); + .map(mapper::toDto) + .toList(); } @Transactional(readOnly = true) @@ -36,7 +35,7 @@ public List retrieveRecruitmentsByEndDate() { LocalDateTime endOfDay = now.with(LocalTime.MAX); return retrieveRecruitmentPort.findByEndDateBetween(weekAgo, endOfDay).stream() - .map(mapper::toEndDateDto) - .toList(); + .map(mapper::toEndDateDto) + .toList(); } } diff --git a/src/main/java/page/clab/api/domain/hiring/recruitment/application/service/RecruitmentStatusUpdater.java b/src/main/java/page/clab/api/domain/hiring/recruitment/application/service/RecruitmentStatusUpdater.java index 69e19c602..65a488a46 100644 --- a/src/main/java/page/clab/api/domain/hiring/recruitment/application/service/RecruitmentStatusUpdater.java +++ b/src/main/java/page/clab/api/domain/hiring/recruitment/application/service/RecruitmentStatusUpdater.java @@ -1,5 +1,7 @@ package page.clab.api.domain.hiring.recruitment.application.service; +import java.time.LocalDateTime; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; @@ -8,9 +10,6 @@ import page.clab.api.domain.hiring.recruitment.domain.Recruitment; import page.clab.api.domain.hiring.recruitment.domain.RecruitmentStatus; -import java.time.LocalDateTime; -import java.util.List; - @Component @RequiredArgsConstructor public class RecruitmentStatusUpdater { diff --git a/src/main/java/page/clab/api/domain/hiring/recruitment/domain/Recruitment.java b/src/main/java/page/clab/api/domain/hiring/recruitment/domain/Recruitment.java index 356f5fa17..85e879407 100644 --- a/src/main/java/page/clab/api/domain/hiring/recruitment/domain/Recruitment.java +++ b/src/main/java/page/clab/api/domain/hiring/recruitment/domain/Recruitment.java @@ -1,5 +1,8 @@ package page.clab.api.domain.hiring.recruitment.domain; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.Optional; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -12,10 +15,6 @@ import page.clab.api.domain.hiring.recruitment.application.dto.request.RecruitmentUpdateRequestDto; import page.clab.api.global.exception.InvalidDateRangeException; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.util.Optional; - @Getter @Setter @Builder diff --git a/src/main/java/page/clab/api/domain/library/book/adapter/in/web/BookDetailsRetrievalController.java b/src/main/java/page/clab/api/domain/library/book/adapter/in/web/BookDetailsRetrievalController.java index 1133748a9..802f8dca6 100644 --- a/src/main/java/page/clab/api/domain/library/book/adapter/in/web/BookDetailsRetrievalController.java +++ b/src/main/java/page/clab/api/domain/library/book/adapter/in/web/BookDetailsRetrievalController.java @@ -24,7 +24,7 @@ public class BookDetailsRetrievalController { @PreAuthorize("hasRole('GUEST')") @GetMapping("/{bookId}") public ApiResponse retrieveBookDetails( - @PathVariable(name = "bookId") Long bookId + @PathVariable(name = "bookId") Long bookId ) { BookDetailsResponseDto book = retrieveBookDetailsUseCase.retrieveBookDetails(bookId); return ApiResponse.success(book); diff --git a/src/main/java/page/clab/api/domain/library/book/adapter/in/web/BookRegisterController.java b/src/main/java/page/clab/api/domain/library/book/adapter/in/web/BookRegisterController.java index bef5a99e1..9d5d3fde8 100644 --- a/src/main/java/page/clab/api/domain/library/book/adapter/in/web/BookRegisterController.java +++ b/src/main/java/page/clab/api/domain/library/book/adapter/in/web/BookRegisterController.java @@ -25,7 +25,7 @@ public class BookRegisterController { @PreAuthorize("hasRole('ADMIN')") @PostMapping("") public ApiResponse registerBook( - @Valid @RequestBody BookRequestDto requestDto + @Valid @RequestBody BookRequestDto requestDto ) { Long id = registerBookUseCase.registerBook(requestDto); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/library/book/adapter/in/web/BookRemoveController.java b/src/main/java/page/clab/api/domain/library/book/adapter/in/web/BookRemoveController.java index 6438aa88b..b2eb3a5b3 100644 --- a/src/main/java/page/clab/api/domain/library/book/adapter/in/web/BookRemoveController.java +++ b/src/main/java/page/clab/api/domain/library/book/adapter/in/web/BookRemoveController.java @@ -23,7 +23,7 @@ public class BookRemoveController { @PreAuthorize("hasRole('ADMIN')") @DeleteMapping("/{bookId}") public ApiResponse removeBook( - @PathVariable(name = "bookId") Long bookId + @PathVariable(name = "bookId") Long bookId ) { Long id = removeBookUseCase.removeBook(bookId); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/library/book/adapter/in/web/BookUpdateController.java b/src/main/java/page/clab/api/domain/library/book/adapter/in/web/BookUpdateController.java index c014b3830..48a365dc7 100644 --- a/src/main/java/page/clab/api/domain/library/book/adapter/in/web/BookUpdateController.java +++ b/src/main/java/page/clab/api/domain/library/book/adapter/in/web/BookUpdateController.java @@ -26,8 +26,8 @@ public class BookUpdateController { @PreAuthorize("hasRole('ADMIN')") @PatchMapping("") public ApiResponse updateBookInfo( - @RequestParam(name = "bookId") Long bookId, - @Valid @RequestBody BookUpdateRequestDto requestDto + @RequestParam(name = "bookId") Long bookId, + @Valid @RequestBody BookUpdateRequestDto requestDto ) { Long id = updateBookUseCase.updateBookInfo(bookId, requestDto); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/library/book/adapter/in/web/BooksByConditionsRetrievalController.java b/src/main/java/page/clab/api/domain/library/book/adapter/in/web/BooksByConditionsRetrievalController.java index 09b318382..386020e0d 100644 --- a/src/main/java/page/clab/api/domain/library/book/adapter/in/web/BooksByConditionsRetrievalController.java +++ b/src/main/java/page/clab/api/domain/library/book/adapter/in/web/BooksByConditionsRetrievalController.java @@ -2,6 +2,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.security.access.prepost.PreAuthorize; @@ -17,8 +18,6 @@ import page.clab.api.global.exception.SortingArgumentException; import page.clab.api.global.util.PageableUtils; -import java.util.List; - @RestController @RequestMapping("/api/v1/books") @RequiredArgsConstructor @@ -29,24 +28,25 @@ public class BooksByConditionsRetrievalController { private final PageableUtils pageableUtils; @Operation(summary = "[G] 도서 목록 조회(제목, 카테고리, 출판사, 대여자 ID, 대여자 이름 기준)", description = "ROLE_GUEST 이상의 권한이 필요함
" + - "5개의 파라미터를 자유롭게 조합하여 필터링 가능
" + - "제목, 카테고리, 출판사, 대여자 ID, 대여자 이름 중 하나라도 입력하지 않으면 전체 조회됨
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") + "5개의 파라미터를 자유롭게 조합하여 필터링 가능
" + + "제목, 카테고리, 출판사, 대여자 ID, 대여자 이름 중 하나라도 입력하지 않으면 전체 조회됨
" + + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") @PreAuthorize("hasRole('GUEST')") @GetMapping("") public ApiResponse> retrieveBooksByConditions( - @RequestParam(name = "title", required = false) String title, - @RequestParam(name = "category", required = false) String category, - @RequestParam(name = "publisher", required = false) String publisher, - @RequestParam(name = "borrowerId", required = false) String borrowerId, - @RequestParam(name = "borrowerName", required = false) String borrowerName, - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection + @RequestParam(name = "title", required = false) String title, + @RequestParam(name = "category", required = false) String category, + @RequestParam(name = "publisher", required = false) String publisher, + @RequestParam(name = "borrowerId", required = false) String borrowerId, + @RequestParam(name = "borrowerName", required = false) String borrowerName, + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection ) throws SortingArgumentException, InvalidColumnException { Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, BookResponseDto.class); - PagedResponseDto books = retrieveBooksByConditionsUseCase.retrieveBooks(title, category, publisher, borrowerId, borrowerName, pageable); + PagedResponseDto books = retrieveBooksByConditionsUseCase.retrieveBooks(title, category, + publisher, borrowerId, borrowerName, pageable); return ApiResponse.success(books); } } diff --git a/src/main/java/page/clab/api/domain/library/book/adapter/out/persistence/BookJpaEntity.java b/src/main/java/page/clab/api/domain/library/book/adapter/out/persistence/BookJpaEntity.java index f04a6a143..2b816845e 100644 --- a/src/main/java/page/clab/api/domain/library/book/adapter/out/persistence/BookJpaEntity.java +++ b/src/main/java/page/clab/api/domain/library/book/adapter/out/persistence/BookJpaEntity.java @@ -8,6 +8,7 @@ import jakarta.persistence.Id; import jakarta.persistence.Table; import jakarta.persistence.Version; +import java.util.List; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -19,8 +20,6 @@ import page.clab.api.global.common.domain.BaseEntity; import page.clab.api.global.util.StringJsonConverter; -import java.util.List; - @Entity @Table(name = "book") @Getter diff --git a/src/main/java/page/clab/api/domain/library/book/adapter/out/persistence/BookPersistenceAdapter.java b/src/main/java/page/clab/api/domain/library/book/adapter/out/persistence/BookPersistenceAdapter.java index 197c219fe..540e0cbd5 100644 --- a/src/main/java/page/clab/api/domain/library/book/adapter/out/persistence/BookPersistenceAdapter.java +++ b/src/main/java/page/clab/api/domain/library/book/adapter/out/persistence/BookPersistenceAdapter.java @@ -13,9 +13,9 @@ @Component @RequiredArgsConstructor public class BookPersistenceAdapter implements - RegisterBookPort, - RemoveBookPort, - RetrieveBookPort { + RegisterBookPort, + RemoveBookPort, + RetrieveBookPort { private final BookRepository bookRepository; private final BookMapper bookMapper; @@ -35,14 +35,15 @@ public void delete(Book book) { @Override public Book getById(Long bookId) { return bookRepository.findById(bookId) - .map(bookMapper::toDomain) - .orElseThrow(() -> new NotFoundException("[Book] id: " + bookId + "에 해당하는 책이 존재하지 않습니다.")); + .map(bookMapper::toDomain) + .orElseThrow(() -> new NotFoundException("[Book] id: " + bookId + "에 해당하는 책이 존재하지 않습니다.")); } @Override - public Page findByConditions(String title, String category, String publisher, String borrowerId, String borrowerName, Pageable pageable) { + public Page findByConditions(String title, String category, String publisher, String borrowerId, + String borrowerName, Pageable pageable) { return bookRepository.findByConditions(title, category, publisher, borrowerId, borrowerName, pageable) - .map(bookMapper::toDomain); + .map(bookMapper::toDomain); } @Override diff --git a/src/main/java/page/clab/api/domain/library/book/adapter/out/persistence/BookRepository.java b/src/main/java/page/clab/api/domain/library/book/adapter/out/persistence/BookRepository.java index b57bdc349..aa39b96e0 100644 --- a/src/main/java/page/clab/api/domain/library/book/adapter/out/persistence/BookRepository.java +++ b/src/main/java/page/clab/api/domain/library/book/adapter/out/persistence/BookRepository.java @@ -5,6 +5,8 @@ import org.springframework.stereotype.Repository; @Repository -public interface BookRepository extends JpaRepository, BookRepositoryCustom, QuerydslPredicateExecutor { +public interface BookRepository extends JpaRepository, BookRepositoryCustom, + QuerydslPredicateExecutor { + int countByBorrowerId(String memberId); } diff --git a/src/main/java/page/clab/api/domain/library/book/adapter/out/persistence/BookRepositoryCustom.java b/src/main/java/page/clab/api/domain/library/book/adapter/out/persistence/BookRepositoryCustom.java index 25f3d4c81..d32defe46 100644 --- a/src/main/java/page/clab/api/domain/library/book/adapter/out/persistence/BookRepositoryCustom.java +++ b/src/main/java/page/clab/api/domain/library/book/adapter/out/persistence/BookRepositoryCustom.java @@ -4,5 +4,7 @@ import org.springframework.data.domain.Pageable; public interface BookRepositoryCustom { - Page findByConditions(String title, String category, String publisher, String borrowerId, String borrowerName, Pageable pageable); + + Page findByConditions(String title, String category, String publisher, String borrowerId, + String borrowerName, Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/library/book/adapter/out/persistence/BookRepositoryImpl.java b/src/main/java/page/clab/api/domain/library/book/adapter/out/persistence/BookRepositoryImpl.java index 1b3d9a83c..657c59945 100644 --- a/src/main/java/page/clab/api/domain/library/book/adapter/out/persistence/BookRepositoryImpl.java +++ b/src/main/java/page/clab/api/domain/library/book/adapter/out/persistence/BookRepositoryImpl.java @@ -2,6 +2,7 @@ import com.querydsl.core.BooleanBuilder; import com.querydsl.jpa.impl.JPAQueryFactory; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; @@ -10,8 +11,6 @@ import page.clab.api.domain.memberManagement.member.adapter.out.persistence.QMemberJpaEntity; import page.clab.api.global.util.OrderSpecifierUtil; -import java.util.List; - @Repository @RequiredArgsConstructor public class BookRepositoryImpl implements BookRepositoryCustom { @@ -19,29 +18,40 @@ public class BookRepositoryImpl implements BookRepositoryCustom { private final JPAQueryFactory queryFactory; @Override - public Page findByConditions(String title, String category, String publisher, String borrowerId, String borrowerName, Pageable pageable) { + public Page findByConditions(String title, String category, String publisher, String borrowerId, + String borrowerName, Pageable pageable) { QBookJpaEntity book = QBookJpaEntity.bookJpaEntity; QMemberJpaEntity borrower = QMemberJpaEntity.memberJpaEntity; BooleanBuilder builder = new BooleanBuilder(); - if (title != null) builder.and(book.title.containsIgnoreCase(title)); - if (category != null) builder.and(book.category.eq(category)); - if (publisher != null) builder.and(book.publisher.containsIgnoreCase(publisher)); - if (borrowerId != null) builder.and(borrower.id.eq(borrowerId)); - if (borrowerName != null) builder.and(borrower.name.eq(borrowerName)); + if (title != null) { + builder.and(book.title.containsIgnoreCase(title)); + } + if (category != null) { + builder.and(book.category.eq(category)); + } + if (publisher != null) { + builder.and(book.publisher.containsIgnoreCase(publisher)); + } + if (borrowerId != null) { + builder.and(borrower.id.eq(borrowerId)); + } + if (borrowerName != null) { + builder.and(borrower.name.eq(borrowerName)); + } List books = queryFactory.selectFrom(book) - .leftJoin(borrower).on(book.borrowerId.eq(borrower.id)) - .where(builder) - .orderBy(OrderSpecifierUtil.getOrderSpecifiers(pageable, book)) - .offset(pageable.getOffset()) - .limit(pageable.getPageSize()) - .fetch(); + .leftJoin(borrower).on(book.borrowerId.eq(borrower.id)) + .where(builder) + .orderBy(OrderSpecifierUtil.getOrderSpecifiers(pageable, book)) + .offset(pageable.getOffset()) + .limit(pageable.getPageSize()) + .fetch(); long count = queryFactory.selectFrom(book) - .leftJoin(borrower).on(book.borrowerId.eq(borrower.id)) - .where(builder) - .fetchCount(); + .leftJoin(borrower).on(book.borrowerId.eq(borrower.id)) + .where(builder) + .fetchCount(); return new PageImpl<>(books, pageable, count); } diff --git a/src/main/java/page/clab/api/domain/library/book/application/dto/mapper/BookDtoMapper.java b/src/main/java/page/clab/api/domain/library/book/application/dto/mapper/BookDtoMapper.java index 220ca1b06..95fe50717 100644 --- a/src/main/java/page/clab/api/domain/library/book/application/dto/mapper/BookDtoMapper.java +++ b/src/main/java/page/clab/api/domain/library/book/application/dto/mapper/BookDtoMapper.java @@ -1,5 +1,7 @@ package page.clab.api.domain.library.book.application.dto.mapper; +import java.time.LocalDateTime; +import java.util.List; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; import page.clab.api.domain.library.book.application.dto.request.BookRequestDto; @@ -7,54 +9,51 @@ import page.clab.api.domain.library.book.application.dto.response.BookResponseDto; import page.clab.api.domain.library.book.domain.Book; -import java.time.LocalDateTime; -import java.util.List; - @Component public class BookDtoMapper { public Book fromDto(BookRequestDto requestDto) { return Book.builder() - .category(requestDto.getCategory()) - .title(requestDto.getTitle()) - .author(requestDto.getAuthor()) - .publisher(requestDto.getPublisher()) - .imageUrl(requestDto.getImageUrl()) - .reviewLinks(CollectionUtils.isEmpty(requestDto.getReviewLinks()) ? List.of() : requestDto.getReviewLinks()) - .isDeleted(false) - .build(); + .category(requestDto.getCategory()) + .title(requestDto.getTitle()) + .author(requestDto.getAuthor()) + .publisher(requestDto.getPublisher()) + .imageUrl(requestDto.getImageUrl()) + .reviewLinks(CollectionUtils.isEmpty(requestDto.getReviewLinks()) ? List.of() : requestDto.getReviewLinks()) + .isDeleted(false) + .build(); } public BookResponseDto toDto(Book book, String borrowerName, LocalDateTime dueDate) { return BookResponseDto.builder() - .id(book.getId()) - .borrowerId(book.getBorrowerId() == null ? null : book.getBorrowerId()) - .borrowerName(book.getBorrowerId() == null ? null : borrowerName) - .category(book.getCategory()) - .title(book.getTitle()) - .author(book.getAuthor()) - .publisher(book.getPublisher()) - .imageUrl(book.getImageUrl()) - .dueDate(dueDate) - .createdAt(book.getCreatedAt()) - .updatedAt(book.getUpdatedAt()) - .build(); + .id(book.getId()) + .borrowerId(book.getBorrowerId() == null ? null : book.getBorrowerId()) + .borrowerName(book.getBorrowerId() == null ? null : borrowerName) + .category(book.getCategory()) + .title(book.getTitle()) + .author(book.getAuthor()) + .publisher(book.getPublisher()) + .imageUrl(book.getImageUrl()) + .dueDate(dueDate) + .createdAt(book.getCreatedAt()) + .updatedAt(book.getUpdatedAt()) + .build(); } public BookDetailsResponseDto toDetailsDto(Book book, String borrowerName, LocalDateTime dueDate) { return BookDetailsResponseDto.builder() - .id(book.getId()) - .borrowerId(book.getBorrowerId() == null ? null : book.getBorrowerId()) - .borrowerName(book.getBorrowerId() == null ? null : borrowerName) - .category(book.getCategory()) - .title(book.getTitle()) - .author(book.getAuthor()) - .publisher(book.getPublisher()) - .imageUrl(book.getImageUrl()) - .reviewLinks(book.getReviewLinks()) - .dueDate(dueDate) - .createdAt(book.getCreatedAt()) - .updatedAt(book.getUpdatedAt()) - .build(); + .id(book.getId()) + .borrowerId(book.getBorrowerId() == null ? null : book.getBorrowerId()) + .borrowerName(book.getBorrowerId() == null ? null : borrowerName) + .category(book.getCategory()) + .title(book.getTitle()) + .author(book.getAuthor()) + .publisher(book.getPublisher()) + .imageUrl(book.getImageUrl()) + .reviewLinks(book.getReviewLinks()) + .dueDate(dueDate) + .createdAt(book.getCreatedAt()) + .updatedAt(book.getUpdatedAt()) + .build(); } } diff --git a/src/main/java/page/clab/api/domain/library/book/application/dto/request/BookRequestDto.java b/src/main/java/page/clab/api/domain/library/book/application/dto/request/BookRequestDto.java index a8bc9237d..9289b51d5 100644 --- a/src/main/java/page/clab/api/domain/library/book/application/dto/request/BookRequestDto.java +++ b/src/main/java/page/clab/api/domain/library/book/application/dto/request/BookRequestDto.java @@ -2,11 +2,10 @@ import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotNull; +import java.util.List; import lombok.Getter; import lombok.Setter; -import java.util.List; - @Getter @Setter public class BookRequestDto { diff --git a/src/main/java/page/clab/api/domain/library/book/application/dto/request/BookUpdateRequestDto.java b/src/main/java/page/clab/api/domain/library/book/application/dto/request/BookUpdateRequestDto.java index 08e18a99f..4952b603c 100644 --- a/src/main/java/page/clab/api/domain/library/book/application/dto/request/BookUpdateRequestDto.java +++ b/src/main/java/page/clab/api/domain/library/book/application/dto/request/BookUpdateRequestDto.java @@ -1,11 +1,10 @@ package page.clab.api.domain.library.book.application.dto.request; import io.swagger.v3.oas.annotations.media.Schema; +import java.util.List; import lombok.Getter; import lombok.Setter; -import java.util.List; - @Getter @Setter public class BookUpdateRequestDto { diff --git a/src/main/java/page/clab/api/domain/library/book/application/dto/response/BookDetailsResponseDto.java b/src/main/java/page/clab/api/domain/library/book/application/dto/response/BookDetailsResponseDto.java index 172474ae9..b74163cea 100644 --- a/src/main/java/page/clab/api/domain/library/book/application/dto/response/BookDetailsResponseDto.java +++ b/src/main/java/page/clab/api/domain/library/book/application/dto/response/BookDetailsResponseDto.java @@ -1,10 +1,9 @@ package page.clab.api.domain.library.book.application.dto.response; -import lombok.Builder; -import lombok.Getter; - import java.time.LocalDateTime; import java.util.List; +import lombok.Builder; +import lombok.Getter; @Getter @Builder diff --git a/src/main/java/page/clab/api/domain/library/book/application/dto/response/BookResponseDto.java b/src/main/java/page/clab/api/domain/library/book/application/dto/response/BookResponseDto.java index b4e0b494f..521b69059 100644 --- a/src/main/java/page/clab/api/domain/library/book/application/dto/response/BookResponseDto.java +++ b/src/main/java/page/clab/api/domain/library/book/application/dto/response/BookResponseDto.java @@ -1,10 +1,9 @@ package page.clab.api.domain.library.book.application.dto.response; +import java.time.LocalDateTime; import lombok.Builder; import lombok.Getter; -import java.time.LocalDateTime; - @Getter @Builder public class BookResponseDto { diff --git a/src/main/java/page/clab/api/domain/library/book/application/port/in/RegisterBookUseCase.java b/src/main/java/page/clab/api/domain/library/book/application/port/in/RegisterBookUseCase.java index 493513b39..ef7a52a2d 100644 --- a/src/main/java/page/clab/api/domain/library/book/application/port/in/RegisterBookUseCase.java +++ b/src/main/java/page/clab/api/domain/library/book/application/port/in/RegisterBookUseCase.java @@ -3,5 +3,6 @@ import page.clab.api.domain.library.book.application.dto.request.BookRequestDto; public interface RegisterBookUseCase { + Long registerBook(BookRequestDto requestDto); } diff --git a/src/main/java/page/clab/api/domain/library/book/application/port/in/RemoveBookUseCase.java b/src/main/java/page/clab/api/domain/library/book/application/port/in/RemoveBookUseCase.java index ca454075e..1a5bf0073 100644 --- a/src/main/java/page/clab/api/domain/library/book/application/port/in/RemoveBookUseCase.java +++ b/src/main/java/page/clab/api/domain/library/book/application/port/in/RemoveBookUseCase.java @@ -1,5 +1,6 @@ package page.clab.api.domain.library.book.application.port.in; public interface RemoveBookUseCase { + Long removeBook(Long bookId); } diff --git a/src/main/java/page/clab/api/domain/library/book/application/port/in/RetrieveBookDetailsUseCase.java b/src/main/java/page/clab/api/domain/library/book/application/port/in/RetrieveBookDetailsUseCase.java index 1562a38a9..84c528259 100644 --- a/src/main/java/page/clab/api/domain/library/book/application/port/in/RetrieveBookDetailsUseCase.java +++ b/src/main/java/page/clab/api/domain/library/book/application/port/in/RetrieveBookDetailsUseCase.java @@ -3,5 +3,6 @@ import page.clab.api.domain.library.book.application.dto.response.BookDetailsResponseDto; public interface RetrieveBookDetailsUseCase { + BookDetailsResponseDto retrieveBookDetails(Long bookId); } diff --git a/src/main/java/page/clab/api/domain/library/book/application/port/in/RetrieveBooksByConditionsUseCase.java b/src/main/java/page/clab/api/domain/library/book/application/port/in/RetrieveBooksByConditionsUseCase.java index 55934d033..62dd2ffb8 100644 --- a/src/main/java/page/clab/api/domain/library/book/application/port/in/RetrieveBooksByConditionsUseCase.java +++ b/src/main/java/page/clab/api/domain/library/book/application/port/in/RetrieveBooksByConditionsUseCase.java @@ -5,5 +5,7 @@ import page.clab.api.global.common.dto.PagedResponseDto; public interface RetrieveBooksByConditionsUseCase { - PagedResponseDto retrieveBooks(String title, String category, String publisher, String borrowerId, String borrowerName, Pageable pageable); + + PagedResponseDto retrieveBooks(String title, String category, String publisher, String borrowerId, + String borrowerName, Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/library/book/application/port/in/UpdateBookUseCase.java b/src/main/java/page/clab/api/domain/library/book/application/port/in/UpdateBookUseCase.java index e3c01377a..1775369cf 100644 --- a/src/main/java/page/clab/api/domain/library/book/application/port/in/UpdateBookUseCase.java +++ b/src/main/java/page/clab/api/domain/library/book/application/port/in/UpdateBookUseCase.java @@ -3,5 +3,6 @@ import page.clab.api.domain.library.book.application.dto.request.BookUpdateRequestDto; public interface UpdateBookUseCase { + Long updateBookInfo(Long bookId, BookUpdateRequestDto requestDto); } diff --git a/src/main/java/page/clab/api/domain/library/book/application/port/out/RegisterBookPort.java b/src/main/java/page/clab/api/domain/library/book/application/port/out/RegisterBookPort.java index f8de8b93a..af1d2a1f0 100644 --- a/src/main/java/page/clab/api/domain/library/book/application/port/out/RegisterBookPort.java +++ b/src/main/java/page/clab/api/domain/library/book/application/port/out/RegisterBookPort.java @@ -3,5 +3,6 @@ import page.clab.api.domain.library.book.domain.Book; public interface RegisterBookPort { + Book save(Book book); } diff --git a/src/main/java/page/clab/api/domain/library/book/application/port/out/RemoveBookPort.java b/src/main/java/page/clab/api/domain/library/book/application/port/out/RemoveBookPort.java index 425102648..6b69bcb21 100644 --- a/src/main/java/page/clab/api/domain/library/book/application/port/out/RemoveBookPort.java +++ b/src/main/java/page/clab/api/domain/library/book/application/port/out/RemoveBookPort.java @@ -3,5 +3,6 @@ import page.clab.api.domain.library.book.domain.Book; public interface RemoveBookPort { + void delete(Book book); } diff --git a/src/main/java/page/clab/api/domain/library/book/application/port/out/RetrieveBookPort.java b/src/main/java/page/clab/api/domain/library/book/application/port/out/RetrieveBookPort.java index e2ed89e83..805ddd805 100644 --- a/src/main/java/page/clab/api/domain/library/book/application/port/out/RetrieveBookPort.java +++ b/src/main/java/page/clab/api/domain/library/book/application/port/out/RetrieveBookPort.java @@ -8,7 +8,8 @@ public interface RetrieveBookPort { Book getById(Long bookId); - Page findByConditions(String title, String category, String publisher, String borrowerId, String borrowerName, Pageable pageable); + Page findByConditions(String title, String category, String publisher, String borrowerId, String borrowerName, + Pageable pageable); int countByBorrowerId(String borrowerId); } diff --git a/src/main/java/page/clab/api/domain/library/book/application/port/out/RetrieveDeletedBooksPort.java b/src/main/java/page/clab/api/domain/library/book/application/port/out/RetrieveDeletedBooksPort.java index b9edc6444..dea76c01c 100644 --- a/src/main/java/page/clab/api/domain/library/book/application/port/out/RetrieveDeletedBooksPort.java +++ b/src/main/java/page/clab/api/domain/library/book/application/port/out/RetrieveDeletedBooksPort.java @@ -5,5 +5,6 @@ import page.clab.api.domain.library.book.domain.Book; public interface RetrieveDeletedBooksPort { + Page findAllByIsDeletedTrue(Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/library/book/application/service/BookDetailsRetrievalService.java b/src/main/java/page/clab/api/domain/library/book/application/service/BookDetailsRetrievalService.java index 03856920b..5fb8e97e2 100644 --- a/src/main/java/page/clab/api/domain/library/book/application/service/BookDetailsRetrievalService.java +++ b/src/main/java/page/clab/api/domain/library/book/application/service/BookDetailsRetrievalService.java @@ -1,5 +1,6 @@ package page.clab.api.domain.library.book.application.service; +import java.time.LocalDateTime; import lombok.RequiredArgsConstructor; import org.jetbrains.annotations.NotNull; import org.springframework.stereotype.Service; @@ -12,8 +13,6 @@ import page.clab.api.external.library.bookLoanRecord.application.port.ExternalRetrieveBookLoanRecordUseCase; import page.clab.api.external.memberManagement.member.application.port.ExternalRetrieveMemberUseCase; -import java.time.LocalDateTime; - @Service @RequiredArgsConstructor public class BookDetailsRetrievalService implements RetrieveBookDetailsUseCase { diff --git a/src/main/java/page/clab/api/domain/library/book/application/service/BooksByConditionsRetrievalService.java b/src/main/java/page/clab/api/domain/library/book/application/service/BooksByConditionsRetrievalService.java index 6f9884bdc..4c932b0b7 100644 --- a/src/main/java/page/clab/api/domain/library/book/application/service/BooksByConditionsRetrievalService.java +++ b/src/main/java/page/clab/api/domain/library/book/application/service/BooksByConditionsRetrievalService.java @@ -1,5 +1,6 @@ package page.clab.api.domain.library.book.application.service; +import java.time.LocalDateTime; import lombok.RequiredArgsConstructor; import org.jetbrains.annotations.NotNull; import org.springframework.data.domain.Page; @@ -15,8 +16,6 @@ import page.clab.api.external.memberManagement.member.application.port.ExternalRetrieveMemberUseCase; import page.clab.api.global.common.dto.PagedResponseDto; -import java.time.LocalDateTime; - @Service @RequiredArgsConstructor public class BooksByConditionsRetrievalService implements RetrieveBooksByConditionsUseCase { @@ -28,8 +27,10 @@ public class BooksByConditionsRetrievalService implements RetrieveBooksByConditi @Transactional(readOnly = true) @Override - public PagedResponseDto retrieveBooks(String title, String category, String publisher, String borrowerId, String borrowerName, Pageable pageable) { - Page books = retrieveBookPort.findByConditions(title, category, publisher, borrowerId, borrowerName, pageable); + public PagedResponseDto retrieveBooks(String title, String category, String publisher, + String borrowerId, String borrowerName, Pageable pageable) { + Page books = retrieveBookPort.findByConditions(title, category, publisher, borrowerId, borrowerName, + pageable); return new PagedResponseDto<>(books.map(this::mapToBookResponseDto)); } diff --git a/src/main/java/page/clab/api/domain/library/book/domain/Book.java b/src/main/java/page/clab/api/domain/library/book/domain/Book.java index b3a515afc..d4a566cca 100644 --- a/src/main/java/page/clab/api/domain/library/book/domain/Book.java +++ b/src/main/java/page/clab/api/domain/library/book/domain/Book.java @@ -1,5 +1,8 @@ package page.clab.api.domain.library.book.domain; +import java.time.LocalDateTime; +import java.util.List; +import java.util.Optional; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -10,10 +13,6 @@ import page.clab.api.domain.library.book.application.exception.BookAlreadyBorrowedException; import page.clab.api.domain.library.book.application.exception.InvalidBorrowerException; -import java.time.LocalDateTime; -import java.util.List; -import java.util.Optional; - @Getter @Setter @Builder diff --git a/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/in/web/BookLoanApprovalController.java b/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/in/web/BookLoanApprovalController.java index ef7ae4ee7..f36729b83 100644 --- a/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/in/web/BookLoanApprovalController.java +++ b/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/in/web/BookLoanApprovalController.java @@ -23,7 +23,7 @@ public class BookLoanApprovalController { @PreAuthorize("hasRole('ADMIN')") @PatchMapping("/approve/{bookLoanRecordId}") public ApiResponse approveBookLoan( - @PathVariable(name = "bookLoanRecordId") Long bookLoanRecordId + @PathVariable(name = "bookLoanRecordId") Long bookLoanRecordId ) { Long id = approveBookLoanUseCase.approveBookLoan(bookLoanRecordId); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/in/web/BookLoanExtensionController.java b/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/in/web/BookLoanExtensionController.java index a21809422..16494500e 100644 --- a/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/in/web/BookLoanExtensionController.java +++ b/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/in/web/BookLoanExtensionController.java @@ -25,7 +25,7 @@ public class BookLoanExtensionController { @PreAuthorize("hasRole('USER')") @PostMapping("/extend") public ApiResponse extendBookLoan( - @Valid @RequestBody BookLoanRecordRequestDto requestDto + @Valid @RequestBody BookLoanRecordRequestDto requestDto ) { Long id = extendBookLoanUseCase.extendBookLoan(requestDto); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/in/web/BookLoanRecordsByConditionsRetrievalController.java b/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/in/web/BookLoanRecordsByConditionsRetrievalController.java index 7f0f2bed6..a618e2f6a 100644 --- a/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/in/web/BookLoanRecordsByConditionsRetrievalController.java +++ b/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/in/web/BookLoanRecordsByConditionsRetrievalController.java @@ -2,6 +2,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.security.access.prepost.PreAuthorize; @@ -18,8 +19,6 @@ import page.clab.api.global.exception.SortingArgumentException; import page.clab.api.global.util.PageableUtils; -import java.util.List; - @RestController @RequestMapping("/api/v1/book-loan-records") @RequiredArgsConstructor @@ -30,23 +29,24 @@ public class BookLoanRecordsByConditionsRetrievalController { private final PageableUtils pageableUtils; @Operation(summary = "[G] 도서 대출 내역 조회(도서 ID, 대출자 ID, 대출 상태 기준)", description = "ROLE_GUEST 이상의 권한이 필요함
" + - "3개의 파라미터를 자유롭게 조합하여 필터링 가능
" + - "도서 ID, 대출자 ID, 대출 가능 여부 중 하나라도 입력하지 않으면 전체 조회됨
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") + "3개의 파라미터를 자유롭게 조합하여 필터링 가능
" + + "도서 ID, 대출자 ID, 대출 가능 여부 중 하나라도 입력하지 않으면 전체 조회됨
" + + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") @PreAuthorize("hasRole('GUEST')") @GetMapping("/conditions") public ApiResponse> retrieveBookLoanRecordsByConditions( - @RequestParam(name = "bookId", required = false) Long bookId, - @RequestParam(name = "borrowerId", required = false) String borrowerId, - @RequestParam(name = "status", required = false) BookLoanStatus status, - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "borrowedAt") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection + @RequestParam(name = "bookId", required = false) Long bookId, + @RequestParam(name = "borrowerId", required = false) String borrowerId, + @RequestParam(name = "status", required = false) BookLoanStatus status, + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "borrowedAt") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection ) throws SortingArgumentException, InvalidColumnException { - Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, BookLoanRecordResponseDto.class); + Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, + BookLoanRecordResponseDto.class); PagedResponseDto bookLoanRecords = - retrieveBookLoanRecordsByConditionsUseCase.retrieveBookLoanRecords(bookId, borrowerId, status, pageable); + retrieveBookLoanRecordsByConditionsUseCase.retrieveBookLoanRecords(bookId, borrowerId, status, pageable); return ApiResponse.success(bookLoanRecords); } } diff --git a/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/in/web/BookLoanRejectionController.java b/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/in/web/BookLoanRejectionController.java index 2b9c705fc..7f2dd53ae 100644 --- a/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/in/web/BookLoanRejectionController.java +++ b/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/in/web/BookLoanRejectionController.java @@ -23,7 +23,7 @@ public class BookLoanRejectionController { @PreAuthorize("hasRole('ADMIN')") @PatchMapping("/reject/{bookLoanRecordId}") public ApiResponse rejectBookLoan( - @PathVariable(name = "bookLoanRecordId") Long bookLoanRecordId + @PathVariable(name = "bookLoanRecordId") Long bookLoanRecordId ) { Long id = rejectBookLoanUseCase.rejectBookLoan(bookLoanRecordId); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/in/web/BookLoanRequestController.java b/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/in/web/BookLoanRequestController.java index 3f5deecb8..b54eab508 100644 --- a/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/in/web/BookLoanRequestController.java +++ b/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/in/web/BookLoanRequestController.java @@ -26,7 +26,7 @@ public class BookLoanRequestController { @PreAuthorize("hasRole('USER')") @PostMapping("") public ApiResponse requestBookLoan( - @Valid @RequestBody BookLoanRecordRequestDto requestDto + @Valid @RequestBody BookLoanRecordRequestDto requestDto ) throws CustomOptimisticLockingFailureException { Long id = requestBookLoanUseCase.requestBookLoan(requestDto); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/in/web/BookReturnController.java b/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/in/web/BookReturnController.java index b19ebb433..9f146f972 100644 --- a/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/in/web/BookReturnController.java +++ b/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/in/web/BookReturnController.java @@ -25,7 +25,7 @@ public class BookReturnController { @PreAuthorize("hasRole('USER')") @PostMapping("/return") public ApiResponse returnBook( - @Valid @RequestBody BookLoanRecordRequestDto requestDto + @Valid @RequestBody BookLoanRecordRequestDto requestDto ) { Long id = returnBookUseCase.returnBook(requestDto); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/in/web/OverdueBookLoanRecordsRetrievalController.java b/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/in/web/OverdueBookLoanRecordsRetrievalController.java index 4929aaf7d..30fcb116a 100644 --- a/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/in/web/OverdueBookLoanRecordsRetrievalController.java +++ b/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/in/web/OverdueBookLoanRecordsRetrievalController.java @@ -2,6 +2,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.security.access.prepost.PreAuthorize; @@ -17,8 +18,6 @@ import page.clab.api.global.exception.SortingArgumentException; import page.clab.api.global.util.PageableUtils; -import java.util.List; - @RestController @RequestMapping("/api/v1/book-loan-records") @RequiredArgsConstructor @@ -29,18 +28,19 @@ public class OverdueBookLoanRecordsRetrievalController { private final PageableUtils pageableUtils; @Operation(summary = "[A] 도서 연체자 조회", description = "ROLE_ADMIN 이상의 권한이 필요함
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") @PreAuthorize("hasRole('ADMIN')") @GetMapping("/overdue") public ApiResponse> retrieveOverdueBookLoanRecords( - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "dueDate") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "asc") List sortDirection + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "dueDate") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "asc") List sortDirection ) throws SortingArgumentException, InvalidColumnException { - Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, BookLoanRecordOverdueResponseDto.class); + Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, + BookLoanRecordOverdueResponseDto.class); PagedResponseDto overdueRecords = - retrieveOverdueBookLoanRecordsUseCase.retrieveOverdueBookLoanRecords(pageable); + retrieveOverdueBookLoanRecordsUseCase.retrieveOverdueBookLoanRecords(pageable); return ApiResponse.success(overdueRecords); } } diff --git a/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/out/persistence/BookLoanRecordJpaEntity.java b/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/out/persistence/BookLoanRecordJpaEntity.java index ee37a1e74..159ff77c4 100644 --- a/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/out/persistence/BookLoanRecordJpaEntity.java +++ b/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/out/persistence/BookLoanRecordJpaEntity.java @@ -8,6 +8,7 @@ import jakarta.persistence.GenerationType; import jakarta.persistence.Id; import jakarta.persistence.Table; +import java.time.LocalDateTime; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -19,8 +20,6 @@ import page.clab.api.domain.library.bookLoanRecord.domain.BookLoanStatus; import page.clab.api.global.common.domain.BaseEntity; -import java.time.LocalDateTime; - @Entity @Table(name = "book_loan_record") @Getter diff --git a/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/out/persistence/BookLoanRecordPersistenceAdapter.java b/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/out/persistence/BookLoanRecordPersistenceAdapter.java index 8ad059b80..550ae2f27 100644 --- a/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/out/persistence/BookLoanRecordPersistenceAdapter.java +++ b/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/out/persistence/BookLoanRecordPersistenceAdapter.java @@ -1,5 +1,6 @@ package page.clab.api.domain.library.bookLoanRecord.adapter.out.persistence; +import java.util.Optional; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -12,13 +13,11 @@ import page.clab.api.domain.library.bookLoanRecord.domain.BookLoanStatus; import page.clab.api.global.exception.NotFoundException; -import java.util.Optional; - @Component @RequiredArgsConstructor public class BookLoanRecordPersistenceAdapter implements - RegisterBookLoanRecordPort, - RetrieveBookLoanRecordPort { + RegisterBookLoanRecordPort, + RetrieveBookLoanRecordPort { private final BookLoanRecordRepository bookLoanRecordRepository; private final BookLoanRecordMapper bookLoanRecordMapper; @@ -33,12 +32,14 @@ public BookLoanRecord save(BookLoanRecord bookLoanRecord) { @Override public BookLoanRecord getById(Long bookLoanRecordId) { return bookLoanRecordRepository.findById(bookLoanRecordId) - .map(bookLoanRecordMapper::toDomain) - .orElseThrow(() -> new NotFoundException("[BookLoanRecord] id: " + bookLoanRecordId + "에 해당하는 대출 기록이 존재하지 않습니다.")); + .map(bookLoanRecordMapper::toDomain) + .orElseThrow( + () -> new NotFoundException("[BookLoanRecord] id: " + bookLoanRecordId + "에 해당하는 대출 기록이 존재하지 않습니다.")); } @Override - public Page findByConditions(Long bookId, String borrowerId, BookLoanStatus status, Pageable pageable) { + public Page findByConditions(Long bookId, String borrowerId, BookLoanStatus status, + Pageable pageable) { return bookLoanRecordRepository.findByConditions(bookId, borrowerId, status, pageable); } @@ -48,21 +49,23 @@ public Page findOverdueBookLoanRecords(Pageabl } @Override - public Optional findByBookIdAndReturnedAtIsNullAndStatus(Long bookId, BookLoanStatus bookLoanStatus) { + public Optional findByBookIdAndReturnedAtIsNullAndStatus(Long bookId, + BookLoanStatus bookLoanStatus) { return bookLoanRecordRepository.findByBookIdAndReturnedAtIsNullAndStatus(bookId, bookLoanStatus) - .map(bookLoanRecordMapper::toDomain); + .map(bookLoanRecordMapper::toDomain); } @Override public BookLoanRecord getByBookIdAndReturnedAtIsNullAndStatus(Long bookId, BookLoanStatus bookLoanStatus) { return bookLoanRecordRepository.findByBookIdAndReturnedAtIsNullAndStatus(bookId, bookLoanStatus) - .map(bookLoanRecordMapper::toDomain) - .orElseThrow(() -> new NotFoundException("[Book] id: " + bookId + "에 해당하는 대출 기록이 존재하지 않습니다.")); + .map(bookLoanRecordMapper::toDomain) + .orElseThrow(() -> new NotFoundException("[Book] id: " + bookId + "에 해당하는 대출 기록이 존재하지 않습니다.")); } @Override - public Optional findByBookIdAndBorrowerIdAndStatus(Long bookId, String borrowerId, BookLoanStatus bookLoanStatus) { + public Optional findByBookIdAndBorrowerIdAndStatus(Long bookId, String borrowerId, + BookLoanStatus bookLoanStatus) { return bookLoanRecordRepository.findByBookIdAndBorrowerIdAndStatus(bookId, borrowerId, bookLoanStatus) - .map(bookLoanRecordMapper::toDomain); + .map(bookLoanRecordMapper::toDomain); } } diff --git a/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/out/persistence/BookLoanRecordRepository.java b/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/out/persistence/BookLoanRecordRepository.java index 8efbb6f81..54dc61535 100644 --- a/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/out/persistence/BookLoanRecordRepository.java +++ b/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/out/persistence/BookLoanRecordRepository.java @@ -1,15 +1,17 @@ package page.clab.api.domain.library.bookLoanRecord.adapter.out.persistence; +import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; import page.clab.api.domain.library.bookLoanRecord.domain.BookLoanStatus; -import java.util.Optional; - @Repository -public interface BookLoanRecordRepository extends JpaRepository, BookLoanRecordRepositoryCustom { +public interface BookLoanRecordRepository extends JpaRepository, + BookLoanRecordRepositoryCustom { - Optional findByBookIdAndReturnedAtIsNullAndStatus(Long bookId, BookLoanStatus bookLoanStatus); + Optional findByBookIdAndReturnedAtIsNullAndStatus(Long bookId, + BookLoanStatus bookLoanStatus); - Optional findByBookIdAndBorrowerIdAndStatus(Long bookId, String borrowerId, BookLoanStatus bookLoanStatus); + Optional findByBookIdAndBorrowerIdAndStatus(Long bookId, String borrowerId, + BookLoanStatus bookLoanStatus); } diff --git a/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/out/persistence/BookLoanRecordRepositoryCustom.java b/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/out/persistence/BookLoanRecordRepositoryCustom.java index 47838014e..43a1f0451 100644 --- a/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/out/persistence/BookLoanRecordRepositoryCustom.java +++ b/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/out/persistence/BookLoanRecordRepositoryCustom.java @@ -8,7 +8,8 @@ public interface BookLoanRecordRepositoryCustom { - Page findByConditions(Long bookId, String borrowerId, BookLoanStatus status, Pageable pageable); + Page findByConditions(Long bookId, String borrowerId, BookLoanStatus status, + Pageable pageable); Page findOverdueBookLoanRecords(Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/out/persistence/BookLoanRecordRepositoryImpl.java b/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/out/persistence/BookLoanRecordRepositoryImpl.java index e5954f821..dfa8c294f 100644 --- a/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/out/persistence/BookLoanRecordRepositoryImpl.java +++ b/src/main/java/page/clab/api/domain/library/bookLoanRecord/adapter/out/persistence/BookLoanRecordRepositoryImpl.java @@ -3,6 +3,8 @@ import com.querydsl.core.BooleanBuilder; import com.querydsl.core.types.Projections; import com.querydsl.jpa.impl.JPAQueryFactory; +import java.time.LocalDateTime; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; @@ -15,9 +17,6 @@ import page.clab.api.domain.memberManagement.member.adapter.out.persistence.QMemberJpaEntity; import page.clab.api.global.util.OrderSpecifierUtil; -import java.time.LocalDateTime; -import java.util.List; - @Repository @RequiredArgsConstructor public class BookLoanRecordRepositoryImpl implements BookLoanRecordRepositoryCustom { @@ -25,46 +24,53 @@ public class BookLoanRecordRepositoryImpl implements BookLoanRecordRepositoryCus private final JPAQueryFactory queryFactory; @Override - public Page findByConditions(Long bookId, String borrowerId, BookLoanStatus status, Pageable pageable) { + public Page findByConditions(Long bookId, String borrowerId, BookLoanStatus status, + Pageable pageable) { QBookLoanRecordJpaEntity bookLoanRecord = QBookLoanRecordJpaEntity.bookLoanRecordJpaEntity; QBookJpaEntity book = QBookJpaEntity.bookJpaEntity; QMemberJpaEntity member = QMemberJpaEntity.memberJpaEntity; BooleanBuilder builder = new BooleanBuilder(); - if (bookId != null) builder.and(bookLoanRecord.bookId.eq(bookId)); - if (borrowerId != null && !borrowerId.trim().isEmpty()) builder.and(bookLoanRecord.borrowerId.eq(borrowerId)); - if (status != null) builder.and(bookLoanRecord.status.eq(status)); + if (bookId != null) { + builder.and(bookLoanRecord.bookId.eq(bookId)); + } + if (borrowerId != null && !borrowerId.trim().isEmpty()) { + builder.and(bookLoanRecord.borrowerId.eq(borrowerId)); + } + if (status != null) { + builder.and(bookLoanRecord.status.eq(status)); + } List results = queryFactory - .select(Projections.constructor( - BookLoanRecordResponseDto.class, - bookLoanRecord.id, - bookLoanRecord.bookId, - book.title, - book.imageUrl, - bookLoanRecord.borrowerId, - member.name.as("borrowerName"), - bookLoanRecord.borrowedAt, - bookLoanRecord.returnedAt, - bookLoanRecord.dueDate, - bookLoanRecord.loanExtensionCount, - bookLoanRecord.status - )) - .from(bookLoanRecord) - .leftJoin(book).on(bookLoanRecord.bookId.eq(book.id)) - .leftJoin(member).on(bookLoanRecord.borrowerId.eq(member.id)) - .where(builder) - .offset(pageable.getOffset()) - .limit(pageable.getPageSize()) - .orderBy(OrderSpecifierUtil.getOrderSpecifiers(pageable, bookLoanRecord)) - .fetch(); + .select(Projections.constructor( + BookLoanRecordResponseDto.class, + bookLoanRecord.id, + bookLoanRecord.bookId, + book.title, + book.imageUrl, + bookLoanRecord.borrowerId, + member.name.as("borrowerName"), + bookLoanRecord.borrowedAt, + bookLoanRecord.returnedAt, + bookLoanRecord.dueDate, + bookLoanRecord.loanExtensionCount, + bookLoanRecord.status + )) + .from(bookLoanRecord) + .leftJoin(book).on(bookLoanRecord.bookId.eq(book.id)) + .leftJoin(member).on(bookLoanRecord.borrowerId.eq(member.id)) + .where(builder) + .offset(pageable.getOffset()) + .limit(pageable.getPageSize()) + .orderBy(OrderSpecifierUtil.getOrderSpecifiers(pageable, bookLoanRecord)) + .fetch(); long total = queryFactory - .selectFrom(bookLoanRecord) - .leftJoin(book).on(bookLoanRecord.bookId.eq(book.id)) - .leftJoin(member).on(bookLoanRecord.borrowerId.eq(member.id)) - .where(builder) - .fetchCount(); + .selectFrom(bookLoanRecord) + .leftJoin(book).on(bookLoanRecord.bookId.eq(book.id)) + .leftJoin(member).on(bookLoanRecord.borrowerId.eq(member.id)) + .where(builder) + .fetchCount(); return new PageImpl<>(results, pageable, total); } @@ -78,33 +84,33 @@ public Page findOverdueBookLoanRecords(Pageabl LocalDateTime now = LocalDateTime.now(); List results = queryFactory - .select(Projections.constructor( - BookLoanRecordOverdueResponseDto.class, - bookLoanRecord.bookId, - book.title, - bookLoanRecord.borrowerId, - member.name.as("borrowerName"), - bookLoanRecord.borrowedAt, - bookLoanRecord.dueDate, - bookLoanRecord.status - )) - .from(bookLoanRecord) - .leftJoin(book).on(bookLoanRecord.bookId.eq(book.id)) - .leftJoin(member).on(bookLoanRecord.borrowerId.eq(member.id)) - .where(bookLoanRecord.status.eq(BookLoanStatus.APPROVED) - .and(bookLoanRecord.dueDate.lt(now))) - .offset(pageable.getOffset()) - .limit(pageable.getPageSize()) - .orderBy(OrderSpecifierUtil.getOrderSpecifiers(pageable, bookLoanRecord)) - .fetch(); + .select(Projections.constructor( + BookLoanRecordOverdueResponseDto.class, + bookLoanRecord.bookId, + book.title, + bookLoanRecord.borrowerId, + member.name.as("borrowerName"), + bookLoanRecord.borrowedAt, + bookLoanRecord.dueDate, + bookLoanRecord.status + )) + .from(bookLoanRecord) + .leftJoin(book).on(bookLoanRecord.bookId.eq(book.id)) + .leftJoin(member).on(bookLoanRecord.borrowerId.eq(member.id)) + .where(bookLoanRecord.status.eq(BookLoanStatus.APPROVED) + .and(bookLoanRecord.dueDate.lt(now))) + .offset(pageable.getOffset()) + .limit(pageable.getPageSize()) + .orderBy(OrderSpecifierUtil.getOrderSpecifiers(pageable, bookLoanRecord)) + .fetch(); long total = queryFactory - .selectFrom(bookLoanRecord) - .leftJoin(book).on(bookLoanRecord.bookId.eq(book.id)) - .leftJoin(member).on(bookLoanRecord.borrowerId.eq(member.id)) - .where(bookLoanRecord.status.eq(BookLoanStatus.APPROVED) - .and(bookLoanRecord.dueDate.lt(now))) - .fetchCount(); + .selectFrom(bookLoanRecord) + .leftJoin(book).on(bookLoanRecord.bookId.eq(book.id)) + .leftJoin(member).on(bookLoanRecord.borrowerId.eq(member.id)) + .where(bookLoanRecord.status.eq(BookLoanStatus.APPROVED) + .and(bookLoanRecord.dueDate.lt(now))) + .fetchCount(); return new PageImpl<>(results, pageable, total); } diff --git a/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/dto/response/BookLoanRecordOverdueResponseDto.java b/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/dto/response/BookLoanRecordOverdueResponseDto.java index 41fcac44b..daf4d40d1 100644 --- a/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/dto/response/BookLoanRecordOverdueResponseDto.java +++ b/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/dto/response/BookLoanRecordOverdueResponseDto.java @@ -1,12 +1,11 @@ package page.clab.api.domain.library.bookLoanRecord.application.dto.response; +import java.time.LocalDateTime; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; import page.clab.api.domain.library.bookLoanRecord.domain.BookLoanStatus; -import java.time.LocalDateTime; - @Getter @NoArgsConstructor @AllArgsConstructor diff --git a/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/dto/response/BookLoanRecordResponseDto.java b/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/dto/response/BookLoanRecordResponseDto.java index d9ac92203..76460cfc0 100644 --- a/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/dto/response/BookLoanRecordResponseDto.java +++ b/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/dto/response/BookLoanRecordResponseDto.java @@ -1,12 +1,11 @@ package page.clab.api.domain.library.bookLoanRecord.application.dto.response; +import java.time.LocalDateTime; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; import page.clab.api.domain.library.bookLoanRecord.domain.BookLoanStatus; -import java.time.LocalDateTime; - @Getter @NoArgsConstructor @AllArgsConstructor diff --git a/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/port/in/ApproveBookLoanUseCase.java b/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/port/in/ApproveBookLoanUseCase.java index 5b763e423..5054b9702 100644 --- a/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/port/in/ApproveBookLoanUseCase.java +++ b/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/port/in/ApproveBookLoanUseCase.java @@ -1,5 +1,6 @@ package page.clab.api.domain.library.bookLoanRecord.application.port.in; public interface ApproveBookLoanUseCase { + Long approveBookLoan(Long bookLoanRecordId); } diff --git a/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/port/in/ExtendBookLoanUseCase.java b/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/port/in/ExtendBookLoanUseCase.java index 58b2ec477..44f669285 100644 --- a/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/port/in/ExtendBookLoanUseCase.java +++ b/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/port/in/ExtendBookLoanUseCase.java @@ -3,5 +3,6 @@ import page.clab.api.domain.library.bookLoanRecord.application.dto.request.BookLoanRecordRequestDto; public interface ExtendBookLoanUseCase { + Long extendBookLoan(BookLoanRecordRequestDto requestDto); } diff --git a/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/port/in/RejectBookLoanUseCase.java b/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/port/in/RejectBookLoanUseCase.java index 6ddffee0c..859e39cc4 100644 --- a/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/port/in/RejectBookLoanUseCase.java +++ b/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/port/in/RejectBookLoanUseCase.java @@ -1,5 +1,6 @@ package page.clab.api.domain.library.bookLoanRecord.application.port.in; public interface RejectBookLoanUseCase { + Long rejectBookLoan(Long bookLoanRecordId); } diff --git a/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/port/in/RequestBookLoanUseCase.java b/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/port/in/RequestBookLoanUseCase.java index b39a749f6..a36e71509 100644 --- a/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/port/in/RequestBookLoanUseCase.java +++ b/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/port/in/RequestBookLoanUseCase.java @@ -4,5 +4,6 @@ import page.clab.api.global.exception.CustomOptimisticLockingFailureException; public interface RequestBookLoanUseCase { + Long requestBookLoan(BookLoanRecordRequestDto requestDto) throws CustomOptimisticLockingFailureException; } diff --git a/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/port/in/RetrieveBookLoanRecordsByConditionsUseCase.java b/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/port/in/RetrieveBookLoanRecordsByConditionsUseCase.java index a881a1cfe..5d3284085 100644 --- a/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/port/in/RetrieveBookLoanRecordsByConditionsUseCase.java +++ b/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/port/in/RetrieveBookLoanRecordsByConditionsUseCase.java @@ -6,5 +6,7 @@ import page.clab.api.global.common.dto.PagedResponseDto; public interface RetrieveBookLoanRecordsByConditionsUseCase { - PagedResponseDto retrieveBookLoanRecords(Long bookId, String borrowerId, BookLoanStatus status, Pageable pageable); + + PagedResponseDto retrieveBookLoanRecords(Long bookId, String borrowerId, + BookLoanStatus status, Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/port/in/RetrieveOverdueBookLoanRecordsUseCase.java b/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/port/in/RetrieveOverdueBookLoanRecordsUseCase.java index 02914bad0..7cc6ffb69 100644 --- a/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/port/in/RetrieveOverdueBookLoanRecordsUseCase.java +++ b/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/port/in/RetrieveOverdueBookLoanRecordsUseCase.java @@ -5,5 +5,6 @@ import page.clab.api.global.common.dto.PagedResponseDto; public interface RetrieveOverdueBookLoanRecordsUseCase { + PagedResponseDto retrieveOverdueBookLoanRecords(Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/port/in/ReturnBookUseCase.java b/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/port/in/ReturnBookUseCase.java index 1ea723616..fdde11e8c 100644 --- a/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/port/in/ReturnBookUseCase.java +++ b/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/port/in/ReturnBookUseCase.java @@ -3,5 +3,6 @@ import page.clab.api.domain.library.bookLoanRecord.application.dto.request.BookLoanRecordRequestDto; public interface ReturnBookUseCase { + Long returnBook(BookLoanRecordRequestDto requestDto); } diff --git a/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/port/out/RegisterBookLoanRecordPort.java b/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/port/out/RegisterBookLoanRecordPort.java index ce494586a..abd1ad96b 100644 --- a/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/port/out/RegisterBookLoanRecordPort.java +++ b/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/port/out/RegisterBookLoanRecordPort.java @@ -3,5 +3,6 @@ import page.clab.api.domain.library.bookLoanRecord.domain.BookLoanRecord; public interface RegisterBookLoanRecordPort { + BookLoanRecord save(BookLoanRecord bookLoanRecord); } diff --git a/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/port/out/RetrieveBookLoanRecordPort.java b/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/port/out/RetrieveBookLoanRecordPort.java index dcbbe6fbb..204b0dda3 100644 --- a/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/port/out/RetrieveBookLoanRecordPort.java +++ b/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/port/out/RetrieveBookLoanRecordPort.java @@ -1,5 +1,6 @@ package page.clab.api.domain.library.bookLoanRecord.application.port.out; +import java.util.Optional; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import page.clab.api.domain.library.bookLoanRecord.application.dto.response.BookLoanRecordOverdueResponseDto; @@ -7,13 +8,12 @@ import page.clab.api.domain.library.bookLoanRecord.domain.BookLoanRecord; import page.clab.api.domain.library.bookLoanRecord.domain.BookLoanStatus; -import java.util.Optional; - public interface RetrieveBookLoanRecordPort { BookLoanRecord getById(Long bookLoanRecordId); - Page findByConditions(Long bookId, String borrowerId, BookLoanStatus status, Pageable pageable); + Page findByConditions(Long bookId, String borrowerId, BookLoanStatus status, + Pageable pageable); Page findOverdueBookLoanRecords(Pageable pageable); @@ -21,5 +21,6 @@ public interface RetrieveBookLoanRecordPort { BookLoanRecord getByBookIdAndReturnedAtIsNullAndStatus(Long bookId, BookLoanStatus bookLoanStatus); - Optional findByBookIdAndBorrowerIdAndStatus(Long bookId, String borrowerId, BookLoanStatus bookLoanStatus); + Optional findByBookIdAndBorrowerIdAndStatus(Long bookId, String borrowerId, + BookLoanStatus bookLoanStatus); } diff --git a/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/service/BookLoanApprovalService.java b/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/service/BookLoanApprovalService.java index bc373105a..3a1219e6c 100644 --- a/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/service/BookLoanApprovalService.java +++ b/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/service/BookLoanApprovalService.java @@ -25,8 +25,7 @@ public class BookLoanApprovalService implements ApproveBookLoanUseCase { * 도서 대출을 승인합니다. * *

대출 기록을 조회하고, 도서와 대출자의 상태를 검증합니다. - * 도서가 이미 대출 중인지 확인하고, 대출자의 대출 한도를 검증합니다. - * 승인된 대출 기록과 도서 정보를 저장한 후 대출 기록 ID를 반환합니다.

+ * 도서가 이미 대출 중인지 확인하고, 대출자의 대출 한도를 검증합니다. 승인된 대출 기록과 도서 정보를 저장한 후 대출 기록 ID를 반환합니다.

* * @param bookLoanRecordId 대출 기록의 ID * @return 승인된 대출 기록의 ID diff --git a/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/service/BookLoanExtensionService.java b/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/service/BookLoanExtensionService.java index 28fa23137..592e51856 100644 --- a/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/service/BookLoanExtensionService.java +++ b/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/service/BookLoanExtensionService.java @@ -29,9 +29,7 @@ public class BookLoanExtensionService implements ExtendBookLoanUseCase { * 도서 대출을 연장합니다. * *

현재 로그인한 멤버의 정보를 기반으로 대출 기록을 조회하고, - * 해당 사용자가 도서의 현재 대출자인지 검증합니다. - * 대출을 연장한 후 사용자에게 알림을 전송하고, - * 연장된 대출 기록을 저장합니다.

+ * 해당 사용자가 도서의 현재 대출자인지 검증합니다. 대출을 연장한 후 사용자에게 알림을 전송하고, 연장된 대출 기록을 저장합니다.

* * @param requestDto 도서 대출 연장 요청 DTO * @return 연장된 대출 기록의 ID @@ -44,10 +42,12 @@ public Long extendBookLoan(BookLoanRecordRequestDto requestDto) { Book book = externalRetrieveBookUseCase.getById(requestDto.getBookId()); book.validateCurrentBorrower(currentMemberId); - BookLoanRecord bookLoanRecord = retrieveBookLoanRecordPort.getByBookIdAndReturnedAtIsNullAndStatus(book.getId(), BookLoanStatus.APPROVED); + BookLoanRecord bookLoanRecord = retrieveBookLoanRecordPort.getByBookIdAndReturnedAtIsNullAndStatus(book.getId(), + BookLoanStatus.APPROVED); bookLoanRecord.extendLoan(borrowerInfo); - externalSendNotificationUseCase.sendNotificationToMember(currentMemberId, "[" + book.getTitle() + "] 도서 대출 연장이 완료되었습니다."); + externalSendNotificationUseCase.sendNotificationToMember(currentMemberId, + "[" + book.getTitle() + "] 도서 대출 연장이 완료되었습니다."); return registerBookLoanRecordPort.save(bookLoanRecord).getId(); } diff --git a/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/service/BookLoanRecordsByConditionsRetrievalService.java b/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/service/BookLoanRecordsByConditionsRetrievalService.java index 1dc47d694..7e61c1b59 100644 --- a/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/service/BookLoanRecordsByConditionsRetrievalService.java +++ b/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/service/BookLoanRecordsByConditionsRetrievalService.java @@ -19,8 +19,10 @@ public class BookLoanRecordsByConditionsRetrievalService implements RetrieveBook @Transactional(readOnly = true) @Override - public PagedResponseDto retrieveBookLoanRecords(Long bookId, String borrowerId, BookLoanStatus status, Pageable pageable) { - Page bookLoanRecords = retrieveBookLoanRecordPort.findByConditions(bookId, borrowerId, status, pageable); + public PagedResponseDto retrieveBookLoanRecords(Long bookId, String borrowerId, + BookLoanStatus status, Pageable pageable) { + Page bookLoanRecords = retrieveBookLoanRecordPort.findByConditions(bookId, + borrowerId, status, pageable); return new PagedResponseDto<>(bookLoanRecords); } } diff --git a/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/service/BookLoanRequestService.java b/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/service/BookLoanRequestService.java index 9f32d5adb..2a4bc1e66 100644 --- a/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/service/BookLoanRequestService.java +++ b/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/service/BookLoanRequestService.java @@ -61,12 +61,12 @@ public Long requestBookLoan(BookLoanRecordRequestDto requestDto) throws CustomOp BookLoanRecord bookLoanRecord = BookLoanRecord.create(book.getId(), borrowerInfo); externalSendNotificationUseCase.sendNotificationToMember(borrowerInfo.getMemberId(), - "[" + book.getTitle() + "] 도서 대출 신청이 완료되었습니다."); + "[" + book.getTitle() + "] 도서 대출 신청이 완료되었습니다."); BookLoanRecordNotificationInfo bookLoanRecordInfo = BookLoanRecordNotificationInfo.create(book, - borrowerInfo); + borrowerInfo); eventPublisher.publishEvent(new NotificationEvent(this, ExecutivesAlertType.NEW_BOOK_LOAN_REQUEST, null, - bookLoanRecordInfo)); + bookLoanRecordInfo)); return registerBookLoanRecordPort.save(bookLoanRecord).getId(); } catch (ObjectOptimisticLockingFailureException e) { @@ -84,8 +84,8 @@ private void validateBorrowLimit(String borrowerId) { private void checkIfLoanAlreadyApplied(Long bookId, String borrowerId) { retrieveBookLoanRecordPort.findByBookIdAndBorrowerIdAndStatus(bookId, borrowerId, BookLoanStatus.PENDING) - .ifPresent(bookLoanRecord -> { - throw new BookAlreadyAppliedForLoanException("이미 대출 신청한 도서입니다."); - }); + .ifPresent(bookLoanRecord -> { + throw new BookAlreadyAppliedForLoanException("이미 대출 신청한 도서입니다."); + }); } } diff --git a/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/service/BookReturnService.java b/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/service/BookReturnService.java index ca35e647f..a65ca21c9 100644 --- a/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/service/BookReturnService.java +++ b/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/service/BookReturnService.java @@ -33,9 +33,7 @@ public class BookReturnService implements ReturnBookUseCase { * 도서 반납을 처리합니다. * *

현재 로그인한 멤버가 대출한 도서를 반납 처리하고, - * 대출 기록을 "RETURNED"로 표시합니다. - * 반납 이후 회원의 대출 정지 날짜를 업데이트하고, - * 반납 완료 알림을 사용자에게 전송합니다.

+ * 대출 기록을 "RETURNED"로 표시합니다. 반납 이후 회원의 대출 정지 날짜를 업데이트하고, 반납 완료 알림을 사용자에게 전송합니다.

* * @param requestDto 도서 반납 요청 정보 DTO * @return 반납된 대출 기록의 ID @@ -49,12 +47,15 @@ public Long returnBook(BookLoanRecordRequestDto requestDto) { book.returnBook(currentMemberId); externalRegisterBookUseCase.save(book); - BookLoanRecord bookLoanRecord = retrieveBookLoanRecordPort.getByBookIdAndReturnedAtIsNullAndStatus(book.getId(), BookLoanStatus.APPROVED); + BookLoanRecord bookLoanRecord = retrieveBookLoanRecordPort.getByBookIdAndReturnedAtIsNullAndStatus(book.getId(), + BookLoanStatus.APPROVED); bookLoanRecord.markAsReturned(borrowerInfo); - externalUpdateMemberUseCase.updateLoanSuspensionDate(borrowerInfo.getMemberId(), borrowerInfo.getLoanSuspensionDate()); + externalUpdateMemberUseCase.updateLoanSuspensionDate(borrowerInfo.getMemberId(), + borrowerInfo.getLoanSuspensionDate()); - externalSendNotificationUseCase.sendNotificationToMember(currentMemberId, "[" + book.getTitle() + "] 도서 반납이 완료되었습니다."); + externalSendNotificationUseCase.sendNotificationToMember(currentMemberId, + "[" + book.getTitle() + "] 도서 반납이 완료되었습니다."); return registerBookLoanRecordPort.save(bookLoanRecord).getId(); } } diff --git a/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/service/OverdueBookLoanRecordsRetrievalService.java b/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/service/OverdueBookLoanRecordsRetrievalService.java index 4053d5e13..3c68726cd 100644 --- a/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/service/OverdueBookLoanRecordsRetrievalService.java +++ b/src/main/java/page/clab/api/domain/library/bookLoanRecord/application/service/OverdueBookLoanRecordsRetrievalService.java @@ -19,7 +19,8 @@ public class OverdueBookLoanRecordsRetrievalService implements RetrieveOverdueBo @Transactional(readOnly = true) @Override public PagedResponseDto retrieveOverdueBookLoanRecords(Pageable pageable) { - Page overdueBookLoanRecords = retrieveBookLoanRecordPort.findOverdueBookLoanRecords(pageable); + Page overdueBookLoanRecords = retrieveBookLoanRecordPort.findOverdueBookLoanRecords( + pageable); return new PagedResponseDto<>(overdueBookLoanRecords); } } diff --git a/src/main/java/page/clab/api/domain/library/bookLoanRecord/domain/BookLoanRecord.java b/src/main/java/page/clab/api/domain/library/bookLoanRecord/domain/BookLoanRecord.java index 7578609f4..a9a6c5411 100644 --- a/src/main/java/page/clab/api/domain/library/bookLoanRecord/domain/BookLoanRecord.java +++ b/src/main/java/page/clab/api/domain/library/bookLoanRecord/domain/BookLoanRecord.java @@ -1,5 +1,7 @@ package page.clab.api.domain.library.bookLoanRecord.domain; +import java.time.LocalDateTime; +import java.time.temporal.ChronoUnit; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -12,9 +14,6 @@ import page.clab.api.domain.library.bookLoanRecord.application.exception.OverdueException; import page.clab.api.domain.memberManagement.member.application.dto.shared.MemberBorrowerInfoDto; -import java.time.LocalDateTime; -import java.time.temporal.ChronoUnit; - @Getter @Setter @Builder @@ -34,12 +33,12 @@ public class BookLoanRecord { public static BookLoanRecord create(Long bookId, MemberBorrowerInfoDto borrowerInfo) { return BookLoanRecord.builder() - .bookId(bookId) - .borrowerId(borrowerInfo.getMemberId()) - .loanExtensionCount(0L) - .status(BookLoanStatus.PENDING) - .isDeleted(false) - .build(); + .bookId(bookId) + .borrowerId(borrowerInfo.getMemberId()) + .loanExtensionCount(0L) + .status(BookLoanStatus.PENDING) + .isDeleted(false) + .build(); } public void markAsReturned(MemberBorrowerInfoDto borrowerInfo) { diff --git a/src/main/java/page/clab/api/domain/memberManagement/award/adapter/in/web/AwardRegisterController.java b/src/main/java/page/clab/api/domain/memberManagement/award/adapter/in/web/AwardRegisterController.java index 85b209b74..17dbde97d 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/award/adapter/in/web/AwardRegisterController.java +++ b/src/main/java/page/clab/api/domain/memberManagement/award/adapter/in/web/AwardRegisterController.java @@ -25,7 +25,7 @@ public class AwardRegisterController { @PreAuthorize("hasRole('USER')") @PostMapping("") public ApiResponse registerAward( - @Valid @RequestBody AwardRequestDto requestDto + @Valid @RequestBody AwardRequestDto requestDto ) { Long id = registerAwardUseCase.registerAward(requestDto); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/memberManagement/award/adapter/in/web/AwardRemoveController.java b/src/main/java/page/clab/api/domain/memberManagement/award/adapter/in/web/AwardRemoveController.java index 4db7d32d6..34cca1019 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/award/adapter/in/web/AwardRemoveController.java +++ b/src/main/java/page/clab/api/domain/memberManagement/award/adapter/in/web/AwardRemoveController.java @@ -21,11 +21,11 @@ public class AwardRemoveController { private final RemoveAwardUseCase removeAwardUseCase; @Operation(summary = "[U] 수상 이력 삭제", description = "ROLE_USER 이상의 권한이 필요함
" + - "본인 외의 정보는 ROLE_SUPER만 가능") + "본인 외의 정보는 ROLE_SUPER만 가능") @PreAuthorize("hasRole('USER')") @DeleteMapping("/{awardId}") public ApiResponse removeAward( - @PathVariable(name = "awardId") Long awardId + @PathVariable(name = "awardId") Long awardId ) throws PermissionDeniedException { Long id = removeAwardUseCase.removeAward(awardId); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/memberManagement/award/adapter/in/web/AwardRetrievalController.java b/src/main/java/page/clab/api/domain/memberManagement/award/adapter/in/web/AwardRetrievalController.java index df93f56ff..dc823ce8c 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/award/adapter/in/web/AwardRetrievalController.java +++ b/src/main/java/page/clab/api/domain/memberManagement/award/adapter/in/web/AwardRetrievalController.java @@ -2,6 +2,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.security.access.prepost.PreAuthorize; @@ -17,8 +18,6 @@ import page.clab.api.global.exception.SortingArgumentException; import page.clab.api.global.util.PageableUtils; -import java.util.List; - @RestController @RequestMapping("/api/v1/awards") @RequiredArgsConstructor @@ -29,18 +28,18 @@ public class AwardRetrievalController { private final PageableUtils pageableUtils; @Operation(summary = "[G] 수상 이력 조회(학번, 연도 기준)", description = "ROLE_GUEST 이상의 권한이 필요함
" + - "2개의 파라미터를 자유롭게 조합하여 필터링 가능
" + - "학번, 연도 중 하나라도 입력하지 않으면 전체 조회됨
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") + "2개의 파라미터를 자유롭게 조합하여 필터링 가능
" + + "학번, 연도 중 하나라도 입력하지 않으면 전체 조회됨
" + + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") @PreAuthorize("hasRole('GUEST')") @GetMapping("") public ApiResponse> retrieveAwards( - @RequestParam(name = "memberId", required = false) String memberId, - @RequestParam(name = "year", required = false) Long year, - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "awardDate") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection + @RequestParam(name = "memberId", required = false) String memberId, + @RequestParam(name = "year", required = false) Long year, + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "awardDate") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection ) throws SortingArgumentException, InvalidColumnException { Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, AwardResponseDto.class); PagedResponseDto awards = retrieveAwardsUseCase.retrieveAwards(memberId, year, pageable); diff --git a/src/main/java/page/clab/api/domain/memberManagement/award/adapter/in/web/AwardUpdateController.java b/src/main/java/page/clab/api/domain/memberManagement/award/adapter/in/web/AwardUpdateController.java index 8ab74d729..8a3c2b2bd 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/award/adapter/in/web/AwardUpdateController.java +++ b/src/main/java/page/clab/api/domain/memberManagement/award/adapter/in/web/AwardUpdateController.java @@ -24,12 +24,12 @@ public class AwardUpdateController { private final UpdateAwardUseCase updateAwardUseCase; @Operation(summary = "[U] 수상 이력 수정", description = "ROLE_USER 이상의 권한이 필요함
" + - "본인 외의 정보는 ROLE_SUPER만 가능") + "본인 외의 정보는 ROLE_SUPER만 가능") @PreAuthorize("hasRole('USER')") @PatchMapping("/{awardId}") public ApiResponse updateAward( - @PathVariable(name = "awardId") Long awardId, - @Valid @RequestBody AwardUpdateRequestDto requestDto + @PathVariable(name = "awardId") Long awardId, + @Valid @RequestBody AwardUpdateRequestDto requestDto ) throws PermissionDeniedException { Long id = updateAwardUseCase.updateAward(awardId, requestDto); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/memberManagement/award/adapter/in/web/DeletedAwardRetrievalController.java b/src/main/java/page/clab/api/domain/memberManagement/award/adapter/in/web/DeletedAwardRetrievalController.java index 2c8e63b6f..4efe0c0e6 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/award/adapter/in/web/DeletedAwardRetrievalController.java +++ b/src/main/java/page/clab/api/domain/memberManagement/award/adapter/in/web/DeletedAwardRetrievalController.java @@ -27,8 +27,8 @@ public class DeletedAwardRetrievalController { @PreAuthorize("hasRole('SUPER')") @GetMapping("/deleted") public ApiResponse> retrieveDeletedAwards( - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size ) { Pageable pageable = PageRequest.of(page, size); PagedResponseDto awards = retrieveDeletedAwardsUseCase.retrieveDeletedAwards(pageable); diff --git a/src/main/java/page/clab/api/domain/memberManagement/award/adapter/in/web/MyAwardRetrievalController.java b/src/main/java/page/clab/api/domain/memberManagement/award/adapter/in/web/MyAwardRetrievalController.java index 401babc67..3d68c156c 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/award/adapter/in/web/MyAwardRetrievalController.java +++ b/src/main/java/page/clab/api/domain/memberManagement/award/adapter/in/web/MyAwardRetrievalController.java @@ -2,6 +2,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.security.access.prepost.PreAuthorize; @@ -17,8 +18,6 @@ import page.clab.api.global.exception.SortingArgumentException; import page.clab.api.global.util.PageableUtils; -import java.util.List; - @RestController @RequestMapping("/api/v1/awards") @RequiredArgsConstructor @@ -29,14 +28,14 @@ public class MyAwardRetrievalController { private final PageableUtils pageableUtils; @Operation(summary = "[G] 나의 수상 이력 조회", description = "ROLE_GUEST 이상의 권한이 필요함
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") @PreAuthorize("hasRole('GUEST')") @GetMapping("/my") public ApiResponse> retrieveMyAwards( - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "awardDate") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "awardDate") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection ) throws SortingArgumentException, InvalidColumnException { Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, AwardResponseDto.class); PagedResponseDto myAwards = retrieveMyAwardsUseCase.retrieveMyAwards(pageable); diff --git a/src/main/java/page/clab/api/domain/memberManagement/award/adapter/out/persistence/AwardJpaEntity.java b/src/main/java/page/clab/api/domain/memberManagement/award/adapter/out/persistence/AwardJpaEntity.java index d2c52dd56..fc712a369 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/award/adapter/out/persistence/AwardJpaEntity.java +++ b/src/main/java/page/clab/api/domain/memberManagement/award/adapter/out/persistence/AwardJpaEntity.java @@ -7,6 +7,7 @@ import jakarta.persistence.Id; import jakarta.persistence.Table; import jakarta.validation.constraints.Size; +import java.time.LocalDate; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -17,8 +18,6 @@ import org.hibernate.annotations.SQLRestriction; import page.clab.api.global.common.domain.BaseEntity; -import java.time.LocalDate; - @Entity @Table(name = "award") @Getter diff --git a/src/main/java/page/clab/api/domain/memberManagement/award/adapter/out/persistence/AwardPersistenceAdapter.java b/src/main/java/page/clab/api/domain/memberManagement/award/adapter/out/persistence/AwardPersistenceAdapter.java index bb3b9acf9..7ccad5775 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/award/adapter/out/persistence/AwardPersistenceAdapter.java +++ b/src/main/java/page/clab/api/domain/memberManagement/award/adapter/out/persistence/AwardPersistenceAdapter.java @@ -1,5 +1,6 @@ package page.clab.api.domain.memberManagement.award.adapter.out.persistence; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -10,14 +11,12 @@ import page.clab.api.domain.memberManagement.award.domain.Award; import page.clab.api.global.exception.NotFoundException; -import java.util.List; - @Component @RequiredArgsConstructor public class AwardPersistenceAdapter implements - RegisterAwardPort, - RetrieveAwardPort, - RemoveAwardPort { + RegisterAwardPort, + RetrieveAwardPort, + RemoveAwardPort { private final AwardRepository awardRepository; private final AwardMapper awardMapper; @@ -32,8 +31,8 @@ public Award save(Award award) { @Override public void saveAll(List awards) { List entities = awards.stream() - .map(awardMapper::toEntity) - .toList(); + .map(awardMapper::toEntity) + .toList(); awardRepository.saveAll(entities); } @@ -46,32 +45,32 @@ public void delete(Award award) { @Override public Award getById(Long awardId) { return awardRepository.findById(awardId) - .map(awardMapper::toDomain) - .orElseThrow(() -> new NotFoundException("[Award] id: " + awardId + "에 해당하는 수상 이력이 존재하지 않습니다.")); + .map(awardMapper::toDomain) + .orElseThrow(() -> new NotFoundException("[Award] id: " + awardId + "에 해당하는 수상 이력이 존재하지 않습니다.")); } @Override public Page findByConditions(String memberId, Long year, Pageable pageable) { return awardRepository.findByConditions(memberId, year, pageable) - .map(awardMapper::toDomain); + .map(awardMapper::toDomain); } @Override public Page findAllByIsDeletedTrue(Pageable pageable) { return awardRepository.findAllByIsDeletedTrue(pageable) - .map(awardMapper::toDomain); + .map(awardMapper::toDomain); } @Override public Page findByMemberId(String memberId, Pageable pageable) { return awardRepository.findByMemberId(memberId, pageable) - .map(awardMapper::toDomain); + .map(awardMapper::toDomain); } @Override public List findByMemberId(String memberId) { return awardRepository.findByMemberId(memberId).stream() - .map(awardMapper::toDomain) - .toList(); + .map(awardMapper::toDomain) + .toList(); } } diff --git a/src/main/java/page/clab/api/domain/memberManagement/award/adapter/out/persistence/AwardRepository.java b/src/main/java/page/clab/api/domain/memberManagement/award/adapter/out/persistence/AwardRepository.java index b84affd4a..e49547c4b 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/award/adapter/out/persistence/AwardRepository.java +++ b/src/main/java/page/clab/api/domain/memberManagement/award/adapter/out/persistence/AwardRepository.java @@ -1,13 +1,12 @@ package page.clab.api.domain.memberManagement.award.adapter.out.persistence; +import java.util.List; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; -import java.util.List; - @Repository public interface AwardRepository extends JpaRepository, AwardRepositoryCustom { diff --git a/src/main/java/page/clab/api/domain/memberManagement/award/adapter/out/persistence/AwardRepositoryCustom.java b/src/main/java/page/clab/api/domain/memberManagement/award/adapter/out/persistence/AwardRepositoryCustom.java index 47b1827f6..5c1a568ae 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/award/adapter/out/persistence/AwardRepositoryCustom.java +++ b/src/main/java/page/clab/api/domain/memberManagement/award/adapter/out/persistence/AwardRepositoryCustom.java @@ -4,5 +4,6 @@ import org.springframework.data.domain.Pageable; public interface AwardRepositoryCustom { + Page findByConditions(String memberId, Long year, Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/memberManagement/award/adapter/out/persistence/AwardRepositoryImpl.java b/src/main/java/page/clab/api/domain/memberManagement/award/adapter/out/persistence/AwardRepositoryImpl.java index f55e2612d..8dec7cae4 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/award/adapter/out/persistence/AwardRepositoryImpl.java +++ b/src/main/java/page/clab/api/domain/memberManagement/award/adapter/out/persistence/AwardRepositoryImpl.java @@ -2,6 +2,8 @@ import com.querydsl.core.BooleanBuilder; import com.querydsl.jpa.impl.JPAQueryFactory; +import java.time.LocalDate; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; @@ -10,9 +12,6 @@ import page.clab.api.domain.memberManagement.member.adapter.out.persistence.QMemberJpaEntity; import page.clab.api.global.util.OrderSpecifierUtil; -import java.time.LocalDate; -import java.util.List; - @Repository @RequiredArgsConstructor public class AwardRepositoryImpl implements AwardRepositoryCustom { @@ -25,7 +24,9 @@ public Page findByConditions(String memberId, Long year, Pageabl QMemberJpaEntity member = QMemberJpaEntity.memberJpaEntity; BooleanBuilder builder = new BooleanBuilder(); - if (memberId != null) builder.and(award.memberId.eq(memberId)); + if (memberId != null) { + builder.and(award.memberId.eq(memberId)); + } if (year != null) { LocalDate startOfYear = LocalDate.of(year.intValue(), 1, 1); LocalDate endOfYear = LocalDate.of(year.intValue(), 12, 31); @@ -33,17 +34,17 @@ public Page findByConditions(String memberId, Long year, Pageabl } List awards = queryFactory.selectFrom(award) - .leftJoin(member).on(award.memberId.eq(member.id)) - .where(builder) - .orderBy(OrderSpecifierUtil.getOrderSpecifiers(pageable, award)) - .offset(pageable.getOffset()) - .limit(pageable.getPageSize()) - .fetch(); + .leftJoin(member).on(award.memberId.eq(member.id)) + .where(builder) + .orderBy(OrderSpecifierUtil.getOrderSpecifiers(pageable, award)) + .offset(pageable.getOffset()) + .limit(pageable.getPageSize()) + .fetch(); long count = queryFactory - .selectFrom(award) - .where(builder) - .fetchCount(); + .selectFrom(award) + .where(builder) + .fetchCount(); return new PageImpl<>(awards, pageable, count); } diff --git a/src/main/java/page/clab/api/domain/memberManagement/award/application/dto/mapper/AwardDtoMapper.java b/src/main/java/page/clab/api/domain/memberManagement/award/application/dto/mapper/AwardDtoMapper.java index aa9630637..6badf272c 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/award/application/dto/mapper/AwardDtoMapper.java +++ b/src/main/java/page/clab/api/domain/memberManagement/award/application/dto/mapper/AwardDtoMapper.java @@ -10,22 +10,22 @@ public class AwardDtoMapper { public Award fromDto(AwardRequestDto requestDto, String memberId) { return Award.builder() - .competitionName(requestDto.getCompetitionName()) - .organizer(requestDto.getOrganizer()) - .awardName(requestDto.getAwardName()) - .awardDate(requestDto.getAwardDate()) - .memberId(memberId) - .isDeleted(false) - .build(); + .competitionName(requestDto.getCompetitionName()) + .organizer(requestDto.getOrganizer()) + .awardName(requestDto.getAwardName()) + .awardDate(requestDto.getAwardDate()) + .memberId(memberId) + .isDeleted(false) + .build(); } public AwardResponseDto toDto(Award award) { return AwardResponseDto.builder() - .id(award.getId()) - .competitionName(award.getCompetitionName()) - .organizer(award.getOrganizer()) - .awardName(award.getAwardName()) - .awardDate(award.getAwardDate()) - .build(); + .id(award.getId()) + .competitionName(award.getCompetitionName()) + .organizer(award.getOrganizer()) + .awardName(award.getAwardName()) + .awardDate(award.getAwardDate()) + .build(); } } diff --git a/src/main/java/page/clab/api/domain/memberManagement/award/application/dto/request/AwardRequestDto.java b/src/main/java/page/clab/api/domain/memberManagement/award/application/dto/request/AwardRequestDto.java index 6fbb69a0d..e9beb7f02 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/award/application/dto/request/AwardRequestDto.java +++ b/src/main/java/page/clab/api/domain/memberManagement/award/application/dto/request/AwardRequestDto.java @@ -2,11 +2,10 @@ import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotNull; +import java.time.LocalDate; import lombok.Getter; import lombok.Setter; -import java.time.LocalDate; - @Getter @Setter public class AwardRequestDto { diff --git a/src/main/java/page/clab/api/domain/memberManagement/award/application/dto/request/AwardUpdateRequestDto.java b/src/main/java/page/clab/api/domain/memberManagement/award/application/dto/request/AwardUpdateRequestDto.java index 94b439807..72947d9d9 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/award/application/dto/request/AwardUpdateRequestDto.java +++ b/src/main/java/page/clab/api/domain/memberManagement/award/application/dto/request/AwardUpdateRequestDto.java @@ -1,11 +1,10 @@ package page.clab.api.domain.memberManagement.award.application.dto.request; import io.swagger.v3.oas.annotations.media.Schema; +import java.time.LocalDate; import lombok.Getter; import lombok.Setter; -import java.time.LocalDate; - @Getter @Setter public class AwardUpdateRequestDto { diff --git a/src/main/java/page/clab/api/domain/memberManagement/award/application/dto/response/AwardResponseDto.java b/src/main/java/page/clab/api/domain/memberManagement/award/application/dto/response/AwardResponseDto.java index 8ffd49672..159366500 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/award/application/dto/response/AwardResponseDto.java +++ b/src/main/java/page/clab/api/domain/memberManagement/award/application/dto/response/AwardResponseDto.java @@ -1,10 +1,9 @@ package page.clab.api.domain.memberManagement.award.application.dto.response; +import java.time.LocalDate; import lombok.Builder; import lombok.Getter; -import java.time.LocalDate; - @Getter @Builder public class AwardResponseDto { diff --git a/src/main/java/page/clab/api/domain/memberManagement/award/application/event/AwardEventProcessor.java b/src/main/java/page/clab/api/domain/memberManagement/award/application/event/AwardEventProcessor.java index 0c1cd2056..eff7ea72e 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/award/application/event/AwardEventProcessor.java +++ b/src/main/java/page/clab/api/domain/memberManagement/award/application/event/AwardEventProcessor.java @@ -1,6 +1,7 @@ package page.clab.api.domain.memberManagement.award.application.event; import jakarta.annotation.PostConstruct; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; @@ -10,8 +11,6 @@ import page.clab.api.domain.memberManagement.member.application.event.MemberEventProcessor; import page.clab.api.domain.memberManagement.member.application.event.MemberEventProcessorRegistry; -import java.util.List; - @Component @RequiredArgsConstructor public class AwardEventProcessor implements MemberEventProcessor { diff --git a/src/main/java/page/clab/api/domain/memberManagement/award/application/port/in/RegisterAwardUseCase.java b/src/main/java/page/clab/api/domain/memberManagement/award/application/port/in/RegisterAwardUseCase.java index b47ec9140..aa6aa324a 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/award/application/port/in/RegisterAwardUseCase.java +++ b/src/main/java/page/clab/api/domain/memberManagement/award/application/port/in/RegisterAwardUseCase.java @@ -3,5 +3,6 @@ import page.clab.api.domain.memberManagement.award.application.dto.request.AwardRequestDto; public interface RegisterAwardUseCase { + Long registerAward(AwardRequestDto requestDto); } diff --git a/src/main/java/page/clab/api/domain/memberManagement/award/application/port/in/RemoveAwardUseCase.java b/src/main/java/page/clab/api/domain/memberManagement/award/application/port/in/RemoveAwardUseCase.java index 4c02de864..bbea5341e 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/award/application/port/in/RemoveAwardUseCase.java +++ b/src/main/java/page/clab/api/domain/memberManagement/award/application/port/in/RemoveAwardUseCase.java @@ -3,5 +3,6 @@ import page.clab.api.global.exception.PermissionDeniedException; public interface RemoveAwardUseCase { + Long removeAward(Long awardId) throws PermissionDeniedException; } diff --git a/src/main/java/page/clab/api/domain/memberManagement/award/application/port/in/RetrieveAwardsUseCase.java b/src/main/java/page/clab/api/domain/memberManagement/award/application/port/in/RetrieveAwardsUseCase.java index 7aaaba419..6707548e0 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/award/application/port/in/RetrieveAwardsUseCase.java +++ b/src/main/java/page/clab/api/domain/memberManagement/award/application/port/in/RetrieveAwardsUseCase.java @@ -5,5 +5,6 @@ import page.clab.api.global.common.dto.PagedResponseDto; public interface RetrieveAwardsUseCase { + PagedResponseDto retrieveAwards(String memberId, Long year, Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/memberManagement/award/application/port/in/RetrieveDeletedAwardsUseCase.java b/src/main/java/page/clab/api/domain/memberManagement/award/application/port/in/RetrieveDeletedAwardsUseCase.java index dc6e11034..c7bda5236 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/award/application/port/in/RetrieveDeletedAwardsUseCase.java +++ b/src/main/java/page/clab/api/domain/memberManagement/award/application/port/in/RetrieveDeletedAwardsUseCase.java @@ -5,5 +5,6 @@ import page.clab.api.global.common.dto.PagedResponseDto; public interface RetrieveDeletedAwardsUseCase { + PagedResponseDto retrieveDeletedAwards(Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/memberManagement/award/application/port/in/RetrieveMyAwardsUseCase.java b/src/main/java/page/clab/api/domain/memberManagement/award/application/port/in/RetrieveMyAwardsUseCase.java index 3b81ce02e..8461acab4 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/award/application/port/in/RetrieveMyAwardsUseCase.java +++ b/src/main/java/page/clab/api/domain/memberManagement/award/application/port/in/RetrieveMyAwardsUseCase.java @@ -5,5 +5,6 @@ import page.clab.api.global.common.dto.PagedResponseDto; public interface RetrieveMyAwardsUseCase { + PagedResponseDto retrieveMyAwards(Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/memberManagement/award/application/port/in/UpdateAwardUseCase.java b/src/main/java/page/clab/api/domain/memberManagement/award/application/port/in/UpdateAwardUseCase.java index 7fd6712c7..8ffd083d6 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/award/application/port/in/UpdateAwardUseCase.java +++ b/src/main/java/page/clab/api/domain/memberManagement/award/application/port/in/UpdateAwardUseCase.java @@ -4,5 +4,6 @@ import page.clab.api.global.exception.PermissionDeniedException; public interface UpdateAwardUseCase { + Long updateAward(Long awardId, AwardUpdateRequestDto requestDto) throws PermissionDeniedException; } diff --git a/src/main/java/page/clab/api/domain/memberManagement/award/application/port/out/RegisterAwardPort.java b/src/main/java/page/clab/api/domain/memberManagement/award/application/port/out/RegisterAwardPort.java index 40c3d47ac..509e1797f 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/award/application/port/out/RegisterAwardPort.java +++ b/src/main/java/page/clab/api/domain/memberManagement/award/application/port/out/RegisterAwardPort.java @@ -1,8 +1,7 @@ package page.clab.api.domain.memberManagement.award.application.port.out; -import page.clab.api.domain.memberManagement.award.domain.Award; - import java.util.List; +import page.clab.api.domain.memberManagement.award.domain.Award; public interface RegisterAwardPort { diff --git a/src/main/java/page/clab/api/domain/memberManagement/award/application/port/out/RemoveAwardPort.java b/src/main/java/page/clab/api/domain/memberManagement/award/application/port/out/RemoveAwardPort.java index 85e5aade0..86c1b1e8c 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/award/application/port/out/RemoveAwardPort.java +++ b/src/main/java/page/clab/api/domain/memberManagement/award/application/port/out/RemoveAwardPort.java @@ -3,5 +3,6 @@ import page.clab.api.domain.memberManagement.award.domain.Award; public interface RemoveAwardPort { + void delete(Award award); } diff --git a/src/main/java/page/clab/api/domain/memberManagement/award/application/port/out/RetrieveAwardPort.java b/src/main/java/page/clab/api/domain/memberManagement/award/application/port/out/RetrieveAwardPort.java index e1f65a345..ca89f254e 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/award/application/port/out/RetrieveAwardPort.java +++ b/src/main/java/page/clab/api/domain/memberManagement/award/application/port/out/RetrieveAwardPort.java @@ -1,11 +1,10 @@ package page.clab.api.domain.memberManagement.award.application.port.out; +import java.util.List; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import page.clab.api.domain.memberManagement.award.domain.Award; -import java.util.List; - public interface RetrieveAwardPort { Award getById(Long awardId); diff --git a/src/main/java/page/clab/api/domain/memberManagement/award/domain/Award.java b/src/main/java/page/clab/api/domain/memberManagement/award/domain/Award.java index 6fb6c372b..4d7ef906c 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/award/domain/Award.java +++ b/src/main/java/page/clab/api/domain/memberManagement/award/domain/Award.java @@ -1,5 +1,7 @@ package page.clab.api.domain.memberManagement.award.domain; +import java.time.LocalDate; +import java.util.Optional; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -10,9 +12,6 @@ import page.clab.api.domain.memberManagement.member.application.dto.shared.MemberDetailedInfoDto; import page.clab.api.global.exception.PermissionDeniedException; -import java.time.LocalDate; -import java.util.Optional; - @Getter @Setter @Builder diff --git a/src/main/java/page/clab/api/domain/memberManagement/cloud/adapter/in/web/CloudUsageRetrievalAllController.java b/src/main/java/page/clab/api/domain/memberManagement/cloud/adapter/in/web/CloudUsageRetrievalAllController.java index 886e54b23..6a93f38fb 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/cloud/adapter/in/web/CloudUsageRetrievalAllController.java +++ b/src/main/java/page/clab/api/domain/memberManagement/cloud/adapter/in/web/CloudUsageRetrievalAllController.java @@ -27,11 +27,12 @@ public class CloudUsageRetrievalAllController { @PreAuthorize("hasRole('SUPER')") @GetMapping("") public ApiResponse> retrieveAllCloudUsages( - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size ) { Pageable pageable = PageRequest.of(page, size); - PagedResponseDto cloudUsageInfos = retrieveAllCloudUsageUseCase.retrieveAllCloudUsages(pageable); + PagedResponseDto cloudUsageInfos = retrieveAllCloudUsageUseCase.retrieveAllCloudUsages( + pageable); return ApiResponse.success(cloudUsageInfos); } } diff --git a/src/main/java/page/clab/api/domain/memberManagement/cloud/adapter/in/web/CloudUsageRetrievalByMemberIdController.java b/src/main/java/page/clab/api/domain/memberManagement/cloud/adapter/in/web/CloudUsageRetrievalByMemberIdController.java index ffc0448a8..bdbf43ef2 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/cloud/adapter/in/web/CloudUsageRetrievalByMemberIdController.java +++ b/src/main/java/page/clab/api/domain/memberManagement/cloud/adapter/in/web/CloudUsageRetrievalByMemberIdController.java @@ -22,11 +22,11 @@ public class CloudUsageRetrievalByMemberIdController { private final RetrieveCloudUsageByMemberIdUseCase retrieveCloudUsageByMemberIdUseCase; @Operation(summary = "[G] 멤버의 클라우드 사용량 조회", description = "ROLE_GUEST 이상의 권한이 필요함
" + - "본인 외의 정보는 ROLE_SUPER만 가능") + "본인 외의 정보는 ROLE_SUPER만 가능") @PreAuthorize("hasRole('GUEST')") @GetMapping("/{memberId}") public ApiResponse retrieveCloudUsageByMemberId( - @PathVariable(name = "memberId") String memberId + @PathVariable(name = "memberId") String memberId ) throws PermissionDeniedException { CloudUsageInfo usage = retrieveCloudUsageByMemberIdUseCase.retrieveCloudUsage(memberId); return ApiResponse.success(usage); diff --git a/src/main/java/page/clab/api/domain/memberManagement/cloud/adapter/in/web/FilesInMemberDirectoryRetrievalController.java b/src/main/java/page/clab/api/domain/memberManagement/cloud/adapter/in/web/FilesInMemberDirectoryRetrievalController.java index 01ea4c563..53ed0304f 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/cloud/adapter/in/web/FilesInMemberDirectoryRetrievalController.java +++ b/src/main/java/page/clab/api/domain/memberManagement/cloud/adapter/in/web/FilesInMemberDirectoryRetrievalController.java @@ -25,16 +25,17 @@ public class FilesInMemberDirectoryRetrievalController { private final RetrieveFilesInMemberDirectoryUseCase retrieveFilesInMemberDirectoryUseCase; @Operation(summary = "[U] 멤버 업로드 파일 리스트 조회", description = "ROLE_USER 이상의 권한이 필요함
" + - "본인 정보만 조회 가능") + "본인 정보만 조회 가능") @PreAuthorize("hasRole('USER')") @GetMapping("/files/{memberId}") public ApiResponse> retrieveFilesInMemberDirectory( - @PathVariable(name = "memberId") String memberId, - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size + @PathVariable(name = "memberId") String memberId, + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size ) { Pageable pageable = PageRequest.of(page, size); - PagedResponseDto files = retrieveFilesInMemberDirectoryUseCase.retrieveFilesInMemberDirectory(memberId, pageable); + PagedResponseDto files = retrieveFilesInMemberDirectoryUseCase.retrieveFilesInMemberDirectory( + memberId, pageable); return ApiResponse.success(files); } } diff --git a/src/main/java/page/clab/api/domain/memberManagement/cloud/application/dto/mapper/CloudDtoMapper.java b/src/main/java/page/clab/api/domain/memberManagement/cloud/application/dto/mapper/CloudDtoMapper.java index 4b38181a7..3e26f704b 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/cloud/application/dto/mapper/CloudDtoMapper.java +++ b/src/main/java/page/clab/api/domain/memberManagement/cloud/application/dto/mapper/CloudDtoMapper.java @@ -8,8 +8,8 @@ public class CloudDtoMapper { public CloudUsageInfo of(String memberId, Long usage) { return CloudUsageInfo.builder() - .memberId(memberId) - .usage(usage) - .build(); + .memberId(memberId) + .usage(usage) + .build(); } } diff --git a/src/main/java/page/clab/api/domain/memberManagement/cloud/application/port/in/RetrieveAllCloudUsageUseCase.java b/src/main/java/page/clab/api/domain/memberManagement/cloud/application/port/in/RetrieveAllCloudUsageUseCase.java index bdf72969a..1bd9e76d7 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/cloud/application/port/in/RetrieveAllCloudUsageUseCase.java +++ b/src/main/java/page/clab/api/domain/memberManagement/cloud/application/port/in/RetrieveAllCloudUsageUseCase.java @@ -5,5 +5,6 @@ import page.clab.api.global.common.dto.PagedResponseDto; public interface RetrieveAllCloudUsageUseCase { + PagedResponseDto retrieveAllCloudUsages(Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/memberManagement/cloud/application/port/in/RetrieveCloudUsageByMemberIdUseCase.java b/src/main/java/page/clab/api/domain/memberManagement/cloud/application/port/in/RetrieveCloudUsageByMemberIdUseCase.java index 057f12918..7d359a77a 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/cloud/application/port/in/RetrieveCloudUsageByMemberIdUseCase.java +++ b/src/main/java/page/clab/api/domain/memberManagement/cloud/application/port/in/RetrieveCloudUsageByMemberIdUseCase.java @@ -4,5 +4,6 @@ import page.clab.api.global.exception.PermissionDeniedException; public interface RetrieveCloudUsageByMemberIdUseCase { + CloudUsageInfo retrieveCloudUsage(String memberId) throws PermissionDeniedException; } diff --git a/src/main/java/page/clab/api/domain/memberManagement/cloud/application/port/in/RetrieveFilesInMemberDirectoryUseCase.java b/src/main/java/page/clab/api/domain/memberManagement/cloud/application/port/in/RetrieveFilesInMemberDirectoryUseCase.java index 9538d58bf..f22c2c04a 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/cloud/application/port/in/RetrieveFilesInMemberDirectoryUseCase.java +++ b/src/main/java/page/clab/api/domain/memberManagement/cloud/application/port/in/RetrieveFilesInMemberDirectoryUseCase.java @@ -5,5 +5,6 @@ import page.clab.api.global.common.file.dto.response.FileInfo; public interface RetrieveFilesInMemberDirectoryUseCase { + PagedResponseDto retrieveFilesInMemberDirectory(String memberId, Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/memberManagement/cloud/application/service/CloudUsageRetrievalAllService.java b/src/main/java/page/clab/api/domain/memberManagement/cloud/application/service/CloudUsageRetrievalAllService.java index 3c5ca2e36..c4a34d528 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/cloud/application/service/CloudUsageRetrievalAllService.java +++ b/src/main/java/page/clab/api/domain/memberManagement/cloud/application/service/CloudUsageRetrievalAllService.java @@ -1,5 +1,6 @@ package page.clab.api.domain.memberManagement.cloud.application.service; +import java.io.File; import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.domain.Page; @@ -14,8 +15,6 @@ import page.clab.api.global.common.dto.PagedResponseDto; import page.clab.api.global.util.FileSystemUtil; -import java.io.File; - @Service @RequiredArgsConstructor public class CloudUsageRetrievalAllService implements RetrieveAllCloudUsageUseCase { diff --git a/src/main/java/page/clab/api/domain/memberManagement/cloud/application/service/CloudUsageRetrievalByMemberIdService.java b/src/main/java/page/clab/api/domain/memberManagement/cloud/application/service/CloudUsageRetrievalByMemberIdService.java index c7722cc8a..49cb18f3b 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/cloud/application/service/CloudUsageRetrievalByMemberIdService.java +++ b/src/main/java/page/clab/api/domain/memberManagement/cloud/application/service/CloudUsageRetrievalByMemberIdService.java @@ -1,5 +1,6 @@ package page.clab.api.domain.memberManagement.cloud.application.service; +import java.io.File; import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -13,8 +14,6 @@ import page.clab.api.global.exception.PermissionDeniedException; import page.clab.api.global.util.FileSystemUtil; -import java.io.File; - @Service @RequiredArgsConstructor public class CloudUsageRetrievalByMemberIdService implements RetrieveCloudUsageByMemberIdUseCase { diff --git a/src/main/java/page/clab/api/domain/memberManagement/cloud/application/service/FilesInMemberDirectoryRetrievalService.java b/src/main/java/page/clab/api/domain/memberManagement/cloud/application/service/FilesInMemberDirectoryRetrievalService.java index df985ce6d..5a838e5d6 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/cloud/application/service/FilesInMemberDirectoryRetrievalService.java +++ b/src/main/java/page/clab/api/domain/memberManagement/cloud/application/service/FilesInMemberDirectoryRetrievalService.java @@ -1,5 +1,7 @@ package page.clab.api.domain.memberManagement.cloud.application.service; +import java.io.File; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.domain.Pageable; @@ -13,9 +15,6 @@ import page.clab.api.global.common.file.dto.response.FileInfo; import page.clab.api.global.util.FileSystemUtil; -import java.io.File; -import java.util.List; - @Service @RequiredArgsConstructor public class FilesInMemberDirectoryRetrievalService implements RetrieveFilesInMemberDirectoryUseCase { diff --git a/src/main/java/page/clab/api/domain/memberManagement/member/adapter/in/web/MemberBirthdayRetrievalThisMonthController.java b/src/main/java/page/clab/api/domain/memberManagement/member/adapter/in/web/MemberBirthdayRetrievalThisMonthController.java index 5da65c6c1..b25ea943f 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/member/adapter/in/web/MemberBirthdayRetrievalThisMonthController.java +++ b/src/main/java/page/clab/api/domain/memberManagement/member/adapter/in/web/MemberBirthdayRetrievalThisMonthController.java @@ -2,6 +2,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.security.access.prepost.PreAuthorize; @@ -17,8 +18,6 @@ import page.clab.api.global.exception.SortingArgumentException; import page.clab.api.global.util.PageableUtils; -import java.util.List; - @RestController @RequestMapping("/api/v1/members") @RequiredArgsConstructor @@ -29,19 +28,20 @@ public class MemberBirthdayRetrievalThisMonthController { private final PageableUtils pageableUtils; @Operation(summary = "[G] 이달의 생일자 조회", description = "ROLE_GUEST 이상의 권한이 필요함
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") @PreAuthorize("hasRole('GUEST')") @GetMapping("/birthday") public ApiResponse> retrieveBirthdaysThisMonth( - @RequestParam(name = "month") int month, - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "birth") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "asc") List sortDirection + @RequestParam(name = "month") int month, + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "birth") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "asc") List sortDirection ) throws SortingArgumentException, InvalidColumnException { - Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, MemberBirthdayResponseDto.class); + Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, + MemberBirthdayResponseDto.class); PagedResponseDto birthdayMembers = - retrieveMemberBirthdaysThisMonthUseCase.retrieveBirthdaysThisMonth(month, pageable); + retrieveMemberBirthdaysThisMonthUseCase.retrieveBirthdaysThisMonth(month, pageable); return ApiResponse.success(birthdayMembers); } } diff --git a/src/main/java/page/clab/api/domain/memberManagement/member/adapter/in/web/MemberInfoUpdateController.java b/src/main/java/page/clab/api/domain/memberManagement/member/adapter/in/web/MemberInfoUpdateController.java index c0fd6b634..8ffd7c724 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/member/adapter/in/web/MemberInfoUpdateController.java +++ b/src/main/java/page/clab/api/domain/memberManagement/member/adapter/in/web/MemberInfoUpdateController.java @@ -23,12 +23,12 @@ public class MemberInfoUpdateController { private final UpdateMemberUseCase updateMemberUseCase; @Operation(summary = "[U] 멤버 정보 수정", description = "ROLE_USER 이상의 권한이 필요함
" + - "본인 외의 정보는 ROLE_SUPER만 가능") + "본인 외의 정보는 ROLE_SUPER만 가능") @PreAuthorize("hasRole('USER')") @PatchMapping("/{memberId}") public ApiResponse updateMemberInfo( - @PathVariable(name = "memberId") String memberId, - @RequestBody MemberUpdateRequestDto requestDto + @PathVariable(name = "memberId") String memberId, + @RequestBody MemberUpdateRequestDto requestDto ) throws PermissionDeniedException { String id = updateMemberUseCase.updateMember(memberId, requestDto); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/memberManagement/member/adapter/in/web/MemberPasswordController.java b/src/main/java/page/clab/api/domain/memberManagement/member/adapter/in/web/MemberPasswordController.java index 6cc72d0fb..6d86dfb2e 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/member/adapter/in/web/MemberPasswordController.java +++ b/src/main/java/page/clab/api/domain/memberManagement/member/adapter/in/web/MemberPasswordController.java @@ -26,7 +26,7 @@ public class MemberPasswordController { @PreAuthorize("hasRole('SUPER')") @PostMapping("/password/{memberId}/resend") public ApiResponse resendMemberPassword( - @PathVariable(name = "memberId") String memberId + @PathVariable(name = "memberId") String memberId ) { String id = manageMemberPasswordUseCase.resendMemberPassword(memberId); return ApiResponse.success(id); @@ -35,7 +35,7 @@ public ApiResponse resendMemberPassword( @Operation(summary = "멤버 비밀번호 재발급 요청", description = "ROLE_ANONYMOUS 이상의 권한이 필요함") @PostMapping("/password/reset-requests") public ApiResponse requestResetMemberPassword( - @RequestBody MemberResetPasswordRequestDto requestDto + @RequestBody MemberResetPasswordRequestDto requestDto ) { String id = manageMemberPasswordUseCase.requestMemberPasswordReset(requestDto); return ApiResponse.success(id); @@ -44,7 +44,7 @@ public ApiResponse requestResetMemberPassword( @Operation(summary = "멤버 비밀번호 재발급 인증", description = "ROLE_ANONYMOUS 이상의 권한이 필요함") @PostMapping("/password/reset-verifications") public ApiResponse verifyResetMemberPassword( - @RequestBody VerificationRequestDto requestDto + @RequestBody VerificationRequestDto requestDto ) { String id = manageMemberPasswordUseCase.verifyMemberPasswordReset(requestDto); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/memberManagement/member/adapter/in/web/MemberRegisterController.java b/src/main/java/page/clab/api/domain/memberManagement/member/adapter/in/web/MemberRegisterController.java index 55f748ecd..455b1b424 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/member/adapter/in/web/MemberRegisterController.java +++ b/src/main/java/page/clab/api/domain/memberManagement/member/adapter/in/web/MemberRegisterController.java @@ -24,7 +24,7 @@ public class MemberRegisterController { @PreAuthorize("hasRole('SUPER')") @PostMapping("") public ApiResponse registerMember( - @RequestBody MemberRequestDto requestDto + @RequestBody MemberRequestDto requestDto ) { String id = registerMemberUseCase.registerMember(requestDto); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/memberManagement/member/adapter/in/web/MemberRemoveController.java b/src/main/java/page/clab/api/domain/memberManagement/member/adapter/in/web/MemberRemoveController.java index ad85cec17..8789d9d02 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/member/adapter/in/web/MemberRemoveController.java +++ b/src/main/java/page/clab/api/domain/memberManagement/member/adapter/in/web/MemberRemoveController.java @@ -23,7 +23,7 @@ public class MemberRemoveController { @PreAuthorize("hasRole('SUPER')") @DeleteMapping("/{memberId}") public ApiResponse removeMember( - @PathVariable(name = "memberId") String memberId + @PathVariable(name = "memberId") String memberId ) { String id = removeMemberUseCase.removeMember(memberId); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/memberManagement/member/adapter/in/web/MemberRoleInfoRetrievalController.java b/src/main/java/page/clab/api/domain/memberManagement/member/adapter/in/web/MemberRoleInfoRetrievalController.java index 933458cc3..b3fdb53de 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/member/adapter/in/web/MemberRoleInfoRetrievalController.java +++ b/src/main/java/page/clab/api/domain/memberManagement/member/adapter/in/web/MemberRoleInfoRetrievalController.java @@ -2,6 +2,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.security.access.prepost.PreAuthorize; @@ -18,8 +19,6 @@ import page.clab.api.global.exception.SortingArgumentException; import page.clab.api.global.util.PageableUtils; -import java.util.List; - @RestController @RequestMapping("/api/v1/members") @RequiredArgsConstructor @@ -30,22 +29,24 @@ public class MemberRoleInfoRetrievalController { private final PageableUtils pageableUtils; @Operation(summary = "[A] 멤버 권한 조회", description = "ROLE_ADMIN 이상의 권한이 필요함
" + - "3개의 파라미터를 자유롭게 조합하여 필터링 가능
" + - "멤버 ID, 멤버 이름, 권한 중 하나라도 입력하지 않으면 전체 조회됨
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") + "3개의 파라미터를 자유롭게 조합하여 필터링 가능
" + + "멤버 ID, 멤버 이름, 권한 중 하나라도 입력하지 않으면 전체 조회됨
" + + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") @PreAuthorize("hasRole('ADMIN')") @GetMapping("/roles") public ApiResponse> retrieveMemberRoleInfo( - @RequestParam(required = false) String memberId, - @RequestParam(required = false) String memberName, - @RequestParam(required = false) Role role, - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "id") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "asc") List sortDirection + @RequestParam(required = false) String memberId, + @RequestParam(required = false) String memberName, + @RequestParam(required = false) Role role, + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "id") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "asc") List sortDirection ) throws InvalidColumnException, SortingArgumentException { - Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, MemberRoleInfoResponseDto.class); - PagedResponseDto memberRoles = retrieveMemberRoleInfoUseCase.retrieveMemberRoleInfo(memberId, memberName, role, pageable); + Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, + MemberRoleInfoResponseDto.class); + PagedResponseDto memberRoles = retrieveMemberRoleInfoUseCase.retrieveMemberRoleInfo( + memberId, memberName, role, pageable); return ApiResponse.success(memberRoles); } } diff --git a/src/main/java/page/clab/api/domain/memberManagement/member/adapter/in/web/MemberRoleManagementController.java b/src/main/java/page/clab/api/domain/memberManagement/member/adapter/in/web/MemberRoleManagementController.java index 3e90d5d8c..5deecf522 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/member/adapter/in/web/MemberRoleManagementController.java +++ b/src/main/java/page/clab/api/domain/memberManagement/member/adapter/in/web/MemberRoleManagementController.java @@ -23,14 +23,14 @@ public class MemberRoleManagementController { private final ManageMemberRoleUseCase manageMemberRoleUseCase; @Operation(summary = "[S] 멤버 권한 변경", description = "ROLE_SUPER 이상의 권한이 필요함
" + - "권한 계층: SUPER > ADMIN > USER > GUEST
" + - "GUEST 권한은 변경 불가능함") + "권한 계층: SUPER > ADMIN > USER > GUEST
" + + "GUEST 권한은 변경 불가능함") @PreAuthorize("hasRole('SUPER')") @PatchMapping("/{memberId}/roles") public ApiResponse changeMemberRole( - HttpServletRequest httpServletRequest, - @PathVariable(name = "memberId") String memberId, - @RequestBody ChangeMemberRoleRequest request + HttpServletRequest httpServletRequest, + @PathVariable(name = "memberId") String memberId, + @RequestBody ChangeMemberRoleRequest request ) { String id = manageMemberRoleUseCase.changeMemberRole(httpServletRequest, memberId, request); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/memberManagement/member/adapter/in/web/MembersByConditionsRetrievalController.java b/src/main/java/page/clab/api/domain/memberManagement/member/adapter/in/web/MembersByConditionsRetrievalController.java index d2221ed38..bfaecef6e 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/member/adapter/in/web/MembersByConditionsRetrievalController.java +++ b/src/main/java/page/clab/api/domain/memberManagement/member/adapter/in/web/MembersByConditionsRetrievalController.java @@ -2,6 +2,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.security.access.prepost.PreAuthorize; @@ -17,8 +18,6 @@ import page.clab.api.global.exception.SortingArgumentException; import page.clab.api.global.util.PageableUtils; -import java.util.List; - @RestController @RequestMapping("/api/v1/members") @RequiredArgsConstructor @@ -29,19 +28,20 @@ public class MembersByConditionsRetrievalController { private final PageableUtils pageableUtils; @Operation(summary = "[A] 멤버 정보 조회(멤버 ID, 이름 기준)", description = "ROLE_ADMIN 이상의 권한이 필요함
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") @PreAuthorize("hasRole('ADMIN')") @GetMapping("") public ApiResponse> retrieveMembersByConditions( - @RequestParam(name = "id", required = false) String id, - @RequestParam(name = "name", required = false) String name, - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection + @RequestParam(name = "id", required = false) String id, + @RequestParam(name = "name", required = false) String name, + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection ) throws SortingArgumentException, InvalidColumnException { Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, MemberResponseDto.class); - PagedResponseDto members = retrieveMembersByConditionsUseCase.retrieveMembers(id, name, pageable); + PagedResponseDto members = retrieveMembersByConditionsUseCase.retrieveMembers(id, name, + pageable); return ApiResponse.success(members); } } diff --git a/src/main/java/page/clab/api/domain/memberManagement/member/adapter/out/persistence/MemberJpaEntity.java b/src/main/java/page/clab/api/domain/memberManagement/member/adapter/out/persistence/MemberJpaEntity.java index 6efcdc6ba..59cebc656 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/member/adapter/out/persistence/MemberJpaEntity.java +++ b/src/main/java/page/clab/api/domain/memberManagement/member/adapter/out/persistence/MemberJpaEntity.java @@ -11,6 +11,8 @@ import jakarta.validation.constraints.Max; import jakarta.validation.constraints.Min; import jakarta.validation.constraints.Size; +import java.time.LocalDate; +import java.time.LocalDateTime; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -24,9 +26,6 @@ import page.clab.api.domain.memberManagement.member.domain.StudentStatus; import page.clab.api.global.common.domain.BaseEntity; -import java.time.LocalDate; -import java.time.LocalDateTime; - @Entity @Table(name = "member") @Getter diff --git a/src/main/java/page/clab/api/domain/memberManagement/member/adapter/out/persistence/MemberPersistenceAdapter.java b/src/main/java/page/clab/api/domain/memberManagement/member/adapter/out/persistence/MemberPersistenceAdapter.java index ba503140f..b351cac6d 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/member/adapter/out/persistence/MemberPersistenceAdapter.java +++ b/src/main/java/page/clab/api/domain/memberManagement/member/adapter/out/persistence/MemberPersistenceAdapter.java @@ -1,5 +1,7 @@ package page.clab.api.domain.memberManagement.member.adapter.out.persistence; +import java.util.List; +import java.util.Optional; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -12,16 +14,13 @@ import page.clab.api.domain.memberManagement.member.domain.Role; import page.clab.api.global.exception.NotFoundException; -import java.util.List; -import java.util.Optional; - @Component @RequiredArgsConstructor public class MemberPersistenceAdapter implements - CheckMemberExistencePort, - RegisterMemberPort, - UpdateMemberPort, - RetrieveMemberPort { + CheckMemberExistencePort, + RegisterMemberPort, + UpdateMemberPort, + RetrieveMemberPort { private final MemberRepository memberRepository; private final MemberMapper memberMapper; @@ -64,7 +63,7 @@ public Page findByConditions(String id, String name, Pageable pageable) @Override public Member getFirstByRole(Role role) { MemberJpaEntity jpaEntity = memberRepository.findFirstByRole(role) - .orElseThrow(() -> new NotFoundException("[Member] role: " + role + "에 해당하는 회원이 존재하지 않습니다.")); + .orElseThrow(() -> new NotFoundException("[Member] role: " + role + "에 해당하는 회원이 존재하지 않습니다.")); return memberMapper.toDomain(jpaEntity); } @@ -76,7 +75,7 @@ public Optional findById(String memberId) { @Override public Member getById(String memberId) { MemberJpaEntity jpaEntity = memberRepository.findById(memberId) - .orElseThrow(() -> new NotFoundException("[Member] id: " + memberId + "에 해당하는 회원이 존재하지 않습니다.")); + .orElseThrow(() -> new NotFoundException("[Member] id: " + memberId + "에 해당하는 회원이 존재하지 않습니다.")); return memberMapper.toDomain(jpaEntity); } @@ -84,12 +83,14 @@ public Member getById(String memberId) { public List findAll() { List jpaEntities = memberRepository.findAll(); return jpaEntities.stream() - .map(memberMapper::toDomain) - .toList(); + .map(memberMapper::toDomain) + .toList(); } - public Page findMemberRoleInfoByConditions(String memberId, String memberName, Role role, Pageable pageable) { - Page jpaEntities = memberRepository.findMemberRoleInfoByConditions(memberId, memberName, role, pageable); + public Page findMemberRoleInfoByConditions(String memberId, String memberName, Role role, + Pageable pageable) { + Page jpaEntities = memberRepository.findMemberRoleInfoByConditions(memberId, memberName, role, + pageable); return jpaEntities.map(memberMapper::toDomain); } @@ -102,7 +103,7 @@ public Page findAllByOrderByCreatedAtDesc(Pageable pageable) { @Override public Member getByEmail(String email) { MemberJpaEntity jpaEntity = memberRepository.findByEmail(email) - .orElseThrow(() -> new NotFoundException("[Member] email: " + email + "을 사용하는 회원이 존재하지 않습니다.")); + .orElseThrow(() -> new NotFoundException("[Member] email: " + email + "을 사용하는 회원이 존재하지 않습니다.")); return memberMapper.toDomain(jpaEntity); } diff --git a/src/main/java/page/clab/api/domain/memberManagement/member/adapter/out/persistence/MemberRepository.java b/src/main/java/page/clab/api/domain/memberManagement/member/adapter/out/persistence/MemberRepository.java index 5c45257e7..44ce4b54f 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/member/adapter/out/persistence/MemberRepository.java +++ b/src/main/java/page/clab/api/domain/memberManagement/member/adapter/out/persistence/MemberRepository.java @@ -1,5 +1,6 @@ package page.clab.api.domain.memberManagement.member.adapter.out.persistence; +import java.util.Optional; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; @@ -7,10 +8,9 @@ import org.springframework.stereotype.Repository; import page.clab.api.domain.memberManagement.member.domain.Role; -import java.util.Optional; - @Repository -public interface MemberRepository extends JpaRepository, MemberRepositoryCustom, QuerydslPredicateExecutor { +public interface MemberRepository extends JpaRepository, MemberRepositoryCustom, + QuerydslPredicateExecutor { boolean existsByContact(String contact); diff --git a/src/main/java/page/clab/api/domain/memberManagement/member/adapter/out/persistence/MemberRepositoryCustom.java b/src/main/java/page/clab/api/domain/memberManagement/member/adapter/out/persistence/MemberRepositoryCustom.java index e16fa6eca..bb1c4713f 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/member/adapter/out/persistence/MemberRepositoryCustom.java +++ b/src/main/java/page/clab/api/domain/memberManagement/member/adapter/out/persistence/MemberRepositoryCustom.java @@ -10,5 +10,6 @@ public interface MemberRepositoryCustom { Page findBirthdaysThisMonth(int month, Pageable pageable); - Page findMemberRoleInfoByConditions(String memberId, String memberName, Role role, Pageable pageable); + Page findMemberRoleInfoByConditions(String memberId, String memberName, Role role, + Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/memberManagement/member/adapter/out/persistence/MemberRepositoryImpl.java b/src/main/java/page/clab/api/domain/memberManagement/member/adapter/out/persistence/MemberRepositoryImpl.java index 13349209f..23a51331d 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/member/adapter/out/persistence/MemberRepositoryImpl.java +++ b/src/main/java/page/clab/api/domain/memberManagement/member/adapter/out/persistence/MemberRepositoryImpl.java @@ -7,6 +7,8 @@ import com.querydsl.core.types.dsl.Expressions; import com.querydsl.core.types.dsl.PathBuilder; import com.querydsl.jpa.impl.JPAQueryFactory; +import java.util.ArrayList; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; @@ -16,9 +18,6 @@ import page.clab.api.domain.memberManagement.member.domain.Role; import page.clab.api.global.util.OrderSpecifierUtil; -import java.util.ArrayList; -import java.util.List; - @Repository @RequiredArgsConstructor public class MemberRepositoryImpl implements MemberRepositoryCustom { @@ -30,20 +29,24 @@ public Page findByConditions(String id, String name, Pageable p QMemberJpaEntity member = QMemberJpaEntity.memberJpaEntity; BooleanBuilder builder = new BooleanBuilder(); - if (id != null) builder.and(member.id.eq(id)); - if (name != null) builder.and(member.name.eq(name)); + if (id != null) { + builder.and(member.id.eq(id)); + } + if (name != null) { + builder.and(member.name.eq(name)); + } List members = queryFactory - .selectFrom(member) - .where(builder) - .orderBy(OrderSpecifierUtil.getOrderSpecifiers(pageable, member)) - .offset(pageable.getOffset()) - .limit(pageable.getPageSize()) - .fetch(); + .selectFrom(member) + .where(builder) + .orderBy(OrderSpecifierUtil.getOrderSpecifiers(pageable, member)) + .offset(pageable.getOffset()) + .limit(pageable.getPageSize()) + .fetch(); long totalCount = queryFactory.selectFrom(member) - .where(builder) - .fetchCount(); + .where(builder) + .fetchCount(); return new PageImpl<>(members, pageable, totalCount); } @@ -58,8 +61,8 @@ public Page findBirthdaysThisMonth(int month, Pageable pageable Order direction = order.isAscending() ? Order.ASC : Order.DESC; if ("birth".equals(property)) { OrderSpecifier dayOrderSpecifier = new OrderSpecifier<>( - direction, - Expressions.numberTemplate(Integer.class, "day({0})", qMember.birth) + direction, + Expressions.numberTemplate(Integer.class, "day({0})", qMember.birth) ); orderSpecifiers.add(dayOrderSpecifier); } else { @@ -69,41 +72,48 @@ public Page findBirthdaysThisMonth(int month, Pageable pageable } List members = queryFactory - .selectFrom(qMember) - .where(birthdayInMonth(month)) - .orderBy(orderSpecifiers.toArray(new OrderSpecifier[0])) - .offset(pageable.getOffset()) - .limit(pageable.getPageSize()) - .fetch(); + .selectFrom(qMember) + .where(birthdayInMonth(month)) + .orderBy(orderSpecifiers.toArray(new OrderSpecifier[0])) + .offset(pageable.getOffset()) + .limit(pageable.getPageSize()) + .fetch(); long total = queryFactory - .selectFrom(qMember) - .where(birthdayInMonth(month)) - .fetchCount(); + .selectFrom(qMember) + .where(birthdayInMonth(month)) + .fetchCount(); return new PageImpl<>(members, pageable, total); } @Override - public Page findMemberRoleInfoByConditions(String memberId, String memberName, Role role, Pageable pageable) { + public Page findMemberRoleInfoByConditions(String memberId, String memberName, Role role, + Pageable pageable) { QMemberJpaEntity member = QMemberJpaEntity.memberJpaEntity; BooleanBuilder builder = new BooleanBuilder(); - if (memberId != null) builder.and(member.id.eq(memberId)); - if (memberName != null) builder.and(member.name.eq(memberName)); - if (role != null) builder.and(member.role.eq(role)); + if (memberId != null) { + builder.and(member.id.eq(memberId)); + } + if (memberName != null) { + builder.and(member.name.eq(memberName)); + } + if (role != null) { + builder.and(member.role.eq(role)); + } List members = queryFactory - .selectFrom(member) - .where(builder) - .orderBy(OrderSpecifierUtil.getOrderSpecifiers(pageable, member)) - .offset(pageable.getOffset()) - .limit(pageable.getPageSize()) - .fetch(); + .selectFrom(member) + .where(builder) + .orderBy(OrderSpecifierUtil.getOrderSpecifiers(pageable, member)) + .offset(pageable.getOffset()) + .limit(pageable.getPageSize()) + .fetch(); long totalCount = queryFactory.selectFrom(member) - .where(builder) - .fetchCount(); + .where(builder) + .fetchCount(); return new PageImpl<>(members, pageable, totalCount); } diff --git a/src/main/java/page/clab/api/domain/memberManagement/member/application/dto/mapper/MemberDtoMapper.java b/src/main/java/page/clab/api/domain/memberManagement/member/application/dto/mapper/MemberDtoMapper.java index 8607a36c5..1b01f10bd 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/member/application/dto/mapper/MemberDtoMapper.java +++ b/src/main/java/page/clab/api/domain/memberManagement/member/application/dto/mapper/MemberDtoMapper.java @@ -22,139 +22,139 @@ public class MemberDtoMapper { public Member fromDto(MemberRequestDto requestDto) { return Member.builder() - .id(requestDto.getId()) - .password(requestDto.getPassword()) - .name(requestDto.getName()) - .contact(Contact.of(requestDto.getContact()).getValue()) - .email(requestDto.getEmail()) - .department(requestDto.getDepartment()) - .grade(requestDto.getGrade()) - .birth(requestDto.getBirth()) - .address(requestDto.getAddress()) - .interests(requestDto.getInterests()) - .githubUrl(requestDto.getGithubUrl()) - .studentStatus(requestDto.getStudentStatus()) - .imageUrl(requestDto.getImageUrl()) - .role(Role.USER) - .isOtpEnabled(false) - .isDeleted(false) - .build(); + .id(requestDto.getId()) + .password(requestDto.getPassword()) + .name(requestDto.getName()) + .contact(Contact.of(requestDto.getContact()).getValue()) + .email(requestDto.getEmail()) + .department(requestDto.getDepartment()) + .grade(requestDto.getGrade()) + .birth(requestDto.getBirth()) + .address(requestDto.getAddress()) + .interests(requestDto.getInterests()) + .githubUrl(requestDto.getGithubUrl()) + .studentStatus(requestDto.getStudentStatus()) + .imageUrl(requestDto.getImageUrl()) + .role(Role.USER) + .isOtpEnabled(false) + .isDeleted(false) + .build(); } public MemberResponseDto toDto(Member member) { return MemberResponseDto.builder() - .id(member.getId()) - .name(member.getName()) - .contact(member.getContact()) - .email(member.getEmail()) - .department(member.getDepartment()) - .grade(member.getGrade()) - .birth(member.getBirth()) - .address(member.getAddress()) - .interests(member.getInterests()) - .githubUrl(member.getGithubUrl()) - .studentStatus(member.getStudentStatus()) - .imageUrl(member.getImageUrl()) - .role(member.getRole()) - .lastLoginTime(member.getLastLoginTime()) - .loanSuspensionDate(member.getLoanSuspensionDate()) - .isOtpEnabled(member.getIsOtpEnabled()) - .createdAt(member.getCreatedAt()) - .build(); + .id(member.getId()) + .name(member.getName()) + .contact(member.getContact()) + .email(member.getEmail()) + .department(member.getDepartment()) + .grade(member.getGrade()) + .birth(member.getBirth()) + .address(member.getAddress()) + .interests(member.getInterests()) + .githubUrl(member.getGithubUrl()) + .studentStatus(member.getStudentStatus()) + .imageUrl(member.getImageUrl()) + .role(member.getRole()) + .lastLoginTime(member.getLastLoginTime()) + .loanSuspensionDate(member.getLoanSuspensionDate()) + .isOtpEnabled(member.getIsOtpEnabled()) + .createdAt(member.getCreatedAt()) + .build(); } public MemberBirthdayResponseDto toBirthdayDto(Member member) { return MemberBirthdayResponseDto.builder() - .id(member.getId()) - .name(member.getName()) - .birth(member.getBirth()) - .imageUrl(member.getImageUrl()) - .build(); + .id(member.getId()) + .name(member.getName()) + .birth(member.getBirth()) + .imageUrl(member.getImageUrl()) + .build(); } public MemberRoleInfoResponseDto toRoleInfoDto(Member member) { return MemberRoleInfoResponseDto.builder() - .id(member.getId()) - .name(member.getName()) - .role(member.getRole()) - .build(); + .id(member.getId()) + .name(member.getName()) + .role(member.getRole()) + .build(); } public MyProfileResponseDto toMyProfileDto(Member member) { return MyProfileResponseDto.builder() - .name(member.getName()) - .id(member.getId()) - .interests(member.getInterests()) - .contact(member.getContact()) - .email(member.getEmail()) - .address(member.getAddress()) - .githubUrl(member.getGithubUrl()) - .studentStatus(member.getStudentStatus()) - .imageUrl(member.getImageUrl()) - .roleLevel(member.getRole().toRoleLevel()) - .isOtpEnabled(member.getIsOtpEnabled()) - .createdAt(member.getCreatedAt()) - .build(); + .name(member.getName()) + .id(member.getId()) + .interests(member.getInterests()) + .contact(member.getContact()) + .email(member.getEmail()) + .address(member.getAddress()) + .githubUrl(member.getGithubUrl()) + .studentStatus(member.getStudentStatus()) + .imageUrl(member.getImageUrl()) + .roleLevel(member.getRole().toRoleLevel()) + .isOtpEnabled(member.getIsOtpEnabled()) + .createdAt(member.getCreatedAt()) + .build(); } public MemberReviewInfoDto toReviewInfoDto(Member member) { return MemberReviewInfoDto.builder() - .memberId(member.getId()) - .memberName(member.getName()) - .department(member.getDepartment()) - .build(); + .memberId(member.getId()) + .memberName(member.getName()) + .department(member.getDepartment()) + .build(); } public MemberPositionInfoDto toPositionInfoDto(Member member) { return MemberPositionInfoDto.builder() - .memberId(member.getId()) - .memberName(member.getName()) - .email(member.getEmail()) - .imageUrl(member.getImageUrl()) - .interests(member.getInterests()) - .githubUrl(member.getGithubUrl()) - .build(); + .memberId(member.getId()) + .memberName(member.getName()) + .email(member.getEmail()) + .imageUrl(member.getImageUrl()) + .interests(member.getInterests()) + .githubUrl(member.getGithubUrl()) + .build(); } public MemberLoginInfoDto toLoginInfoDto(Member member) { return MemberLoginInfoDto.builder() - .memberId(member.getId()) - .memberName(member.getName()) - .role(member.getRole()) - .isOtpEnabled(member.getIsOtpEnabled()) - .build(); + .memberId(member.getId()) + .memberName(member.getName()) + .role(member.getRole()) + .isOtpEnabled(member.getIsOtpEnabled()) + .build(); } public MemberEmailInfoDto toEmailInfoDto(Member member) { return MemberEmailInfoDto.builder() - .memberName(member.getName()) - .email(member.getEmail()) - .build(); + .memberName(member.getName()) + .email(member.getEmail()) + .build(); } public MemberDetailedInfoDto toDetailedInfoDto(Member member) { return MemberDetailedInfoDto.builder() - .memberId(member.getId()) - .memberName(member.getName()) - .roleLevel(member.getRole().toRoleLevel()) - .imageUrl(member.getImageUrl()) - .isGraduated(member.isGraduated()) - .build(); + .memberId(member.getId()) + .memberName(member.getName()) + .roleLevel(member.getRole().toRoleLevel()) + .imageUrl(member.getImageUrl()) + .isGraduated(member.isGraduated()) + .build(); } public MemberBorrowerInfoDto toBorrowerInfoDto(Member member) { return MemberBorrowerInfoDto.builder() - .memberId(member.getId()) - .memberName(member.getName()) - .loanSuspensionDate(member.getLoanSuspensionDate()) - .build(); + .memberId(member.getId()) + .memberName(member.getName()) + .loanSuspensionDate(member.getLoanSuspensionDate()) + .build(); } public MemberBasicInfoDto toBasicInfoDto(Member member) { return MemberBasicInfoDto.builder() - .memberId(member.getId()) - .memberName(member.getName()) - .build(); + .memberId(member.getId()) + .memberName(member.getName()) + .build(); } } diff --git a/src/main/java/page/clab/api/domain/memberManagement/member/application/dto/request/MemberRequestDto.java b/src/main/java/page/clab/api/domain/memberManagement/member/application/dto/request/MemberRequestDto.java index fba2527f7..7a77352d2 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/member/application/dto/request/MemberRequestDto.java +++ b/src/main/java/page/clab/api/domain/memberManagement/member/application/dto/request/MemberRequestDto.java @@ -2,12 +2,11 @@ import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotNull; +import java.time.LocalDate; import lombok.Getter; import lombok.Setter; import page.clab.api.domain.memberManagement.member.domain.StudentStatus; -import java.time.LocalDate; - @Getter @Setter public class MemberRequestDto { diff --git a/src/main/java/page/clab/api/domain/memberManagement/member/application/dto/request/MemberUpdateRequestDto.java b/src/main/java/page/clab/api/domain/memberManagement/member/application/dto/request/MemberUpdateRequestDto.java index 9931c3d4f..04083d654 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/member/application/dto/request/MemberUpdateRequestDto.java +++ b/src/main/java/page/clab/api/domain/memberManagement/member/application/dto/request/MemberUpdateRequestDto.java @@ -1,12 +1,11 @@ package page.clab.api.domain.memberManagement.member.application.dto.request; import io.swagger.v3.oas.annotations.media.Schema; +import java.time.LocalDate; import lombok.Getter; import lombok.Setter; import page.clab.api.domain.memberManagement.member.domain.StudentStatus; -import java.time.LocalDate; - @Getter @Setter public class MemberUpdateRequestDto { diff --git a/src/main/java/page/clab/api/domain/memberManagement/member/application/dto/response/MemberBirthdayResponseDto.java b/src/main/java/page/clab/api/domain/memberManagement/member/application/dto/response/MemberBirthdayResponseDto.java index 16931edef..6308b99d3 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/member/application/dto/response/MemberBirthdayResponseDto.java +++ b/src/main/java/page/clab/api/domain/memberManagement/member/application/dto/response/MemberBirthdayResponseDto.java @@ -1,10 +1,9 @@ package page.clab.api.domain.memberManagement.member.application.dto.response; +import java.time.LocalDate; import lombok.Builder; import lombok.Getter; -import java.time.LocalDate; - @Getter @Builder public class MemberBirthdayResponseDto { diff --git a/src/main/java/page/clab/api/domain/memberManagement/member/application/dto/response/MemberResponseDto.java b/src/main/java/page/clab/api/domain/memberManagement/member/application/dto/response/MemberResponseDto.java index 74aab3140..ccf80bb62 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/member/application/dto/response/MemberResponseDto.java +++ b/src/main/java/page/clab/api/domain/memberManagement/member/application/dto/response/MemberResponseDto.java @@ -1,13 +1,12 @@ package page.clab.api.domain.memberManagement.member.application.dto.response; +import java.time.LocalDate; +import java.time.LocalDateTime; import lombok.Builder; import lombok.Getter; import page.clab.api.domain.memberManagement.member.domain.Role; import page.clab.api.domain.memberManagement.member.domain.StudentStatus; -import java.time.LocalDate; -import java.time.LocalDateTime; - @Getter @Builder public class MemberResponseDto { diff --git a/src/main/java/page/clab/api/domain/memberManagement/member/application/dto/response/MyProfileResponseDto.java b/src/main/java/page/clab/api/domain/memberManagement/member/application/dto/response/MyProfileResponseDto.java index c083bdecd..b55a870a4 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/member/application/dto/response/MyProfileResponseDto.java +++ b/src/main/java/page/clab/api/domain/memberManagement/member/application/dto/response/MyProfileResponseDto.java @@ -1,11 +1,10 @@ package page.clab.api.domain.memberManagement.member.application.dto.response; +import java.time.LocalDateTime; import lombok.Builder; import lombok.Getter; import page.clab.api.domain.memberManagement.member.domain.StudentStatus; -import java.time.LocalDateTime; - @Getter @Builder public class MyProfileResponseDto { diff --git a/src/main/java/page/clab/api/domain/memberManagement/member/application/dto/shared/MemberBorrowerInfoDto.java b/src/main/java/page/clab/api/domain/memberManagement/member/application/dto/shared/MemberBorrowerInfoDto.java index 852788a5d..8fbbbaeac 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/member/application/dto/shared/MemberBorrowerInfoDto.java +++ b/src/main/java/page/clab/api/domain/memberManagement/member/application/dto/shared/MemberBorrowerInfoDto.java @@ -1,11 +1,10 @@ package page.clab.api.domain.memberManagement.member.application.dto.shared; +import java.time.LocalDateTime; import lombok.Builder; import lombok.Getter; import page.clab.api.domain.library.bookLoanRecord.application.exception.LoanSuspensionException; -import java.time.LocalDateTime; - @Getter @Builder public class MemberBorrowerInfoDto { diff --git a/src/main/java/page/clab/api/domain/memberManagement/member/application/event/MemberEventDispatcher.java b/src/main/java/page/clab/api/domain/memberManagement/member/application/event/MemberEventDispatcher.java index 1be1d66aa..87d2bfc5b 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/member/application/event/MemberEventDispatcher.java +++ b/src/main/java/page/clab/api/domain/memberManagement/member/application/event/MemberEventDispatcher.java @@ -1,11 +1,10 @@ package page.clab.api.domain.memberManagement.member.application.event; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.context.event.EventListener; import org.springframework.stereotype.Component; -import java.util.List; - @Component @RequiredArgsConstructor public class MemberEventDispatcher { diff --git a/src/main/java/page/clab/api/domain/memberManagement/member/application/event/MemberEventProcessorRegistry.java b/src/main/java/page/clab/api/domain/memberManagement/member/application/event/MemberEventProcessorRegistry.java index 0dd188849..4294e7485 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/member/application/event/MemberEventProcessorRegistry.java +++ b/src/main/java/page/clab/api/domain/memberManagement/member/application/event/MemberEventProcessorRegistry.java @@ -1,10 +1,9 @@ package page.clab.api.domain.memberManagement.member.application.event; -import org.springframework.stereotype.Component; - import java.util.ArrayList; import java.util.Collections; import java.util.List; +import org.springframework.stereotype.Component; @Component public class MemberEventProcessorRegistry { diff --git a/src/main/java/page/clab/api/domain/memberManagement/member/application/port/in/ManageMemberRoleUseCase.java b/src/main/java/page/clab/api/domain/memberManagement/member/application/port/in/ManageMemberRoleUseCase.java index 6fdb7d658..ee2258d1e 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/member/application/port/in/ManageMemberRoleUseCase.java +++ b/src/main/java/page/clab/api/domain/memberManagement/member/application/port/in/ManageMemberRoleUseCase.java @@ -4,5 +4,6 @@ import page.clab.api.domain.memberManagement.member.application.dto.request.ChangeMemberRoleRequest; public interface ManageMemberRoleUseCase { + String changeMemberRole(HttpServletRequest httpServletRequest, String memberId, ChangeMemberRoleRequest request); } diff --git a/src/main/java/page/clab/api/domain/memberManagement/member/application/port/in/RegisterMemberUseCase.java b/src/main/java/page/clab/api/domain/memberManagement/member/application/port/in/RegisterMemberUseCase.java index 53fc76918..3b63acff5 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/member/application/port/in/RegisterMemberUseCase.java +++ b/src/main/java/page/clab/api/domain/memberManagement/member/application/port/in/RegisterMemberUseCase.java @@ -3,5 +3,6 @@ import page.clab.api.domain.memberManagement.member.application.dto.request.MemberRequestDto; public interface RegisterMemberUseCase { + String registerMember(MemberRequestDto requestDto); } diff --git a/src/main/java/page/clab/api/domain/memberManagement/member/application/port/in/RemoveMemberUseCase.java b/src/main/java/page/clab/api/domain/memberManagement/member/application/port/in/RemoveMemberUseCase.java index 2e95e1b17..0624d677f 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/member/application/port/in/RemoveMemberUseCase.java +++ b/src/main/java/page/clab/api/domain/memberManagement/member/application/port/in/RemoveMemberUseCase.java @@ -1,5 +1,6 @@ package page.clab.api.domain.memberManagement.member.application.port.in; public interface RemoveMemberUseCase { + String removeMember(String memberId); } diff --git a/src/main/java/page/clab/api/domain/memberManagement/member/application/port/in/RetrieveMemberBirthdaysThisMonthUseCase.java b/src/main/java/page/clab/api/domain/memberManagement/member/application/port/in/RetrieveMemberBirthdaysThisMonthUseCase.java index 7e1e4eb4a..b378edaa0 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/member/application/port/in/RetrieveMemberBirthdaysThisMonthUseCase.java +++ b/src/main/java/page/clab/api/domain/memberManagement/member/application/port/in/RetrieveMemberBirthdaysThisMonthUseCase.java @@ -5,5 +5,6 @@ import page.clab.api.global.common.dto.PagedResponseDto; public interface RetrieveMemberBirthdaysThisMonthUseCase { + PagedResponseDto retrieveBirthdaysThisMonth(int month, Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/memberManagement/member/application/port/in/RetrieveMemberRoleInfoUseCase.java b/src/main/java/page/clab/api/domain/memberManagement/member/application/port/in/RetrieveMemberRoleInfoUseCase.java index 739792bfc..9d8792efe 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/member/application/port/in/RetrieveMemberRoleInfoUseCase.java +++ b/src/main/java/page/clab/api/domain/memberManagement/member/application/port/in/RetrieveMemberRoleInfoUseCase.java @@ -6,5 +6,7 @@ import page.clab.api.global.common.dto.PagedResponseDto; public interface RetrieveMemberRoleInfoUseCase { - PagedResponseDto retrieveMemberRoleInfo(String memberId, String memberName, Role role, Pageable pageable); + + PagedResponseDto retrieveMemberRoleInfo(String memberId, String memberName, Role role, + Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/memberManagement/member/application/port/in/RetrieveMemberUseCase.java b/src/main/java/page/clab/api/domain/memberManagement/member/application/port/in/RetrieveMemberUseCase.java index bb1e48c52..1064f74a4 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/member/application/port/in/RetrieveMemberUseCase.java +++ b/src/main/java/page/clab/api/domain/memberManagement/member/application/port/in/RetrieveMemberUseCase.java @@ -3,5 +3,6 @@ import page.clab.api.domain.memberManagement.member.domain.Member; public interface RetrieveMemberUseCase { + Member getCurrentMember(); } diff --git a/src/main/java/page/clab/api/domain/memberManagement/member/application/port/in/RetrieveMembersByConditionsUseCase.java b/src/main/java/page/clab/api/domain/memberManagement/member/application/port/in/RetrieveMembersByConditionsUseCase.java index 283e1c361..e8835e496 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/member/application/port/in/RetrieveMembersByConditionsUseCase.java +++ b/src/main/java/page/clab/api/domain/memberManagement/member/application/port/in/RetrieveMembersByConditionsUseCase.java @@ -5,5 +5,6 @@ import page.clab.api.global.common.dto.PagedResponseDto; public interface RetrieveMembersByConditionsUseCase { + PagedResponseDto retrieveMembers(String id, String name, Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/memberManagement/member/application/port/in/RetrieveMyProfileUseCase.java b/src/main/java/page/clab/api/domain/memberManagement/member/application/port/in/RetrieveMyProfileUseCase.java index f361f163b..222dd5c58 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/member/application/port/in/RetrieveMyProfileUseCase.java +++ b/src/main/java/page/clab/api/domain/memberManagement/member/application/port/in/RetrieveMyProfileUseCase.java @@ -3,5 +3,6 @@ import page.clab.api.domain.memberManagement.member.application.dto.response.MyProfileResponseDto; public interface RetrieveMyProfileUseCase { + MyProfileResponseDto retrieveMyProfile(); } diff --git a/src/main/java/page/clab/api/domain/memberManagement/member/application/port/in/UpdateMemberUseCase.java b/src/main/java/page/clab/api/domain/memberManagement/member/application/port/in/UpdateMemberUseCase.java index 4f1eacfa3..05dcc65fd 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/member/application/port/in/UpdateMemberUseCase.java +++ b/src/main/java/page/clab/api/domain/memberManagement/member/application/port/in/UpdateMemberUseCase.java @@ -4,5 +4,6 @@ import page.clab.api.global.exception.PermissionDeniedException; public interface UpdateMemberUseCase { + String updateMember(String memberId, MemberUpdateRequestDto requestDto) throws PermissionDeniedException; } diff --git a/src/main/java/page/clab/api/domain/memberManagement/member/application/port/out/RegisterMemberPort.java b/src/main/java/page/clab/api/domain/memberManagement/member/application/port/out/RegisterMemberPort.java index d06983475..67a34d7a1 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/member/application/port/out/RegisterMemberPort.java +++ b/src/main/java/page/clab/api/domain/memberManagement/member/application/port/out/RegisterMemberPort.java @@ -3,5 +3,6 @@ import page.clab.api.domain.memberManagement.member.domain.Member; public interface RegisterMemberPort { + Member save(Member member); } diff --git a/src/main/java/page/clab/api/domain/memberManagement/member/application/port/out/RetrieveMemberPort.java b/src/main/java/page/clab/api/domain/memberManagement/member/application/port/out/RetrieveMemberPort.java index 83aec72ef..acd2f1562 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/member/application/port/out/RetrieveMemberPort.java +++ b/src/main/java/page/clab/api/domain/memberManagement/member/application/port/out/RetrieveMemberPort.java @@ -1,13 +1,12 @@ package page.clab.api.domain.memberManagement.member.application.port.out; +import java.util.List; +import java.util.Optional; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import page.clab.api.domain.memberManagement.member.domain.Member; import page.clab.api.domain.memberManagement.member.domain.Role; -import java.util.List; -import java.util.Optional; - public interface RetrieveMemberPort { Optional findById(String memberId); diff --git a/src/main/java/page/clab/api/domain/memberManagement/member/application/port/out/UpdateMemberPort.java b/src/main/java/page/clab/api/domain/memberManagement/member/application/port/out/UpdateMemberPort.java index 1cd1ef4ae..f4c6dff26 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/member/application/port/out/UpdateMemberPort.java +++ b/src/main/java/page/clab/api/domain/memberManagement/member/application/port/out/UpdateMemberPort.java @@ -3,5 +3,6 @@ import page.clab.api.domain.memberManagement.member.domain.Member; public interface UpdateMemberPort { + Member update(Member member); } diff --git a/src/main/java/page/clab/api/domain/memberManagement/member/application/service/MemberPasswordManagementService.java b/src/main/java/page/clab/api/domain/memberManagement/member/application/service/MemberPasswordManagementService.java index 130ccd99d..1aeeca28d 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/member/application/service/MemberPasswordManagementService.java +++ b/src/main/java/page/clab/api/domain/memberManagement/member/application/service/MemberPasswordManagementService.java @@ -61,8 +61,8 @@ public String verifyMemberPasswordReset(VerificationRequestDto requestDto) { @Override public String generateOrRetrievePassword(String password) { return StringUtils.isEmpty(password) - ? verificationService.generateVerificationCode() - : password; + ? verificationService.generateVerificationCode() + : password; } private Member validateResetPasswordRequest(MemberResetPasswordRequestDto requestDto) { diff --git a/src/main/java/page/clab/api/domain/memberManagement/member/application/service/MemberRegisterService.java b/src/main/java/page/clab/api/domain/memberManagement/member/application/service/MemberRegisterService.java index 4d80b9ef7..2bca8e4b8 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/member/application/service/MemberRegisterService.java +++ b/src/main/java/page/clab/api/domain/memberManagement/member/application/service/MemberRegisterService.java @@ -1,5 +1,6 @@ package page.clab.api.domain.memberManagement.member.application.service; +import java.time.LocalDate; import lombok.RequiredArgsConstructor; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.stereotype.Service; @@ -20,8 +21,6 @@ import page.clab.api.external.memberManagement.position.application.port.ExternalRetrievePositionUseCase; import page.clab.api.global.common.email.application.EmailService; -import java.time.LocalDate; - @Service @RequiredArgsConstructor public class MemberRegisterService implements RegisterMemberUseCase { @@ -39,15 +38,14 @@ public class MemberRegisterService implements RegisterMemberUseCase { * 새 멤버를 등록합니다. * *

입력된 회원 정보를 검증하고, 중복되는 회원 정보(ID, 연락처, 이메일)가 없는지 확인합니다. - * 비밀번호가 입력되지 않은 경우 새 비밀번호를 생성하거나, 입력된 비밀번호를 사용합니다. - * 등록이 완료되면 기본 직책(Position)을 생성하며, 최종적으로 생성된 계정 정보를 - * 이메일을 통해 사용자에게 전송합니다.

+ * 비밀번호가 입력되지 않은 경우 새 비밀번호를 생성하거나, 입력된 비밀번호를 사용합니다. 등록이 완료되면 기본 직책(Position)을 생성하며, 최종적으로 생성된 계정 정보를 이메일을 통해 사용자에게 + * 전송합니다.

* * @param requestDto 회원 등록 요청 정보를 담은 DTO * @return 생성된 멤버의 ID - * @throws DuplicateMemberIdException 중복된 아이디가 있을 경우 예외 발생 + * @throws DuplicateMemberIdException 중복된 아이디가 있을 경우 예외 발생 * @throws DuplicateMemberContactException 중복된 연락처가 있을 경우 예외 발생 - * @throws DuplicateMemberEmailException 중복된 이메일이 있을 경우 예외 발생 + * @throws DuplicateMemberEmailException 중복된 이메일이 있을 경우 예외 발생 */ @Transactional @Override @@ -63,16 +61,20 @@ public String registerMember(MemberRequestDto requestDto) { } private void checkMemberUniqueness(MemberRequestDto requestDto) { - if (checkMemberExistencePort.existsById(requestDto.getId())) + if (checkMemberExistencePort.existsById(requestDto.getId())) { throw new DuplicateMemberIdException("이미 사용 중인 아이디입니다."); - if (checkMemberExistencePort.existsByContact(requestDto.getContact())) + } + if (checkMemberExistencePort.existsByContact(requestDto.getContact())) { throw new DuplicateMemberContactException("이미 사용 중인 연락처입니다."); - if (checkMemberExistencePort.existsByEmail(requestDto.getEmail())) + } + if (checkMemberExistencePort.existsByEmail(requestDto.getEmail())) { throw new DuplicateMemberEmailException("이미 사용 중인 이메일입니다."); + } } public void createPositionByMember(Member member) { - if (externalRetrievePositionUseCase.findByMemberIdAndYearAndPositionType(member.getId(), String.valueOf(LocalDate.now().getYear()), PositionType.MEMBER).isPresent()) { + if (externalRetrievePositionUseCase.findByMemberIdAndYearAndPositionType(member.getId(), + String.valueOf(LocalDate.now().getYear()), PositionType.MEMBER).isPresent()) { return; } Position position = Position.create(member.getId()); diff --git a/src/main/java/page/clab/api/domain/memberManagement/member/application/service/MemberRoleInfoRetrievalService.java b/src/main/java/page/clab/api/domain/memberManagement/member/application/service/MemberRoleInfoRetrievalService.java index dde2bb970..9a3f0b9d3 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/member/application/service/MemberRoleInfoRetrievalService.java +++ b/src/main/java/page/clab/api/domain/memberManagement/member/application/service/MemberRoleInfoRetrievalService.java @@ -22,7 +22,8 @@ public class MemberRoleInfoRetrievalService implements RetrieveMemberRoleInfoUse @Transactional(readOnly = true) @Override - public PagedResponseDto retrieveMemberRoleInfo(String memberId, String memberName, Role role, Pageable pageable) { + public PagedResponseDto retrieveMemberRoleInfo(String memberId, String memberName, + Role role, Pageable pageable) { Page members = retrieveMemberPort.findMemberRoleInfoByConditions(memberId, memberName, role, pageable); return new PagedResponseDto<>(members.map(mapper::toRoleInfoDto)); } diff --git a/src/main/java/page/clab/api/domain/memberManagement/member/application/service/MemberRoleManagementService.java b/src/main/java/page/clab/api/domain/memberManagement/member/application/service/MemberRoleManagementService.java index ceed5fb73..fdf61fc1f 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/member/application/service/MemberRoleManagementService.java +++ b/src/main/java/page/clab/api/domain/memberManagement/member/application/service/MemberRoleManagementService.java @@ -26,7 +26,7 @@ public class MemberRoleManagementService implements ManageMemberRoleUseCase { @Transactional @Override public String changeMemberRole(HttpServletRequest httpServletRequest, String memberId, - ChangeMemberRoleRequest request) { + ChangeMemberRoleRequest request) { Member member = retrieveMemberPort.getById(memberId); Role oldRole = member.getRole(); @@ -38,10 +38,10 @@ public String changeMemberRole(HttpServletRequest httpServletRequest, String mem updateMemberPort.update(member); String memberRoleChangedMessage = String.format("[%s] %s: %s -> %s", member.getId(), member.getName(), oldRole, - newRole); + newRole); eventPublisher.publishEvent( - new NotificationEvent(this, SecurityAlertType.MEMBER_ROLE_CHANGED, httpServletRequest, - memberRoleChangedMessage)); + new NotificationEvent(this, SecurityAlertType.MEMBER_ROLE_CHANGED, httpServletRequest, + memberRoleChangedMessage)); return memberId; } diff --git a/src/main/java/page/clab/api/domain/memberManagement/member/domain/Member.java b/src/main/java/page/clab/api/domain/memberManagement/member/domain/Member.java index 1060c1f0c..1e59c9aac 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/member/domain/Member.java +++ b/src/main/java/page/clab/api/domain/memberManagement/member/domain/Member.java @@ -1,5 +1,10 @@ package page.clab.api.domain.memberManagement.member.domain; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.Collection; +import java.util.Collections; +import java.util.Optional; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -14,12 +19,6 @@ import page.clab.api.domain.memberManagement.member.application.dto.request.MemberUpdateRequestDto; import page.clab.api.global.exception.PermissionDeniedException; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.Collections; -import java.util.Optional; - @Getter @Setter @Builder @@ -74,7 +73,7 @@ public Collection getAuthorities() { public void update(MemberUpdateRequestDto requestDto, PasswordEncoder passwordEncoder) { Optional.ofNullable(requestDto.getPassword()) - .ifPresent(password -> setPassword(passwordEncoder.encode(password))); + .ifPresent(password -> setPassword(passwordEncoder.encode(password))); Optional.ofNullable(requestDto.getContact()).ifPresent(this::setContact); Optional.ofNullable(requestDto.getEmail()).ifPresent(this::setEmail); Optional.ofNullable(requestDto.getGrade()).ifPresent(this::setGrade); @@ -165,21 +164,21 @@ public void clearImageUrl() { public static Member toMember(ApplicationMemberCreationDto dto) { return Member.builder() - .id(dto.getStudentId()) - .name(dto.getName()) - .contact(dto.getContact()) - .email(dto.getEmail()) - .department(dto.getDepartment()) - .grade(dto.getGrade()) - .birth(dto.getBirth()) - .address(dto.getAddress()) - .interests(dto.getInterests()) - .githubUrl(dto.getGithubUrl()) - .studentStatus(StudentStatus.CURRENT) - .imageUrl("") - .role(Role.USER) - .isOtpEnabled(false) - .isDeleted(false) - .build(); + .id(dto.getStudentId()) + .name(dto.getName()) + .contact(dto.getContact()) + .email(dto.getEmail()) + .department(dto.getDepartment()) + .grade(dto.getGrade()) + .birth(dto.getBirth()) + .address(dto.getAddress()) + .interests(dto.getInterests()) + .githubUrl(dto.getGithubUrl()) + .studentStatus(StudentStatus.CURRENT) + .imageUrl("") + .role(Role.USER) + .isOtpEnabled(false) + .isDeleted(false) + .build(); } } diff --git a/src/main/java/page/clab/api/domain/memberManagement/notification/adapter/in/web/NotificationsRetrievalController.java b/src/main/java/page/clab/api/domain/memberManagement/notification/adapter/in/web/NotificationsRetrievalController.java index 5491701e5..0893cd395 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/notification/adapter/in/web/NotificationsRetrievalController.java +++ b/src/main/java/page/clab/api/domain/memberManagement/notification/adapter/in/web/NotificationsRetrievalController.java @@ -2,6 +2,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.security.access.prepost.PreAuthorize; @@ -17,8 +18,6 @@ import page.clab.api.global.exception.SortingArgumentException; import page.clab.api.global.util.PageableUtils; -import java.util.List; - @RestController @RequestMapping("/api/v1/notifications") @RequiredArgsConstructor @@ -29,17 +28,19 @@ public class NotificationsRetrievalController { private final PageableUtils pageableUtils; @Operation(summary = "[G] 나의 알림 조회", description = "ROLE_GUEST 이상의 권한이 필요함
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") @PreAuthorize("hasRole('GUEST')") @GetMapping("") public ApiResponse> retrieveNotifications( - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection ) throws SortingArgumentException, InvalidColumnException { - Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, NotificationResponseDto.class); - PagedResponseDto notifications = retrieveNotificationsUseCase.retrieveNotifications(pageable); + Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, + NotificationResponseDto.class); + PagedResponseDto notifications = retrieveNotificationsUseCase.retrieveNotifications( + pageable); return ApiResponse.success(notifications); } } diff --git a/src/main/java/page/clab/api/domain/memberManagement/notification/adapter/out/persistence/NotificationPersistenceAdapter.java b/src/main/java/page/clab/api/domain/memberManagement/notification/adapter/out/persistence/NotificationPersistenceAdapter.java index a3014cb6c..a20c6c5b6 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/notification/adapter/out/persistence/NotificationPersistenceAdapter.java +++ b/src/main/java/page/clab/api/domain/memberManagement/notification/adapter/out/persistence/NotificationPersistenceAdapter.java @@ -1,5 +1,6 @@ package page.clab.api.domain.memberManagement.notification.adapter.out.persistence; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -9,13 +10,11 @@ import page.clab.api.domain.memberManagement.notification.domain.Notification; import page.clab.api.global.exception.NotFoundException; -import java.util.List; - @Component @RequiredArgsConstructor public class NotificationPersistenceAdapter implements - RegisterNotificationPort, - RetrieveNotificationPort { + RegisterNotificationPort, + RetrieveNotificationPort { private final NotificationRepository repository; private final NotificationMapper mapper; @@ -30,28 +29,28 @@ public Notification save(Notification notification) { @Override public void saveAll(List notifications) { List entities = notifications.stream() - .map(mapper::toEntity) - .toList(); + .map(mapper::toEntity) + .toList(); repository.saveAll(entities); } @Override public Notification getById(Long id) { return repository.findById(id) - .map(mapper::toDomain) - .orElseThrow(() -> new NotFoundException("[Notification] id: " + id + "에 해당하는 알림이 존재하지 않습니다.")); + .map(mapper::toDomain) + .orElseThrow(() -> new NotFoundException("[Notification] id: " + id + "에 해당하는 알림이 존재하지 않습니다.")); } @Override public List findByMemberId(String memberId) { return repository.findByMemberId(memberId).stream() - .map(mapper::toDomain) - .toList(); + .map(mapper::toDomain) + .toList(); } @Override public Page findByMemberId(String memberId, Pageable pageable) { return repository.findByMemberId(memberId, pageable) - .map(mapper::toDomain); + .map(mapper::toDomain); } } diff --git a/src/main/java/page/clab/api/domain/memberManagement/notification/adapter/out/persistence/NotificationRepository.java b/src/main/java/page/clab/api/domain/memberManagement/notification/adapter/out/persistence/NotificationRepository.java index 34a3645bb..eadd2a826 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/notification/adapter/out/persistence/NotificationRepository.java +++ b/src/main/java/page/clab/api/domain/memberManagement/notification/adapter/out/persistence/NotificationRepository.java @@ -1,11 +1,10 @@ package page.clab.api.domain.memberManagement.notification.adapter.out.persistence; +import java.util.List; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; -import java.util.List; - public interface NotificationRepository extends JpaRepository { Page findByMemberId(String memberId, Pageable pageable); diff --git a/src/main/java/page/clab/api/domain/memberManagement/notification/application/dto/mapper/NotificationDtoMapper.java b/src/main/java/page/clab/api/domain/memberManagement/notification/application/dto/mapper/NotificationDtoMapper.java index 61accf5da..0371323e6 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/notification/application/dto/mapper/NotificationDtoMapper.java +++ b/src/main/java/page/clab/api/domain/memberManagement/notification/application/dto/mapper/NotificationDtoMapper.java @@ -9,9 +9,9 @@ public class NotificationDtoMapper { public NotificationResponseDto toDto(Notification notification) { return NotificationResponseDto.builder() - .id(notification.getId()) - .content(notification.getContent()) - .createdAt(notification.getCreatedAt()) - .build(); + .id(notification.getId()) + .content(notification.getContent()) + .createdAt(notification.getCreatedAt()) + .build(); } } diff --git a/src/main/java/page/clab/api/domain/memberManagement/notification/application/dto/response/NotificationResponseDto.java b/src/main/java/page/clab/api/domain/memberManagement/notification/application/dto/response/NotificationResponseDto.java index dcbc680f8..98d58976a 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/notification/application/dto/response/NotificationResponseDto.java +++ b/src/main/java/page/clab/api/domain/memberManagement/notification/application/dto/response/NotificationResponseDto.java @@ -1,10 +1,9 @@ package page.clab.api.domain.memberManagement.notification.application.dto.response; +import java.time.LocalDateTime; import lombok.Builder; import lombok.Getter; -import java.time.LocalDateTime; - @Getter @Builder public class NotificationResponseDto { diff --git a/src/main/java/page/clab/api/domain/memberManagement/notification/application/event/NotificationEventProcessor.java b/src/main/java/page/clab/api/domain/memberManagement/notification/application/event/NotificationEventProcessor.java index c71fe1bd7..bf7d593a2 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/notification/application/event/NotificationEventProcessor.java +++ b/src/main/java/page/clab/api/domain/memberManagement/notification/application/event/NotificationEventProcessor.java @@ -1,6 +1,7 @@ package page.clab.api.domain.memberManagement.notification.application.event; import jakarta.annotation.PostConstruct; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; @@ -10,8 +11,6 @@ import page.clab.api.domain.memberManagement.notification.application.port.out.RetrieveNotificationPort; import page.clab.api.domain.memberManagement.notification.domain.Notification; -import java.util.List; - @Component @RequiredArgsConstructor public class NotificationEventProcessor implements MemberEventProcessor { diff --git a/src/main/java/page/clab/api/domain/memberManagement/notification/application/port/in/RetrieveNotificationsUseCase.java b/src/main/java/page/clab/api/domain/memberManagement/notification/application/port/in/RetrieveNotificationsUseCase.java index 636458290..d61b76e9e 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/notification/application/port/in/RetrieveNotificationsUseCase.java +++ b/src/main/java/page/clab/api/domain/memberManagement/notification/application/port/in/RetrieveNotificationsUseCase.java @@ -5,5 +5,6 @@ import page.clab.api.global.common.dto.PagedResponseDto; public interface RetrieveNotificationsUseCase { + PagedResponseDto retrieveNotifications(Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/memberManagement/notification/application/port/out/RegisterNotificationPort.java b/src/main/java/page/clab/api/domain/memberManagement/notification/application/port/out/RegisterNotificationPort.java index 487085f8f..d56e595ce 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/notification/application/port/out/RegisterNotificationPort.java +++ b/src/main/java/page/clab/api/domain/memberManagement/notification/application/port/out/RegisterNotificationPort.java @@ -1,8 +1,7 @@ package page.clab.api.domain.memberManagement.notification.application.port.out; -import page.clab.api.domain.memberManagement.notification.domain.Notification; - import java.util.List; +import page.clab.api.domain.memberManagement.notification.domain.Notification; public interface RegisterNotificationPort { diff --git a/src/main/java/page/clab/api/domain/memberManagement/notification/application/port/out/RetrieveNotificationPort.java b/src/main/java/page/clab/api/domain/memberManagement/notification/application/port/out/RetrieveNotificationPort.java index 693b67252..4d24ee25e 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/notification/application/port/out/RetrieveNotificationPort.java +++ b/src/main/java/page/clab/api/domain/memberManagement/notification/application/port/out/RetrieveNotificationPort.java @@ -1,11 +1,10 @@ package page.clab.api.domain.memberManagement.notification.application.port.out; +import java.util.List; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import page.clab.api.domain.memberManagement.notification.domain.Notification; -import java.util.List; - public interface RetrieveNotificationPort { Notification getById(Long id); diff --git a/src/main/java/page/clab/api/domain/memberManagement/notification/domain/Notification.java b/src/main/java/page/clab/api/domain/memberManagement/notification/domain/Notification.java index a848a33aa..c6f544525 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/notification/domain/Notification.java +++ b/src/main/java/page/clab/api/domain/memberManagement/notification/domain/Notification.java @@ -1,5 +1,6 @@ package page.clab.api.domain.memberManagement.notification.domain; +import java.time.LocalDateTime; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -7,8 +8,6 @@ import lombok.NoArgsConstructor; import lombok.Setter; -import java.time.LocalDateTime; - @Getter @Setter @Builder @@ -24,10 +23,10 @@ public class Notification { public static Notification create(String memberId, String content) { return Notification.builder() - .memberId(memberId) - .content(content) - .isDeleted(false) - .build(); + .memberId(memberId) + .content(content) + .isDeleted(false) + .build(); } public void delete() { diff --git a/src/main/java/page/clab/api/domain/memberManagement/position/adapter/in/web/MyPositionsByYearRetrievalController.java b/src/main/java/page/clab/api/domain/memberManagement/position/adapter/in/web/MyPositionsByYearRetrievalController.java index 2688cd51c..9b6e0c0b7 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/position/adapter/in/web/MyPositionsByYearRetrievalController.java +++ b/src/main/java/page/clab/api/domain/memberManagement/position/adapter/in/web/MyPositionsByYearRetrievalController.java @@ -24,7 +24,7 @@ public class MyPositionsByYearRetrievalController { @PreAuthorize("hasRole('GUEST')") @GetMapping("/my-positions") public ApiResponse retrieveMyPositionsByYear( - @RequestParam(name = "year", required = false) String year + @RequestParam(name = "year", required = false) String year ) { PositionMyResponseDto positions = retrieveMyPositionsByYearUseCase.retrieveMyPositionsByYear(year); return ApiResponse.success(positions); diff --git a/src/main/java/page/clab/api/domain/memberManagement/position/adapter/in/web/PositionRegisterController.java b/src/main/java/page/clab/api/domain/memberManagement/position/adapter/in/web/PositionRegisterController.java index ba1359156..25a0d67b4 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/position/adapter/in/web/PositionRegisterController.java +++ b/src/main/java/page/clab/api/domain/memberManagement/position/adapter/in/web/PositionRegisterController.java @@ -25,7 +25,7 @@ public class PositionRegisterController { @PreAuthorize("hasRole('SUPER')") @PostMapping("") public ApiResponse registerPosition( - @Valid @RequestBody PositionRequestDto requestDto + @Valid @RequestBody PositionRequestDto requestDto ) { Long id = registerPositionUseCase.registerPosition(requestDto); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/memberManagement/position/adapter/in/web/PositionRemoveController.java b/src/main/java/page/clab/api/domain/memberManagement/position/adapter/in/web/PositionRemoveController.java index 600360586..124ee32b6 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/position/adapter/in/web/PositionRemoveController.java +++ b/src/main/java/page/clab/api/domain/memberManagement/position/adapter/in/web/PositionRemoveController.java @@ -23,7 +23,7 @@ public class PositionRemoveController { @PreAuthorize("hasRole('SUPER')") @DeleteMapping("/{positionId}") public ApiResponse removePosition( - @PathVariable("positionId") Long positionId + @PathVariable("positionId") Long positionId ) { Long id = removePositionUseCase.removePosition(positionId); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/memberManagement/position/adapter/in/web/PositionsByConditionsRetrievalController.java b/src/main/java/page/clab/api/domain/memberManagement/position/adapter/in/web/PositionsByConditionsRetrievalController.java index d664d62b0..bab2c5ade 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/position/adapter/in/web/PositionsByConditionsRetrievalController.java +++ b/src/main/java/page/clab/api/domain/memberManagement/position/adapter/in/web/PositionsByConditionsRetrievalController.java @@ -2,6 +2,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.security.access.prepost.PreAuthorize; @@ -18,8 +19,6 @@ import page.clab.api.global.exception.SortingArgumentException; import page.clab.api.global.util.PageableUtils; -import java.util.List; - @RestController @RequestMapping("/api/v1/positions") @RequiredArgsConstructor @@ -30,21 +29,22 @@ public class PositionsByConditionsRetrievalController { private final PageableUtils pageableUtils; @Operation(summary = "[G] 연도/직책별 목록 조회", description = "ROLE_GUEST 이상의 권한이 필요함
" + - "2개의 파라미터를 자유롭게 조합하여 필터링 가능
" + - "연도, 직책 중 하나라도 입력하지 않으면 전체 조회됨
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") + "2개의 파라미터를 자유롭게 조합하여 필터링 가능
" + + "연도, 직책 중 하나라도 입력하지 않으면 전체 조회됨
" + + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") @PreAuthorize("hasRole('GUEST')") @GetMapping("") public ApiResponse> retrievePositionsByConditions( - @RequestParam(name = "year", required = false) String year, - @RequestParam(name = "positionType", required = false) PositionType positionType, - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "year, positionType") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "desc, asc") List sortDirection + @RequestParam(name = "year", required = false) String year, + @RequestParam(name = "positionType", required = false) PositionType positionType, + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "year, positionType") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "desc, asc") List sortDirection ) throws SortingArgumentException, InvalidColumnException { Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, PositionResponseDto.class); - PagedResponseDto positions = retrievePositionsByConditionsUseCase.retrievePositions(year, positionType, pageable); + PagedResponseDto positions = retrievePositionsByConditionsUseCase.retrievePositions(year, + positionType, pageable); return ApiResponse.success(positions); } } diff --git a/src/main/java/page/clab/api/domain/memberManagement/position/adapter/out/persistence/PositionPersistenceAdapter.java b/src/main/java/page/clab/api/domain/memberManagement/position/adapter/out/persistence/PositionPersistenceAdapter.java index 4d4c820d8..8c16c68f2 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/position/adapter/out/persistence/PositionPersistenceAdapter.java +++ b/src/main/java/page/clab/api/domain/memberManagement/position/adapter/out/persistence/PositionPersistenceAdapter.java @@ -1,5 +1,7 @@ package page.clab.api.domain.memberManagement.position.adapter.out.persistence; +import java.util.List; +import java.util.Optional; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -11,15 +13,12 @@ import page.clab.api.domain.memberManagement.position.domain.PositionType; import page.clab.api.global.exception.NotFoundException; -import java.util.List; -import java.util.Optional; - @Component @RequiredArgsConstructor public class PositionPersistenceAdapter implements - RegisterPositionPort, - RetrievePositionPort, - UpdatePositionPort { + RegisterPositionPort, + RetrievePositionPort, + UpdatePositionPort { private final PositionRepository repository; private final PositionMapper mapper; @@ -34,8 +33,8 @@ public Position save(Position position) { @Override public void saveAll(List positions) { List entities = positions.stream() - .map(mapper::toEntity) - .toList(); + .map(mapper::toEntity) + .toList(); repository.saveAll(entities); } @@ -49,33 +48,34 @@ public Position update(Position position) { @Override public Position getById(Long id) { return repository.findById(id) - .map(mapper::toDomain) - .orElseThrow(() -> new NotFoundException("[Position] id: " + id + "에 해당하는 직책이 존재하지 않습니다.")); + .map(mapper::toDomain) + .orElseThrow(() -> new NotFoundException("[Position] id: " + id + "에 해당하는 직책이 존재하지 않습니다.")); } @Override - public Optional findByMemberIdAndYearAndPositionType(String memberId, String year, PositionType positionType) { + public Optional findByMemberIdAndYearAndPositionType(String memberId, String year, + PositionType positionType) { return repository.findByMemberIdAndYearAndPositionType(memberId, year, positionType) - .map(mapper::toDomain); + .map(mapper::toDomain); } @Override public List findAllByMemberIdAndYearOrderByPositionTypeAsc(String memberId, String year) { return repository.findAllByMemberIdAndYearOrderByPositionTypeAsc(memberId, year).stream() - .map(mapper::toDomain) - .toList(); + .map(mapper::toDomain) + .toList(); } @Override public Page findByConditions(String year, PositionType positionType, Pageable pageable) { return repository.findByConditions(year, positionType, pageable) - .map(mapper::toDomain); + .map(mapper::toDomain); } @Override public List findByMemberId(String memberId) { return repository.findByMemberId(memberId).stream() - .map(mapper::toDomain) - .toList(); + .map(mapper::toDomain) + .toList(); } } diff --git a/src/main/java/page/clab/api/domain/memberManagement/position/adapter/out/persistence/PositionRepository.java b/src/main/java/page/clab/api/domain/memberManagement/position/adapter/out/persistence/PositionRepository.java index 9b1683b43..bba32cff3 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/position/adapter/out/persistence/PositionRepository.java +++ b/src/main/java/page/clab/api/domain/memberManagement/position/adapter/out/persistence/PositionRepository.java @@ -1,17 +1,18 @@ package page.clab.api.domain.memberManagement.position.adapter.out.persistence; +import java.util.List; +import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.querydsl.QuerydslPredicateExecutor; import page.clab.api.domain.memberManagement.position.domain.PositionType; -import java.util.List; -import java.util.Optional; - -public interface PositionRepository extends JpaRepository, PositionRepositoryCustom, QuerydslPredicateExecutor { +public interface PositionRepository extends JpaRepository, PositionRepositoryCustom, + QuerydslPredicateExecutor { List findByMemberId(String id); - Optional findByMemberIdAndYearAndPositionType(String memberId, String year, PositionType positionType); + Optional findByMemberIdAndYearAndPositionType(String memberId, String year, + PositionType positionType); List findAllByMemberIdAndYearOrderByPositionTypeAsc(String memberId, String year); } diff --git a/src/main/java/page/clab/api/domain/memberManagement/position/adapter/out/persistence/PositionRepositoryCustom.java b/src/main/java/page/clab/api/domain/memberManagement/position/adapter/out/persistence/PositionRepositoryCustom.java index d64bc8c72..416bc4a7f 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/position/adapter/out/persistence/PositionRepositoryCustom.java +++ b/src/main/java/page/clab/api/domain/memberManagement/position/adapter/out/persistence/PositionRepositoryCustom.java @@ -5,5 +5,6 @@ import page.clab.api.domain.memberManagement.position.domain.PositionType; public interface PositionRepositoryCustom { + Page findByConditions(String year, PositionType positionType, Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/memberManagement/position/adapter/out/persistence/PositionRepositoryImpl.java b/src/main/java/page/clab/api/domain/memberManagement/position/adapter/out/persistence/PositionRepositoryImpl.java index de2780eac..9113ce332 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/position/adapter/out/persistence/PositionRepositoryImpl.java +++ b/src/main/java/page/clab/api/domain/memberManagement/position/adapter/out/persistence/PositionRepositoryImpl.java @@ -2,6 +2,7 @@ import com.querydsl.core.BooleanBuilder; import com.querydsl.jpa.impl.JPAQueryFactory; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; @@ -10,8 +11,6 @@ import page.clab.api.domain.memberManagement.position.domain.PositionType; import page.clab.api.global.util.OrderSpecifierUtil; -import java.util.List; - @Repository @RequiredArgsConstructor public class PositionRepositoryImpl implements PositionRepositoryCustom { @@ -23,19 +22,23 @@ public Page findByConditions(String year, PositionType positi QPositionJpaEntity position = QPositionJpaEntity.positionJpaEntity; BooleanBuilder builder = new BooleanBuilder(); - if (year != null) builder.and(position.year.eq(year)); - if (positionType != null) builder.and(position.positionType.eq(positionType)); + if (year != null) { + builder.and(position.year.eq(year)); + } + if (positionType != null) { + builder.and(position.positionType.eq(positionType)); + } List positions = queryFactory.selectFrom(position) - .where(builder) - .orderBy(OrderSpecifierUtil.getOrderSpecifiers(pageable, position)) - .offset(pageable.getOffset()) - .limit(pageable.getPageSize()) - .fetch(); + .where(builder) + .orderBy(OrderSpecifierUtil.getOrderSpecifiers(pageable, position)) + .offset(pageable.getOffset()) + .limit(pageable.getPageSize()) + .fetch(); long count = queryFactory.selectFrom(position) - .where(builder) - .fetchCount(); + .where(builder) + .fetchCount(); return new PageImpl<>(positions, pageable, count); } diff --git a/src/main/java/page/clab/api/domain/memberManagement/position/application/dto/mapper/PositionDtoMapper.java b/src/main/java/page/clab/api/domain/memberManagement/position/application/dto/mapper/PositionDtoMapper.java index b9b47805c..9e9afa7ea 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/position/application/dto/mapper/PositionDtoMapper.java +++ b/src/main/java/page/clab/api/domain/memberManagement/position/application/dto/mapper/PositionDtoMapper.java @@ -1,5 +1,8 @@ package page.clab.api.domain.memberManagement.position.application.dto.mapper; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; import org.springframework.stereotype.Component; import page.clab.api.domain.memberManagement.member.application.dto.shared.MemberPositionInfoDto; import page.clab.api.domain.memberManagement.position.application.dto.request.PositionRequestDto; @@ -8,48 +11,44 @@ import page.clab.api.domain.memberManagement.position.domain.Position; import page.clab.api.domain.memberManagement.position.domain.PositionType; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - @Component public class PositionDtoMapper { public Position fromDto(PositionRequestDto positionRequestDto) { return Position.builder() - .memberId(positionRequestDto.getMemberId()) - .positionType(positionRequestDto.getPositionType()) - .year(positionRequestDto.getYear()) - .isDeleted(false) - .build(); + .memberId(positionRequestDto.getMemberId()) + .positionType(positionRequestDto.getPositionType()) + .year(positionRequestDto.getYear()) + .isDeleted(false) + .build(); } public PositionMyResponseDto toDto(List positions, MemberPositionInfoDto memberInfo) { Map> positionTypesByYear = positions.stream() - .collect(Collectors.groupingBy( - Position::getYear, - Collectors.mapping(Position::getPositionType, Collectors.toList()) - )); + .collect(Collectors.groupingBy( + Position::getYear, + Collectors.mapping(Position::getPositionType, Collectors.toList()) + )); return PositionMyResponseDto.builder() - .name(memberInfo.getMemberName()) - .email(memberInfo.getEmail()) - .imageUrl(memberInfo.getImageUrl()) - .interests(memberInfo.getInterests()) - .githubUrl(memberInfo.getGithubUrl()) - .positionTypes(positionTypesByYear) - .build(); + .name(memberInfo.getMemberName()) + .email(memberInfo.getEmail()) + .imageUrl(memberInfo.getImageUrl()) + .interests(memberInfo.getInterests()) + .githubUrl(memberInfo.getGithubUrl()) + .positionTypes(positionTypesByYear) + .build(); } public PositionResponseDto toDto(Position position, MemberPositionInfoDto memberInfo) { return PositionResponseDto.builder() - .id(position.getId()) - .name(memberInfo.getMemberName()) - .email(memberInfo.getEmail()) - .imageUrl(memberInfo.getImageUrl()) - .interests(memberInfo.getInterests()) - .githubUrl(memberInfo.getGithubUrl()) - .positionType(position.getPositionType()) - .year(position.getYear()) - .build(); + .id(position.getId()) + .name(memberInfo.getMemberName()) + .email(memberInfo.getEmail()) + .imageUrl(memberInfo.getImageUrl()) + .interests(memberInfo.getInterests()) + .githubUrl(memberInfo.getGithubUrl()) + .positionType(position.getPositionType()) + .year(position.getYear()) + .build(); } } diff --git a/src/main/java/page/clab/api/domain/memberManagement/position/application/dto/response/PositionMyResponseDto.java b/src/main/java/page/clab/api/domain/memberManagement/position/application/dto/response/PositionMyResponseDto.java index a7908ae61..f00425739 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/position/application/dto/response/PositionMyResponseDto.java +++ b/src/main/java/page/clab/api/domain/memberManagement/position/application/dto/response/PositionMyResponseDto.java @@ -1,12 +1,11 @@ package page.clab.api.domain.memberManagement.position.application.dto.response; +import java.util.List; +import java.util.Map; import lombok.Builder; import lombok.Getter; import page.clab.api.domain.memberManagement.position.domain.PositionType; -import java.util.List; -import java.util.Map; - @Getter @Builder public class PositionMyResponseDto { diff --git a/src/main/java/page/clab/api/domain/memberManagement/position/application/event/PositionEventProcessor.java b/src/main/java/page/clab/api/domain/memberManagement/position/application/event/PositionEventProcessor.java index cbf540701..e7f5e264e 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/position/application/event/PositionEventProcessor.java +++ b/src/main/java/page/clab/api/domain/memberManagement/position/application/event/PositionEventProcessor.java @@ -1,18 +1,16 @@ package page.clab.api.domain.memberManagement.position.application.event; import jakarta.annotation.PostConstruct; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; -import page.clab.api.domain.hiring.application.domain.Application; import page.clab.api.domain.memberManagement.member.application.event.MemberEventProcessor; import page.clab.api.domain.memberManagement.member.application.event.MemberEventProcessorRegistry; import page.clab.api.domain.memberManagement.position.application.port.out.RegisterPositionPort; import page.clab.api.domain.memberManagement.position.application.port.out.RetrievePositionPort; import page.clab.api.domain.memberManagement.position.domain.Position; -import java.util.List; - @Component @RequiredArgsConstructor public class PositionEventProcessor implements MemberEventProcessor { diff --git a/src/main/java/page/clab/api/domain/memberManagement/position/application/port/in/RegisterPositionUseCase.java b/src/main/java/page/clab/api/domain/memberManagement/position/application/port/in/RegisterPositionUseCase.java index e40e9ff18..80a71d3d9 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/position/application/port/in/RegisterPositionUseCase.java +++ b/src/main/java/page/clab/api/domain/memberManagement/position/application/port/in/RegisterPositionUseCase.java @@ -3,5 +3,6 @@ import page.clab.api.domain.memberManagement.position.application.dto.request.PositionRequestDto; public interface RegisterPositionUseCase { + Long registerPosition(PositionRequestDto requestDto); } diff --git a/src/main/java/page/clab/api/domain/memberManagement/position/application/port/in/RemovePositionUseCase.java b/src/main/java/page/clab/api/domain/memberManagement/position/application/port/in/RemovePositionUseCase.java index 3fb619013..57dee18cc 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/position/application/port/in/RemovePositionUseCase.java +++ b/src/main/java/page/clab/api/domain/memberManagement/position/application/port/in/RemovePositionUseCase.java @@ -1,5 +1,6 @@ package page.clab.api.domain.memberManagement.position.application.port.in; public interface RemovePositionUseCase { + Long removePosition(Long positionId); } diff --git a/src/main/java/page/clab/api/domain/memberManagement/position/application/port/in/RetrieveMyPositionsByYearUseCase.java b/src/main/java/page/clab/api/domain/memberManagement/position/application/port/in/RetrieveMyPositionsByYearUseCase.java index 819df78c1..404da5d38 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/position/application/port/in/RetrieveMyPositionsByYearUseCase.java +++ b/src/main/java/page/clab/api/domain/memberManagement/position/application/port/in/RetrieveMyPositionsByYearUseCase.java @@ -3,5 +3,6 @@ import page.clab.api.domain.memberManagement.position.application.dto.response.PositionMyResponseDto; public interface RetrieveMyPositionsByYearUseCase { + PositionMyResponseDto retrieveMyPositionsByYear(String year); } diff --git a/src/main/java/page/clab/api/domain/memberManagement/position/application/port/in/RetrievePositionsByConditionsUseCase.java b/src/main/java/page/clab/api/domain/memberManagement/position/application/port/in/RetrievePositionsByConditionsUseCase.java index 21ba9625b..7290ef978 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/position/application/port/in/RetrievePositionsByConditionsUseCase.java +++ b/src/main/java/page/clab/api/domain/memberManagement/position/application/port/in/RetrievePositionsByConditionsUseCase.java @@ -6,5 +6,6 @@ import page.clab.api.global.common.dto.PagedResponseDto; public interface RetrievePositionsByConditionsUseCase { + PagedResponseDto retrievePositions(String year, PositionType positionType, Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/memberManagement/position/application/port/out/RegisterPositionPort.java b/src/main/java/page/clab/api/domain/memberManagement/position/application/port/out/RegisterPositionPort.java index df3f41eb0..cb1cd1731 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/position/application/port/out/RegisterPositionPort.java +++ b/src/main/java/page/clab/api/domain/memberManagement/position/application/port/out/RegisterPositionPort.java @@ -1,8 +1,7 @@ package page.clab.api.domain.memberManagement.position.application.port.out; -import page.clab.api.domain.memberManagement.position.domain.Position; - import java.util.List; +import page.clab.api.domain.memberManagement.position.domain.Position; public interface RegisterPositionPort { diff --git a/src/main/java/page/clab/api/domain/memberManagement/position/application/port/out/RetrievePositionPort.java b/src/main/java/page/clab/api/domain/memberManagement/position/application/port/out/RetrievePositionPort.java index 4265c6388..c6a2aabbe 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/position/application/port/out/RetrievePositionPort.java +++ b/src/main/java/page/clab/api/domain/memberManagement/position/application/port/out/RetrievePositionPort.java @@ -1,13 +1,12 @@ package page.clab.api.domain.memberManagement.position.application.port.out; +import java.util.List; +import java.util.Optional; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import page.clab.api.domain.memberManagement.position.domain.Position; import page.clab.api.domain.memberManagement.position.domain.PositionType; -import java.util.List; -import java.util.Optional; - public interface RetrievePositionPort { Position getById(Long id); diff --git a/src/main/java/page/clab/api/domain/memberManagement/position/application/port/out/UpdatePositionPort.java b/src/main/java/page/clab/api/domain/memberManagement/position/application/port/out/UpdatePositionPort.java index e97e6928a..7c94aacbb 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/position/application/port/out/UpdatePositionPort.java +++ b/src/main/java/page/clab/api/domain/memberManagement/position/application/port/out/UpdatePositionPort.java @@ -3,5 +3,6 @@ import page.clab.api.domain.memberManagement.position.domain.Position; public interface UpdatePositionPort { + Position update(Position position); } diff --git a/src/main/java/page/clab/api/domain/memberManagement/position/application/service/MyPositionsByYearRetrievalService.java b/src/main/java/page/clab/api/domain/memberManagement/position/application/service/MyPositionsByYearRetrievalService.java index 9e76ab185..c999dbc30 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/position/application/service/MyPositionsByYearRetrievalService.java +++ b/src/main/java/page/clab/api/domain/memberManagement/position/application/service/MyPositionsByYearRetrievalService.java @@ -1,5 +1,6 @@ package page.clab.api.domain.memberManagement.position.application.service; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -12,8 +13,6 @@ import page.clab.api.external.memberManagement.member.application.port.ExternalRetrieveMemberUseCase; import page.clab.api.global.exception.NotFoundException; -import java.util.List; - @Service @RequiredArgsConstructor public class MyPositionsByYearRetrievalService implements RetrieveMyPositionsByYearUseCase { @@ -26,7 +25,7 @@ public class MyPositionsByYearRetrievalService implements RetrieveMyPositionsByY public PositionMyResponseDto retrieveMyPositionsByYear(String year) { MemberPositionInfoDto currentMemberInfo = externalRetrieveMemberUseCase.getCurrentMemberPositionInfo(); List positions = retrievePositionPort.findAllByMemberIdAndYearOrderByPositionTypeAsc( - currentMemberInfo.getMemberId(), year); + currentMemberInfo.getMemberId(), year); if (positions.isEmpty()) { throw new NotFoundException("해당 멤버의 " + year + "년도 직책이 존재하지 않습니다."); } diff --git a/src/main/java/page/clab/api/domain/memberManagement/position/application/service/PositionRegisterService.java b/src/main/java/page/clab/api/domain/memberManagement/position/application/service/PositionRegisterService.java index a40fa4062..253cb6782 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/position/application/service/PositionRegisterService.java +++ b/src/main/java/page/clab/api/domain/memberManagement/position/application/service/PositionRegisterService.java @@ -24,11 +24,11 @@ public class PositionRegisterService implements RegisterPositionUseCase { public Long registerPosition(PositionRequestDto requestDto) { externalRetrieveMemberUseCase.ensureMemberExists(requestDto.getMemberId()); return retrievePositionPort.findByMemberIdAndYearAndPositionType( - requestDto.getMemberId(), requestDto.getYear(), requestDto.getPositionType()) - .map(Position::getId) - .orElseGet(() -> { - Position position = mapper.fromDto(requestDto); - return registerPositionPort.save(position).getId(); - }); + requestDto.getMemberId(), requestDto.getYear(), requestDto.getPositionType()) + .map(Position::getId) + .orElseGet(() -> { + Position position = mapper.fromDto(requestDto); + return registerPositionPort.save(position).getId(); + }); } } diff --git a/src/main/java/page/clab/api/domain/memberManagement/position/application/service/PositionsByConditionsRetrievalService.java b/src/main/java/page/clab/api/domain/memberManagement/position/application/service/PositionsByConditionsRetrievalService.java index 5b2d69b1a..cf1e43bf8 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/position/application/service/PositionsByConditionsRetrievalService.java +++ b/src/main/java/page/clab/api/domain/memberManagement/position/application/service/PositionsByConditionsRetrievalService.java @@ -24,7 +24,8 @@ public class PositionsByConditionsRetrievalService implements RetrievePositionsB private final PositionDtoMapper mapper; @Transactional(readOnly = true) - public PagedResponseDto retrievePositions(String year, PositionType positionType, Pageable pageable) { + public PagedResponseDto retrievePositions(String year, PositionType positionType, + Pageable pageable) { MemberPositionInfoDto currentMemberInfo = externalRetrieveMemberUseCase.getCurrentMemberPositionInfo(); Page positions = retrievePositionPort.findByConditions(year, positionType, pageable); return new PagedResponseDto<>(positions.map(position -> mapper.toDto(position, currentMemberInfo))); diff --git a/src/main/java/page/clab/api/domain/memberManagement/position/domain/Position.java b/src/main/java/page/clab/api/domain/memberManagement/position/domain/Position.java index f8b5575cd..b8ef5a9b6 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/position/domain/Position.java +++ b/src/main/java/page/clab/api/domain/memberManagement/position/domain/Position.java @@ -1,5 +1,6 @@ package page.clab.api.domain.memberManagement.position.domain; +import java.time.LocalDate; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -7,8 +8,6 @@ import lombok.NoArgsConstructor; import lombok.Setter; -import java.time.LocalDate; - @Getter @Setter @Builder @@ -24,11 +23,11 @@ public class Position { public static Position create(String memberId) { return Position.builder() - .memberId(memberId) - .positionType(PositionType.MEMBER) - .year(String.valueOf(LocalDate.now().getYear())) - .isDeleted(false) - .build(); + .memberId(memberId) + .positionType(PositionType.MEMBER) + .year(String.valueOf(LocalDate.now().getYear())) + .isDeleted(false) + .build(); } public void delete() { diff --git a/src/main/java/page/clab/api/domain/memberManagement/workExperience/adapter/in/web/DeletedWorkExperiencesRetrievalController.java b/src/main/java/page/clab/api/domain/memberManagement/workExperience/adapter/in/web/DeletedWorkExperiencesRetrievalController.java index 50f9c4d6e..15fefb6e3 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/workExperience/adapter/in/web/DeletedWorkExperiencesRetrievalController.java +++ b/src/main/java/page/clab/api/domain/memberManagement/workExperience/adapter/in/web/DeletedWorkExperiencesRetrievalController.java @@ -27,12 +27,12 @@ public class DeletedWorkExperiencesRetrievalController { @PreAuthorize("hasRole('SUPER')") @GetMapping("/deleted") public ApiResponse> retrieveDeletedWorkExperiences( - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size ) { Pageable pageable = PageRequest.of(page, size); PagedResponseDto workExperiences = - retrieveDeletedWorkExperiencesUseCase.retrieveDeletedWorkExperiences(pageable); + retrieveDeletedWorkExperiencesUseCase.retrieveDeletedWorkExperiences(pageable); return ApiResponse.success(workExperiences); } } diff --git a/src/main/java/page/clab/api/domain/memberManagement/workExperience/adapter/in/web/MyWorkExperienceRetrievalController.java b/src/main/java/page/clab/api/domain/memberManagement/workExperience/adapter/in/web/MyWorkExperienceRetrievalController.java index d67f848b5..3d36bcb86 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/workExperience/adapter/in/web/MyWorkExperienceRetrievalController.java +++ b/src/main/java/page/clab/api/domain/memberManagement/workExperience/adapter/in/web/MyWorkExperienceRetrievalController.java @@ -2,6 +2,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.security.access.prepost.PreAuthorize; @@ -17,8 +18,6 @@ import page.clab.api.global.exception.SortingArgumentException; import page.clab.api.global.util.PageableUtils; -import java.util.List; - @RestController @RequestMapping("/api/v1/work-experiences") @RequiredArgsConstructor @@ -29,18 +28,20 @@ public class MyWorkExperienceRetrievalController { private final PageableUtils pageableUtils; @Operation(summary = "[G] 나의 경력사항 조회", description = "ROLE_GUEST 이상의 권한이 필요함
" + - "입사일을 기준으로 내림차순 정렬하여 결과를 보여줌
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") + "입사일을 기준으로 내림차순 정렬하여 결과를 보여줌
" + + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") @PreAuthorize("hasRole('GUEST')") @GetMapping("") public ApiResponse> retrieveMyWorkExperience( - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "startDate") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "startDate") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection ) throws SortingArgumentException, InvalidColumnException { - Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, WorkExperienceResponseDto.class); - PagedResponseDto myWorkExperience = retrieveMyWorkExperienceUseCase.retrieveMyWorkExperience(pageable); + Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, + WorkExperienceResponseDto.class); + PagedResponseDto myWorkExperience = retrieveMyWorkExperienceUseCase.retrieveMyWorkExperience( + pageable); return ApiResponse.success(myWorkExperience); } } diff --git a/src/main/java/page/clab/api/domain/memberManagement/workExperience/adapter/in/web/WorkExperienceRegisterController.java b/src/main/java/page/clab/api/domain/memberManagement/workExperience/adapter/in/web/WorkExperienceRegisterController.java index 9af7af3f3..fb821c1e2 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/workExperience/adapter/in/web/WorkExperienceRegisterController.java +++ b/src/main/java/page/clab/api/domain/memberManagement/workExperience/adapter/in/web/WorkExperienceRegisterController.java @@ -25,7 +25,7 @@ public class WorkExperienceRegisterController { @PreAuthorize("hasRole('USER')") @PostMapping("") public ApiResponse registerWorkExperience( - @Valid @RequestBody WorkExperienceRequestDto requestDto + @Valid @RequestBody WorkExperienceRequestDto requestDto ) { Long id = registerWorkExperienceUseCase.registerWorkExperience(requestDto); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/memberManagement/workExperience/adapter/in/web/WorkExperienceRemoveController.java b/src/main/java/page/clab/api/domain/memberManagement/workExperience/adapter/in/web/WorkExperienceRemoveController.java index 4e0b0f52c..f0f38953a 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/workExperience/adapter/in/web/WorkExperienceRemoveController.java +++ b/src/main/java/page/clab/api/domain/memberManagement/workExperience/adapter/in/web/WorkExperienceRemoveController.java @@ -21,11 +21,11 @@ public class WorkExperienceRemoveController { private final RemoveWorkExperienceUseCase removeWorkExperienceUseCase; @Operation(summary = "[U] 경력사항 삭제", description = "ROLE_USER 이상의 권한이 필요함
" + - "본인 외의 정보는 ROLE_SUPER만 가능") + "본인 외의 정보는 ROLE_SUPER만 가능") @PreAuthorize("hasRole('USER')") @DeleteMapping("/{workExperienceId}") public ApiResponse removeWorkExperience( - @PathVariable(name = "workExperienceId") Long workExperienceId + @PathVariable(name = "workExperienceId") Long workExperienceId ) throws PermissionDeniedException { Long id = removeWorkExperienceUseCase.removeWorkExperience(workExperienceId); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/memberManagement/workExperience/adapter/in/web/WorkExperienceUpdateController.java b/src/main/java/page/clab/api/domain/memberManagement/workExperience/adapter/in/web/WorkExperienceUpdateController.java index 628b20e85..bb3a4b9fc 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/workExperience/adapter/in/web/WorkExperienceUpdateController.java +++ b/src/main/java/page/clab/api/domain/memberManagement/workExperience/adapter/in/web/WorkExperienceUpdateController.java @@ -24,12 +24,12 @@ public class WorkExperienceUpdateController { private final UpdateWorkExperienceUseCase updateWorkExperienceUseCase; @Operation(summary = "[U] 경력사항 수정", description = "ROLE_USER 이상의 권한이 필요함
" + - "본인 외의 정보는 ROLE_SUPER만 가능") + "본인 외의 정보는 ROLE_SUPER만 가능") @PreAuthorize("hasRole('USER')") @PatchMapping("/{workExperienceId}") public ApiResponse updateWorkExperience( - @PathVariable(name = "workExperienceId") Long workExperienceId, - @Valid @RequestBody WorkExperienceUpdateRequestDto requestDto + @PathVariable(name = "workExperienceId") Long workExperienceId, + @Valid @RequestBody WorkExperienceUpdateRequestDto requestDto ) throws PermissionDeniedException { Long id = updateWorkExperienceUseCase.updateWorkExperience(workExperienceId, requestDto); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/memberManagement/workExperience/adapter/in/web/WorkExperiencesByConditionsRetrievalController.java b/src/main/java/page/clab/api/domain/memberManagement/workExperience/adapter/in/web/WorkExperiencesByConditionsRetrievalController.java index 5718aa7c8..0d14235c6 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/workExperience/adapter/in/web/WorkExperiencesByConditionsRetrievalController.java +++ b/src/main/java/page/clab/api/domain/memberManagement/workExperience/adapter/in/web/WorkExperiencesByConditionsRetrievalController.java @@ -2,6 +2,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.security.access.prepost.PreAuthorize; @@ -17,8 +18,6 @@ import page.clab.api.global.exception.SortingArgumentException; import page.clab.api.global.util.PageableUtils; -import java.util.List; - @RestController @RequestMapping("/api/v1/work-experiences") @RequiredArgsConstructor @@ -29,19 +28,21 @@ public class WorkExperiencesByConditionsRetrievalController { private final PageableUtils pageableUtils; @Operation(summary = "[U] 멤버의 경력사항 검색", description = "ROLE_USER 이상의 권한이 필요함
" + - "입사일을 기준으로 내림차순 정렬하여 결과를 보여줌
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") + "입사일을 기준으로 내림차순 정렬하여 결과를 보여줌
" + + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") @PreAuthorize("hasRole('USER')") @GetMapping("/conditions") public ApiResponse> retrieveWorkExperiencesByConditions( - @RequestParam String memberId, - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "startDate") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection + @RequestParam String memberId, + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "startDate") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection ) throws SortingArgumentException, InvalidColumnException { - Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, WorkExperienceResponseDto.class); - PagedResponseDto workExperiences = retrieveWorkExperiencesByConditionsUseCase.retrieveWorkExperiences(memberId, pageable); + Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, + WorkExperienceResponseDto.class); + PagedResponseDto workExperiences = retrieveWorkExperiencesByConditionsUseCase.retrieveWorkExperiences( + memberId, pageable); return ApiResponse.success(workExperiences); } } diff --git a/src/main/java/page/clab/api/domain/memberManagement/workExperience/adapter/out/persistence/WorkExperienceJpaEntity.java b/src/main/java/page/clab/api/domain/memberManagement/workExperience/adapter/out/persistence/WorkExperienceJpaEntity.java index 32e195126..b722b552f 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/workExperience/adapter/out/persistence/WorkExperienceJpaEntity.java +++ b/src/main/java/page/clab/api/domain/memberManagement/workExperience/adapter/out/persistence/WorkExperienceJpaEntity.java @@ -7,6 +7,7 @@ import jakarta.persistence.Id; import jakarta.persistence.Table; import jakarta.validation.constraints.Size; +import java.time.LocalDate; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -17,8 +18,6 @@ import org.hibernate.annotations.SQLRestriction; import page.clab.api.global.common.domain.BaseEntity; -import java.time.LocalDate; - @Entity @Table(name = "work_experience") @Getter diff --git a/src/main/java/page/clab/api/domain/memberManagement/workExperience/adapter/out/persistence/WorkExperiencePersistenceAdapter.java b/src/main/java/page/clab/api/domain/memberManagement/workExperience/adapter/out/persistence/WorkExperiencePersistenceAdapter.java index 0f91a3f70..fac86a704 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/workExperience/adapter/out/persistence/WorkExperiencePersistenceAdapter.java +++ b/src/main/java/page/clab/api/domain/memberManagement/workExperience/adapter/out/persistence/WorkExperiencePersistenceAdapter.java @@ -1,5 +1,7 @@ package page.clab.api.domain.memberManagement.workExperience.adapter.out.persistence; +import java.util.List; +import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -10,15 +12,12 @@ import page.clab.api.domain.memberManagement.workExperience.domain.WorkExperience; import page.clab.api.global.exception.NotFoundException; -import java.util.List; -import java.util.stream.Collectors; - @Component @RequiredArgsConstructor public class WorkExperiencePersistenceAdapter implements - RegisterWorkExperiencePort, - UpdateWorkExperiencePort, - RetrieveWorkExperiencePort { + RegisterWorkExperiencePort, + UpdateWorkExperiencePort, + RetrieveWorkExperiencePort { private final WorkExperienceRepository repository; private final WorkExperienceMapper mapper; @@ -33,35 +32,35 @@ public WorkExperience save(WorkExperience workExperience) { @Override public void saveAll(List workExperiences) { List entities = workExperiences.stream() - .map(mapper::toEntity) - .collect(Collectors.toList()); + .map(mapper::toEntity) + .collect(Collectors.toList()); repository.saveAll(entities); } @Override public Page findAllByIsDeletedTrue(Pageable pageable) { return repository.findAllByIsDeletedTrue(pageable) - .map(mapper::toDomain); + .map(mapper::toDomain); } @Override public List findByMemberId(String memberId) { return repository.findByMemberId(memberId).stream() - .map(mapper::toDomain) - .toList(); + .map(mapper::toDomain) + .toList(); } @Override public Page findByMemberId(String memberId, Pageable pageable) { Page workExperienceJpaEntities = repository.findByMemberId(memberId, pageable); return workExperienceJpaEntities - .map(mapper::toDomain); + .map(mapper::toDomain); } @Override public Page findByConditions(String memberId, Pageable pageable) { return repository.findByMemberId(memberId, pageable) - .map(mapper::toDomain); + .map(mapper::toDomain); } @Override @@ -74,7 +73,7 @@ public WorkExperience update(WorkExperience workExperience) { @Override public WorkExperience getById(Long id) { return repository.findById(id) - .map(mapper::toDomain) - .orElseThrow(() -> new NotFoundException("[WorkExperience] id: " + id + "에 해당하는 경력사항이 존재하지 않습니다.")); + .map(mapper::toDomain) + .orElseThrow(() -> new NotFoundException("[WorkExperience] id: " + id + "에 해당하는 경력사항이 존재하지 않습니다.")); } } diff --git a/src/main/java/page/clab/api/domain/memberManagement/workExperience/adapter/out/persistence/WorkExperienceRepository.java b/src/main/java/page/clab/api/domain/memberManagement/workExperience/adapter/out/persistence/WorkExperienceRepository.java index 315ac21fe..dfad0f188 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/workExperience/adapter/out/persistence/WorkExperienceRepository.java +++ b/src/main/java/page/clab/api/domain/memberManagement/workExperience/adapter/out/persistence/WorkExperienceRepository.java @@ -1,13 +1,12 @@ package page.clab.api.domain.memberManagement.workExperience.adapter.out.persistence; +import java.util.List; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; -import java.util.List; - @Repository public interface WorkExperienceRepository extends JpaRepository { diff --git a/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/dto/mapper/WorkExperienceDtoMapper.java b/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/dto/mapper/WorkExperienceDtoMapper.java index e92dc518c..13f4a26e6 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/dto/mapper/WorkExperienceDtoMapper.java +++ b/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/dto/mapper/WorkExperienceDtoMapper.java @@ -10,22 +10,22 @@ public class WorkExperienceDtoMapper { public WorkExperience fromDto(WorkExperienceRequestDto requestDto, String memberId) { return WorkExperience.builder() - .companyName(requestDto.getCompanyName()) - .position(requestDto.getPosition()) - .startDate(requestDto.getStartDate()) - .endDate(requestDto.getEndDate()) - .memberId(memberId) - .isDeleted(false) - .build(); + .companyName(requestDto.getCompanyName()) + .position(requestDto.getPosition()) + .startDate(requestDto.getStartDate()) + .endDate(requestDto.getEndDate()) + .memberId(memberId) + .isDeleted(false) + .build(); } public WorkExperienceResponseDto toDto(WorkExperience workExperience) { return WorkExperienceResponseDto.builder() - .id(workExperience.getId()) - .companyName(workExperience.getCompanyName()) - .position(workExperience.getPosition()) - .startDate(workExperience.getStartDate()) - .endDate(workExperience.getEndDate()) - .build(); + .id(workExperience.getId()) + .companyName(workExperience.getCompanyName()) + .position(workExperience.getPosition()) + .startDate(workExperience.getStartDate()) + .endDate(workExperience.getEndDate()) + .build(); } } diff --git a/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/dto/request/WorkExperienceRequestDto.java b/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/dto/request/WorkExperienceRequestDto.java index 47714e804..fab2016af 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/dto/request/WorkExperienceRequestDto.java +++ b/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/dto/request/WorkExperienceRequestDto.java @@ -2,11 +2,10 @@ import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotNull; +import java.time.LocalDate; import lombok.Getter; import lombok.Setter; -import java.time.LocalDate; - @Getter @Setter public class WorkExperienceRequestDto { diff --git a/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/dto/request/WorkExperienceUpdateRequestDto.java b/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/dto/request/WorkExperienceUpdateRequestDto.java index 0c7c6242e..b8fcc39ca 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/dto/request/WorkExperienceUpdateRequestDto.java +++ b/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/dto/request/WorkExperienceUpdateRequestDto.java @@ -1,11 +1,10 @@ package page.clab.api.domain.memberManagement.workExperience.application.dto.request; import io.swagger.v3.oas.annotations.media.Schema; +import java.time.LocalDate; import lombok.Getter; import lombok.Setter; -import java.time.LocalDate; - @Getter @Setter public class WorkExperienceUpdateRequestDto { diff --git a/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/dto/response/WorkExperienceResponseDto.java b/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/dto/response/WorkExperienceResponseDto.java index 9806c6d11..290ec4f33 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/dto/response/WorkExperienceResponseDto.java +++ b/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/dto/response/WorkExperienceResponseDto.java @@ -1,10 +1,9 @@ package page.clab.api.domain.memberManagement.workExperience.application.dto.response; +import java.time.LocalDate; import lombok.Builder; import lombok.Getter; -import java.time.LocalDate; - @Getter @Builder public class WorkExperienceResponseDto { diff --git a/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/event/WorkExperienceEventProcessor.java b/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/event/WorkExperienceEventProcessor.java index d4898e66c..a2a6a84d3 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/event/WorkExperienceEventProcessor.java +++ b/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/event/WorkExperienceEventProcessor.java @@ -1,6 +1,7 @@ package page.clab.api.domain.memberManagement.workExperience.application.event; import jakarta.annotation.PostConstruct; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; @@ -10,8 +11,6 @@ import page.clab.api.domain.memberManagement.workExperience.application.port.out.RetrieveWorkExperiencePort; import page.clab.api.domain.memberManagement.workExperience.domain.WorkExperience; -import java.util.List; - @Component @RequiredArgsConstructor public class WorkExperienceEventProcessor implements MemberEventProcessor { diff --git a/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/port/in/RegisterWorkExperienceUseCase.java b/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/port/in/RegisterWorkExperienceUseCase.java index 9807360b2..28b9af32c 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/port/in/RegisterWorkExperienceUseCase.java +++ b/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/port/in/RegisterWorkExperienceUseCase.java @@ -3,5 +3,6 @@ import page.clab.api.domain.memberManagement.workExperience.application.dto.request.WorkExperienceRequestDto; public interface RegisterWorkExperienceUseCase { + Long registerWorkExperience(WorkExperienceRequestDto requestDto); } diff --git a/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/port/in/RemoveWorkExperienceUseCase.java b/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/port/in/RemoveWorkExperienceUseCase.java index 7abbc4541..dbe79a7f8 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/port/in/RemoveWorkExperienceUseCase.java +++ b/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/port/in/RemoveWorkExperienceUseCase.java @@ -3,5 +3,6 @@ import page.clab.api.global.exception.PermissionDeniedException; public interface RemoveWorkExperienceUseCase { + Long removeWorkExperience(Long workExperienceId) throws PermissionDeniedException; } diff --git a/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/port/in/RetrieveDeletedWorkExperiencesUseCase.java b/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/port/in/RetrieveDeletedWorkExperiencesUseCase.java index 1d2234766..f2b80d5fe 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/port/in/RetrieveDeletedWorkExperiencesUseCase.java +++ b/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/port/in/RetrieveDeletedWorkExperiencesUseCase.java @@ -5,5 +5,6 @@ import page.clab.api.global.common.dto.PagedResponseDto; public interface RetrieveDeletedWorkExperiencesUseCase { + PagedResponseDto retrieveDeletedWorkExperiences(Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/port/in/RetrieveMyWorkExperienceUseCase.java b/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/port/in/RetrieveMyWorkExperienceUseCase.java index 3851e5102..23256e681 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/port/in/RetrieveMyWorkExperienceUseCase.java +++ b/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/port/in/RetrieveMyWorkExperienceUseCase.java @@ -5,5 +5,6 @@ import page.clab.api.global.common.dto.PagedResponseDto; public interface RetrieveMyWorkExperienceUseCase { + PagedResponseDto retrieveMyWorkExperience(Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/port/in/RetrieveWorkExperiencesByConditionsUseCase.java b/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/port/in/RetrieveWorkExperiencesByConditionsUseCase.java index a27621ef5..fe45e4b51 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/port/in/RetrieveWorkExperiencesByConditionsUseCase.java +++ b/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/port/in/RetrieveWorkExperiencesByConditionsUseCase.java @@ -5,5 +5,6 @@ import page.clab.api.global.common.dto.PagedResponseDto; public interface RetrieveWorkExperiencesByConditionsUseCase { + PagedResponseDto retrieveWorkExperiences(String memberId, Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/port/in/UpdateWorkExperienceUseCase.java b/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/port/in/UpdateWorkExperienceUseCase.java index 3fe553c2e..2fe12f0fa 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/port/in/UpdateWorkExperienceUseCase.java +++ b/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/port/in/UpdateWorkExperienceUseCase.java @@ -4,5 +4,7 @@ import page.clab.api.global.exception.PermissionDeniedException; public interface UpdateWorkExperienceUseCase { - Long updateWorkExperience(Long workExperienceId, WorkExperienceUpdateRequestDto requestDto) throws PermissionDeniedException; + + Long updateWorkExperience(Long workExperienceId, WorkExperienceUpdateRequestDto requestDto) + throws PermissionDeniedException; } diff --git a/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/port/out/RegisterWorkExperiencePort.java b/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/port/out/RegisterWorkExperiencePort.java index 81fcd08fc..4af343f4d 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/port/out/RegisterWorkExperiencePort.java +++ b/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/port/out/RegisterWorkExperiencePort.java @@ -1,8 +1,7 @@ package page.clab.api.domain.memberManagement.workExperience.application.port.out; -import page.clab.api.domain.memberManagement.workExperience.domain.WorkExperience; - import java.util.List; +import page.clab.api.domain.memberManagement.workExperience.domain.WorkExperience; public interface RegisterWorkExperiencePort { diff --git a/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/port/out/RetrieveWorkExperiencePort.java b/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/port/out/RetrieveWorkExperiencePort.java index 539d7b4f2..01876fba9 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/port/out/RetrieveWorkExperiencePort.java +++ b/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/port/out/RetrieveWorkExperiencePort.java @@ -1,11 +1,10 @@ package page.clab.api.domain.memberManagement.workExperience.application.port.out; +import java.util.List; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import page.clab.api.domain.memberManagement.workExperience.domain.WorkExperience; -import java.util.List; - public interface RetrieveWorkExperiencePort { WorkExperience getById(Long id); diff --git a/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/port/out/UpdateWorkExperiencePort.java b/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/port/out/UpdateWorkExperiencePort.java index b162061c6..6c143ad85 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/port/out/UpdateWorkExperiencePort.java +++ b/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/port/out/UpdateWorkExperiencePort.java @@ -3,5 +3,6 @@ import page.clab.api.domain.memberManagement.workExperience.domain.WorkExperience; public interface UpdateWorkExperiencePort { + WorkExperience update(WorkExperience workExperience); } diff --git a/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/service/WorkExperienceUpdateService.java b/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/service/WorkExperienceUpdateService.java index f3af3c0e2..fac6a21a4 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/service/WorkExperienceUpdateService.java +++ b/src/main/java/page/clab/api/domain/memberManagement/workExperience/application/service/WorkExperienceUpdateService.java @@ -22,7 +22,8 @@ public class WorkExperienceUpdateService implements UpdateWorkExperienceUseCase @Override @Transactional - public Long updateWorkExperience(Long workExperienceId, WorkExperienceUpdateRequestDto requestDto) throws PermissionDeniedException { + public Long updateWorkExperience(Long workExperienceId, WorkExperienceUpdateRequestDto requestDto) + throws PermissionDeniedException { MemberDetailedInfoDto currentMemberInfo = externalRetrieveMemberUseCase.getCurrentMemberDetailedInfo(); WorkExperience workExperience = retrieveWorkExperiencePort.getById(workExperienceId); workExperience.validateAccessPermission(currentMemberInfo); diff --git a/src/main/java/page/clab/api/domain/memberManagement/workExperience/domain/WorkExperience.java b/src/main/java/page/clab/api/domain/memberManagement/workExperience/domain/WorkExperience.java index d99f01e89..2c99bafc8 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/workExperience/domain/WorkExperience.java +++ b/src/main/java/page/clab/api/domain/memberManagement/workExperience/domain/WorkExperience.java @@ -1,5 +1,7 @@ package page.clab.api.domain.memberManagement.workExperience.domain; +import java.time.LocalDate; +import java.util.Optional; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -11,9 +13,6 @@ import page.clab.api.global.exception.InvalidDateRangeException; import page.clab.api.global.exception.PermissionDeniedException; -import java.time.LocalDate; -import java.util.Optional; - @Getter @Setter @Builder diff --git a/src/main/java/page/clab/api/domain/members/activityPhoto/adapter/in/web/ActivityPhotoRegisterController.java b/src/main/java/page/clab/api/domain/members/activityPhoto/adapter/in/web/ActivityPhotoRegisterController.java index 469d07f49..c762be4ab 100644 --- a/src/main/java/page/clab/api/domain/members/activityPhoto/adapter/in/web/ActivityPhotoRegisterController.java +++ b/src/main/java/page/clab/api/domain/members/activityPhoto/adapter/in/web/ActivityPhotoRegisterController.java @@ -25,7 +25,7 @@ public class ActivityPhotoRegisterController { @PreAuthorize("hasRole('ADMIN')") @PostMapping("") public ApiResponse registerActivityPhoto( - @Valid @RequestBody ActivityPhotoRequestDto requestDto + @Valid @RequestBody ActivityPhotoRequestDto requestDto ) { Long id = registerActivityPhotoUseCase.registerActivityPhoto(requestDto); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/members/activityPhoto/adapter/in/web/ActivityPhotoRemoveController.java b/src/main/java/page/clab/api/domain/members/activityPhoto/adapter/in/web/ActivityPhotoRemoveController.java index 834e4673a..db9338672 100644 --- a/src/main/java/page/clab/api/domain/members/activityPhoto/adapter/in/web/ActivityPhotoRemoveController.java +++ b/src/main/java/page/clab/api/domain/members/activityPhoto/adapter/in/web/ActivityPhotoRemoveController.java @@ -23,7 +23,7 @@ public class ActivityPhotoRemoveController { @PreAuthorize("hasRole('ADMIN')") @DeleteMapping("/{activityPhotoId}") public ApiResponse removeActivityPhoto( - @PathVariable(name = "activityPhotoId") Long activityPhotoId + @PathVariable(name = "activityPhotoId") Long activityPhotoId ) { Long id = removeActivityPhotoUseCase.removeActivityPhoto(activityPhotoId); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/members/activityPhoto/adapter/in/web/ActivityPhotoRetrievalController.java b/src/main/java/page/clab/api/domain/members/activityPhoto/adapter/in/web/ActivityPhotoRetrievalController.java index db87bbc02..c1101015d 100644 --- a/src/main/java/page/clab/api/domain/members/activityPhoto/adapter/in/web/ActivityPhotoRetrievalController.java +++ b/src/main/java/page/clab/api/domain/members/activityPhoto/adapter/in/web/ActivityPhotoRetrievalController.java @@ -2,6 +2,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.web.bind.annotation.GetMapping; @@ -16,8 +17,6 @@ import page.clab.api.global.exception.SortingArgumentException; import page.clab.api.global.util.PageableUtils; -import java.util.List; - @RestController @RequestMapping("/api/v1/activity-photos") @RequiredArgsConstructor @@ -28,18 +27,20 @@ public class ActivityPhotoRetrievalController { private final PageableUtils pageableUtils; @Operation(summary = "활동 사진 목록 조회", description = "ROLE_ANONYMOUS 이상의 권한이 필요함
" + - "공개 여부를 입력하지 않으면 전체 조회됨
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") + "공개 여부를 입력하지 않으면 전체 조회됨
" + + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") @GetMapping("") public ApiResponse> retrieveActivityPhotos( - @RequestParam(name = "isPublic", required = false) Boolean isPublic, - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection + @RequestParam(name = "isPublic", required = false) Boolean isPublic, + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection ) throws SortingArgumentException, InvalidColumnException { - Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, ActivityPhotoResponseDto.class); - PagedResponseDto activityPhotos = retrieveActivityPhotoUseCase.retrieveActivityPhotos(isPublic, pageable); + Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, + ActivityPhotoResponseDto.class); + PagedResponseDto activityPhotos = retrieveActivityPhotoUseCase.retrieveActivityPhotos( + isPublic, pageable); return ApiResponse.success(activityPhotos); } } diff --git a/src/main/java/page/clab/api/domain/members/activityPhoto/adapter/in/web/ActivityPhotoVisibilityController.java b/src/main/java/page/clab/api/domain/members/activityPhoto/adapter/in/web/ActivityPhotoVisibilityController.java index 596949456..fa9d2face 100644 --- a/src/main/java/page/clab/api/domain/members/activityPhoto/adapter/in/web/ActivityPhotoVisibilityController.java +++ b/src/main/java/page/clab/api/domain/members/activityPhoto/adapter/in/web/ActivityPhotoVisibilityController.java @@ -23,7 +23,7 @@ public class ActivityPhotoVisibilityController { @PreAuthorize("hasRole('ADMIN')") @PatchMapping("/{activityPhotoId}") public ApiResponse toggleActivityPhotoVisibility( - @PathVariable(name = "activityPhotoId") Long activityPhotoId + @PathVariable(name = "activityPhotoId") Long activityPhotoId ) { Long id = toggleActivityPhotoVisibilityUseCase.toggleActivityPhotoVisibility(activityPhotoId); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/members/activityPhoto/adapter/out/persistence/ActivityPhotoJpaEntity.java b/src/main/java/page/clab/api/domain/members/activityPhoto/adapter/out/persistence/ActivityPhotoJpaEntity.java index 1954b4fd0..f6a66612f 100644 --- a/src/main/java/page/clab/api/domain/members/activityPhoto/adapter/out/persistence/ActivityPhotoJpaEntity.java +++ b/src/main/java/page/clab/api/domain/members/activityPhoto/adapter/out/persistence/ActivityPhotoJpaEntity.java @@ -9,6 +9,8 @@ import jakarta.persistence.JoinColumn; import jakarta.persistence.OneToMany; import jakarta.persistence.Table; +import java.time.LocalDate; +import java.util.List; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -20,9 +22,6 @@ import page.clab.api.global.common.domain.BaseEntity; import page.clab.api.global.common.file.domain.UploadedFile; -import java.time.LocalDate; -import java.util.List; - @Entity @Table(name = "activity_photo") @Getter diff --git a/src/main/java/page/clab/api/domain/members/activityPhoto/adapter/out/persistence/ActivityPhotoPersistenceAdapter.java b/src/main/java/page/clab/api/domain/members/activityPhoto/adapter/out/persistence/ActivityPhotoPersistenceAdapter.java index 1816f4147..d640c1a62 100644 --- a/src/main/java/page/clab/api/domain/members/activityPhoto/adapter/out/persistence/ActivityPhotoPersistenceAdapter.java +++ b/src/main/java/page/clab/api/domain/members/activityPhoto/adapter/out/persistence/ActivityPhotoPersistenceAdapter.java @@ -12,8 +12,8 @@ @Component @RequiredArgsConstructor public class ActivityPhotoPersistenceAdapter implements - RegisterActivityPhotoPort, - RetrieveActivityPhotoPort { + RegisterActivityPhotoPort, + RetrieveActivityPhotoPort { private final ActivityPhotoRepository activityPhotoRepository; private final ActivityPhotoMapper activityPhotoMapper; @@ -28,13 +28,14 @@ public ActivityPhoto save(ActivityPhoto activityPhoto) { @Override public ActivityPhoto getById(Long activityPhotoId) { return activityPhotoRepository.findById(activityPhotoId) - .map(activityPhotoMapper::toDomain) - .orElseThrow(() -> new NotFoundException("[ActivityPhoto] id: " + activityPhotoId + "에 해당하는 활동 사진이 존재하지 않습니다.")); + .map(activityPhotoMapper::toDomain) + .orElseThrow( + () -> new NotFoundException("[ActivityPhoto] id: " + activityPhotoId + "에 해당하는 활동 사진이 존재하지 않습니다.")); } @Override public Page findByConditions(Boolean isPublic, Pageable pageable) { return activityPhotoRepository.findByConditions(isPublic, pageable) - .map(activityPhotoMapper::toDomain); + .map(activityPhotoMapper::toDomain); } } diff --git a/src/main/java/page/clab/api/domain/members/activityPhoto/adapter/out/persistence/ActivityPhotoRepository.java b/src/main/java/page/clab/api/domain/members/activityPhoto/adapter/out/persistence/ActivityPhotoRepository.java index 4fad374bf..7ccd8b638 100644 --- a/src/main/java/page/clab/api/domain/members/activityPhoto/adapter/out/persistence/ActivityPhotoRepository.java +++ b/src/main/java/page/clab/api/domain/members/activityPhoto/adapter/out/persistence/ActivityPhotoRepository.java @@ -5,5 +5,7 @@ import org.springframework.stereotype.Repository; @Repository -public interface ActivityPhotoRepository extends JpaRepository, ActivityPhotoRepositoryCustom, QuerydslPredicateExecutor { +public interface ActivityPhotoRepository extends JpaRepository, + ActivityPhotoRepositoryCustom, QuerydslPredicateExecutor { + } diff --git a/src/main/java/page/clab/api/domain/members/activityPhoto/adapter/out/persistence/ActivityPhotoRepositoryCustom.java b/src/main/java/page/clab/api/domain/members/activityPhoto/adapter/out/persistence/ActivityPhotoRepositoryCustom.java index d04831d02..a67b4d023 100644 --- a/src/main/java/page/clab/api/domain/members/activityPhoto/adapter/out/persistence/ActivityPhotoRepositoryCustom.java +++ b/src/main/java/page/clab/api/domain/members/activityPhoto/adapter/out/persistence/ActivityPhotoRepositoryCustom.java @@ -4,5 +4,6 @@ import org.springframework.data.domain.Pageable; public interface ActivityPhotoRepositoryCustom { + Page findByConditions(Boolean isPublic, Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/members/activityPhoto/adapter/out/persistence/ActivityPhotoRepositoryImpl.java b/src/main/java/page/clab/api/domain/members/activityPhoto/adapter/out/persistence/ActivityPhotoRepositoryImpl.java index 9855d59a2..111d7a622 100644 --- a/src/main/java/page/clab/api/domain/members/activityPhoto/adapter/out/persistence/ActivityPhotoRepositoryImpl.java +++ b/src/main/java/page/clab/api/domain/members/activityPhoto/adapter/out/persistence/ActivityPhotoRepositoryImpl.java @@ -2,14 +2,13 @@ import com.querydsl.core.BooleanBuilder; import com.querydsl.jpa.impl.JPAQueryFactory; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Repository; -import java.util.List; - @Repository @RequiredArgsConstructor public class ActivityPhotoRepositoryImpl implements ActivityPhotoRepositoryCustom { @@ -21,18 +20,20 @@ public Page findByConditions(Boolean isPublic, Pageable QActivityPhotoJpaEntity activityPhoto = QActivityPhotoJpaEntity.activityPhotoJpaEntity; BooleanBuilder builder = new BooleanBuilder(); - if (isPublic != null) builder.and(activityPhoto.isPublic.eq(isPublic)); + if (isPublic != null) { + builder.and(activityPhoto.isPublic.eq(isPublic)); + } List photos = queryFactory.selectFrom(activityPhoto) - .where(builder) - .orderBy(activityPhoto.createdAt.desc()) - .offset(pageable.getOffset()) - .limit(pageable.getPageSize()) - .fetch(); + .where(builder) + .orderBy(activityPhoto.createdAt.desc()) + .offset(pageable.getOffset()) + .limit(pageable.getPageSize()) + .fetch(); long total = queryFactory.selectFrom(activityPhoto) - .where(builder) - .fetchCount(); + .where(builder) + .fetchCount(); return new PageImpl<>(photos, pageable, total); } diff --git a/src/main/java/page/clab/api/domain/members/activityPhoto/application/dto/mapper/ActivityPhotoDtoMapper.java b/src/main/java/page/clab/api/domain/members/activityPhoto/application/dto/mapper/ActivityPhotoDtoMapper.java index 619bc29f5..f7fab1b2f 100644 --- a/src/main/java/page/clab/api/domain/members/activityPhoto/application/dto/mapper/ActivityPhotoDtoMapper.java +++ b/src/main/java/page/clab/api/domain/members/activityPhoto/application/dto/mapper/ActivityPhotoDtoMapper.java @@ -1,5 +1,6 @@ package page.clab.api.domain.members.activityPhoto.application.dto.mapper; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; import page.clab.api.domain.members.activityPhoto.application.dto.request.ActivityPhotoRequestDto; @@ -8,8 +9,6 @@ import page.clab.api.global.common.file.domain.UploadedFile; import page.clab.api.global.common.file.dto.mapper.FileDtoMapper; -import java.util.List; - @Component @RequiredArgsConstructor public class ActivityPhotoDtoMapper { @@ -18,22 +17,22 @@ public class ActivityPhotoDtoMapper { public ActivityPhoto fromDto(ActivityPhotoRequestDto requestDto, List uploadedFiles) { return ActivityPhoto.builder() - .title(requestDto.getTitle()) - .uploadedFiles(uploadedFiles) - .date(requestDto.getDate()) - .isPublic(false) - .isDeleted(false) - .build(); + .title(requestDto.getTitle()) + .uploadedFiles(uploadedFiles) + .date(requestDto.getDate()) + .isPublic(false) + .isDeleted(false) + .build(); } public ActivityPhotoResponseDto toDto(ActivityPhoto activityPhoto) { return ActivityPhotoResponseDto.builder() - .id(activityPhoto.getId()) - .title(activityPhoto.getTitle()) - .files(mapper.toDto(activityPhoto.getUploadedFiles())) - .date(activityPhoto.getDate()) - .isPublic(activityPhoto.getIsPublic()) - .createdAt(activityPhoto.getCreatedAt()) - .build(); + .id(activityPhoto.getId()) + .title(activityPhoto.getTitle()) + .files(mapper.toDto(activityPhoto.getUploadedFiles())) + .date(activityPhoto.getDate()) + .isPublic(activityPhoto.getIsPublic()) + .createdAt(activityPhoto.getCreatedAt()) + .build(); } } diff --git a/src/main/java/page/clab/api/domain/members/activityPhoto/application/dto/request/ActivityPhotoRequestDto.java b/src/main/java/page/clab/api/domain/members/activityPhoto/application/dto/request/ActivityPhotoRequestDto.java index b35e2efc6..0bd4438cb 100644 --- a/src/main/java/page/clab/api/domain/members/activityPhoto/application/dto/request/ActivityPhotoRequestDto.java +++ b/src/main/java/page/clab/api/domain/members/activityPhoto/application/dto/request/ActivityPhotoRequestDto.java @@ -2,11 +2,10 @@ import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotNull; -import lombok.Getter; -import lombok.Setter; - import java.time.LocalDate; import java.util.List; +import lombok.Getter; +import lombok.Setter; @Getter @Setter diff --git a/src/main/java/page/clab/api/domain/members/activityPhoto/application/dto/response/ActivityPhotoResponseDto.java b/src/main/java/page/clab/api/domain/members/activityPhoto/application/dto/response/ActivityPhotoResponseDto.java index 01b763ba6..612d24e87 100644 --- a/src/main/java/page/clab/api/domain/members/activityPhoto/application/dto/response/ActivityPhotoResponseDto.java +++ b/src/main/java/page/clab/api/domain/members/activityPhoto/application/dto/response/ActivityPhotoResponseDto.java @@ -1,12 +1,11 @@ package page.clab.api.domain.members.activityPhoto.application.dto.response; -import lombok.Builder; -import lombok.Getter; -import page.clab.api.global.common.file.dto.response.UploadedFileResponseDto; - import java.time.LocalDate; import java.time.LocalDateTime; import java.util.List; +import lombok.Builder; +import lombok.Getter; +import page.clab.api.global.common.file.dto.response.UploadedFileResponseDto; @Getter @Builder diff --git a/src/main/java/page/clab/api/domain/members/activityPhoto/application/port/in/RegisterActivityPhotoUseCase.java b/src/main/java/page/clab/api/domain/members/activityPhoto/application/port/in/RegisterActivityPhotoUseCase.java index bdbbca13d..4bc050739 100644 --- a/src/main/java/page/clab/api/domain/members/activityPhoto/application/port/in/RegisterActivityPhotoUseCase.java +++ b/src/main/java/page/clab/api/domain/members/activityPhoto/application/port/in/RegisterActivityPhotoUseCase.java @@ -3,5 +3,6 @@ import page.clab.api.domain.members.activityPhoto.application.dto.request.ActivityPhotoRequestDto; public interface RegisterActivityPhotoUseCase { + Long registerActivityPhoto(ActivityPhotoRequestDto requestDto); } diff --git a/src/main/java/page/clab/api/domain/members/activityPhoto/application/port/in/RemoveActivityPhotoUseCase.java b/src/main/java/page/clab/api/domain/members/activityPhoto/application/port/in/RemoveActivityPhotoUseCase.java index fa98fa96c..a25cb50b0 100644 --- a/src/main/java/page/clab/api/domain/members/activityPhoto/application/port/in/RemoveActivityPhotoUseCase.java +++ b/src/main/java/page/clab/api/domain/members/activityPhoto/application/port/in/RemoveActivityPhotoUseCase.java @@ -1,5 +1,6 @@ package page.clab.api.domain.members.activityPhoto.application.port.in; public interface RemoveActivityPhotoUseCase { + Long removeActivityPhoto(Long activityPhotoId); } diff --git a/src/main/java/page/clab/api/domain/members/activityPhoto/application/port/in/RetrieveActivityPhotoUseCase.java b/src/main/java/page/clab/api/domain/members/activityPhoto/application/port/in/RetrieveActivityPhotoUseCase.java index 31a80a86d..690c29a43 100644 --- a/src/main/java/page/clab/api/domain/members/activityPhoto/application/port/in/RetrieveActivityPhotoUseCase.java +++ b/src/main/java/page/clab/api/domain/members/activityPhoto/application/port/in/RetrieveActivityPhotoUseCase.java @@ -5,5 +5,6 @@ import page.clab.api.global.common.dto.PagedResponseDto; public interface RetrieveActivityPhotoUseCase { + PagedResponseDto retrieveActivityPhotos(Boolean isPublic, Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/members/activityPhoto/application/port/in/ToggleActivityPhotoVisibilityUseCase.java b/src/main/java/page/clab/api/domain/members/activityPhoto/application/port/in/ToggleActivityPhotoVisibilityUseCase.java index 1fd1d36b5..d9dcda5f4 100644 --- a/src/main/java/page/clab/api/domain/members/activityPhoto/application/port/in/ToggleActivityPhotoVisibilityUseCase.java +++ b/src/main/java/page/clab/api/domain/members/activityPhoto/application/port/in/ToggleActivityPhotoVisibilityUseCase.java @@ -1,5 +1,6 @@ package page.clab.api.domain.members.activityPhoto.application.port.in; public interface ToggleActivityPhotoVisibilityUseCase { + Long toggleActivityPhotoVisibility(Long activityPhotoId); } diff --git a/src/main/java/page/clab/api/domain/members/activityPhoto/application/port/out/RegisterActivityPhotoPort.java b/src/main/java/page/clab/api/domain/members/activityPhoto/application/port/out/RegisterActivityPhotoPort.java index d95d76de7..9884f0187 100644 --- a/src/main/java/page/clab/api/domain/members/activityPhoto/application/port/out/RegisterActivityPhotoPort.java +++ b/src/main/java/page/clab/api/domain/members/activityPhoto/application/port/out/RegisterActivityPhotoPort.java @@ -3,5 +3,6 @@ import page.clab.api.domain.members.activityPhoto.domain.ActivityPhoto; public interface RegisterActivityPhotoPort { + ActivityPhoto save(ActivityPhoto activityPhoto); } diff --git a/src/main/java/page/clab/api/domain/members/activityPhoto/application/service/ActivityPhotoRegisterService.java b/src/main/java/page/clab/api/domain/members/activityPhoto/application/service/ActivityPhotoRegisterService.java index 5482a9a9d..b5cadfd85 100644 --- a/src/main/java/page/clab/api/domain/members/activityPhoto/application/service/ActivityPhotoRegisterService.java +++ b/src/main/java/page/clab/api/domain/members/activityPhoto/application/service/ActivityPhotoRegisterService.java @@ -1,5 +1,6 @@ package page.clab.api.domain.members.activityPhoto.application.service; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -11,8 +12,6 @@ import page.clab.api.global.common.file.application.UploadedFileService; import page.clab.api.global.common.file.domain.UploadedFile; -import java.util.List; - @Service @RequiredArgsConstructor public class ActivityPhotoRegisterService implements RegisterActivityPhotoUseCase { diff --git a/src/main/java/page/clab/api/domain/members/activityPhoto/domain/ActivityPhoto.java b/src/main/java/page/clab/api/domain/members/activityPhoto/domain/ActivityPhoto.java index ae497f5ad..a35ce5328 100644 --- a/src/main/java/page/clab/api/domain/members/activityPhoto/domain/ActivityPhoto.java +++ b/src/main/java/page/clab/api/domain/members/activityPhoto/domain/ActivityPhoto.java @@ -1,5 +1,7 @@ package page.clab.api.domain.members.activityPhoto.domain; +import java.time.LocalDate; +import java.util.List; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -9,9 +11,6 @@ import page.clab.api.global.common.domain.BaseEntity; import page.clab.api.global.common.file.domain.UploadedFile; -import java.time.LocalDate; -import java.util.List; - @Getter @Setter @Builder diff --git a/src/main/java/page/clab/api/domain/members/blog/adapter/in/web/BlogDetailsRetrievalController.java b/src/main/java/page/clab/api/domain/members/blog/adapter/in/web/BlogDetailsRetrievalController.java index 6d438c828..c436b798b 100644 --- a/src/main/java/page/clab/api/domain/members/blog/adapter/in/web/BlogDetailsRetrievalController.java +++ b/src/main/java/page/clab/api/domain/members/blog/adapter/in/web/BlogDetailsRetrievalController.java @@ -24,7 +24,7 @@ public class BlogDetailsRetrievalController { @PreAuthorize("hasRole('GUEST')") @GetMapping("/{blogId}") public ApiResponse retrieveBlogDetails( - @PathVariable(name = "blogId") Long blogId + @PathVariable(name = "blogId") Long blogId ) { BlogDetailsResponseDto blog = retrieveBlogDetailsUseCase.retrieveBlogDetails(blogId); return ApiResponse.success(blog); diff --git a/src/main/java/page/clab/api/domain/members/blog/adapter/in/web/BlogRegisterController.java b/src/main/java/page/clab/api/domain/members/blog/adapter/in/web/BlogRegisterController.java index 5a5583aaa..6ea18f446 100644 --- a/src/main/java/page/clab/api/domain/members/blog/adapter/in/web/BlogRegisterController.java +++ b/src/main/java/page/clab/api/domain/members/blog/adapter/in/web/BlogRegisterController.java @@ -25,7 +25,7 @@ public class BlogRegisterController { @PreAuthorize("hasRole('ADMIN')") @PostMapping("") public ApiResponse registerBlog( - @Valid @RequestBody BlogRequestDto requestDto + @Valid @RequestBody BlogRequestDto requestDto ) { Long id = registerBlogUseCase.registerBlog(requestDto); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/members/blog/adapter/in/web/BlogRemoveController.java b/src/main/java/page/clab/api/domain/members/blog/adapter/in/web/BlogRemoveController.java index f435a724f..54e58a5e7 100644 --- a/src/main/java/page/clab/api/domain/members/blog/adapter/in/web/BlogRemoveController.java +++ b/src/main/java/page/clab/api/domain/members/blog/adapter/in/web/BlogRemoveController.java @@ -24,7 +24,7 @@ public class BlogRemoveController { @PreAuthorize("hasRole('ADMIN')") @DeleteMapping("/{blogId}") public ApiResponse removeBlog( - @PathVariable(name = "blogId") Long blogId + @PathVariable(name = "blogId") Long blogId ) throws PermissionDeniedException { Long id = removeBlogUseCase.removeBlog(blogId); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/members/blog/adapter/in/web/BlogUpdateController.java b/src/main/java/page/clab/api/domain/members/blog/adapter/in/web/BlogUpdateController.java index 396703d7f..e57842975 100644 --- a/src/main/java/page/clab/api/domain/members/blog/adapter/in/web/BlogUpdateController.java +++ b/src/main/java/page/clab/api/domain/members/blog/adapter/in/web/BlogUpdateController.java @@ -27,8 +27,8 @@ public class BlogUpdateController { @PreAuthorize("hasRole('ADMIN')") @PatchMapping("/{blogId}") public ApiResponse updateBlog( - @PathVariable(name = "blogId") Long blogId, - @Valid @RequestBody BlogUpdateRequestDto requestDto + @PathVariable(name = "blogId") Long blogId, + @Valid @RequestBody BlogUpdateRequestDto requestDto ) throws PermissionDeniedException { Long id = updateBlogUseCase.updateBlog(blogId, requestDto); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/members/blog/adapter/in/web/BlogsRetrievalController.java b/src/main/java/page/clab/api/domain/members/blog/adapter/in/web/BlogsRetrievalController.java index 5ce48c2bd..c2f7b24ff 100644 --- a/src/main/java/page/clab/api/domain/members/blog/adapter/in/web/BlogsRetrievalController.java +++ b/src/main/java/page/clab/api/domain/members/blog/adapter/in/web/BlogsRetrievalController.java @@ -2,6 +2,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.security.access.prepost.PreAuthorize; @@ -17,8 +18,6 @@ import page.clab.api.global.exception.SortingArgumentException; import page.clab.api.global.util.PageableUtils; -import java.util.List; - @RestController @RequestMapping("/api/v1/blogs") @RequiredArgsConstructor @@ -29,18 +28,18 @@ public class BlogsRetrievalController { private final PageableUtils pageableUtils; @Operation(summary = "[G] 블로그 포스트 조회(제목, 작성자명 기준)", description = "ROLE_GUEST 이상의 권한이 필요함
" + - "2개의 파라미터를 자유롭게 조합하여 필터링 가능
" + - "제목, 작성자명 중 하나라도 입력하지 않으면 전체 조회됨
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") + "2개의 파라미터를 자유롭게 조합하여 필터링 가능
" + + "제목, 작성자명 중 하나라도 입력하지 않으면 전체 조회됨
" + + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") @PreAuthorize("hasRole('GUEST')") @GetMapping("") public ApiResponse> retrieveBlogs( - @RequestParam(name = "title", required = false) String title, - @RequestParam(name = "memberName", required = false) String memberName, - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection + @RequestParam(name = "title", required = false) String title, + @RequestParam(name = "memberName", required = false) String memberName, + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection ) throws SortingArgumentException, InvalidColumnException { Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, BlogResponseDto.class); PagedResponseDto blogs = retrieveBlogsUseCase.retrieveBlogs(title, memberName, pageable); diff --git a/src/main/java/page/clab/api/domain/members/blog/adapter/in/web/DeletedBlogsRetrievalController.java b/src/main/java/page/clab/api/domain/members/blog/adapter/in/web/DeletedBlogsRetrievalController.java index b6d40bf8f..145119d8a 100644 --- a/src/main/java/page/clab/api/domain/members/blog/adapter/in/web/DeletedBlogsRetrievalController.java +++ b/src/main/java/page/clab/api/domain/members/blog/adapter/in/web/DeletedBlogsRetrievalController.java @@ -27,8 +27,8 @@ public class DeletedBlogsRetrievalController { @PreAuthorize("hasRole('SUPER')") @GetMapping("/deleted") public ApiResponse> retrieveDeletedBlogs( - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size ) { Pageable pageable = PageRequest.of(page, size); PagedResponseDto blogs = retrieveDeletedBlogsUseCase.retrieveDeletedBlogs(pageable); diff --git a/src/main/java/page/clab/api/domain/members/blog/adapter/out/persistence/BlogPersistenceAdapter.java b/src/main/java/page/clab/api/domain/members/blog/adapter/out/persistence/BlogPersistenceAdapter.java index ab374db25..6ab54440a 100644 --- a/src/main/java/page/clab/api/domain/members/blog/adapter/out/persistence/BlogPersistenceAdapter.java +++ b/src/main/java/page/clab/api/domain/members/blog/adapter/out/persistence/BlogPersistenceAdapter.java @@ -12,8 +12,8 @@ @Component @RequiredArgsConstructor public class BlogPersistenceAdapter implements - RegisterBlogPort, - RetrieveBlogPort { + RegisterBlogPort, + RetrieveBlogPort { private final BlogRepository blogRepository; private final BlogMapper blogMapper; @@ -28,19 +28,19 @@ public Blog save(Blog blog) { @Override public Blog getById(Long blogId) { return blogRepository.findById(blogId) - .map(blogMapper::toDomain) - .orElseThrow(() -> new NotFoundException("[Blog] id: " + blogId + "에 해당하는 게시글이 존재하지 않습니다.")); + .map(blogMapper::toDomain) + .orElseThrow(() -> new NotFoundException("[Blog] id: " + blogId + "에 해당하는 게시글이 존재하지 않습니다.")); } @Override public Page findByConditions(String title, String memberName, Pageable pageable) { return blogRepository.findByConditions(title, memberName, pageable) - .map(blogMapper::toDomain); + .map(blogMapper::toDomain); } @Override public Page findAllByIsDeletedTrue(Pageable pageable) { return blogRepository.findAllByIsDeletedTrue(pageable) - .map(blogMapper::toDomain); + .map(blogMapper::toDomain); } } diff --git a/src/main/java/page/clab/api/domain/members/blog/adapter/out/persistence/BlogRepository.java b/src/main/java/page/clab/api/domain/members/blog/adapter/out/persistence/BlogRepository.java index 2bc4e8ad4..0fc2a2c9d 100644 --- a/src/main/java/page/clab/api/domain/members/blog/adapter/out/persistence/BlogRepository.java +++ b/src/main/java/page/clab/api/domain/members/blog/adapter/out/persistence/BlogRepository.java @@ -1,5 +1,6 @@ package page.clab.api.domain.members.blog.adapter.out.persistence; +import java.util.List; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; @@ -7,10 +8,9 @@ import org.springframework.data.querydsl.QuerydslPredicateExecutor; import org.springframework.stereotype.Repository; -import java.util.List; - @Repository -public interface BlogRepository extends JpaRepository, BlogRepositoryCustom, QuerydslPredicateExecutor { +public interface BlogRepository extends JpaRepository, BlogRepositoryCustom, + QuerydslPredicateExecutor { @Query(value = "SELECT b.* FROM blog b WHERE b.is_deleted = true", nativeQuery = true) Page findAllByIsDeletedTrue(Pageable pageable); diff --git a/src/main/java/page/clab/api/domain/members/blog/adapter/out/persistence/BlogRepositoryCustom.java b/src/main/java/page/clab/api/domain/members/blog/adapter/out/persistence/BlogRepositoryCustom.java index 7f5043125..1863521b3 100644 --- a/src/main/java/page/clab/api/domain/members/blog/adapter/out/persistence/BlogRepositoryCustom.java +++ b/src/main/java/page/clab/api/domain/members/blog/adapter/out/persistence/BlogRepositoryCustom.java @@ -4,5 +4,6 @@ import org.springframework.data.domain.Pageable; public interface BlogRepositoryCustom { + Page findByConditions(String title, String memberName, Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/members/blog/adapter/out/persistence/BlogRepositoryImpl.java b/src/main/java/page/clab/api/domain/members/blog/adapter/out/persistence/BlogRepositoryImpl.java index f9aee7430..67a55805c 100644 --- a/src/main/java/page/clab/api/domain/members/blog/adapter/out/persistence/BlogRepositoryImpl.java +++ b/src/main/java/page/clab/api/domain/members/blog/adapter/out/persistence/BlogRepositoryImpl.java @@ -2,6 +2,7 @@ import com.querydsl.core.BooleanBuilder; import com.querydsl.jpa.impl.JPAQueryFactory; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; @@ -10,8 +11,6 @@ import page.clab.api.domain.memberManagement.member.adapter.out.persistence.QMemberJpaEntity; import page.clab.api.global.util.OrderSpecifierUtil; -import java.util.List; - @Repository @RequiredArgsConstructor public class BlogRepositoryImpl implements BlogRepositoryCustom { @@ -25,22 +24,26 @@ public Page findByConditions(String title, String memberName, Pag BooleanBuilder builder = new BooleanBuilder(); - if (title != null && !title.isBlank()) builder.and(blog.title.containsIgnoreCase(title)); - if (memberName != null && !memberName.isBlank()) builder.and(member.name.eq(memberName)); + if (title != null && !title.isBlank()) { + builder.and(blog.title.containsIgnoreCase(title)); + } + if (memberName != null && !memberName.isBlank()) { + builder.and(member.name.eq(memberName)); + } List blogs = queryFactory.selectFrom(blog) - .leftJoin(member).on(blog.memberId.eq(member.id)) - .where(builder) - .orderBy(OrderSpecifierUtil.getOrderSpecifiers(pageable, blog)) - .offset(pageable.getOffset()) - .limit(pageable.getPageSize()) - .fetch(); + .leftJoin(member).on(blog.memberId.eq(member.id)) + .where(builder) + .orderBy(OrderSpecifierUtil.getOrderSpecifiers(pageable, blog)) + .offset(pageable.getOffset()) + .limit(pageable.getPageSize()) + .fetch(); long count = queryFactory - .selectFrom(blog) - .leftJoin(member).on(blog.memberId.eq(member.id)) - .where(builder) - .fetchCount(); + .selectFrom(blog) + .leftJoin(member).on(blog.memberId.eq(member.id)) + .where(builder) + .fetchCount(); return new PageImpl<>(blogs, pageable, count); } diff --git a/src/main/java/page/clab/api/domain/members/blog/application/dto/mapper/BlogDtoMapper.java b/src/main/java/page/clab/api/domain/members/blog/application/dto/mapper/BlogDtoMapper.java index 5d0803380..acb7d0e5f 100644 --- a/src/main/java/page/clab/api/domain/members/blog/application/dto/mapper/BlogDtoMapper.java +++ b/src/main/java/page/clab/api/domain/members/blog/application/dto/mapper/BlogDtoMapper.java @@ -12,39 +12,39 @@ public class BlogDtoMapper { public Blog fromDto(BlogRequestDto requestDto, String memberId) { return Blog.builder() - .memberId(memberId) - .title(requestDto.getTitle()) - .subTitle(requestDto.getSubTitle()) - .content(requestDto.getContent()) - .hyperlink(requestDto.getHyperlink()) - .imageUrl(requestDto.getImageUrl()) - .isDeleted(false) - .build(); + .memberId(memberId) + .title(requestDto.getTitle()) + .subTitle(requestDto.getSubTitle()) + .content(requestDto.getContent()) + .hyperlink(requestDto.getHyperlink()) + .imageUrl(requestDto.getImageUrl()) + .isDeleted(false) + .build(); } public BlogDetailsResponseDto toDto(Blog blog, MemberBasicInfoDto memberInfo, boolean isOwner) { return BlogDetailsResponseDto.builder() - .id(blog.getId()) - .memberId(memberInfo.getMemberId()) - .name(memberInfo.getMemberName()) - .title(blog.getTitle()) - .subTitle(blog.getSubTitle()) - .content(blog.getContent()) - .imageUrl(blog.getImageUrl()) - .hyperlink(blog.getHyperlink()) - .isOwner(isOwner) - .createdAt(blog.getCreatedAt()) - .build(); + .id(blog.getId()) + .memberId(memberInfo.getMemberId()) + .name(memberInfo.getMemberName()) + .title(blog.getTitle()) + .subTitle(blog.getSubTitle()) + .content(blog.getContent()) + .imageUrl(blog.getImageUrl()) + .hyperlink(blog.getHyperlink()) + .isOwner(isOwner) + .createdAt(blog.getCreatedAt()) + .build(); } public BlogResponseDto toDto(Blog blog) { return BlogResponseDto.builder() - .id(blog.getId()) - .title(blog.getTitle()) - .subTitle(blog.getSubTitle()) - .imageUrl(blog.getImageUrl()) - .hyperlink(blog.getHyperlink()) - .createdAt(blog.getCreatedAt()) - .build(); + .id(blog.getId()) + .title(blog.getTitle()) + .subTitle(blog.getSubTitle()) + .imageUrl(blog.getImageUrl()) + .hyperlink(blog.getHyperlink()) + .createdAt(blog.getCreatedAt()) + .build(); } } diff --git a/src/main/java/page/clab/api/domain/members/blog/application/dto/response/BlogDetailsResponseDto.java b/src/main/java/page/clab/api/domain/members/blog/application/dto/response/BlogDetailsResponseDto.java index 672971b4b..a8af2bb19 100644 --- a/src/main/java/page/clab/api/domain/members/blog/application/dto/response/BlogDetailsResponseDto.java +++ b/src/main/java/page/clab/api/domain/members/blog/application/dto/response/BlogDetailsResponseDto.java @@ -1,11 +1,10 @@ package page.clab.api.domain.members.blog.application.dto.response; import com.fasterxml.jackson.annotation.JsonProperty; +import java.time.LocalDateTime; import lombok.Builder; import lombok.Getter; -import java.time.LocalDateTime; - @Getter @Builder public class BlogDetailsResponseDto { diff --git a/src/main/java/page/clab/api/domain/members/blog/application/dto/response/BlogResponseDto.java b/src/main/java/page/clab/api/domain/members/blog/application/dto/response/BlogResponseDto.java index 7fce3e1c3..5c3fdfb4a 100644 --- a/src/main/java/page/clab/api/domain/members/blog/application/dto/response/BlogResponseDto.java +++ b/src/main/java/page/clab/api/domain/members/blog/application/dto/response/BlogResponseDto.java @@ -1,10 +1,9 @@ package page.clab.api.domain.members.blog.application.dto.response; +import java.time.LocalDateTime; import lombok.Builder; import lombok.Getter; -import java.time.LocalDateTime; - @Getter @Builder public class BlogResponseDto { diff --git a/src/main/java/page/clab/api/domain/members/blog/application/port/in/RegisterBlogUseCase.java b/src/main/java/page/clab/api/domain/members/blog/application/port/in/RegisterBlogUseCase.java index d4c542419..c9931091f 100644 --- a/src/main/java/page/clab/api/domain/members/blog/application/port/in/RegisterBlogUseCase.java +++ b/src/main/java/page/clab/api/domain/members/blog/application/port/in/RegisterBlogUseCase.java @@ -3,5 +3,6 @@ import page.clab.api.domain.members.blog.application.dto.request.BlogRequestDto; public interface RegisterBlogUseCase { + Long registerBlog(BlogRequestDto requestDto); } diff --git a/src/main/java/page/clab/api/domain/members/blog/application/port/in/RemoveBlogUseCase.java b/src/main/java/page/clab/api/domain/members/blog/application/port/in/RemoveBlogUseCase.java index c16f038c0..72ddccfeb 100644 --- a/src/main/java/page/clab/api/domain/members/blog/application/port/in/RemoveBlogUseCase.java +++ b/src/main/java/page/clab/api/domain/members/blog/application/port/in/RemoveBlogUseCase.java @@ -3,5 +3,6 @@ import page.clab.api.global.exception.PermissionDeniedException; public interface RemoveBlogUseCase { + Long removeBlog(Long blogId) throws PermissionDeniedException; } diff --git a/src/main/java/page/clab/api/domain/members/blog/application/port/in/RetrieveBlogDetailsUseCase.java b/src/main/java/page/clab/api/domain/members/blog/application/port/in/RetrieveBlogDetailsUseCase.java index 5a5761344..0f7023a73 100644 --- a/src/main/java/page/clab/api/domain/members/blog/application/port/in/RetrieveBlogDetailsUseCase.java +++ b/src/main/java/page/clab/api/domain/members/blog/application/port/in/RetrieveBlogDetailsUseCase.java @@ -3,5 +3,6 @@ import page.clab.api.domain.members.blog.application.dto.response.BlogDetailsResponseDto; public interface RetrieveBlogDetailsUseCase { + BlogDetailsResponseDto retrieveBlogDetails(Long blogId); } diff --git a/src/main/java/page/clab/api/domain/members/blog/application/port/in/RetrieveBlogsUseCase.java b/src/main/java/page/clab/api/domain/members/blog/application/port/in/RetrieveBlogsUseCase.java index 8f583ca32..fe60f09be 100644 --- a/src/main/java/page/clab/api/domain/members/blog/application/port/in/RetrieveBlogsUseCase.java +++ b/src/main/java/page/clab/api/domain/members/blog/application/port/in/RetrieveBlogsUseCase.java @@ -5,5 +5,6 @@ import page.clab.api.global.common.dto.PagedResponseDto; public interface RetrieveBlogsUseCase { + PagedResponseDto retrieveBlogs(String title, String memberName, Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/members/blog/application/port/in/RetrieveDeletedBlogsUseCase.java b/src/main/java/page/clab/api/domain/members/blog/application/port/in/RetrieveDeletedBlogsUseCase.java index 43ec1ad0a..6c0e38bdb 100644 --- a/src/main/java/page/clab/api/domain/members/blog/application/port/in/RetrieveDeletedBlogsUseCase.java +++ b/src/main/java/page/clab/api/domain/members/blog/application/port/in/RetrieveDeletedBlogsUseCase.java @@ -5,5 +5,6 @@ import page.clab.api.global.common.dto.PagedResponseDto; public interface RetrieveDeletedBlogsUseCase { + PagedResponseDto retrieveDeletedBlogs(Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/members/blog/application/port/in/UpdateBlogUseCase.java b/src/main/java/page/clab/api/domain/members/blog/application/port/in/UpdateBlogUseCase.java index d872c6806..937af31e1 100644 --- a/src/main/java/page/clab/api/domain/members/blog/application/port/in/UpdateBlogUseCase.java +++ b/src/main/java/page/clab/api/domain/members/blog/application/port/in/UpdateBlogUseCase.java @@ -4,5 +4,6 @@ import page.clab.api.global.exception.PermissionDeniedException; public interface UpdateBlogUseCase { + Long updateBlog(Long blogId, BlogUpdateRequestDto requestDto) throws PermissionDeniedException; } diff --git a/src/main/java/page/clab/api/domain/members/blog/application/port/out/RegisterBlogPort.java b/src/main/java/page/clab/api/domain/members/blog/application/port/out/RegisterBlogPort.java index 20cb6ac4c..a0777c904 100644 --- a/src/main/java/page/clab/api/domain/members/blog/application/port/out/RegisterBlogPort.java +++ b/src/main/java/page/clab/api/domain/members/blog/application/port/out/RegisterBlogPort.java @@ -3,5 +3,6 @@ import page.clab.api.domain.members.blog.domain.Blog; public interface RegisterBlogPort { + Blog save(Blog blog); } diff --git a/src/main/java/page/clab/api/domain/members/blog/application/service/DeletedBlogsRetrievalService.java b/src/main/java/page/clab/api/domain/members/blog/application/service/DeletedBlogsRetrievalService.java index aeb179c17..78bdb33ee 100644 --- a/src/main/java/page/clab/api/domain/members/blog/application/service/DeletedBlogsRetrievalService.java +++ b/src/main/java/page/clab/api/domain/members/blog/application/service/DeletedBlogsRetrievalService.java @@ -27,6 +27,7 @@ public class DeletedBlogsRetrievalService implements RetrieveDeletedBlogsUseCase public PagedResponseDto retrieveDeletedBlogs(Pageable pageable) { MemberBasicInfoDto currentMemberInfo = externalRetrieveMemberUseCase.getCurrentMemberBasicInfo(); Page blogs = retrieveBlogPort.findAllByIsDeletedTrue(pageable); - return new PagedResponseDto<>(blogs.map(blog -> mapper.toDto(blog, currentMemberInfo, blog.isOwner(currentMemberInfo.getMemberId())))); + return new PagedResponseDto<>( + blogs.map(blog -> mapper.toDto(blog, currentMemberInfo, blog.isOwner(currentMemberInfo.getMemberId())))); } } diff --git a/src/main/java/page/clab/api/domain/members/blog/domain/Blog.java b/src/main/java/page/clab/api/domain/members/blog/domain/Blog.java index a89e21ed4..bd1bfe656 100644 --- a/src/main/java/page/clab/api/domain/members/blog/domain/Blog.java +++ b/src/main/java/page/clab/api/domain/members/blog/domain/Blog.java @@ -1,5 +1,7 @@ package page.clab.api.domain.members.blog.domain; +import java.time.LocalDateTime; +import java.util.Optional; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -10,9 +12,6 @@ import page.clab.api.domain.members.blog.application.dto.request.BlogUpdateRequestDto; import page.clab.api.global.exception.PermissionDeniedException; -import java.time.LocalDateTime; -import java.util.Optional; - @Getter @Setter @Builder diff --git a/src/main/java/page/clab/api/domain/members/donation/adapter/in/web/DeletedDonationsRetrievalController.java b/src/main/java/page/clab/api/domain/members/donation/adapter/in/web/DeletedDonationsRetrievalController.java index 29851e041..ae3c9bcbc 100644 --- a/src/main/java/page/clab/api/domain/members/donation/adapter/in/web/DeletedDonationsRetrievalController.java +++ b/src/main/java/page/clab/api/domain/members/donation/adapter/in/web/DeletedDonationsRetrievalController.java @@ -27,11 +27,12 @@ public class DeletedDonationsRetrievalController { @PreAuthorize("hasRole('SUPER')") @GetMapping("/deleted") public ApiResponse> retrieveDeletedDonations( - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size ) { Pageable pageable = PageRequest.of(page, size); - PagedResponseDto donations = retrieveDeletedDonationsUseCase.retrieveDeletedDonations(pageable); + PagedResponseDto donations = retrieveDeletedDonationsUseCase.retrieveDeletedDonations( + pageable); return ApiResponse.success(donations); } } diff --git a/src/main/java/page/clab/api/domain/members/donation/adapter/in/web/DonationRegisterController.java b/src/main/java/page/clab/api/domain/members/donation/adapter/in/web/DonationRegisterController.java index 93faaf362..b514e9f3d 100644 --- a/src/main/java/page/clab/api/domain/members/donation/adapter/in/web/DonationRegisterController.java +++ b/src/main/java/page/clab/api/domain/members/donation/adapter/in/web/DonationRegisterController.java @@ -25,7 +25,7 @@ public class DonationRegisterController { @PreAuthorize("hasRole('SUPER')") @PostMapping("") public ApiResponse registerDonation( - @Valid @RequestBody DonationRequestDto requestDto + @Valid @RequestBody DonationRequestDto requestDto ) { Long id = registerDonationUseCase.registerDonation(requestDto); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/members/donation/adapter/in/web/DonationRemoveController.java b/src/main/java/page/clab/api/domain/members/donation/adapter/in/web/DonationRemoveController.java index ce4b804b9..043d05fad 100644 --- a/src/main/java/page/clab/api/domain/members/donation/adapter/in/web/DonationRemoveController.java +++ b/src/main/java/page/clab/api/domain/members/donation/adapter/in/web/DonationRemoveController.java @@ -24,7 +24,7 @@ public class DonationRemoveController { @PreAuthorize("hasRole('SUPER')") @DeleteMapping("/{donationId}") public ApiResponse removeDonation( - @PathVariable(name = "donationId") Long donationId + @PathVariable(name = "donationId") Long donationId ) throws PermissionDeniedException { Long id = removeDonationUseCase.removeDonation(donationId); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/members/donation/adapter/in/web/DonationUpdateController.java b/src/main/java/page/clab/api/domain/members/donation/adapter/in/web/DonationUpdateController.java index bed1e3994..6330a905c 100644 --- a/src/main/java/page/clab/api/domain/members/donation/adapter/in/web/DonationUpdateController.java +++ b/src/main/java/page/clab/api/domain/members/donation/adapter/in/web/DonationUpdateController.java @@ -27,8 +27,8 @@ public class DonationUpdateController { @PreAuthorize("hasRole('SUPER')") @PatchMapping("/{donationId}") public ApiResponse updateDonation( - @PathVariable(name = "donationId") Long donationId, - @Valid @RequestBody DonationUpdateRequestDto requestDto + @PathVariable(name = "donationId") Long donationId, + @Valid @RequestBody DonationUpdateRequestDto requestDto ) throws PermissionDeniedException { Long id = updateDonationUseCase.updateDonation(donationId, requestDto); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/members/donation/adapter/in/web/DonationsByConditionsRetrievalController.java b/src/main/java/page/clab/api/domain/members/donation/adapter/in/web/DonationsByConditionsRetrievalController.java index 9a0d95ad1..a4331f5cc 100644 --- a/src/main/java/page/clab/api/domain/members/donation/adapter/in/web/DonationsByConditionsRetrievalController.java +++ b/src/main/java/page/clab/api/domain/members/donation/adapter/in/web/DonationsByConditionsRetrievalController.java @@ -2,6 +2,8 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import java.time.LocalDate; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.security.access.prepost.PreAuthorize; @@ -17,9 +19,6 @@ import page.clab.api.global.exception.SortingArgumentException; import page.clab.api.global.util.PageableUtils; -import java.time.LocalDate; -import java.util.List; - @RestController @RequestMapping("/api/v1/donations") @RequiredArgsConstructor @@ -30,23 +29,24 @@ public class DonationsByConditionsRetrievalController { private final PageableUtils pageableUtils; @Operation(summary = "[G] 후원 목록 조회(멤버 ID, 멤버 이름, 기간 기준)", description = "ROLE_GUEST 이상의 권한이 필요함
" + - "3개의 파라미터를 자유롭게 조합하여 필터링 가능
" + - "멤버 ID, 멤버 이름, 기간 중 하나라도 입력하지 않으면 전체 조회됨
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") + "3개의 파라미터를 자유롭게 조합하여 필터링 가능
" + + "멤버 ID, 멤버 이름, 기간 중 하나라도 입력하지 않으면 전체 조회됨
" + + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") @PreAuthorize("hasRole('GUEST')") @GetMapping("") public ApiResponse> retrieveDonationsByConditions( - @RequestParam(name = "memberId", required = false) String memberId, - @RequestParam(name = "name", required = false) String name, - @RequestParam(name = "startDate", required = false) LocalDate startDate, - @RequestParam(name = "endDate", required = false) LocalDate endDate, - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection + @RequestParam(name = "memberId", required = false) String memberId, + @RequestParam(name = "name", required = false) String name, + @RequestParam(name = "startDate", required = false) LocalDate startDate, + @RequestParam(name = "endDate", required = false) LocalDate endDate, + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection ) throws SortingArgumentException, InvalidColumnException { Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, DonationResponseDto.class); - PagedResponseDto donations = retrieveDonationsByConditionsUseCase.retrieveDonations(memberId, name, startDate, endDate, pageable); + PagedResponseDto donations = retrieveDonationsByConditionsUseCase.retrieveDonations( + memberId, name, startDate, endDate, pageable); return ApiResponse.success(donations); } } diff --git a/src/main/java/page/clab/api/domain/members/donation/adapter/in/web/MyDonationsRetrievalController.java b/src/main/java/page/clab/api/domain/members/donation/adapter/in/web/MyDonationsRetrievalController.java index d298ee315..df739d0d4 100644 --- a/src/main/java/page/clab/api/domain/members/donation/adapter/in/web/MyDonationsRetrievalController.java +++ b/src/main/java/page/clab/api/domain/members/donation/adapter/in/web/MyDonationsRetrievalController.java @@ -2,6 +2,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.security.access.prepost.PreAuthorize; @@ -17,8 +18,6 @@ import page.clab.api.global.exception.SortingArgumentException; import page.clab.api.global.util.PageableUtils; -import java.util.List; - @RestController @RequestMapping("/api/v1/donations") @RequiredArgsConstructor @@ -29,14 +28,14 @@ public class MyDonationsRetrievalController { private final PageableUtils pageableUtils; @Operation(summary = "[G] 나의 후원 정보", description = "ROLE_GUEST 이상의 권한이 필요함
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") @PreAuthorize("hasRole('GUEST')") @GetMapping("/my-donations") public ApiResponse> retrieveMyDonations( - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection ) throws SortingArgumentException, InvalidColumnException { Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, DonationResponseDto.class); PagedResponseDto donations = retrieveMyDonationsUseCase.retrieveMyDonations(pageable); diff --git a/src/main/java/page/clab/api/domain/members/donation/adapter/out/persistence/DonationPersistenceAdapter.java b/src/main/java/page/clab/api/domain/members/donation/adapter/out/persistence/DonationPersistenceAdapter.java index 0a25f2b96..4c2747ad8 100644 --- a/src/main/java/page/clab/api/domain/members/donation/adapter/out/persistence/DonationPersistenceAdapter.java +++ b/src/main/java/page/clab/api/domain/members/donation/adapter/out/persistence/DonationPersistenceAdapter.java @@ -1,5 +1,6 @@ package page.clab.api.domain.members.donation.adapter.out.persistence; +import java.time.LocalDate; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -9,13 +10,11 @@ import page.clab.api.domain.members.donation.domain.Donation; import page.clab.api.global.exception.NotFoundException; -import java.time.LocalDate; - @Component @RequiredArgsConstructor public class DonationPersistenceAdapter implements - RegisterDonationPort, - RetrieveDonationPort { + RegisterDonationPort, + RetrieveDonationPort { private final DonationRepository repository; private final DonationMapper donationMapper; @@ -30,25 +29,26 @@ public Donation save(Donation donation) { @Override public Page findAllByIsDeletedTrue(Pageable pageable) { return repository.findAllByIsDeletedTrue(pageable) - .map(donationMapper::toDomain); + .map(donationMapper::toDomain); } @Override - public Page findByConditions(String memberId, String name, LocalDate startDate, LocalDate endDate, Pageable pageable) { + public Page findByConditions(String memberId, String name, LocalDate startDate, LocalDate endDate, + Pageable pageable) { return repository.findByConditions(memberId, name, startDate, endDate, pageable) - .map(donationMapper::toDomain); + .map(donationMapper::toDomain); } @Override public Donation getById(Long donationId) { return repository.findById(donationId) - .map(donationMapper::toDomain) - .orElseThrow(() -> new NotFoundException("[Donation] id: " + donationId + "에 해당하는 후원이 존재하지 않습니다.")); + .map(donationMapper::toDomain) + .orElseThrow(() -> new NotFoundException("[Donation] id: " + donationId + "에 해당하는 후원이 존재하지 않습니다.")); } @Override public Page findByMemberId(String memberId, Pageable pageable) { return repository.findByMemberId(memberId, pageable) - .map(donationMapper::toDomain); + .map(donationMapper::toDomain); } } diff --git a/src/main/java/page/clab/api/domain/members/donation/adapter/out/persistence/DonationRepository.java b/src/main/java/page/clab/api/domain/members/donation/adapter/out/persistence/DonationRepository.java index c158f2e68..d9d09ba08 100644 --- a/src/main/java/page/clab/api/domain/members/donation/adapter/out/persistence/DonationRepository.java +++ b/src/main/java/page/clab/api/domain/members/donation/adapter/out/persistence/DonationRepository.java @@ -8,7 +8,8 @@ import org.springframework.stereotype.Repository; @Repository -public interface DonationRepository extends JpaRepository, DonationRepositoryCustom, QuerydslPredicateExecutor { +public interface DonationRepository extends JpaRepository, DonationRepositoryCustom, + QuerydslPredicateExecutor { Page findByMemberId(String memberId, Pageable pageable); diff --git a/src/main/java/page/clab/api/domain/members/donation/adapter/out/persistence/DonationRepositoryCustom.java b/src/main/java/page/clab/api/domain/members/donation/adapter/out/persistence/DonationRepositoryCustom.java index 62e406f0c..bc286b108 100644 --- a/src/main/java/page/clab/api/domain/members/donation/adapter/out/persistence/DonationRepositoryCustom.java +++ b/src/main/java/page/clab/api/domain/members/donation/adapter/out/persistence/DonationRepositoryCustom.java @@ -1,10 +1,11 @@ package page.clab.api.domain.members.donation.adapter.out.persistence; +import java.time.LocalDate; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; -import java.time.LocalDate; - public interface DonationRepositoryCustom { - Page findByConditions(String memberId, String name, LocalDate startDate, LocalDate endDate, Pageable pageable); + + Page findByConditions(String memberId, String name, LocalDate startDate, LocalDate endDate, + Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/members/donation/adapter/out/persistence/DonationRepositoryImpl.java b/src/main/java/page/clab/api/domain/members/donation/adapter/out/persistence/DonationRepositoryImpl.java index 70a4cbc5b..a1a03b829 100644 --- a/src/main/java/page/clab/api/domain/members/donation/adapter/out/persistence/DonationRepositoryImpl.java +++ b/src/main/java/page/clab/api/domain/members/donation/adapter/out/persistence/DonationRepositoryImpl.java @@ -2,6 +2,8 @@ import com.querydsl.core.BooleanBuilder; import com.querydsl.jpa.impl.JPAQueryFactory; +import java.time.LocalDate; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; @@ -10,9 +12,6 @@ import page.clab.api.domain.memberManagement.member.adapter.out.persistence.QMemberJpaEntity; import page.clab.api.global.util.OrderSpecifierUtil; -import java.time.LocalDate; -import java.util.List; - @Repository @RequiredArgsConstructor public class DonationRepositoryImpl implements DonationRepositoryCustom { @@ -20,30 +19,39 @@ public class DonationRepositoryImpl implements DonationRepositoryCustom { private final JPAQueryFactory queryFactory; @Override - public Page findByConditions(String memberId, String name, LocalDate startDate, LocalDate endDate, Pageable pageable) { + public Page findByConditions(String memberId, String name, LocalDate startDate, + LocalDate endDate, Pageable pageable) { QDonationJpaEntity donation = QDonationJpaEntity.donationJpaEntity; QMemberJpaEntity member = QMemberJpaEntity.memberJpaEntity; BooleanBuilder builder = new BooleanBuilder(); - if (memberId != null && !memberId.isBlank()) builder.and(donation.memberId.eq(memberId)); - if (name != null && !name.isBlank()) builder.and(member.name.containsIgnoreCase(name)); - if (startDate != null) builder.and(donation.createdAt.goe(startDate.atStartOfDay())); - if (endDate != null) builder.and(donation.createdAt.loe(endDate.plusDays(1).atStartOfDay())); + if (memberId != null && !memberId.isBlank()) { + builder.and(donation.memberId.eq(memberId)); + } + if (name != null && !name.isBlank()) { + builder.and(member.name.containsIgnoreCase(name)); + } + if (startDate != null) { + builder.and(donation.createdAt.goe(startDate.atStartOfDay())); + } + if (endDate != null) { + builder.and(donation.createdAt.loe(endDate.plusDays(1).atStartOfDay())); + } List results = queryFactory - .selectFrom(donation) - .leftJoin(member).on(donation.memberId.eq(member.id)) - .where(builder) - .orderBy(OrderSpecifierUtil.getOrderSpecifiers(pageable, donation)) - .offset(pageable.getOffset()) - .limit(pageable.getPageSize()) - .fetch(); + .selectFrom(donation) + .leftJoin(member).on(donation.memberId.eq(member.id)) + .where(builder) + .orderBy(OrderSpecifierUtil.getOrderSpecifiers(pageable, donation)) + .offset(pageable.getOffset()) + .limit(pageable.getPageSize()) + .fetch(); long count = queryFactory - .selectFrom(donation) - .leftJoin(member).on(donation.memberId.eq(member.id)) - .where(builder) - .fetchCount(); + .selectFrom(donation) + .leftJoin(member).on(donation.memberId.eq(member.id)) + .where(builder) + .fetchCount(); return new PageImpl<>(results, pageable, count); } diff --git a/src/main/java/page/clab/api/domain/members/donation/application/dto/mapper/DonationDtoMapper.java b/src/main/java/page/clab/api/domain/members/donation/application/dto/mapper/DonationDtoMapper.java index 466002f8d..c5aaaf4e6 100644 --- a/src/main/java/page/clab/api/domain/members/donation/application/dto/mapper/DonationDtoMapper.java +++ b/src/main/java/page/clab/api/domain/members/donation/application/dto/mapper/DonationDtoMapper.java @@ -10,21 +10,21 @@ public class DonationDtoMapper { public Donation fromDto(DonationRequestDto requestDto, String memberId) { return Donation.builder() - .memberId(memberId) - .amount(requestDto.getAmount()) - .message(requestDto.getMessage()) - .isDeleted(false) - .build(); + .memberId(memberId) + .amount(requestDto.getAmount()) + .message(requestDto.getMessage()) + .isDeleted(false) + .build(); } public DonationResponseDto toDto(Donation donation, String memberName) { return DonationResponseDto.builder() - .id(donation.getId()) - .memberId(donation.getMemberId()) - .memberName(memberName) - .amount(donation.getAmount()) - .message(donation.getMessage()) - .createdAt(donation.getCreatedAt()) - .build(); + .id(donation.getId()) + .memberId(donation.getMemberId()) + .memberName(memberName) + .amount(donation.getAmount()) + .message(donation.getMessage()) + .createdAt(donation.getCreatedAt()) + .build(); } } diff --git a/src/main/java/page/clab/api/domain/members/donation/application/dto/response/DonationResponseDto.java b/src/main/java/page/clab/api/domain/members/donation/application/dto/response/DonationResponseDto.java index 3de241d90..9acd032af 100644 --- a/src/main/java/page/clab/api/domain/members/donation/application/dto/response/DonationResponseDto.java +++ b/src/main/java/page/clab/api/domain/members/donation/application/dto/response/DonationResponseDto.java @@ -1,10 +1,9 @@ package page.clab.api.domain.members.donation.application.dto.response; +import java.time.LocalDateTime; import lombok.Builder; import lombok.Getter; -import java.time.LocalDateTime; - @Getter @Builder public class DonationResponseDto { diff --git a/src/main/java/page/clab/api/domain/members/donation/application/port/in/RegisterDonationUseCase.java b/src/main/java/page/clab/api/domain/members/donation/application/port/in/RegisterDonationUseCase.java index 0de5742f6..49db3d16d 100644 --- a/src/main/java/page/clab/api/domain/members/donation/application/port/in/RegisterDonationUseCase.java +++ b/src/main/java/page/clab/api/domain/members/donation/application/port/in/RegisterDonationUseCase.java @@ -3,5 +3,6 @@ import page.clab.api.domain.members.donation.application.dto.request.DonationRequestDto; public interface RegisterDonationUseCase { + Long registerDonation(DonationRequestDto requestDto); } diff --git a/src/main/java/page/clab/api/domain/members/donation/application/port/in/RemoveDonationUseCase.java b/src/main/java/page/clab/api/domain/members/donation/application/port/in/RemoveDonationUseCase.java index fd6559e0a..28bacb632 100644 --- a/src/main/java/page/clab/api/domain/members/donation/application/port/in/RemoveDonationUseCase.java +++ b/src/main/java/page/clab/api/domain/members/donation/application/port/in/RemoveDonationUseCase.java @@ -3,5 +3,6 @@ import page.clab.api.global.exception.PermissionDeniedException; public interface RemoveDonationUseCase { + Long removeDonation(Long donationId) throws PermissionDeniedException; } diff --git a/src/main/java/page/clab/api/domain/members/donation/application/port/in/RetrieveDeletedDonationsUseCase.java b/src/main/java/page/clab/api/domain/members/donation/application/port/in/RetrieveDeletedDonationsUseCase.java index 48e97c9c9..9f874a8f1 100644 --- a/src/main/java/page/clab/api/domain/members/donation/application/port/in/RetrieveDeletedDonationsUseCase.java +++ b/src/main/java/page/clab/api/domain/members/donation/application/port/in/RetrieveDeletedDonationsUseCase.java @@ -5,5 +5,6 @@ import page.clab.api.global.common.dto.PagedResponseDto; public interface RetrieveDeletedDonationsUseCase { + PagedResponseDto retrieveDeletedDonations(Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/members/donation/application/port/in/RetrieveDonationsByConditionsUseCase.java b/src/main/java/page/clab/api/domain/members/donation/application/port/in/RetrieveDonationsByConditionsUseCase.java index fed3d8e87..94eedd2bb 100644 --- a/src/main/java/page/clab/api/domain/members/donation/application/port/in/RetrieveDonationsByConditionsUseCase.java +++ b/src/main/java/page/clab/api/domain/members/donation/application/port/in/RetrieveDonationsByConditionsUseCase.java @@ -1,11 +1,12 @@ package page.clab.api.domain.members.donation.application.port.in; +import java.time.LocalDate; import org.springframework.data.domain.Pageable; import page.clab.api.domain.members.donation.application.dto.response.DonationResponseDto; import page.clab.api.global.common.dto.PagedResponseDto; -import java.time.LocalDate; - public interface RetrieveDonationsByConditionsUseCase { - PagedResponseDto retrieveDonations(String memberId, String name, LocalDate startDate, LocalDate endDate, Pageable pageable); + + PagedResponseDto retrieveDonations(String memberId, String name, LocalDate startDate, + LocalDate endDate, Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/members/donation/application/port/in/RetrieveMyDonationsUseCase.java b/src/main/java/page/clab/api/domain/members/donation/application/port/in/RetrieveMyDonationsUseCase.java index f75f60d9e..8130da7ee 100644 --- a/src/main/java/page/clab/api/domain/members/donation/application/port/in/RetrieveMyDonationsUseCase.java +++ b/src/main/java/page/clab/api/domain/members/donation/application/port/in/RetrieveMyDonationsUseCase.java @@ -5,5 +5,6 @@ import page.clab.api.global.common.dto.PagedResponseDto; public interface RetrieveMyDonationsUseCase { + PagedResponseDto retrieveMyDonations(Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/members/donation/application/port/in/UpdateDonationUseCase.java b/src/main/java/page/clab/api/domain/members/donation/application/port/in/UpdateDonationUseCase.java index d18d31439..d7f047fb7 100644 --- a/src/main/java/page/clab/api/domain/members/donation/application/port/in/UpdateDonationUseCase.java +++ b/src/main/java/page/clab/api/domain/members/donation/application/port/in/UpdateDonationUseCase.java @@ -4,5 +4,7 @@ import page.clab.api.global.exception.PermissionDeniedException; public interface UpdateDonationUseCase { - Long updateDonation(Long donationId, DonationUpdateRequestDto donationUpdateRequestDto) throws PermissionDeniedException; + + Long updateDonation(Long donationId, DonationUpdateRequestDto donationUpdateRequestDto) + throws PermissionDeniedException; } diff --git a/src/main/java/page/clab/api/domain/members/donation/application/port/out/RegisterDonationPort.java b/src/main/java/page/clab/api/domain/members/donation/application/port/out/RegisterDonationPort.java index e3219a1b5..da201aa92 100644 --- a/src/main/java/page/clab/api/domain/members/donation/application/port/out/RegisterDonationPort.java +++ b/src/main/java/page/clab/api/domain/members/donation/application/port/out/RegisterDonationPort.java @@ -3,5 +3,6 @@ import page.clab.api.domain.members.donation.domain.Donation; public interface RegisterDonationPort { + Donation save(Donation donation); } diff --git a/src/main/java/page/clab/api/domain/members/donation/application/port/out/RetrieveDonationPort.java b/src/main/java/page/clab/api/domain/members/donation/application/port/out/RetrieveDonationPort.java index 052991247..ee356479d 100644 --- a/src/main/java/page/clab/api/domain/members/donation/application/port/out/RetrieveDonationPort.java +++ b/src/main/java/page/clab/api/domain/members/donation/application/port/out/RetrieveDonationPort.java @@ -1,18 +1,18 @@ package page.clab.api.domain.members.donation.application.port.out; +import java.time.LocalDate; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import page.clab.api.domain.members.donation.domain.Donation; -import java.time.LocalDate; - public interface RetrieveDonationPort { Donation getById(Long donationId); Page findAllByIsDeletedTrue(Pageable pageable); - Page findByConditions(String memberId, String name, LocalDate startDate, LocalDate endDate, Pageable pageable); + Page findByConditions(String memberId, String name, LocalDate startDate, LocalDate endDate, + Pageable pageable); Page findByMemberId(String memberId, Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/members/donation/application/service/DeletedDonationsRetrievalService.java b/src/main/java/page/clab/api/domain/members/donation/application/service/DeletedDonationsRetrievalService.java index 87109b0c2..9938c3f04 100644 --- a/src/main/java/page/clab/api/domain/members/donation/application/service/DeletedDonationsRetrievalService.java +++ b/src/main/java/page/clab/api/domain/members/donation/application/service/DeletedDonationsRetrievalService.java @@ -27,7 +27,8 @@ public class DeletedDonationsRetrievalService implements RetrieveDeletedDonation public PagedResponseDto retrieveDeletedDonations(Pageable pageable) { Page donations = retrieveDonationPort.findAllByIsDeletedTrue(pageable); return new PagedResponseDto<>(donations.map(donation -> { - MemberBasicInfoDto memberInfo = externalRetrieveMemberUseCase.getMemberBasicInfoById(donation.getMemberId()); + MemberBasicInfoDto memberInfo = externalRetrieveMemberUseCase.getMemberBasicInfoById( + donation.getMemberId()); return mapper.toDto(donation, memberInfo.getMemberName()); })); } diff --git a/src/main/java/page/clab/api/domain/members/donation/application/service/DonationUpdateService.java b/src/main/java/page/clab/api/domain/members/donation/application/service/DonationUpdateService.java index 4bfc49e9c..505b8d2fa 100644 --- a/src/main/java/page/clab/api/domain/members/donation/application/service/DonationUpdateService.java +++ b/src/main/java/page/clab/api/domain/members/donation/application/service/DonationUpdateService.java @@ -22,7 +22,8 @@ public class DonationUpdateService implements UpdateDonationUseCase { @Transactional @Override - public Long updateDonation(Long donationId, DonationUpdateRequestDto donationUpdateRequestDto) throws PermissionDeniedException { + public Long updateDonation(Long donationId, DonationUpdateRequestDto donationUpdateRequestDto) + throws PermissionDeniedException { MemberDetailedInfoDto currentMemberInfo = externalRetrieveMemberUseCase.getCurrentMemberDetailedInfo(); Donation donation = retrieveDonationPort.getById(donationId); donation.validateAccessPermission(currentMemberInfo.isSuperAdminRole()); diff --git a/src/main/java/page/clab/api/domain/members/donation/application/service/DonationsByConditionsRetrievalService.java b/src/main/java/page/clab/api/domain/members/donation/application/service/DonationsByConditionsRetrievalService.java index 158e6d3e7..f3f602ef4 100644 --- a/src/main/java/page/clab/api/domain/members/donation/application/service/DonationsByConditionsRetrievalService.java +++ b/src/main/java/page/clab/api/domain/members/donation/application/service/DonationsByConditionsRetrievalService.java @@ -1,5 +1,6 @@ package page.clab.api.domain.members.donation.application.service; +import java.time.LocalDate; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -14,8 +15,6 @@ import page.clab.api.external.memberManagement.member.application.port.ExternalRetrieveMemberUseCase; import page.clab.api.global.common.dto.PagedResponseDto; -import java.time.LocalDate; - @Service @RequiredArgsConstructor public class DonationsByConditionsRetrievalService implements RetrieveDonationsByConditionsUseCase { @@ -26,10 +25,12 @@ public class DonationsByConditionsRetrievalService implements RetrieveDonationsB @Transactional(readOnly = true) @Override - public PagedResponseDto retrieveDonations(String memberId, String name, LocalDate startDate, LocalDate endDate, Pageable pageable) { + public PagedResponseDto retrieveDonations(String memberId, String name, LocalDate startDate, + LocalDate endDate, Pageable pageable) { Page donations = retrieveDonationPort.findByConditions(memberId, name, startDate, endDate, pageable); return new PagedResponseDto<>(donations.map(donation -> { - MemberBasicInfoDto memberInfo = externalRetrieveMemberUseCase.getMemberBasicInfoById(donation.getMemberId()); + MemberBasicInfoDto memberInfo = externalRetrieveMemberUseCase.getMemberBasicInfoById( + donation.getMemberId()); return mapper.toDto(donation, memberInfo.getMemberName()); })); } diff --git a/src/main/java/page/clab/api/domain/members/donation/application/service/MyDonationsRetrievalService.java b/src/main/java/page/clab/api/domain/members/donation/application/service/MyDonationsRetrievalService.java index 80fad7322..d744354ad 100644 --- a/src/main/java/page/clab/api/domain/members/donation/application/service/MyDonationsRetrievalService.java +++ b/src/main/java/page/clab/api/domain/members/donation/application/service/MyDonationsRetrievalService.java @@ -28,7 +28,8 @@ public PagedResponseDto retrieveMyDonations(Pageable pageab String currentMemberId = externalRetrieveMemberUseCase.getCurrentMemberId(); Page donations = retrieveDonationPort.findByMemberId(currentMemberId, pageable); return new PagedResponseDto<>(donations.map(donation -> { - MemberBasicInfoDto memberInfo = externalRetrieveMemberUseCase.getMemberBasicInfoById(donation.getMemberId()); + MemberBasicInfoDto memberInfo = externalRetrieveMemberUseCase.getMemberBasicInfoById( + donation.getMemberId()); return mapper.toDto(donation, memberInfo.getMemberName()); })); } diff --git a/src/main/java/page/clab/api/domain/members/donation/domain/Donation.java b/src/main/java/page/clab/api/domain/members/donation/domain/Donation.java index 947b58adf..54522f5c8 100644 --- a/src/main/java/page/clab/api/domain/members/donation/domain/Donation.java +++ b/src/main/java/page/clab/api/domain/members/donation/domain/Donation.java @@ -1,5 +1,7 @@ package page.clab.api.domain.members.donation.domain; +import java.time.LocalDateTime; +import java.util.Optional; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -9,9 +11,6 @@ import page.clab.api.domain.members.donation.application.dto.request.DonationUpdateRequestDto; import page.clab.api.global.exception.PermissionDeniedException; -import java.time.LocalDateTime; -import java.util.Optional; - @Getter @Setter @Builder diff --git a/src/main/java/page/clab/api/domain/members/membershipFee/adapter/in/web/DeletedMembershipFeesRetrievalController.java b/src/main/java/page/clab/api/domain/members/membershipFee/adapter/in/web/DeletedMembershipFeesRetrievalController.java index 081a410a9..b233501db 100644 --- a/src/main/java/page/clab/api/domain/members/membershipFee/adapter/in/web/DeletedMembershipFeesRetrievalController.java +++ b/src/main/java/page/clab/api/domain/members/membershipFee/adapter/in/web/DeletedMembershipFeesRetrievalController.java @@ -27,12 +27,12 @@ public class DeletedMembershipFeesRetrievalController { @PreAuthorize("hasRole('SUPER')") @GetMapping("/deleted") public ApiResponse> retrieveDeletedMembershipFees( - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size ) { Pageable pageable = PageRequest.of(page, size); PagedResponseDto membershipFees = - retrieveDeletedMembershipFeesUseCase.retrieveDeletedMembershipFees(pageable); + retrieveDeletedMembershipFeesUseCase.retrieveDeletedMembershipFees(pageable); return ApiResponse.success(membershipFees); } } diff --git a/src/main/java/page/clab/api/domain/members/membershipFee/adapter/in/web/MembershipFeeRegisterController.java b/src/main/java/page/clab/api/domain/members/membershipFee/adapter/in/web/MembershipFeeRegisterController.java index 6dd7eb420..cb66059b8 100644 --- a/src/main/java/page/clab/api/domain/members/membershipFee/adapter/in/web/MembershipFeeRegisterController.java +++ b/src/main/java/page/clab/api/domain/members/membershipFee/adapter/in/web/MembershipFeeRegisterController.java @@ -25,7 +25,7 @@ public class MembershipFeeRegisterController { @PreAuthorize("hasRole('USER')") @PostMapping("") public ApiResponse registerMembershipFee( - @Valid @RequestBody MembershipFeeRequestDto requestDto + @Valid @RequestBody MembershipFeeRequestDto requestDto ) { Long id = registerMembershipFeeUseCase.registerMembershipFee(requestDto); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/members/membershipFee/adapter/in/web/MembershipFeeRemoveController.java b/src/main/java/page/clab/api/domain/members/membershipFee/adapter/in/web/MembershipFeeRemoveController.java index 0e167ac6a..a775502e9 100644 --- a/src/main/java/page/clab/api/domain/members/membershipFee/adapter/in/web/MembershipFeeRemoveController.java +++ b/src/main/java/page/clab/api/domain/members/membershipFee/adapter/in/web/MembershipFeeRemoveController.java @@ -24,7 +24,7 @@ public class MembershipFeeRemoveController { @PreAuthorize("hasRole('SUPER')") @DeleteMapping("/{membershipFeeId}") public ApiResponse removeMembershipFee( - @PathVariable(name = "membershipFeeId") Long membershipFeeId + @PathVariable(name = "membershipFeeId") Long membershipFeeId ) throws PermissionDeniedException { Long id = removeMembershipFeeUseCase.removeMembershipFee(membershipFeeId); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/members/membershipFee/adapter/in/web/MembershipFeeUpdateController.java b/src/main/java/page/clab/api/domain/members/membershipFee/adapter/in/web/MembershipFeeUpdateController.java index c83c3e91c..d1616edc9 100644 --- a/src/main/java/page/clab/api/domain/members/membershipFee/adapter/in/web/MembershipFeeUpdateController.java +++ b/src/main/java/page/clab/api/domain/members/membershipFee/adapter/in/web/MembershipFeeUpdateController.java @@ -27,8 +27,8 @@ public class MembershipFeeUpdateController { @PreAuthorize("hasRole('ADMIN')") @PatchMapping("/{membershipFeeId}") public ApiResponse updateMembershipFee( - @PathVariable(name = "membershipFeeId") Long membershipFeeId, - @Valid @RequestBody MembershipFeeUpdateRequestDto requestDto + @PathVariable(name = "membershipFeeId") Long membershipFeeId, + @Valid @RequestBody MembershipFeeUpdateRequestDto requestDto ) throws PermissionDeniedException { Long id = updateMembershipFeeUseCase.updateMembershipFee(membershipFeeId, requestDto); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/members/membershipFee/adapter/in/web/MembershipFeesByConditionsRetrievalController.java b/src/main/java/page/clab/api/domain/members/membershipFee/adapter/in/web/MembershipFeesByConditionsRetrievalController.java index 56f95198b..88e4b1854 100644 --- a/src/main/java/page/clab/api/domain/members/membershipFee/adapter/in/web/MembershipFeesByConditionsRetrievalController.java +++ b/src/main/java/page/clab/api/domain/members/membershipFee/adapter/in/web/MembershipFeesByConditionsRetrievalController.java @@ -2,6 +2,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.security.access.prepost.PreAuthorize; @@ -18,8 +19,6 @@ import page.clab.api.global.exception.SortingArgumentException; import page.clab.api.global.util.PageableUtils; -import java.util.List; - @RestController @RequestMapping("/api/v1/membership-fees") @RequiredArgsConstructor @@ -30,25 +29,27 @@ public class MembershipFeesByConditionsRetrievalController { private final PageableUtils pageableUtils; @Operation(summary = "[G] 회비 정보 조회(멤버 ID, 멤버 이름, 카테고리, 상태 기준)", description = "ROLE_GUEST 이상의 권한이 필요함
" + - "3개의 파라미터를 자유롭게 조합하여 필터링 가능
" + - "멤버 ID, 멤버 이름, 카테고리 중 하나라도 입력하지 않으면 전체 조회됨
" + - "계좌 정보는 관리자 이상의 권한만 조회 가능
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") + "3개의 파라미터를 자유롭게 조합하여 필터링 가능
" + + "멤버 ID, 멤버 이름, 카테고리 중 하나라도 입력하지 않으면 전체 조회됨
" + + "계좌 정보는 관리자 이상의 권한만 조회 가능
" + + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") @PreAuthorize("hasRole('GUEST')") @GetMapping("") public ApiResponse> retrieveMembershipFeesByConditions( - @RequestParam(name = "memberId", required = false) String memberId, - @RequestParam(name = "memberName", required = false) String memberName, - @RequestParam(name = "category", required = false) String category, - @RequestParam(name = "status", required = false) MembershipFeeStatus status, - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection + @RequestParam(name = "memberId", required = false) String memberId, + @RequestParam(name = "memberName", required = false) String memberName, + @RequestParam(name = "category", required = false) String category, + @RequestParam(name = "status", required = false) MembershipFeeStatus status, + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection ) throws SortingArgumentException, InvalidColumnException { - Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, MembershipFeeResponseDto.class); + Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, + MembershipFeeResponseDto.class); PagedResponseDto membershipFees = - retrieveMembershipFeesByConditionsUseCase.retrieveMembershipFees(memberId, memberName, category, status, pageable); + retrieveMembershipFeesByConditionsUseCase.retrieveMembershipFees(memberId, memberName, category, status, + pageable); return ApiResponse.success(membershipFees); } } diff --git a/src/main/java/page/clab/api/domain/members/membershipFee/adapter/out/persistence/MembershipFeePersistenceAdapter.java b/src/main/java/page/clab/api/domain/members/membershipFee/adapter/out/persistence/MembershipFeePersistenceAdapter.java index d31891117..d334086cb 100644 --- a/src/main/java/page/clab/api/domain/members/membershipFee/adapter/out/persistence/MembershipFeePersistenceAdapter.java +++ b/src/main/java/page/clab/api/domain/members/membershipFee/adapter/out/persistence/MembershipFeePersistenceAdapter.java @@ -14,9 +14,9 @@ @Component @RequiredArgsConstructor public class MembershipFeePersistenceAdapter implements - RegisterMembershipFeePort, - UpdateMembershipFeePort, - RetrieveMembershipFeePort { + RegisterMembershipFeePort, + UpdateMembershipFeePort, + RetrieveMembershipFeePort { private final MembershipFeeRepository repository; private final MembershipFeeMapper mapper; @@ -24,8 +24,8 @@ public class MembershipFeePersistenceAdapter implements @Override public MembershipFee getById(Long id) { return repository.findById(id) - .map(mapper::toDomain) - .orElseThrow(() -> new NotFoundException("존재하지 않는 회비 내역입니다.")); + .map(mapper::toDomain) + .orElseThrow(() -> new NotFoundException("존재하지 않는 회비 내역입니다.")); } @Override @@ -45,12 +45,13 @@ public MembershipFee update(MembershipFee membershipFee) { @Override public Page findAllByIsDeletedTrue(Pageable pageable) { return repository.findAllByIsDeletedTrue(pageable) - .map(mapper::toDomain); + .map(mapper::toDomain); } @Override - public Page findByConditions(String memberId, String memberName, String category, MembershipFeeStatus status, Pageable pageable) { + public Page findByConditions(String memberId, String memberName, String category, + MembershipFeeStatus status, Pageable pageable) { return repository.findByConditions(memberId, memberName, category, status, pageable) - .map(mapper::toDomain); + .map(mapper::toDomain); } } diff --git a/src/main/java/page/clab/api/domain/members/membershipFee/adapter/out/persistence/MembershipFeeRepository.java b/src/main/java/page/clab/api/domain/members/membershipFee/adapter/out/persistence/MembershipFeeRepository.java index f236f917b..5df9cf622 100644 --- a/src/main/java/page/clab/api/domain/members/membershipFee/adapter/out/persistence/MembershipFeeRepository.java +++ b/src/main/java/page/clab/api/domain/members/membershipFee/adapter/out/persistence/MembershipFeeRepository.java @@ -7,7 +7,7 @@ import org.springframework.data.querydsl.QuerydslPredicateExecutor; public interface MembershipFeeRepository extends JpaRepository, - MembershipFeeRepositoryCustom, QuerydslPredicateExecutor { + MembershipFeeRepositoryCustom, QuerydslPredicateExecutor { @Query(value = "SELECT m.* FROM membership_fee m WHERE m.is_deleted = true", nativeQuery = true) Page findAllByIsDeletedTrue(Pageable pageable); diff --git a/src/main/java/page/clab/api/domain/members/membershipFee/adapter/out/persistence/MembershipFeeRepositoryCustom.java b/src/main/java/page/clab/api/domain/members/membershipFee/adapter/out/persistence/MembershipFeeRepositoryCustom.java index 010edebf5..24ad23cb5 100644 --- a/src/main/java/page/clab/api/domain/members/membershipFee/adapter/out/persistence/MembershipFeeRepositoryCustom.java +++ b/src/main/java/page/clab/api/domain/members/membershipFee/adapter/out/persistence/MembershipFeeRepositoryCustom.java @@ -5,5 +5,7 @@ import page.clab.api.domain.members.membershipFee.domain.MembershipFeeStatus; public interface MembershipFeeRepositoryCustom { - Page findByConditions(String memberId, String memberName, String category, MembershipFeeStatus status, Pageable pageable); + + Page findByConditions(String memberId, String memberName, String category, + MembershipFeeStatus status, Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/members/membershipFee/adapter/out/persistence/MembershipFeeRepositoryImpl.java b/src/main/java/page/clab/api/domain/members/membershipFee/adapter/out/persistence/MembershipFeeRepositoryImpl.java index 67073fd75..d150c7a4b 100644 --- a/src/main/java/page/clab/api/domain/members/membershipFee/adapter/out/persistence/MembershipFeeRepositoryImpl.java +++ b/src/main/java/page/clab/api/domain/members/membershipFee/adapter/out/persistence/MembershipFeeRepositoryImpl.java @@ -2,6 +2,7 @@ import com.querydsl.core.BooleanBuilder; import com.querydsl.jpa.impl.JPAQueryFactory; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; @@ -11,8 +12,6 @@ import page.clab.api.domain.members.membershipFee.domain.MembershipFeeStatus; import page.clab.api.global.util.OrderSpecifierUtil; -import java.util.List; - @Repository @RequiredArgsConstructor public class MembershipFeeRepositoryImpl implements MembershipFeeRepositoryCustom { @@ -20,28 +19,37 @@ public class MembershipFeeRepositoryImpl implements MembershipFeeRepositoryCusto private final JPAQueryFactory queryFactory; @Override - public Page findByConditions(String memberId, String memberName, String category, MembershipFeeStatus status, Pageable pageable) { + public Page findByConditions(String memberId, String memberName, String category, + MembershipFeeStatus status, Pageable pageable) { QMembershipFeeJpaEntity membershipFee = QMembershipFeeJpaEntity.membershipFeeJpaEntity; QMemberJpaEntity member = QMemberJpaEntity.memberJpaEntity; BooleanBuilder builder = new BooleanBuilder(); - if (memberId != null && !memberId.isEmpty()) builder.and(membershipFee.memberId.eq(memberId)); - if (memberName != null && !memberName.isEmpty()) builder.and(member.name.eq(memberName)); - if (category != null && !category.isEmpty()) builder.and(membershipFee.category.eq(category)); - if (status != null) builder.and(membershipFee.status.eq(status)); + if (memberId != null && !memberId.isEmpty()) { + builder.and(membershipFee.memberId.eq(memberId)); + } + if (memberName != null && !memberName.isEmpty()) { + builder.and(member.name.eq(memberName)); + } + if (category != null && !category.isEmpty()) { + builder.and(membershipFee.category.eq(category)); + } + if (status != null) { + builder.and(membershipFee.status.eq(status)); + } List membershipFees = queryFactory.selectFrom(membershipFee) - .leftJoin(member).on(membershipFee.memberId.eq(member.id)) - .where(builder) - .orderBy(OrderSpecifierUtil.getOrderSpecifiers(pageable, membershipFee)) - .offset(pageable.getOffset()) - .limit(pageable.getPageSize()) - .fetch(); + .leftJoin(member).on(membershipFee.memberId.eq(member.id)) + .where(builder) + .orderBy(OrderSpecifierUtil.getOrderSpecifiers(pageable, membershipFee)) + .offset(pageable.getOffset()) + .limit(pageable.getPageSize()) + .fetch(); long count = queryFactory.selectFrom(membershipFee) - .leftJoin(member).on(membershipFee.memberId.eq(member.id)) - .where(builder) - .fetchCount(); + .leftJoin(member).on(membershipFee.memberId.eq(member.id)) + .where(builder) + .fetchCount(); return new PageImpl<>(membershipFees, pageable, count); } diff --git a/src/main/java/page/clab/api/domain/members/membershipFee/application/dto/mapper/MembershipFeeDtoMapper.java b/src/main/java/page/clab/api/domain/members/membershipFee/application/dto/mapper/MembershipFeeDtoMapper.java index 87de4413b..c3356245d 100644 --- a/src/main/java/page/clab/api/domain/members/membershipFee/application/dto/mapper/MembershipFeeDtoMapper.java +++ b/src/main/java/page/clab/api/domain/members/membershipFee/application/dto/mapper/MembershipFeeDtoMapper.java @@ -11,29 +11,29 @@ public class MembershipFeeDtoMapper { public MembershipFee fromDto(MembershipFeeRequestDto requestDto, String memberId) { return MembershipFee.builder() - .memberId(memberId) - .category(requestDto.getCategory()) - .account(requestDto.getAccount()) - .amount(requestDto.getAmount()) - .content(requestDto.getContent()) - .imageUrl(requestDto.getImageUrl()) - .status(MembershipFeeStatus.PENDING) - .isDeleted(false) - .build(); + .memberId(memberId) + .category(requestDto.getCategory()) + .account(requestDto.getAccount()) + .amount(requestDto.getAmount()) + .content(requestDto.getContent()) + .imageUrl(requestDto.getImageUrl()) + .status(MembershipFeeStatus.PENDING) + .isDeleted(false) + .build(); } public MembershipFeeResponseDto toDto(MembershipFee membershipFee, String memberName, boolean isAdminRole) { return MembershipFeeResponseDto.builder() - .id(membershipFee.getId()) - .memberId(membershipFee.getMemberId()) - .memberName(memberName) - .category(membershipFee.getCategory()) - .account(isAdminRole ? membershipFee.getAccount() : null) - .amount(membershipFee.getAmount()) - .content(membershipFee.getContent()) - .imageUrl(membershipFee.getImageUrl()) - .status(membershipFee.getStatus()) - .createdAt(membershipFee.getCreatedAt()) - .build(); + .id(membershipFee.getId()) + .memberId(membershipFee.getMemberId()) + .memberName(memberName) + .category(membershipFee.getCategory()) + .account(isAdminRole ? membershipFee.getAccount() : null) + .amount(membershipFee.getAmount()) + .content(membershipFee.getContent()) + .imageUrl(membershipFee.getImageUrl()) + .status(membershipFee.getStatus()) + .createdAt(membershipFee.getCreatedAt()) + .build(); } } diff --git a/src/main/java/page/clab/api/domain/members/membershipFee/application/dto/response/MembershipFeeResponseDto.java b/src/main/java/page/clab/api/domain/members/membershipFee/application/dto/response/MembershipFeeResponseDto.java index b32506e3c..778185393 100644 --- a/src/main/java/page/clab/api/domain/members/membershipFee/application/dto/response/MembershipFeeResponseDto.java +++ b/src/main/java/page/clab/api/domain/members/membershipFee/application/dto/response/MembershipFeeResponseDto.java @@ -1,11 +1,10 @@ package page.clab.api.domain.members.membershipFee.application.dto.response; +import java.time.LocalDateTime; import lombok.Builder; import lombok.Getter; import page.clab.api.domain.members.membershipFee.domain.MembershipFeeStatus; -import java.time.LocalDateTime; - @Getter @Builder public class MembershipFeeResponseDto { diff --git a/src/main/java/page/clab/api/domain/members/membershipFee/application/port/in/RegisterMembershipFeeUseCase.java b/src/main/java/page/clab/api/domain/members/membershipFee/application/port/in/RegisterMembershipFeeUseCase.java index c0dd459f6..47ff9c807 100644 --- a/src/main/java/page/clab/api/domain/members/membershipFee/application/port/in/RegisterMembershipFeeUseCase.java +++ b/src/main/java/page/clab/api/domain/members/membershipFee/application/port/in/RegisterMembershipFeeUseCase.java @@ -3,5 +3,6 @@ import page.clab.api.domain.members.membershipFee.application.dto.request.MembershipFeeRequestDto; public interface RegisterMembershipFeeUseCase { + Long registerMembershipFee(MembershipFeeRequestDto requestDto); } diff --git a/src/main/java/page/clab/api/domain/members/membershipFee/application/port/in/RemoveMembershipFeeUseCase.java b/src/main/java/page/clab/api/domain/members/membershipFee/application/port/in/RemoveMembershipFeeUseCase.java index 1dd85b80a..87e4fdfda 100644 --- a/src/main/java/page/clab/api/domain/members/membershipFee/application/port/in/RemoveMembershipFeeUseCase.java +++ b/src/main/java/page/clab/api/domain/members/membershipFee/application/port/in/RemoveMembershipFeeUseCase.java @@ -3,5 +3,6 @@ import page.clab.api.global.exception.PermissionDeniedException; public interface RemoveMembershipFeeUseCase { + Long removeMembershipFee(Long membershipFeeId) throws PermissionDeniedException; } diff --git a/src/main/java/page/clab/api/domain/members/membershipFee/application/port/in/RetrieveDeletedMembershipFeesUseCase.java b/src/main/java/page/clab/api/domain/members/membershipFee/application/port/in/RetrieveDeletedMembershipFeesUseCase.java index a75dfdcc0..af0f2f915 100644 --- a/src/main/java/page/clab/api/domain/members/membershipFee/application/port/in/RetrieveDeletedMembershipFeesUseCase.java +++ b/src/main/java/page/clab/api/domain/members/membershipFee/application/port/in/RetrieveDeletedMembershipFeesUseCase.java @@ -5,5 +5,6 @@ import page.clab.api.global.common.dto.PagedResponseDto; public interface RetrieveDeletedMembershipFeesUseCase { + PagedResponseDto retrieveDeletedMembershipFees(Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/members/membershipFee/application/port/in/RetrieveMembershipFeesByConditionsUseCase.java b/src/main/java/page/clab/api/domain/members/membershipFee/application/port/in/RetrieveMembershipFeesByConditionsUseCase.java index 876e05505..c88dc822d 100644 --- a/src/main/java/page/clab/api/domain/members/membershipFee/application/port/in/RetrieveMembershipFeesByConditionsUseCase.java +++ b/src/main/java/page/clab/api/domain/members/membershipFee/application/port/in/RetrieveMembershipFeesByConditionsUseCase.java @@ -6,5 +6,7 @@ import page.clab.api.global.common.dto.PagedResponseDto; public interface RetrieveMembershipFeesByConditionsUseCase { - PagedResponseDto retrieveMembershipFees(String memberId, String memberName, String category, MembershipFeeStatus status, Pageable pageable); + + PagedResponseDto retrieveMembershipFees(String memberId, String memberName, + String category, MembershipFeeStatus status, Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/members/membershipFee/application/port/in/UpdateMembershipFeeUseCase.java b/src/main/java/page/clab/api/domain/members/membershipFee/application/port/in/UpdateMembershipFeeUseCase.java index ece313c8b..1bbf1327b 100644 --- a/src/main/java/page/clab/api/domain/members/membershipFee/application/port/in/UpdateMembershipFeeUseCase.java +++ b/src/main/java/page/clab/api/domain/members/membershipFee/application/port/in/UpdateMembershipFeeUseCase.java @@ -4,5 +4,7 @@ import page.clab.api.global.exception.PermissionDeniedException; public interface UpdateMembershipFeeUseCase { - Long updateMembershipFee(Long membershipFeeId, MembershipFeeUpdateRequestDto requestDto) throws PermissionDeniedException; + + Long updateMembershipFee(Long membershipFeeId, MembershipFeeUpdateRequestDto requestDto) + throws PermissionDeniedException; } diff --git a/src/main/java/page/clab/api/domain/members/membershipFee/application/port/out/RegisterMembershipFeePort.java b/src/main/java/page/clab/api/domain/members/membershipFee/application/port/out/RegisterMembershipFeePort.java index 17d94f979..41655ddd9 100644 --- a/src/main/java/page/clab/api/domain/members/membershipFee/application/port/out/RegisterMembershipFeePort.java +++ b/src/main/java/page/clab/api/domain/members/membershipFee/application/port/out/RegisterMembershipFeePort.java @@ -3,5 +3,6 @@ import page.clab.api.domain.members.membershipFee.domain.MembershipFee; public interface RegisterMembershipFeePort { + MembershipFee save(MembershipFee membershipFee); } diff --git a/src/main/java/page/clab/api/domain/members/membershipFee/application/port/out/RetrieveMembershipFeePort.java b/src/main/java/page/clab/api/domain/members/membershipFee/application/port/out/RetrieveMembershipFeePort.java index bd5d5ce94..02ace6bcf 100644 --- a/src/main/java/page/clab/api/domain/members/membershipFee/application/port/out/RetrieveMembershipFeePort.java +++ b/src/main/java/page/clab/api/domain/members/membershipFee/application/port/out/RetrieveMembershipFeePort.java @@ -11,5 +11,6 @@ public interface RetrieveMembershipFeePort { Page findAllByIsDeletedTrue(Pageable pageable); - Page findByConditions(String memberId, String memberName, String category, MembershipFeeStatus status, Pageable pageable); + Page findByConditions(String memberId, String memberName, String category, + MembershipFeeStatus status, Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/members/membershipFee/application/port/out/UpdateMembershipFeePort.java b/src/main/java/page/clab/api/domain/members/membershipFee/application/port/out/UpdateMembershipFeePort.java index ac9a548a7..d7b3ae7ac 100644 --- a/src/main/java/page/clab/api/domain/members/membershipFee/application/port/out/UpdateMembershipFeePort.java +++ b/src/main/java/page/clab/api/domain/members/membershipFee/application/port/out/UpdateMembershipFeePort.java @@ -3,5 +3,6 @@ import page.clab.api.domain.members.membershipFee.domain.MembershipFee; public interface UpdateMembershipFeePort { + MembershipFee update(MembershipFee membershipFee); } diff --git a/src/main/java/page/clab/api/domain/members/membershipFee/application/service/DeletedMembershipFeesRetrievalService.java b/src/main/java/page/clab/api/domain/members/membershipFee/application/service/DeletedMembershipFeesRetrievalService.java index 70baa3246..ab3f7d84d 100644 --- a/src/main/java/page/clab/api/domain/members/membershipFee/application/service/DeletedMembershipFeesRetrievalService.java +++ b/src/main/java/page/clab/api/domain/members/membershipFee/application/service/DeletedMembershipFeesRetrievalService.java @@ -28,6 +28,6 @@ public PagedResponseDto retrieveDeletedMembershipFees( MemberDetailedInfoDto memberInfo = externalRetrieveMemberUseCase.getCurrentMemberDetailedInfo(); Page membershipFees = retrieveMembershipFeePort.findAllByIsDeletedTrue(pageable); return new PagedResponseDto<>(membershipFees.map(membershipFee -> - mapper.toDto(membershipFee, memberInfo.getMemberName(), memberInfo.isAdminRole()))); + mapper.toDto(membershipFee, memberInfo.getMemberName(), memberInfo.isAdminRole()))); } } diff --git a/src/main/java/page/clab/api/domain/members/membershipFee/application/service/MembershipFeeRegisterService.java b/src/main/java/page/clab/api/domain/members/membershipFee/application/service/MembershipFeeRegisterService.java index 533b7d879..ec9785748 100644 --- a/src/main/java/page/clab/api/domain/members/membershipFee/application/service/MembershipFeeRegisterService.java +++ b/src/main/java/page/clab/api/domain/members/membershipFee/application/service/MembershipFeeRegisterService.java @@ -33,9 +33,9 @@ public Long registerMembershipFee(MembershipFeeRequestDto requestDto) { MembershipFee membershipFee = mapper.fromDto(requestDto, memberInfo.getMemberId()); externalSendNotificationUseCase.sendNotificationToAdmins("새로운 회비 내역이 등록되었습니다."); MembershipFeeNotificationInfo membershipFeeInfo = MembershipFeeNotificationInfo.create(membershipFee, - memberInfo); + memberInfo); eventPublisher.publishEvent(new NotificationEvent(this, ExecutivesAlertType.NEW_MEMBERSHIP_FEE, null, - membershipFeeInfo)); + membershipFeeInfo)); return registerMembershipFeePort.save(membershipFee).getId(); } } diff --git a/src/main/java/page/clab/api/domain/members/membershipFee/application/service/MembershipFeeUpdateService.java b/src/main/java/page/clab/api/domain/members/membershipFee/application/service/MembershipFeeUpdateService.java index a5bb7c95f..d522ac05b 100644 --- a/src/main/java/page/clab/api/domain/members/membershipFee/application/service/MembershipFeeUpdateService.java +++ b/src/main/java/page/clab/api/domain/members/membershipFee/application/service/MembershipFeeUpdateService.java @@ -22,7 +22,8 @@ public class MembershipFeeUpdateService implements UpdateMembershipFeeUseCase { @Transactional @Override - public Long updateMembershipFee(Long membershipFeeId, MembershipFeeUpdateRequestDto requestDto) throws PermissionDeniedException { + public Long updateMembershipFee(Long membershipFeeId, MembershipFeeUpdateRequestDto requestDto) + throws PermissionDeniedException { MemberDetailedInfoDto currentMemberInfo = externalRetrieveMemberUseCase.getCurrentMemberDetailedInfo(); MembershipFee membershipFee = retrieveMembershipFeePort.getById(membershipFeeId); membershipFee.validateAccessPermission(currentMemberInfo); diff --git a/src/main/java/page/clab/api/domain/members/membershipFee/application/service/MembershipFeesByConditionsRetrievalService.java b/src/main/java/page/clab/api/domain/members/membershipFee/application/service/MembershipFeesByConditionsRetrievalService.java index 153e9ccdb..fe66e013b 100644 --- a/src/main/java/page/clab/api/domain/members/membershipFee/application/service/MembershipFeesByConditionsRetrievalService.java +++ b/src/main/java/page/clab/api/domain/members/membershipFee/application/service/MembershipFeesByConditionsRetrievalService.java @@ -25,14 +25,18 @@ public class MembershipFeesByConditionsRetrievalService implements RetrieveMembe @Transactional(readOnly = true) @Override - public PagedResponseDto retrieveMembershipFees(String memberId, String memberName, String category, MembershipFeeStatus status, Pageable pageable) { - Page membershipFees = retrieveMembershipFeePort.findByConditions(memberId, memberName, category, status, pageable); + public PagedResponseDto retrieveMembershipFees(String memberId, String memberName, + String category, MembershipFeeStatus status, Pageable pageable) { + Page membershipFees = retrieveMembershipFeePort.findByConditions(memberId, memberName, category, + status, pageable); boolean currentMemberIsAdmin = externalRetrieveMemberUseCase.getCurrentMemberDetailedInfo().isAdminRole(); - return new PagedResponseDto<>(membershipFees.map(membership -> getMembershipFeeResponseDto(membership, currentMemberIsAdmin))); + return new PagedResponseDto<>( + membershipFees.map(membership -> getMembershipFeeResponseDto(membership, currentMemberIsAdmin))); } private MembershipFeeResponseDto getMembershipFeeResponseDto(MembershipFee membershipFee, boolean isAdminRole) { - MemberBasicInfoDto memberInfo = externalRetrieveMemberUseCase.getMemberBasicInfoById(membershipFee.getMemberId()); + MemberBasicInfoDto memberInfo = externalRetrieveMemberUseCase.getMemberBasicInfoById( + membershipFee.getMemberId()); return mapper.toDto(membershipFee, memberInfo.getMemberName(), isAdminRole); } } diff --git a/src/main/java/page/clab/api/domain/members/membershipFee/domain/MembershipFee.java b/src/main/java/page/clab/api/domain/members/membershipFee/domain/MembershipFee.java index 71a3ea1a6..acf93563c 100644 --- a/src/main/java/page/clab/api/domain/members/membershipFee/domain/MembershipFee.java +++ b/src/main/java/page/clab/api/domain/members/membershipFee/domain/MembershipFee.java @@ -1,5 +1,7 @@ package page.clab.api.domain.members.membershipFee.domain; +import java.time.LocalDateTime; +import java.util.Optional; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -10,9 +12,6 @@ import page.clab.api.domain.members.membershipFee.application.dto.request.MembershipFeeUpdateRequestDto; import page.clab.api.global.exception.PermissionDeniedException; -import java.time.LocalDateTime; -import java.util.Optional; - @Getter @Setter @Builder diff --git a/src/main/java/page/clab/api/domain/members/product/adapter/in/web/DeletedProductsRetrievalController.java b/src/main/java/page/clab/api/domain/members/product/adapter/in/web/DeletedProductsRetrievalController.java index d6c98d26a..9d61e393b 100644 --- a/src/main/java/page/clab/api/domain/members/product/adapter/in/web/DeletedProductsRetrievalController.java +++ b/src/main/java/page/clab/api/domain/members/product/adapter/in/web/DeletedProductsRetrievalController.java @@ -27,11 +27,12 @@ public class DeletedProductsRetrievalController { @PreAuthorize("hasRole('SUPER')") @GetMapping("/deleted") public ApiResponse> retrieveDeletedProducts( - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size ) { Pageable pageable = PageRequest.of(page, size); - PagedResponseDto products = retrieveDeletedProductsUseCase.retrieveDeletedProducts(pageable); + PagedResponseDto products = retrieveDeletedProductsUseCase.retrieveDeletedProducts( + pageable); return ApiResponse.success(products); } } diff --git a/src/main/java/page/clab/api/domain/members/product/adapter/in/web/ProductRegisterController.java b/src/main/java/page/clab/api/domain/members/product/adapter/in/web/ProductRegisterController.java index e52d7322d..df000cbdb 100644 --- a/src/main/java/page/clab/api/domain/members/product/adapter/in/web/ProductRegisterController.java +++ b/src/main/java/page/clab/api/domain/members/product/adapter/in/web/ProductRegisterController.java @@ -25,7 +25,7 @@ public class ProductRegisterController { @PreAuthorize("hasRole('ADMIN')") @PostMapping("") public ApiResponse registerProduct( - @Valid @RequestBody ProductRequestDto requestDto + @Valid @RequestBody ProductRequestDto requestDto ) { Long id = registerProductUseCase.registerProduct(requestDto); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/members/product/adapter/in/web/ProductRemoveController.java b/src/main/java/page/clab/api/domain/members/product/adapter/in/web/ProductRemoveController.java index c05c6470e..f056fdf98 100644 --- a/src/main/java/page/clab/api/domain/members/product/adapter/in/web/ProductRemoveController.java +++ b/src/main/java/page/clab/api/domain/members/product/adapter/in/web/ProductRemoveController.java @@ -23,7 +23,7 @@ public class ProductRemoveController { @PreAuthorize("hasRole('ADMIN')") @DeleteMapping("") public ApiResponse removeProduct( - @RequestParam Long productId + @RequestParam Long productId ) { Long id = removeProductUseCase.removeProduct(productId); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/members/product/adapter/in/web/ProductUpdateController.java b/src/main/java/page/clab/api/domain/members/product/adapter/in/web/ProductUpdateController.java index da881d922..936b29bcc 100644 --- a/src/main/java/page/clab/api/domain/members/product/adapter/in/web/ProductUpdateController.java +++ b/src/main/java/page/clab/api/domain/members/product/adapter/in/web/ProductUpdateController.java @@ -26,8 +26,8 @@ public class ProductUpdateController { @PreAuthorize("hasRole('ADMIN')") @PatchMapping("/{productId}") public ApiResponse updateProduct( - @PathVariable(name = "productId") Long productId, - @Valid @RequestBody ProductUpdateRequestDto requestDto + @PathVariable(name = "productId") Long productId, + @Valid @RequestBody ProductUpdateRequestDto requestDto ) { Long id = updateProductUseCase.updateProduct(productId, requestDto); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/members/product/adapter/in/web/ProductsByConditionsRetrievalController.java b/src/main/java/page/clab/api/domain/members/product/adapter/in/web/ProductsByConditionsRetrievalController.java index 43a86b0c3..60315f7e3 100644 --- a/src/main/java/page/clab/api/domain/members/product/adapter/in/web/ProductsByConditionsRetrievalController.java +++ b/src/main/java/page/clab/api/domain/members/product/adapter/in/web/ProductsByConditionsRetrievalController.java @@ -2,6 +2,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.security.access.prepost.PreAuthorize; @@ -17,8 +18,6 @@ import page.clab.api.global.exception.SortingArgumentException; import page.clab.api.global.util.PageableUtils; -import java.util.List; - @RestController @RequestMapping("/api/v1/products") @RequiredArgsConstructor @@ -29,19 +28,20 @@ public class ProductsByConditionsRetrievalController { private final PageableUtils pageableUtils; @Operation(summary = "[G] 서비스 조회", description = "ROLE_GUEST 이상의 권한이 필요함
" + - "서비스명을 입력하지 않으면 전체 조회됨
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") + "서비스명을 입력하지 않으면 전체 조회됨
" + + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") @PreAuthorize("hasRole('GUEST')") @GetMapping("") public ApiResponse> retrieveProductsByConditions( - @RequestParam(required = false) String productName, - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection + @RequestParam(required = false) String productName, + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "createdAt") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "desc") List sortDirection ) throws SortingArgumentException, InvalidColumnException { Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, ProductResponseDto.class); - PagedResponseDto products = retrieveProductsByConditionsUseCase.retrieveProducts(productName, pageable); + PagedResponseDto products = retrieveProductsByConditionsUseCase.retrieveProducts( + productName, pageable); return ApiResponse.success(products); } } diff --git a/src/main/java/page/clab/api/domain/members/product/adapter/out/persistence/ProductPersistenceAdapter.java b/src/main/java/page/clab/api/domain/members/product/adapter/out/persistence/ProductPersistenceAdapter.java index 744508665..913dd7dc1 100644 --- a/src/main/java/page/clab/api/domain/members/product/adapter/out/persistence/ProductPersistenceAdapter.java +++ b/src/main/java/page/clab/api/domain/members/product/adapter/out/persistence/ProductPersistenceAdapter.java @@ -13,9 +13,9 @@ @Component @RequiredArgsConstructor public class ProductPersistenceAdapter implements - RegisterProductPort, - UpdateProductPort, - RetrieveProductPort { + RegisterProductPort, + UpdateProductPort, + RetrieveProductPort { private final ProductRepository repository; private final ProductMapper mapper; @@ -37,19 +37,19 @@ public Product update(Product product) { @Override public Product getById(Long productId) { return repository.findById(productId) - .map(mapper::toDomain) - .orElseThrow(() -> new NotFoundException("[Product] id: " + productId + "에 해당하는 상품이 존재하지 않습니다.")); + .map(mapper::toDomain) + .orElseThrow(() -> new NotFoundException("[Product] id: " + productId + "에 해당하는 상품이 존재하지 않습니다.")); } @Override public Page findAllByIsDeletedTrue(Pageable pageable) { return repository.findAllByIsDeletedTrue(pageable) - .map(mapper::toDomain); + .map(mapper::toDomain); } @Override public Page findByConditions(String productName, Pageable pageable) { return repository.findByConditions(productName, pageable) - .map(mapper::toDomain); + .map(mapper::toDomain); } } diff --git a/src/main/java/page/clab/api/domain/members/product/adapter/out/persistence/ProductRepository.java b/src/main/java/page/clab/api/domain/members/product/adapter/out/persistence/ProductRepository.java index 0d5febf85..2d26484a5 100644 --- a/src/main/java/page/clab/api/domain/members/product/adapter/out/persistence/ProductRepository.java +++ b/src/main/java/page/clab/api/domain/members/product/adapter/out/persistence/ProductRepository.java @@ -8,7 +8,8 @@ import org.springframework.stereotype.Repository; @Repository -public interface ProductRepository extends JpaRepository, ProductRepositoryCustom, QuerydslPredicateExecutor { +public interface ProductRepository extends JpaRepository, ProductRepositoryCustom, + QuerydslPredicateExecutor { @Query(value = "SELECT p.* FROM product p WHERE p.is_deleted = true", nativeQuery = true) Page findAllByIsDeletedTrue(Pageable pageable); diff --git a/src/main/java/page/clab/api/domain/members/product/adapter/out/persistence/ProductRepositoryCustom.java b/src/main/java/page/clab/api/domain/members/product/adapter/out/persistence/ProductRepositoryCustom.java index 3c2a995fb..8e22e9f67 100644 --- a/src/main/java/page/clab/api/domain/members/product/adapter/out/persistence/ProductRepositoryCustom.java +++ b/src/main/java/page/clab/api/domain/members/product/adapter/out/persistence/ProductRepositoryCustom.java @@ -4,5 +4,6 @@ import org.springframework.data.domain.Pageable; public interface ProductRepositoryCustom { + Page findByConditions(String productName, Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/members/product/adapter/out/persistence/ProductRepositoryImpl.java b/src/main/java/page/clab/api/domain/members/product/adapter/out/persistence/ProductRepositoryImpl.java index 4f22c128d..7cc12a51c 100644 --- a/src/main/java/page/clab/api/domain/members/product/adapter/out/persistence/ProductRepositoryImpl.java +++ b/src/main/java/page/clab/api/domain/members/product/adapter/out/persistence/ProductRepositoryImpl.java @@ -2,6 +2,7 @@ import com.querydsl.core.BooleanBuilder; import com.querydsl.jpa.impl.JPAQueryFactory; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; @@ -9,8 +10,6 @@ import org.springframework.stereotype.Repository; import page.clab.api.global.util.OrderSpecifierUtil; -import java.util.List; - @Repository @RequiredArgsConstructor public class ProductRepositoryImpl implements ProductRepositoryCustom { @@ -27,15 +26,15 @@ public Page findByConditions(String productName, Pageable page } List products = queryFactory.selectFrom(product) - .where(builder) - .orderBy(OrderSpecifierUtil.getOrderSpecifiers(pageable, product)) - .offset(pageable.getOffset()) - .limit(pageable.getPageSize()) - .fetch(); + .where(builder) + .orderBy(OrderSpecifierUtil.getOrderSpecifiers(pageable, product)) + .offset(pageable.getOffset()) + .limit(pageable.getPageSize()) + .fetch(); long count = queryFactory.query().from(product) - .where(builder) - .fetchCount(); + .where(builder) + .fetchCount(); return new PageImpl<>(products, pageable, count); } diff --git a/src/main/java/page/clab/api/domain/members/product/application/dto/mapper/ProductDtoMapper.java b/src/main/java/page/clab/api/domain/members/product/application/dto/mapper/ProductDtoMapper.java index 503fa73e4..9eed72625 100644 --- a/src/main/java/page/clab/api/domain/members/product/application/dto/mapper/ProductDtoMapper.java +++ b/src/main/java/page/clab/api/domain/members/product/application/dto/mapper/ProductDtoMapper.java @@ -10,20 +10,20 @@ public class ProductDtoMapper { public Product fromDto(ProductRequestDto requestDto) { return Product.builder() - .name(requestDto.getName()) - .description(requestDto.getDescription()) - .url(requestDto.getUrl()) - .isDeleted(false) - .build(); + .name(requestDto.getName()) + .description(requestDto.getDescription()) + .url(requestDto.getUrl()) + .isDeleted(false) + .build(); } public ProductResponseDto toDto(Product product) { return ProductResponseDto.builder() - .id(product.getId()) - .name(product.getName()) - .description(product.getDescription()) - .url(product.getUrl()) - .createdAt(product.getCreatedAt()) - .build(); + .id(product.getId()) + .name(product.getName()) + .description(product.getDescription()) + .url(product.getUrl()) + .createdAt(product.getCreatedAt()) + .build(); } } diff --git a/src/main/java/page/clab/api/domain/members/product/application/dto/response/ProductResponseDto.java b/src/main/java/page/clab/api/domain/members/product/application/dto/response/ProductResponseDto.java index d52a22d16..0a8856834 100644 --- a/src/main/java/page/clab/api/domain/members/product/application/dto/response/ProductResponseDto.java +++ b/src/main/java/page/clab/api/domain/members/product/application/dto/response/ProductResponseDto.java @@ -1,10 +1,9 @@ package page.clab.api.domain.members.product.application.dto.response; +import java.time.LocalDateTime; import lombok.Builder; import lombok.Getter; -import java.time.LocalDateTime; - @Getter @Builder public class ProductResponseDto { diff --git a/src/main/java/page/clab/api/domain/members/product/application/port/in/RegisterProductUseCase.java b/src/main/java/page/clab/api/domain/members/product/application/port/in/RegisterProductUseCase.java index 7bdbf3e45..f4d9338f5 100644 --- a/src/main/java/page/clab/api/domain/members/product/application/port/in/RegisterProductUseCase.java +++ b/src/main/java/page/clab/api/domain/members/product/application/port/in/RegisterProductUseCase.java @@ -3,5 +3,6 @@ import page.clab.api.domain.members.product.application.dto.request.ProductRequestDto; public interface RegisterProductUseCase { + Long registerProduct(ProductRequestDto requestDto); } diff --git a/src/main/java/page/clab/api/domain/members/product/application/port/in/RemoveProductUseCase.java b/src/main/java/page/clab/api/domain/members/product/application/port/in/RemoveProductUseCase.java index a6215cb2e..2ec8d02c4 100644 --- a/src/main/java/page/clab/api/domain/members/product/application/port/in/RemoveProductUseCase.java +++ b/src/main/java/page/clab/api/domain/members/product/application/port/in/RemoveProductUseCase.java @@ -1,5 +1,6 @@ package page.clab.api.domain.members.product.application.port.in; public interface RemoveProductUseCase { + Long removeProduct(Long productId); } diff --git a/src/main/java/page/clab/api/domain/members/product/application/port/in/RetrieveDeletedProductsUseCase.java b/src/main/java/page/clab/api/domain/members/product/application/port/in/RetrieveDeletedProductsUseCase.java index 5aea73881..501a73f4b 100644 --- a/src/main/java/page/clab/api/domain/members/product/application/port/in/RetrieveDeletedProductsUseCase.java +++ b/src/main/java/page/clab/api/domain/members/product/application/port/in/RetrieveDeletedProductsUseCase.java @@ -5,5 +5,6 @@ import page.clab.api.global.common.dto.PagedResponseDto; public interface RetrieveDeletedProductsUseCase { + PagedResponseDto retrieveDeletedProducts(Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/members/product/application/port/in/RetrieveProductsByConditionsUseCase.java b/src/main/java/page/clab/api/domain/members/product/application/port/in/RetrieveProductsByConditionsUseCase.java index 704532e09..e1257d9cd 100644 --- a/src/main/java/page/clab/api/domain/members/product/application/port/in/RetrieveProductsByConditionsUseCase.java +++ b/src/main/java/page/clab/api/domain/members/product/application/port/in/RetrieveProductsByConditionsUseCase.java @@ -5,5 +5,6 @@ import page.clab.api.global.common.dto.PagedResponseDto; public interface RetrieveProductsByConditionsUseCase { + PagedResponseDto retrieveProducts(String productName, Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/members/product/application/port/in/UpdateProductUseCase.java b/src/main/java/page/clab/api/domain/members/product/application/port/in/UpdateProductUseCase.java index cc2dd35eb..ba697abe5 100644 --- a/src/main/java/page/clab/api/domain/members/product/application/port/in/UpdateProductUseCase.java +++ b/src/main/java/page/clab/api/domain/members/product/application/port/in/UpdateProductUseCase.java @@ -3,5 +3,6 @@ import page.clab.api.domain.members.product.application.dto.request.ProductUpdateRequestDto; public interface UpdateProductUseCase { + Long updateProduct(Long productId, ProductUpdateRequestDto requestDto); } diff --git a/src/main/java/page/clab/api/domain/members/product/application/port/out/RegisterProductPort.java b/src/main/java/page/clab/api/domain/members/product/application/port/out/RegisterProductPort.java index d244955a3..5607df78b 100644 --- a/src/main/java/page/clab/api/domain/members/product/application/port/out/RegisterProductPort.java +++ b/src/main/java/page/clab/api/domain/members/product/application/port/out/RegisterProductPort.java @@ -3,5 +3,6 @@ import page.clab.api.domain.members.product.domain.Product; public interface RegisterProductPort { + Product save(Product product); } diff --git a/src/main/java/page/clab/api/domain/members/product/application/port/out/UpdateProductPort.java b/src/main/java/page/clab/api/domain/members/product/application/port/out/UpdateProductPort.java index 943f4f8b4..ebb63d699 100644 --- a/src/main/java/page/clab/api/domain/members/product/application/port/out/UpdateProductPort.java +++ b/src/main/java/page/clab/api/domain/members/product/application/port/out/UpdateProductPort.java @@ -3,5 +3,6 @@ import page.clab.api.domain.members.product.domain.Product; public interface UpdateProductPort { + Product update(Product product); } diff --git a/src/main/java/page/clab/api/domain/members/product/domain/Product.java b/src/main/java/page/clab/api/domain/members/product/domain/Product.java index 0dab1e2c1..fccaf46c2 100644 --- a/src/main/java/page/clab/api/domain/members/product/domain/Product.java +++ b/src/main/java/page/clab/api/domain/members/product/domain/Product.java @@ -1,5 +1,7 @@ package page.clab.api.domain.members.product.domain; +import java.time.LocalDateTime; +import java.util.Optional; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -8,9 +10,6 @@ import lombok.Setter; import page.clab.api.domain.members.product.application.dto.request.ProductUpdateRequestDto; -import java.time.LocalDateTime; -import java.util.Optional; - @Getter @Setter @Builder diff --git a/src/main/java/page/clab/api/domain/members/schedule/adapter/in/web/ActivitySchedulesRetrievalController.java b/src/main/java/page/clab/api/domain/members/schedule/adapter/in/web/ActivitySchedulesRetrievalController.java index 16f24c346..73b8561c0 100644 --- a/src/main/java/page/clab/api/domain/members/schedule/adapter/in/web/ActivitySchedulesRetrievalController.java +++ b/src/main/java/page/clab/api/domain/members/schedule/adapter/in/web/ActivitySchedulesRetrievalController.java @@ -2,6 +2,8 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import java.time.LocalDate; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.security.access.prepost.PreAuthorize; @@ -17,9 +19,6 @@ import page.clab.api.global.exception.SortingArgumentException; import page.clab.api.global.util.PageableUtils; -import java.time.LocalDate; -import java.util.List; - @RestController @RequestMapping("/api/v1/schedules") @RequiredArgsConstructor @@ -30,20 +29,20 @@ public class ActivitySchedulesRetrievalController { private final PageableUtils pageableUtils; @Operation(summary = "[G] 내 활동 일정 조회", description = "ROLE_GUEST 이상의 권한이 필요함
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") @PreAuthorize("hasRole('GUEST')") @GetMapping("/activity") public ApiResponse> retrieveActivitySchedules( - @RequestParam(name = "startDate") LocalDate startDate, - @RequestParam(name = "endDate") LocalDate endDate, - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "startDateTime") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "asc") List sortDirection + @RequestParam(name = "startDate") LocalDate startDate, + @RequestParam(name = "endDate") LocalDate endDate, + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "startDateTime") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "asc") List sortDirection ) throws SortingArgumentException, InvalidColumnException { Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, ScheduleResponseDto.class); PagedResponseDto schedules = - retrieveActivitySchedulesUseCase.retrieveActivitySchedules(startDate, endDate, pageable); + retrieveActivitySchedulesUseCase.retrieveActivitySchedules(startDate, endDate, pageable); return ApiResponse.success(schedules); } } diff --git a/src/main/java/page/clab/api/domain/members/schedule/adapter/in/web/ScheduleRegisterController.java b/src/main/java/page/clab/api/domain/members/schedule/adapter/in/web/ScheduleRegisterController.java index ac568a61d..066d18855 100644 --- a/src/main/java/page/clab/api/domain/members/schedule/adapter/in/web/ScheduleRegisterController.java +++ b/src/main/java/page/clab/api/domain/members/schedule/adapter/in/web/ScheduleRegisterController.java @@ -26,7 +26,7 @@ public class ScheduleRegisterController { @PreAuthorize("hasRole('USER')") @PostMapping("") public ApiResponse registerSchedule( - @Valid @RequestBody ScheduleRequestDto requestDto + @Valid @RequestBody ScheduleRequestDto requestDto ) throws PermissionDeniedException { Long id = registerScheduleUseCase.registerSchedule(requestDto); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/members/schedule/adapter/in/web/ScheduleRemoveController.java b/src/main/java/page/clab/api/domain/members/schedule/adapter/in/web/ScheduleRemoveController.java index 84b04a68f..2f06eb304 100644 --- a/src/main/java/page/clab/api/domain/members/schedule/adapter/in/web/ScheduleRemoveController.java +++ b/src/main/java/page/clab/api/domain/members/schedule/adapter/in/web/ScheduleRemoveController.java @@ -24,7 +24,7 @@ public class ScheduleRemoveController { @PreAuthorize("hasRole('USER')") @DeleteMapping("/{scheduleId}") public ApiResponse removeSchedule( - @PathVariable(name = "scheduleId") Long scheduleId + @PathVariable(name = "scheduleId") Long scheduleId ) throws PermissionDeniedException { Long id = removeScheduleUseCase.removeSchedule(scheduleId); return ApiResponse.success(id); diff --git a/src/main/java/page/clab/api/domain/members/schedule/adapter/in/web/SchedulesByConditionsRetrievalController.java b/src/main/java/page/clab/api/domain/members/schedule/adapter/in/web/SchedulesByConditionsRetrievalController.java index 2bae1af7f..99e621622 100644 --- a/src/main/java/page/clab/api/domain/members/schedule/adapter/in/web/SchedulesByConditionsRetrievalController.java +++ b/src/main/java/page/clab/api/domain/members/schedule/adapter/in/web/SchedulesByConditionsRetrievalController.java @@ -2,6 +2,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.security.access.prepost.PreAuthorize; @@ -18,8 +19,6 @@ import page.clab.api.global.exception.SortingArgumentException; import page.clab.api.global.util.PageableUtils; -import java.util.List; - @RestController @RequestMapping("/api/v1/schedules") @RequiredArgsConstructor @@ -30,23 +29,23 @@ public class SchedulesByConditionsRetrievalController { private final PageableUtils pageableUtils; @Operation(summary = "[G] 일정 조회(연도, 월, 중요도 기준)", description = "ROLE_GUEST 이상의 권한이 필요함
" + - "3개의 파라미터를 자유롭게 조합하여 필터링 가능
" + - "연도, 월, 중요도 중 하나라도 입력하지 않으면 전체 조회됨
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") + "3개의 파라미터를 자유롭게 조합하여 필터링 가능
" + + "연도, 월, 중요도 중 하나라도 입력하지 않으면 전체 조회됨
" + + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") @PreAuthorize("hasRole('GUEST')") @GetMapping("/conditions") public ApiResponse> retrieveSchedulesByConditions( - @RequestParam(name = "year", required = false) Integer year, - @RequestParam(name = "month", required = false) Integer month, - @RequestParam(name = "priority", required = false) SchedulePriority priority, - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "startDateTime") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "asc") List sortDirection + @RequestParam(name = "year", required = false) Integer year, + @RequestParam(name = "month", required = false) Integer month, + @RequestParam(name = "priority", required = false) SchedulePriority priority, + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "startDateTime") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "asc") List sortDirection ) throws SortingArgumentException, InvalidColumnException { Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, ScheduleResponseDto.class); PagedResponseDto schedules = - retrieveSchedulesByConditionsUseCase.retrieveSchedules(year, month, priority, pageable); + retrieveSchedulesByConditionsUseCase.retrieveSchedules(year, month, priority, pageable); return ApiResponse.success(schedules); } } diff --git a/src/main/java/page/clab/api/domain/members/schedule/adapter/in/web/SchedulesWithinDateRangeRetrievalController.java b/src/main/java/page/clab/api/domain/members/schedule/adapter/in/web/SchedulesWithinDateRangeRetrievalController.java index 393570749..02f3afd73 100644 --- a/src/main/java/page/clab/api/domain/members/schedule/adapter/in/web/SchedulesWithinDateRangeRetrievalController.java +++ b/src/main/java/page/clab/api/domain/members/schedule/adapter/in/web/SchedulesWithinDateRangeRetrievalController.java @@ -2,6 +2,8 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import java.time.LocalDate; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.security.access.prepost.PreAuthorize; @@ -17,9 +19,6 @@ import page.clab.api.global.exception.SortingArgumentException; import page.clab.api.global.util.PageableUtils; -import java.time.LocalDate; -import java.util.List; - @RestController @RequestMapping("/api/v1/schedules") @RequiredArgsConstructor @@ -30,20 +29,20 @@ public class SchedulesWithinDateRangeRetrievalController { private final PageableUtils pageableUtils; @Operation(summary = "[G] 일정 조회", description = "ROLE_GUEST 이상의 권한이 필요함
" + - "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") + "DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함") @PreAuthorize("hasRole('GUEST')") @GetMapping("") public ApiResponse> retrieveSchedulesWithinDateRange( - @RequestParam(name = "startDate") LocalDate startDate, - @RequestParam(name = "endDate") LocalDate endDate, - @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "20") int size, - @RequestParam(name = "sortBy", defaultValue = "startDateTime") List sortBy, - @RequestParam(name = "sortDirection", defaultValue = "asc") List sortDirection + @RequestParam(name = "startDate") LocalDate startDate, + @RequestParam(name = "endDate") LocalDate endDate, + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "20") int size, + @RequestParam(name = "sortBy", defaultValue = "startDateTime") List sortBy, + @RequestParam(name = "sortDirection", defaultValue = "asc") List sortDirection ) throws SortingArgumentException, InvalidColumnException { Pageable pageable = pageableUtils.createPageable(page, size, sortBy, sortDirection, ScheduleResponseDto.class); PagedResponseDto schedules = - retrieveSchedulesWithinDateRangeUseCase.retrieveSchedulesWithinDateRange(startDate, endDate, pageable); + retrieveSchedulesWithinDateRangeUseCase.retrieveSchedulesWithinDateRange(startDate, endDate, pageable); return ApiResponse.success(schedules); } } diff --git a/src/main/java/page/clab/api/domain/members/schedule/adapter/out/persistence/ScheduleJpaEntity.java b/src/main/java/page/clab/api/domain/members/schedule/adapter/out/persistence/ScheduleJpaEntity.java index 6963d26af..375ee612b 100644 --- a/src/main/java/page/clab/api/domain/members/schedule/adapter/out/persistence/ScheduleJpaEntity.java +++ b/src/main/java/page/clab/api/domain/members/schedule/adapter/out/persistence/ScheduleJpaEntity.java @@ -10,6 +10,7 @@ import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; import jakarta.persistence.Table; +import java.time.LocalDateTime; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -24,8 +25,6 @@ import page.clab.api.domain.members.schedule.domain.ScheduleType; import page.clab.api.global.common.domain.BaseEntity; -import java.time.LocalDateTime; - @Entity @Table(name = "schedule") @Getter diff --git a/src/main/java/page/clab/api/domain/members/schedule/adapter/out/persistence/SchedulePersistenceAdapter.java b/src/main/java/page/clab/api/domain/members/schedule/adapter/out/persistence/SchedulePersistenceAdapter.java index 012102629..59c860452 100644 --- a/src/main/java/page/clab/api/domain/members/schedule/adapter/out/persistence/SchedulePersistenceAdapter.java +++ b/src/main/java/page/clab/api/domain/members/schedule/adapter/out/persistence/SchedulePersistenceAdapter.java @@ -1,5 +1,7 @@ package page.clab.api.domain.members.schedule.adapter.out.persistence; +import java.time.LocalDate; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -12,14 +14,11 @@ import page.clab.api.domain.members.schedule.domain.SchedulePriority; import page.clab.api.global.exception.NotFoundException; -import java.time.LocalDate; -import java.util.List; - @Component @RequiredArgsConstructor public class SchedulePersistenceAdapter implements - RegisterSchedulePort, - RetrieveSchedulePort { + RegisterSchedulePort, + RetrieveSchedulePort { private final ScheduleRepository repository; private final ScheduleMapper mapper; @@ -34,14 +33,15 @@ public Schedule save(Schedule schedule) { @Override public Schedule getById(Long id) { return repository.findById(id) - .map(mapper::toDomain) - .orElseThrow(() -> new NotFoundException("[Schedule] id: " + id + "에 해당하는 스케줄이 존재하지 않습니다.")); + .map(mapper::toDomain) + .orElseThrow(() -> new NotFoundException("[Schedule] id: " + id + "에 해당하는 스케줄이 존재하지 않습니다.")); } @Override - public Page findActivitySchedulesByDateRangeAndMemberId(LocalDate startDate, LocalDate endDate, String memberId, Pageable pageable) { + public Page findActivitySchedulesByDateRangeAndMemberId(LocalDate startDate, LocalDate endDate, + String memberId, Pageable pageable) { return repository.findActivitySchedulesByDateRangeAndMemberId(startDate, endDate, memberId, pageable) - .map(mapper::toDomain); + .map(mapper::toDomain); } @Override @@ -52,12 +52,13 @@ public ScheduleCollectResponseDto findCollectSchedules() { @Override public Page findByConditions(Integer year, Integer month, SchedulePriority priority, Pageable pageable) { return repository.findByConditions(year, month, priority, pageable) - .map(mapper::toDomain); + .map(mapper::toDomain); } @Override - public Page findByDateRangeAndMember(LocalDate startDate, LocalDate endDate, List myGroups, Pageable pageable) { + public Page findByDateRangeAndMember(LocalDate startDate, LocalDate endDate, List myGroups, + Pageable pageable) { return repository.findByDateRangeAndMember(startDate, endDate, myGroups, pageable) - .map(mapper::toDomain); + .map(mapper::toDomain); } } diff --git a/src/main/java/page/clab/api/domain/members/schedule/adapter/out/persistence/ScheduleRepository.java b/src/main/java/page/clab/api/domain/members/schedule/adapter/out/persistence/ScheduleRepository.java index 1d4ff2654..578089cb1 100644 --- a/src/main/java/page/clab/api/domain/members/schedule/adapter/out/persistence/ScheduleRepository.java +++ b/src/main/java/page/clab/api/domain/members/schedule/adapter/out/persistence/ScheduleRepository.java @@ -3,5 +3,7 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.querydsl.QuerydslPredicateExecutor; -public interface ScheduleRepository extends JpaRepository, ScheduleRepositoryCustom, QuerydslPredicateExecutor { +public interface ScheduleRepository extends JpaRepository, ScheduleRepositoryCustom, + QuerydslPredicateExecutor { + } diff --git a/src/main/java/page/clab/api/domain/members/schedule/adapter/out/persistence/ScheduleRepositoryCustom.java b/src/main/java/page/clab/api/domain/members/schedule/adapter/out/persistence/ScheduleRepositoryCustom.java index 9843f02d8..b2796fb88 100644 --- a/src/main/java/page/clab/api/domain/members/schedule/adapter/out/persistence/ScheduleRepositoryCustom.java +++ b/src/main/java/page/clab/api/domain/members/schedule/adapter/out/persistence/ScheduleRepositoryCustom.java @@ -1,21 +1,22 @@ package page.clab.api.domain.members.schedule.adapter.out.persistence; +import java.time.LocalDate; +import java.util.List; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import page.clab.api.domain.activity.activitygroup.domain.ActivityGroup; import page.clab.api.domain.members.schedule.application.dto.response.ScheduleCollectResponseDto; import page.clab.api.domain.members.schedule.domain.SchedulePriority; -import java.time.LocalDate; -import java.util.List; - public interface ScheduleRepositoryCustom { - Page findByDateRangeAndMember(LocalDate startDate, LocalDate endDate, List myGroups, Pageable pageable); + Page findByDateRangeAndMember(LocalDate startDate, LocalDate endDate, + List myGroups, Pageable pageable); Page findByConditions(Integer year, Integer month, SchedulePriority priority, Pageable pageable); - Page findActivitySchedulesByDateRangeAndMemberId(LocalDate startDate, LocalDate endDate, String memberId, Pageable pageable); + Page findActivitySchedulesByDateRangeAndMemberId(LocalDate startDate, LocalDate endDate, + String memberId, Pageable pageable); ScheduleCollectResponseDto findCollectSchedules(); } diff --git a/src/main/java/page/clab/api/domain/members/schedule/adapter/out/persistence/ScheduleRepositoryImpl.java b/src/main/java/page/clab/api/domain/members/schedule/adapter/out/persistence/ScheduleRepositoryImpl.java index 98b40e471..9c60596d8 100644 --- a/src/main/java/page/clab/api/domain/members/schedule/adapter/out/persistence/ScheduleRepositoryImpl.java +++ b/src/main/java/page/clab/api/domain/members/schedule/adapter/out/persistence/ScheduleRepositoryImpl.java @@ -2,6 +2,9 @@ import com.querydsl.core.BooleanBuilder; import com.querydsl.jpa.impl.JPAQueryFactory; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; @@ -14,10 +17,6 @@ import page.clab.api.domain.members.schedule.domain.ScheduleType; import page.clab.api.global.util.OrderSpecifierUtil; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.util.List; - @Repository @RequiredArgsConstructor public class ScheduleRepositoryImpl implements ScheduleRepositoryCustom { @@ -26,7 +25,8 @@ public class ScheduleRepositoryImpl implements ScheduleRepositoryCustom { private final ScheduleDtoMapper mapper; @Override - public Page findByDateRangeAndMember(LocalDate startDate, LocalDate endDate, List myGroups, Pageable pageable) { + public Page findByDateRangeAndMember(LocalDate startDate, LocalDate endDate, + List myGroups, Pageable pageable) { QScheduleJpaEntity schedule = QScheduleJpaEntity.scheduleJpaEntity; BooleanBuilder builder = new BooleanBuilder(); @@ -34,31 +34,32 @@ public Page findByDateRangeAndMember(LocalDate startDate, Loc LocalDateTime endDateTime = endDate.atTime(23, 59, 59); builder.and(schedule.endDateTime.goe(startDateTime)) - .and(schedule.startDateTime.loe(endDateTime)); + .and(schedule.startDateTime.loe(endDateTime)); if (myGroups != null && !myGroups.isEmpty()) { builder.and(schedule.activityGroup.isNull() - .or(schedule.activityGroup.in(myGroups))); + .or(schedule.activityGroup.in(myGroups))); } else { builder.and(schedule.activityGroup.isNull()); } List results = queryFactory.selectFrom(schedule) - .where(builder) - .orderBy(OrderSpecifierUtil.getOrderSpecifiers(pageable, schedule)) - .offset(pageable.getOffset()) - .limit(pageable.getPageSize()) - .fetch(); + .where(builder) + .orderBy(OrderSpecifierUtil.getOrderSpecifiers(pageable, schedule)) + .offset(pageable.getOffset()) + .limit(pageable.getPageSize()) + .fetch(); long total = queryFactory.selectFrom(schedule) - .where(builder) - .fetchCount(); + .where(builder) + .fetchCount(); return new PageImpl<>(results, pageable, total); } @Override - public Page findByConditions(Integer year, Integer month, SchedulePriority priority, Pageable pageable) { + public Page findByConditions(Integer year, Integer month, SchedulePriority priority, + Pageable pageable) { QScheduleJpaEntity schedule = QScheduleJpaEntity.scheduleJpaEntity; BooleanBuilder builder = new BooleanBuilder(); @@ -73,21 +74,22 @@ public Page findByConditions(Integer year, Integer month, Sch } List results = queryFactory.selectFrom(schedule) - .where(builder) - .orderBy(OrderSpecifierUtil.getOrderSpecifiers(pageable, schedule)) - .offset(pageable.getOffset()) - .limit(pageable.getPageSize()) - .fetch(); + .where(builder) + .orderBy(OrderSpecifierUtil.getOrderSpecifiers(pageable, schedule)) + .offset(pageable.getOffset()) + .limit(pageable.getPageSize()) + .fetch(); long total = queryFactory.selectFrom(schedule) - .where(builder) - .fetchCount(); + .where(builder) + .fetchCount(); return new PageImpl<>(results, pageable, total); } @Override - public Page findActivitySchedulesByDateRangeAndMemberId(LocalDate startDate, LocalDate endDate, String memberId, Pageable pageable) { + public Page findActivitySchedulesByDateRangeAndMemberId(LocalDate startDate, LocalDate endDate, + String memberId, Pageable pageable) { QScheduleJpaEntity schedule = QScheduleJpaEntity.scheduleJpaEntity; BooleanBuilder builder = new BooleanBuilder(); @@ -95,20 +97,20 @@ public Page findActivitySchedulesByDateRangeAndMemberId(Local LocalDateTime endDateTime = endDate.atTime(23, 59, 59); builder.and(schedule.endDateTime.goe(startDateTime)) - .and(schedule.startDateTime.loe(endDateTime)) - .and(schedule.scheduleWriter.eq(memberId)) - .and(schedule.scheduleType.ne(ScheduleType.ALL)); + .and(schedule.startDateTime.loe(endDateTime)) + .and(schedule.scheduleWriter.eq(memberId)) + .and(schedule.scheduleType.ne(ScheduleType.ALL)); List results = queryFactory.selectFrom(schedule) - .where(builder) - .orderBy(OrderSpecifierUtil.getOrderSpecifiers(pageable, schedule)) - .offset(pageable.getOffset()) - .limit(pageable.getPageSize()) - .fetch(); + .where(builder) + .orderBy(OrderSpecifierUtil.getOrderSpecifiers(pageable, schedule)) + .offset(pageable.getOffset()) + .limit(pageable.getPageSize()) + .fetch(); long total = queryFactory.selectFrom(schedule) - .where(builder) - .fetchCount(); + .where(builder) + .fetchCount(); return new PageImpl<>(results, pageable, total); } @@ -122,17 +124,17 @@ public ScheduleCollectResponseDto findCollectSchedules() { LocalDateTime endDateTime = LocalDate.now().withDayOfYear(LocalDate.now().lengthOfYear()).atTime(23, 59, 59); builder.and(schedule.startDateTime.goe(startDateTime)) - .and(schedule.endDateTime.loe(endDateTime)); + .and(schedule.endDateTime.loe(endDateTime)); long total = queryFactory.selectFrom(schedule) - .where(builder) - .fetchCount(); + .where(builder) + .fetchCount(); builder.and(schedule.priority.eq(SchedulePriority.HIGH)); long highPriorityCount = queryFactory.selectFrom(schedule) - .where(builder) - .fetchCount(); + .where(builder) + .fetchCount(); return mapper.of(total, highPriorityCount); } diff --git a/src/main/java/page/clab/api/domain/members/schedule/application/dto/mapper/ScheduleDtoMapper.java b/src/main/java/page/clab/api/domain/members/schedule/application/dto/mapper/ScheduleDtoMapper.java index 5c462192a..ad78e085f 100644 --- a/src/main/java/page/clab/api/domain/members/schedule/application/dto/mapper/ScheduleDtoMapper.java +++ b/src/main/java/page/clab/api/domain/members/schedule/application/dto/mapper/ScheduleDtoMapper.java @@ -12,34 +12,34 @@ public class ScheduleDtoMapper { public Schedule fromDto(ScheduleRequestDto requestDto, String memberId, ActivityGroup activityGroup) { return Schedule.builder() - .scheduleType(requestDto.getScheduleType()) - .title(requestDto.getTitle()) - .detail(requestDto.getDetail()) - .startDateTime(requestDto.getStartDateTime()) - .endDateTime(requestDto.getEndDateTime()) - .priority(requestDto.getPriority()) - .scheduleWriter(memberId) - .activityGroup(activityGroup) - .isDeleted(false) - .build(); + .scheduleType(requestDto.getScheduleType()) + .title(requestDto.getTitle()) + .detail(requestDto.getDetail()) + .startDateTime(requestDto.getStartDateTime()) + .endDateTime(requestDto.getEndDateTime()) + .priority(requestDto.getPriority()) + .scheduleWriter(memberId) + .activityGroup(activityGroup) + .isDeleted(false) + .build(); } public ScheduleResponseDto toDto(Schedule schedule) { return ScheduleResponseDto.builder() - .id(schedule.getId()) - .title(schedule.getTitle()) - .detail(schedule.getDetail()) - .activityName(schedule.isAllSchedule() ? null : schedule.getActivityGroup().getName()) - .startDateTime(schedule.getStartDateTime()) - .endDateTime(schedule.getEndDateTime()) - .priority(schedule.getPriority()) - .build(); + .id(schedule.getId()) + .title(schedule.getTitle()) + .detail(schedule.getDetail()) + .activityName(schedule.isAllSchedule() ? null : schedule.getActivityGroup().getName()) + .startDateTime(schedule.getStartDateTime()) + .endDateTime(schedule.getEndDateTime()) + .priority(schedule.getPriority()) + .build(); } public ScheduleCollectResponseDto of(Long totalScheduleCount, Long totalEventCount) { return ScheduleCollectResponseDto.builder() - .totalScheduleCount(totalScheduleCount) - .totalEventCount(totalEventCount) - .build(); + .totalScheduleCount(totalScheduleCount) + .totalEventCount(totalEventCount) + .build(); } } diff --git a/src/main/java/page/clab/api/domain/members/schedule/application/dto/request/ScheduleRequestDto.java b/src/main/java/page/clab/api/domain/members/schedule/application/dto/request/ScheduleRequestDto.java index be6383f23..8ffb492df 100644 --- a/src/main/java/page/clab/api/domain/members/schedule/application/dto/request/ScheduleRequestDto.java +++ b/src/main/java/page/clab/api/domain/members/schedule/application/dto/request/ScheduleRequestDto.java @@ -2,13 +2,12 @@ import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotNull; +import java.time.LocalDateTime; import lombok.Getter; import lombok.Setter; import page.clab.api.domain.members.schedule.domain.SchedulePriority; import page.clab.api.domain.members.schedule.domain.ScheduleType; -import java.time.LocalDateTime; - @Getter @Setter public class ScheduleRequestDto { diff --git a/src/main/java/page/clab/api/domain/members/schedule/application/dto/response/ScheduleResponseDto.java b/src/main/java/page/clab/api/domain/members/schedule/application/dto/response/ScheduleResponseDto.java index a4e037a2c..6307474e5 100644 --- a/src/main/java/page/clab/api/domain/members/schedule/application/dto/response/ScheduleResponseDto.java +++ b/src/main/java/page/clab/api/domain/members/schedule/application/dto/response/ScheduleResponseDto.java @@ -1,11 +1,10 @@ package page.clab.api.domain.members.schedule.application.dto.response; +import java.time.LocalDateTime; import lombok.Builder; import lombok.Getter; import page.clab.api.domain.members.schedule.domain.SchedulePriority; -import java.time.LocalDateTime; - @Getter @Builder public class ScheduleResponseDto { diff --git a/src/main/java/page/clab/api/domain/members/schedule/application/port/in/RegisterScheduleUseCase.java b/src/main/java/page/clab/api/domain/members/schedule/application/port/in/RegisterScheduleUseCase.java index 3f0fde9ff..ab45c8e07 100644 --- a/src/main/java/page/clab/api/domain/members/schedule/application/port/in/RegisterScheduleUseCase.java +++ b/src/main/java/page/clab/api/domain/members/schedule/application/port/in/RegisterScheduleUseCase.java @@ -4,5 +4,6 @@ import page.clab.api.global.exception.PermissionDeniedException; public interface RegisterScheduleUseCase { + Long registerSchedule(ScheduleRequestDto requestDto) throws PermissionDeniedException; } diff --git a/src/main/java/page/clab/api/domain/members/schedule/application/port/in/RemoveScheduleUseCase.java b/src/main/java/page/clab/api/domain/members/schedule/application/port/in/RemoveScheduleUseCase.java index 496d239a8..543959047 100644 --- a/src/main/java/page/clab/api/domain/members/schedule/application/port/in/RemoveScheduleUseCase.java +++ b/src/main/java/page/clab/api/domain/members/schedule/application/port/in/RemoveScheduleUseCase.java @@ -3,5 +3,6 @@ import page.clab.api.global.exception.PermissionDeniedException; public interface RemoveScheduleUseCase { + Long removeSchedule(Long scheduleId) throws PermissionDeniedException; } diff --git a/src/main/java/page/clab/api/domain/members/schedule/application/port/in/RetrieveActivitySchedulesUseCase.java b/src/main/java/page/clab/api/domain/members/schedule/application/port/in/RetrieveActivitySchedulesUseCase.java index cbe7fa35c..815f10efb 100644 --- a/src/main/java/page/clab/api/domain/members/schedule/application/port/in/RetrieveActivitySchedulesUseCase.java +++ b/src/main/java/page/clab/api/domain/members/schedule/application/port/in/RetrieveActivitySchedulesUseCase.java @@ -1,11 +1,12 @@ package page.clab.api.domain.members.schedule.application.port.in; +import java.time.LocalDate; import org.springframework.data.domain.Pageable; import page.clab.api.domain.members.schedule.application.dto.response.ScheduleResponseDto; import page.clab.api.global.common.dto.PagedResponseDto; -import java.time.LocalDate; - public interface RetrieveActivitySchedulesUseCase { - PagedResponseDto retrieveActivitySchedules(LocalDate startDate, LocalDate endDate, Pageable pageable); + + PagedResponseDto retrieveActivitySchedules(LocalDate startDate, LocalDate endDate, + Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/members/schedule/application/port/in/RetrieveCollectSchedulesUseCase.java b/src/main/java/page/clab/api/domain/members/schedule/application/port/in/RetrieveCollectSchedulesUseCase.java index 2e99d1881..acedb78e5 100644 --- a/src/main/java/page/clab/api/domain/members/schedule/application/port/in/RetrieveCollectSchedulesUseCase.java +++ b/src/main/java/page/clab/api/domain/members/schedule/application/port/in/RetrieveCollectSchedulesUseCase.java @@ -3,5 +3,6 @@ import page.clab.api.domain.members.schedule.application.dto.response.ScheduleCollectResponseDto; public interface RetrieveCollectSchedulesUseCase { + ScheduleCollectResponseDto retrieveCollectSchedules(); } diff --git a/src/main/java/page/clab/api/domain/members/schedule/application/port/in/RetrieveSchedulesByConditionsUseCase.java b/src/main/java/page/clab/api/domain/members/schedule/application/port/in/RetrieveSchedulesByConditionsUseCase.java index f655bbc09..79c5330b0 100644 --- a/src/main/java/page/clab/api/domain/members/schedule/application/port/in/RetrieveSchedulesByConditionsUseCase.java +++ b/src/main/java/page/clab/api/domain/members/schedule/application/port/in/RetrieveSchedulesByConditionsUseCase.java @@ -6,5 +6,7 @@ import page.clab.api.global.common.dto.PagedResponseDto; public interface RetrieveSchedulesByConditionsUseCase { - PagedResponseDto retrieveSchedules(Integer year, Integer month, SchedulePriority priority, Pageable pageable); + + PagedResponseDto retrieveSchedules(Integer year, Integer month, SchedulePriority priority, + Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/members/schedule/application/port/in/RetrieveSchedulesWithinDateRangeUseCase.java b/src/main/java/page/clab/api/domain/members/schedule/application/port/in/RetrieveSchedulesWithinDateRangeUseCase.java index e92ae0cae..9cae4c258 100644 --- a/src/main/java/page/clab/api/domain/members/schedule/application/port/in/RetrieveSchedulesWithinDateRangeUseCase.java +++ b/src/main/java/page/clab/api/domain/members/schedule/application/port/in/RetrieveSchedulesWithinDateRangeUseCase.java @@ -1,11 +1,12 @@ package page.clab.api.domain.members.schedule.application.port.in; +import java.time.LocalDate; import org.springframework.data.domain.Pageable; import page.clab.api.domain.members.schedule.application.dto.response.ScheduleResponseDto; import page.clab.api.global.common.dto.PagedResponseDto; -import java.time.LocalDate; - public interface RetrieveSchedulesWithinDateRangeUseCase { - PagedResponseDto retrieveSchedulesWithinDateRange(LocalDate startDate, LocalDate endDate, Pageable pageable); + + PagedResponseDto retrieveSchedulesWithinDateRange(LocalDate startDate, LocalDate endDate, + Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/members/schedule/application/port/out/RegisterSchedulePort.java b/src/main/java/page/clab/api/domain/members/schedule/application/port/out/RegisterSchedulePort.java index a4ee03252..c31541a40 100644 --- a/src/main/java/page/clab/api/domain/members/schedule/application/port/out/RegisterSchedulePort.java +++ b/src/main/java/page/clab/api/domain/members/schedule/application/port/out/RegisterSchedulePort.java @@ -3,5 +3,6 @@ import page.clab.api.domain.members.schedule.domain.Schedule; public interface RegisterSchedulePort { + Schedule save(Schedule schedule); } diff --git a/src/main/java/page/clab/api/domain/members/schedule/application/port/out/RetrieveSchedulePort.java b/src/main/java/page/clab/api/domain/members/schedule/application/port/out/RetrieveSchedulePort.java index 51f46c649..399e583b6 100644 --- a/src/main/java/page/clab/api/domain/members/schedule/application/port/out/RetrieveSchedulePort.java +++ b/src/main/java/page/clab/api/domain/members/schedule/application/port/out/RetrieveSchedulePort.java @@ -1,5 +1,7 @@ package page.clab.api.domain.members.schedule.application.port.out; +import java.time.LocalDate; +import java.util.List; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import page.clab.api.domain.activity.activitygroup.domain.ActivityGroup; @@ -7,18 +9,17 @@ import page.clab.api.domain.members.schedule.domain.Schedule; import page.clab.api.domain.members.schedule.domain.SchedulePriority; -import java.time.LocalDate; -import java.util.List; - public interface RetrieveSchedulePort { Schedule getById(Long id); Page findByConditions(Integer year, Integer month, SchedulePriority priority, Pageable pageable); - Page findActivitySchedulesByDateRangeAndMemberId(LocalDate startDate, LocalDate endDate, String memberId, Pageable pageable); + Page findActivitySchedulesByDateRangeAndMemberId(LocalDate startDate, LocalDate endDate, String memberId, + Pageable pageable); ScheduleCollectResponseDto findCollectSchedules(); - Page findByDateRangeAndMember(LocalDate startDate, LocalDate endDate, List myGroups, Pageable pageable); + Page findByDateRangeAndMember(LocalDate startDate, LocalDate endDate, List myGroups, + Pageable pageable); } diff --git a/src/main/java/page/clab/api/domain/members/schedule/application/service/ActivitySchedulesRetrievalService.java b/src/main/java/page/clab/api/domain/members/schedule/application/service/ActivitySchedulesRetrievalService.java index 2cf8198b5..2469e917b 100644 --- a/src/main/java/page/clab/api/domain/members/schedule/application/service/ActivitySchedulesRetrievalService.java +++ b/src/main/java/page/clab/api/domain/members/schedule/application/service/ActivitySchedulesRetrievalService.java @@ -1,5 +1,6 @@ package page.clab.api.domain.members.schedule.application.service; +import java.time.LocalDate; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -13,8 +14,6 @@ import page.clab.api.external.memberManagement.member.application.port.ExternalRetrieveMemberUseCase; import page.clab.api.global.common.dto.PagedResponseDto; -import java.time.LocalDate; - @Service @RequiredArgsConstructor public class ActivitySchedulesRetrievalService implements RetrieveActivitySchedulesUseCase { @@ -25,9 +24,11 @@ public class ActivitySchedulesRetrievalService implements RetrieveActivitySchedu @Override @Transactional(readOnly = true) - public PagedResponseDto retrieveActivitySchedules(LocalDate startDate, LocalDate endDate, Pageable pageable) { + public PagedResponseDto retrieveActivitySchedules(LocalDate startDate, LocalDate endDate, + Pageable pageable) { String currentMemberId = externalRetrieveMemberUseCase.getCurrentMemberId(); - Page schedules = retrieveSchedulePort.findActivitySchedulesByDateRangeAndMemberId(startDate, endDate, currentMemberId, pageable); + Page schedules = retrieveSchedulePort.findActivitySchedulesByDateRangeAndMemberId(startDate, endDate, + currentMemberId, pageable); return new PagedResponseDto<>(schedules.map(mapper::toDto)); } } diff --git a/src/main/java/page/clab/api/domain/members/schedule/application/service/ScheduleRegisterService.java b/src/main/java/page/clab/api/domain/members/schedule/application/service/ScheduleRegisterService.java index cdac8c5d4..f8bc9edf3 100644 --- a/src/main/java/page/clab/api/domain/members/schedule/application/service/ScheduleRegisterService.java +++ b/src/main/java/page/clab/api/domain/members/schedule/application/service/ScheduleRegisterService.java @@ -1,5 +1,7 @@ package page.clab.api.domain.members.schedule.application.service; +import java.util.List; +import java.util.Optional; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -19,9 +21,6 @@ import page.clab.api.external.memberManagement.member.application.port.ExternalRetrieveMemberUseCase; import page.clab.api.global.exception.PermissionDeniedException; -import java.util.List; -import java.util.Optional; - @Service @RequiredArgsConstructor public class ScheduleRegisterService implements RegisterScheduleUseCase { @@ -43,21 +42,25 @@ public Long registerSchedule(ScheduleRequestDto requestDto) throws PermissionDen return registerSchedulePort.save(schedule).getId(); } - private ActivityGroup resolveActivityGroupForSchedule(ScheduleRequestDto requestDto, MemberDetailedInfoDto memberInfo) throws PermissionDeniedException { + private ActivityGroup resolveActivityGroupForSchedule(ScheduleRequestDto requestDto, + MemberDetailedInfoDto memberInfo) throws PermissionDeniedException { ScheduleType scheduleType = requestDto.getScheduleType(); ActivityGroup activityGroup = null; if (!scheduleType.equals(ScheduleType.ALL)) { Long activityGroupId = Optional.ofNullable(requestDto.getActivityGroupId()) - .orElseThrow(() -> new NullPointerException("스터디 또는 프로젝트 일정은 그룹 id를 입력해야 합니다.")); + .orElseThrow(() -> new NullPointerException("스터디 또는 프로젝트 일정은 그룹 id를 입력해야 합니다.")); activityGroup = activityGroupAdminService.getActivityGroupById(activityGroupId); validateMemberIsGroupLeaderOrAdmin(memberInfo, activityGroup); } return activityGroup; } - private void validateMemberIsGroupLeaderOrAdmin(MemberDetailedInfoDto memberInfo, ActivityGroup activityGroup) throws PermissionDeniedException { - List groupLeaders = activityGroupMemberService.getGroupMemberByActivityGroupIdAndRole(activityGroup.getId(), ActivityGroupRole.LEADER); - if (!CollectionUtils.isEmpty(groupLeaders) && !memberInfo.isAdminRole() && groupLeaders.stream().noneMatch(leader -> leader.isOwner(memberInfo.getMemberId()))) { + private void validateMemberIsGroupLeaderOrAdmin(MemberDetailedInfoDto memberInfo, ActivityGroup activityGroup) + throws PermissionDeniedException { + List groupLeaders = activityGroupMemberService.getGroupMemberByActivityGroupIdAndRole( + activityGroup.getId(), ActivityGroupRole.LEADER); + if (!CollectionUtils.isEmpty(groupLeaders) && !memberInfo.isAdminRole() && groupLeaders.stream() + .noneMatch(leader -> leader.isOwner(memberInfo.getMemberId()))) { throw new PermissionDeniedException("해당 스터디 또는 프로젝트의 LEADER, 관리자만 그룹 일정을 추가할 수 있습니다."); } } diff --git a/src/main/java/page/clab/api/domain/members/schedule/application/service/SchedulesByConditionsRetrievalService.java b/src/main/java/page/clab/api/domain/members/schedule/application/service/SchedulesByConditionsRetrievalService.java index 5018d061f..0d5ef9d01 100644 --- a/src/main/java/page/clab/api/domain/members/schedule/application/service/SchedulesByConditionsRetrievalService.java +++ b/src/main/java/page/clab/api/domain/members/schedule/application/service/SchedulesByConditionsRetrievalService.java @@ -22,7 +22,8 @@ public class SchedulesByConditionsRetrievalService implements RetrieveSchedulesB @Override @Transactional(readOnly = true) - public PagedResponseDto retrieveSchedules(Integer year, Integer month, SchedulePriority priority, Pageable pageable) { + public PagedResponseDto retrieveSchedules(Integer year, Integer month, + SchedulePriority priority, Pageable pageable) { Page schedules = retrieveSchedulePort.findByConditions(year, month, priority, pageable); return new PagedResponseDto<>(schedules.map(mapper::toDto)); } diff --git a/src/main/java/page/clab/api/domain/members/schedule/application/service/SchedulesWithinDateRangeRetrievalService.java b/src/main/java/page/clab/api/domain/members/schedule/application/service/SchedulesWithinDateRangeRetrievalService.java index dc1d4547e..cd841ca9c 100644 --- a/src/main/java/page/clab/api/domain/members/schedule/application/service/SchedulesWithinDateRangeRetrievalService.java +++ b/src/main/java/page/clab/api/domain/members/schedule/application/service/SchedulesWithinDateRangeRetrievalService.java @@ -1,5 +1,8 @@ package page.clab.api.domain.members.schedule.application.service; +import java.time.LocalDate; +import java.util.List; +import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -16,10 +19,6 @@ import page.clab.api.external.memberManagement.member.application.port.ExternalRetrieveMemberUseCase; import page.clab.api.global.common.dto.PagedResponseDto; -import java.time.LocalDate; -import java.util.List; -import java.util.stream.Collectors; - @Service @RequiredArgsConstructor public class SchedulesWithinDateRangeRetrievalService implements RetrieveSchedulesWithinDateRangeUseCase { @@ -31,17 +30,19 @@ public class SchedulesWithinDateRangeRetrievalService implements RetrieveSchedul @Override @Transactional(readOnly = true) - public PagedResponseDto retrieveSchedulesWithinDateRange(LocalDate startDate, LocalDate endDate, Pageable pageable) { + public PagedResponseDto retrieveSchedulesWithinDateRange(LocalDate startDate, + LocalDate endDate, Pageable pageable) { String currentMemberId = externalRetrieveMemberUseCase.getCurrentMemberId(); List groupMembers = activityGroupMemberService.getGroupMemberByMemberId(currentMemberId); List myGroups = getMyActivityGroups(groupMembers); - Page schedules = retrieveSchedulePort.findByDateRangeAndMember(startDate, endDate, myGroups, pageable); + Page schedules = retrieveSchedulePort.findByDateRangeAndMember(startDate, endDate, myGroups, + pageable); return new PagedResponseDto<>(schedules.map(mapper::toDto)); } private List getMyActivityGroups(List groupMembers) { return groupMembers.stream() - .map(GroupMember::getActivityGroup) - .collect(Collectors.toList()); + .map(GroupMember::getActivityGroup) + .collect(Collectors.toList()); } } diff --git a/src/main/java/page/clab/api/domain/members/schedule/domain/Schedule.java b/src/main/java/page/clab/api/domain/members/schedule/domain/Schedule.java index b74bb5479..8651df20a 100644 --- a/src/main/java/page/clab/api/domain/members/schedule/domain/Schedule.java +++ b/src/main/java/page/clab/api/domain/members/schedule/domain/Schedule.java @@ -1,5 +1,6 @@ package page.clab.api.domain.members.schedule.domain; +import java.time.LocalDateTime; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -12,8 +13,6 @@ import page.clab.api.global.exception.InvalidDateRangeException; import page.clab.api.global.exception.PermissionDeniedException; -import java.time.LocalDateTime; - @Getter @Setter @Builder diff --git a/src/main/java/page/clab/api/external/auth/accountAccessLog/application/port/ExternalRegisterAccountAccessLogUseCase.java b/src/main/java/page/clab/api/external/auth/accountAccessLog/application/port/ExternalRegisterAccountAccessLogUseCase.java index d38d92d72..0af6a3fc6 100644 --- a/src/main/java/page/clab/api/external/auth/accountAccessLog/application/port/ExternalRegisterAccountAccessLogUseCase.java +++ b/src/main/java/page/clab/api/external/auth/accountAccessLog/application/port/ExternalRegisterAccountAccessLogUseCase.java @@ -4,5 +4,6 @@ import page.clab.api.domain.auth.accountAccessLog.domain.AccountAccessResult; public interface ExternalRegisterAccountAccessLogUseCase { + void registerAccountAccessLog(HttpServletRequest request, String memberId, AccountAccessResult accountAccessResult); } diff --git a/src/main/java/page/clab/api/external/auth/accountAccessLog/application/service/ExternalAccountAccessLogRegisterService.java b/src/main/java/page/clab/api/external/auth/accountAccessLog/application/service/ExternalAccountAccessLogRegisterService.java index 2af5d2cd6..cca3fc1bb 100644 --- a/src/main/java/page/clab/api/external/auth/accountAccessLog/application/service/ExternalAccountAccessLogRegisterService.java +++ b/src/main/java/page/clab/api/external/auth/accountAccessLog/application/service/ExternalAccountAccessLogRegisterService.java @@ -20,10 +20,12 @@ public class ExternalAccountAccessLogRegisterService implements ExternalRegister @Transactional @Override - public void registerAccountAccessLog(HttpServletRequest request, String memberId, AccountAccessResult accountAccessResult) { + public void registerAccountAccessLog(HttpServletRequest request, String memberId, + AccountAccessResult accountAccessResult) { String clientIpAddress = HttpReqResUtil.getClientIpAddressIfServletRequestExist(); IPResponse ipResponse = HttpReqResUtil.isBogonRequest(clientIpAddress) ? null : IPInfoUtil.getIpInfo(request); - AccountAccessLog accountAccessLog = AccountAccessLog.create(memberId, request, clientIpAddress, ipResponse, accountAccessResult); + AccountAccessLog accountAccessLog = AccountAccessLog.create(memberId, request, clientIpAddress, ipResponse, + accountAccessResult); registerAccountAccessLogPort.save(accountAccessLog); } } diff --git a/src/main/java/page/clab/api/external/auth/accountLockInfo/application/ExternalManageAccountLockUseCase.java b/src/main/java/page/clab/api/external/auth/accountLockInfo/application/ExternalManageAccountLockUseCase.java index cc5b535da..a335a3c7f 100644 --- a/src/main/java/page/clab/api/external/auth/accountLockInfo/application/ExternalManageAccountLockUseCase.java +++ b/src/main/java/page/clab/api/external/auth/accountLockInfo/application/ExternalManageAccountLockUseCase.java @@ -8,5 +8,6 @@ public interface ExternalManageAccountLockUseCase { void handleAccountLockInfo(String memberId) throws LoginFailedException, MemberLockedException; - void handleLoginFailure(HttpServletRequest request, String memberId) throws LoginFailedException, MemberLockedException; + void handleLoginFailure(HttpServletRequest request, String memberId) + throws LoginFailedException, MemberLockedException; } diff --git a/src/main/java/page/clab/api/external/auth/accountLockInfo/port/ExternalAccountLockManagementService.java b/src/main/java/page/clab/api/external/auth/accountLockInfo/port/ExternalAccountLockManagementService.java index 436c68313..c550ee0be 100644 --- a/src/main/java/page/clab/api/external/auth/accountLockInfo/port/ExternalAccountLockManagementService.java +++ b/src/main/java/page/clab/api/external/auth/accountLockInfo/port/ExternalAccountLockManagementService.java @@ -66,7 +66,7 @@ public void handleAccountLockInfo(String memberId) throws MemberLockedException, @Transactional @Override public void handleLoginFailure(HttpServletRequest request, String memberId) - throws MemberLockedException, LoginFailedException { + throws MemberLockedException, LoginFailedException { ensureMemberExists(memberId); AccountLockInfo accountLockInfo = ensureAccountLockInfo(memberId); validateAccountLockStatus(accountLockInfo); @@ -80,7 +80,7 @@ public void handleLoginFailure(HttpServletRequest request, String memberId) private AccountLockInfo ensureAccountLockInfo(String memberId) { return retrieveAccountLockInfoPort.findByMemberId(memberId) - .orElseGet(() -> registerAccountLockInfoPort.save(AccountLockInfo.create(memberId))); + .orElseGet(() -> registerAccountLockInfoPort.save(AccountLockInfo.create(memberId))); } private void ensureMemberExists(String memberId) throws LoginFailedException { @@ -102,8 +102,8 @@ private void sendSlackLoginFailureNotification(HttpServletRequest request, Strin request.setAttribute("member", memberId + " " + memberName); String repeatedLoginFailuresMessage = "로그인 실패 횟수 초과로 계정이 잠겼습니다."; eventPublisher.publishEvent( - new NotificationEvent(this, SecurityAlertType.REPEATED_LOGIN_FAILURES, request, - repeatedLoginFailuresMessage)); + new NotificationEvent(this, SecurityAlertType.REPEATED_LOGIN_FAILURES, request, + repeatedLoginFailuresMessage)); } } } diff --git a/src/main/java/page/clab/api/external/auth/blacklistIp/application/port/ExternalRegisterBlacklistIpUseCase.java b/src/main/java/page/clab/api/external/auth/blacklistIp/application/port/ExternalRegisterBlacklistIpUseCase.java index 0e3f6bc4c..b209fdc50 100644 --- a/src/main/java/page/clab/api/external/auth/blacklistIp/application/port/ExternalRegisterBlacklistIpUseCase.java +++ b/src/main/java/page/clab/api/external/auth/blacklistIp/application/port/ExternalRegisterBlacklistIpUseCase.java @@ -3,5 +3,6 @@ import page.clab.api.domain.auth.blacklistIp.domain.BlacklistIp; public interface ExternalRegisterBlacklistIpUseCase { + void save(BlacklistIp blacklistIp); } diff --git a/src/main/java/page/clab/api/external/auth/blacklistIp/application/port/ExternalRetrieveBlacklistIpUseCase.java b/src/main/java/page/clab/api/external/auth/blacklistIp/application/port/ExternalRetrieveBlacklistIpUseCase.java index 0eaeda052..dfe0b18b7 100644 --- a/src/main/java/page/clab/api/external/auth/blacklistIp/application/port/ExternalRetrieveBlacklistIpUseCase.java +++ b/src/main/java/page/clab/api/external/auth/blacklistIp/application/port/ExternalRetrieveBlacklistIpUseCase.java @@ -1,5 +1,6 @@ package page.clab.api.external.auth.blacklistIp.application.port; public interface ExternalRetrieveBlacklistIpUseCase { + boolean existsByIpAddress(String clientIpAddress); } diff --git a/src/main/java/page/clab/api/external/auth/redisIpAccessMonitor/application/port/ExternalCheckIpBlockedUseCase.java b/src/main/java/page/clab/api/external/auth/redisIpAccessMonitor/application/port/ExternalCheckIpBlockedUseCase.java index 5da81e5de..ba49239fe 100644 --- a/src/main/java/page/clab/api/external/auth/redisIpAccessMonitor/application/port/ExternalCheckIpBlockedUseCase.java +++ b/src/main/java/page/clab/api/external/auth/redisIpAccessMonitor/application/port/ExternalCheckIpBlockedUseCase.java @@ -1,5 +1,6 @@ package page.clab.api.external.auth.redisIpAccessMonitor.application.port; public interface ExternalCheckIpBlockedUseCase { + boolean isIpBlocked(String clientIpAddress); } diff --git a/src/main/java/page/clab/api/external/auth/redisIpAccessMonitor/application/port/ExternalRegisterIpAccessMonitorUseCase.java b/src/main/java/page/clab/api/external/auth/redisIpAccessMonitor/application/port/ExternalRegisterIpAccessMonitorUseCase.java index acafc0b74..33672b3cb 100644 --- a/src/main/java/page/clab/api/external/auth/redisIpAccessMonitor/application/port/ExternalRegisterIpAccessMonitorUseCase.java +++ b/src/main/java/page/clab/api/external/auth/redisIpAccessMonitor/application/port/ExternalRegisterIpAccessMonitorUseCase.java @@ -3,5 +3,6 @@ import jakarta.servlet.http.HttpServletRequest; public interface ExternalRegisterIpAccessMonitorUseCase { + void registerIpAccessMonitor(HttpServletRequest request, String clientIpAddress); } diff --git a/src/main/java/page/clab/api/external/auth/redisIpAccessMonitor/application/service/ExternalIpAccessMonitorRegisterService.java b/src/main/java/page/clab/api/external/auth/redisIpAccessMonitor/application/service/ExternalIpAccessMonitorRegisterService.java index 61ac9a980..d3b1eb941 100644 --- a/src/main/java/page/clab/api/external/auth/redisIpAccessMonitor/application/service/ExternalIpAccessMonitorRegisterService.java +++ b/src/main/java/page/clab/api/external/auth/redisIpAccessMonitor/application/service/ExternalIpAccessMonitorRegisterService.java @@ -32,8 +32,8 @@ public void registerIpAccessMonitor(HttpServletRequest request, String ipAddress if (redisIpAccessMonitor.isBlocked()) { String abnormalAccessIpBlockedMessage = "Blocked IP: " + ipAddress; eventPublisher.publishEvent( - new NotificationEvent(this, SecurityAlertType.ABNORMAL_ACCESS_IP_BLOCKED, request, - abnormalAccessIpBlockedMessage)); + new NotificationEvent(this, SecurityAlertType.ABNORMAL_ACCESS_IP_BLOCKED, request, + abnormalAccessIpBlockedMessage)); } registerIpAccessMonitorPort.save(redisIpAccessMonitor); } @@ -41,11 +41,11 @@ public void registerIpAccessMonitor(HttpServletRequest request, String ipAddress @NotNull private RedisIpAccessMonitor getOrCreateRedisIpAccessMonitor(String ipAddress) { return retrieveIpAccessMonitorPort.findById(ipAddress) - .map(attempt -> { - attempt.increaseAttempts(); - attempt.updateLastAttempt(); - return attempt; - }) - .orElseGet(() -> RedisIpAccessMonitor.create(ipAddress, maxAttempts)); + .map(attempt -> { + attempt.increaseAttempts(); + attempt.updateLastAttempt(); + return attempt; + }) + .orElseGet(() -> RedisIpAccessMonitor.create(ipAddress, maxAttempts)); } } diff --git a/src/main/java/page/clab/api/external/community/comment/application/port/ExternalRegisterCommentUseCase.java b/src/main/java/page/clab/api/external/community/comment/application/port/ExternalRegisterCommentUseCase.java index 55f9b75e3..4294bd931 100644 --- a/src/main/java/page/clab/api/external/community/comment/application/port/ExternalRegisterCommentUseCase.java +++ b/src/main/java/page/clab/api/external/community/comment/application/port/ExternalRegisterCommentUseCase.java @@ -3,5 +3,6 @@ import page.clab.api.domain.community.comment.domain.Comment; public interface ExternalRegisterCommentUseCase { + Comment save(Comment comment); } diff --git a/src/main/java/page/clab/api/external/hashtag/application/service/ExternalHashtagRetrievalService.java b/src/main/java/page/clab/api/external/hashtag/application/service/ExternalHashtagRetrievalService.java index 0c4bfa9e1..0a856cb16 100644 --- a/src/main/java/page/clab/api/external/hashtag/application/service/ExternalHashtagRetrievalService.java +++ b/src/main/java/page/clab/api/external/hashtag/application/service/ExternalHashtagRetrievalService.java @@ -1,6 +1,5 @@ package page.clab.api.external.hashtag.application.service; -import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import page.clab.api.domain.community.hashtag.application.port.in.RetrieveHashtagUseCase; diff --git a/src/main/java/page/clab/api/external/hiring/application/application/port/ExternalRetrieveRecruitmentUseCase.java b/src/main/java/page/clab/api/external/hiring/application/application/port/ExternalRetrieveRecruitmentUseCase.java index 7ca43d743..7af0945a4 100644 --- a/src/main/java/page/clab/api/external/hiring/application/application/port/ExternalRetrieveRecruitmentUseCase.java +++ b/src/main/java/page/clab/api/external/hiring/application/application/port/ExternalRetrieveRecruitmentUseCase.java @@ -1,5 +1,6 @@ package page.clab.api.external.hiring.application.application.port; public interface ExternalRetrieveRecruitmentUseCase { + void validateRecruitmentForApplication(Long recruitmentId); } diff --git a/src/main/java/page/clab/api/external/library/book/application/port/ExternalRegisterBookUseCase.java b/src/main/java/page/clab/api/external/library/book/application/port/ExternalRegisterBookUseCase.java index 4b0169917..dacee873c 100644 --- a/src/main/java/page/clab/api/external/library/book/application/port/ExternalRegisterBookUseCase.java +++ b/src/main/java/page/clab/api/external/library/book/application/port/ExternalRegisterBookUseCase.java @@ -3,5 +3,6 @@ import page.clab.api.domain.library.book.domain.Book; public interface ExternalRegisterBookUseCase { + void save(Book book); } diff --git a/src/main/java/page/clab/api/external/library/bookLoanRecord/application/service/ExternalBookLoanRecordRetrievalService.java b/src/main/java/page/clab/api/external/library/bookLoanRecord/application/service/ExternalBookLoanRecordRetrievalService.java index 4c13331c9..7a76846b2 100644 --- a/src/main/java/page/clab/api/external/library/bookLoanRecord/application/service/ExternalBookLoanRecordRetrievalService.java +++ b/src/main/java/page/clab/api/external/library/bookLoanRecord/application/service/ExternalBookLoanRecordRetrievalService.java @@ -1,5 +1,6 @@ package page.clab.api.external.library.bookLoanRecord.application.service; +import java.time.LocalDateTime; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -8,8 +9,6 @@ import page.clab.api.domain.library.bookLoanRecord.domain.BookLoanStatus; import page.clab.api.external.library.bookLoanRecord.application.port.ExternalRetrieveBookLoanRecordUseCase; -import java.time.LocalDateTime; - @Service @RequiredArgsConstructor public class ExternalBookLoanRecordRetrievalService implements ExternalRetrieveBookLoanRecordUseCase { @@ -20,7 +19,7 @@ public class ExternalBookLoanRecordRetrievalService implements ExternalRetrieveB @Override public LocalDateTime getDueDateForBook(Long bookId) { return retrieveBookLoanRecordPort.findByBookIdAndReturnedAtIsNullAndStatus(bookId, BookLoanStatus.APPROVED) - .map(BookLoanRecord::getDueDate) - .orElse(null); + .map(BookLoanRecord::getDueDate) + .orElse(null); } } diff --git a/src/main/java/page/clab/api/external/memberManagement/cloud/application/port/ExternalRetrieveCloudUsageByMemberIdUseCase.java b/src/main/java/page/clab/api/external/memberManagement/cloud/application/port/ExternalRetrieveCloudUsageByMemberIdUseCase.java index 974d74d66..64ddaf596 100644 --- a/src/main/java/page/clab/api/external/memberManagement/cloud/application/port/ExternalRetrieveCloudUsageByMemberIdUseCase.java +++ b/src/main/java/page/clab/api/external/memberManagement/cloud/application/port/ExternalRetrieveCloudUsageByMemberIdUseCase.java @@ -4,5 +4,6 @@ import page.clab.api.global.exception.PermissionDeniedException; public interface ExternalRetrieveCloudUsageByMemberIdUseCase { + CloudUsageInfo retrieveCloudUsage(String memberId) throws PermissionDeniedException; } diff --git a/src/main/java/page/clab/api/external/memberManagement/member/application/port/ExternalRegisterMemberUseCase.java b/src/main/java/page/clab/api/external/memberManagement/member/application/port/ExternalRegisterMemberUseCase.java index ead96ecee..a5eccae4c 100644 --- a/src/main/java/page/clab/api/external/memberManagement/member/application/port/ExternalRegisterMemberUseCase.java +++ b/src/main/java/page/clab/api/external/memberManagement/member/application/port/ExternalRegisterMemberUseCase.java @@ -3,5 +3,6 @@ import page.clab.api.domain.memberManagement.member.domain.Member; public interface ExternalRegisterMemberUseCase { + void save(Member member); } diff --git a/src/main/java/page/clab/api/external/memberManagement/member/application/port/ExternalRetrieveMemberUseCase.java b/src/main/java/page/clab/api/external/memberManagement/member/application/port/ExternalRetrieveMemberUseCase.java index 20b5cb4db..e07dd5898 100644 --- a/src/main/java/page/clab/api/external/memberManagement/member/application/port/ExternalRetrieveMemberUseCase.java +++ b/src/main/java/page/clab/api/external/memberManagement/member/application/port/ExternalRetrieveMemberUseCase.java @@ -1,5 +1,7 @@ package page.clab.api.external.memberManagement.member.application.port; +import java.util.List; +import java.util.Optional; import page.clab.api.domain.memberManagement.member.application.dto.shared.MemberBasicInfoDto; import page.clab.api.domain.memberManagement.member.application.dto.shared.MemberBorrowerInfoDto; import page.clab.api.domain.memberManagement.member.application.dto.shared.MemberDetailedInfoDto; @@ -9,9 +11,6 @@ import page.clab.api.domain.memberManagement.member.application.dto.shared.MemberReviewInfoDto; import page.clab.api.domain.memberManagement.member.domain.Member; -import java.util.List; -import java.util.Optional; - public interface ExternalRetrieveMemberUseCase { boolean existsById(String memberId); diff --git a/src/main/java/page/clab/api/external/memberManagement/member/application/service/ExternalMemberRetrievalService.java b/src/main/java/page/clab/api/external/memberManagement/member/application/service/ExternalMemberRetrievalService.java index 5dedb7289..d57856651 100644 --- a/src/main/java/page/clab/api/external/memberManagement/member/application/service/ExternalMemberRetrievalService.java +++ b/src/main/java/page/clab/api/external/memberManagement/member/application/service/ExternalMemberRetrievalService.java @@ -1,5 +1,8 @@ package page.clab.api.external.memberManagement.member.application.service; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -19,10 +22,6 @@ import page.clab.api.global.auth.util.AuthUtil; import page.clab.api.global.exception.NotFoundException; -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; - @Service @RequiredArgsConstructor public class ExternalMemberRetrievalService implements ExternalRetrieveMemberUseCase { @@ -81,37 +80,37 @@ public String getCurrentMemberId() { public List getMembers() { List members = retrieveMemberPort.findAll(); return members.stream() - .map(mapper::toEmailInfoDto) - .collect(Collectors.toList()); + .map(mapper::toEmailInfoDto) + .collect(Collectors.toList()); } @Transactional(readOnly = true) @Override public List getMemberIds() { return retrieveMemberPort.findAll() - .stream() - .map(Member::getId) - .collect(Collectors.toList()); + .stream() + .map(Member::getId) + .collect(Collectors.toList()); } @Transactional(readOnly = true) @Override public List getAdminIds() { return retrieveMemberPort.findAll() - .stream() - .filter(Member::isAdminRole) - .map(Member::getId) - .collect(Collectors.toList()); + .stream() + .filter(Member::isAdminRole) + .map(Member::getId) + .collect(Collectors.toList()); } @Transactional(readOnly = true) @Override public List getSuperAdminIds() { return retrieveMemberPort.findAll() - .stream() - .filter(Member::isSuperAdminRole) - .map(Member::getId) - .collect(Collectors.toList()); + .stream() + .filter(Member::isSuperAdminRole) + .map(Member::getId) + .collect(Collectors.toList()); } @Transactional(readOnly = true) diff --git a/src/main/java/page/clab/api/external/memberManagement/member/application/service/ExternalMemberUpdateService.java b/src/main/java/page/clab/api/external/memberManagement/member/application/service/ExternalMemberUpdateService.java index e188b25a7..5ef545b31 100644 --- a/src/main/java/page/clab/api/external/memberManagement/member/application/service/ExternalMemberUpdateService.java +++ b/src/main/java/page/clab/api/external/memberManagement/member/application/service/ExternalMemberUpdateService.java @@ -1,5 +1,6 @@ package page.clab.api.external.memberManagement.member.application.service; +import java.time.LocalDateTime; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -8,8 +9,6 @@ import page.clab.api.domain.memberManagement.member.domain.Member; import page.clab.api.external.memberManagement.member.application.port.ExternalUpdateMemberUseCase; -import java.time.LocalDateTime; - @Service @RequiredArgsConstructor public class ExternalMemberUpdateService implements ExternalUpdateMemberUseCase { diff --git a/src/main/java/page/clab/api/external/memberManagement/notification/application/service/ExternalSendNotificationService.java b/src/main/java/page/clab/api/external/memberManagement/notification/application/service/ExternalSendNotificationService.java index 9d585c28e..297ae2356 100644 --- a/src/main/java/page/clab/api/external/memberManagement/notification/application/service/ExternalSendNotificationService.java +++ b/src/main/java/page/clab/api/external/memberManagement/notification/application/service/ExternalSendNotificationService.java @@ -1,5 +1,7 @@ package page.clab.api.external.memberManagement.notification.application.service; +import java.util.List; +import java.util.function.Supplier; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -8,9 +10,6 @@ import page.clab.api.external.memberManagement.member.application.port.ExternalRetrieveMemberUseCase; import page.clab.api.external.memberManagement.notification.application.port.ExternalSendNotificationUseCase; -import java.util.List; -import java.util.function.Supplier; - @Service @RequiredArgsConstructor public class ExternalSendNotificationService implements ExternalSendNotificationUseCase { @@ -22,8 +21,8 @@ public class ExternalSendNotificationService implements ExternalSendNotification @Override public void sendNotificationToAllMembers(String content) { List notifications = externalRetrieveMemberUseCase.getMemberIds().stream() - .map(memberId -> Notification.create(memberId, content)) - .toList(); + .map(memberId -> Notification.create(memberId, content)) + .toList(); registerNotificationPort.saveAll(notifications); } @@ -39,8 +38,8 @@ public void sendNotificationToMember(String memberId, String content) { @Override public void sendNotificationToMembers(List memberIds, String content) { List notifications = memberIds.stream() - .map(memberId -> Notification.create(memberId, content)) - .toList(); + .map(memberId -> Notification.create(memberId, content)) + .toList(); registerNotificationPort.saveAll(notifications); } @@ -58,8 +57,8 @@ public void sendNotificationToSuperAdmins(String content) { private void sendNotificationToSpecificRole(Supplier> memberSupplier, String content) { List notifications = memberSupplier.get().stream() - .map(memberId -> Notification.create(memberId, content)) - .toList(); + .map(memberId -> Notification.create(memberId, content)) + .toList(); registerNotificationPort.saveAll(notifications); } } diff --git a/src/main/java/page/clab/api/external/memberManagement/position/application/port/ExternalRegisterPositionUseCase.java b/src/main/java/page/clab/api/external/memberManagement/position/application/port/ExternalRegisterPositionUseCase.java index 0ff2af2d9..7f2b5ca0c 100644 --- a/src/main/java/page/clab/api/external/memberManagement/position/application/port/ExternalRegisterPositionUseCase.java +++ b/src/main/java/page/clab/api/external/memberManagement/position/application/port/ExternalRegisterPositionUseCase.java @@ -3,5 +3,6 @@ import page.clab.api.domain.memberManagement.position.domain.Position; public interface ExternalRegisterPositionUseCase { + void save(Position position); } diff --git a/src/main/java/page/clab/api/external/memberManagement/position/application/port/ExternalRetrievePositionUseCase.java b/src/main/java/page/clab/api/external/memberManagement/position/application/port/ExternalRetrievePositionUseCase.java index 391e34361..50891dc4e 100644 --- a/src/main/java/page/clab/api/external/memberManagement/position/application/port/ExternalRetrievePositionUseCase.java +++ b/src/main/java/page/clab/api/external/memberManagement/position/application/port/ExternalRetrievePositionUseCase.java @@ -1,10 +1,10 @@ package page.clab.api.external.memberManagement.position.application.port; +import java.util.Optional; import page.clab.api.domain.memberManagement.position.domain.Position; import page.clab.api.domain.memberManagement.position.domain.PositionType; -import java.util.Optional; - public interface ExternalRetrievePositionUseCase { + Optional findByMemberIdAndYearAndPositionType(String memberId, String year, PositionType positionType); } diff --git a/src/main/java/page/clab/api/external/memberManagement/position/application/service/ExternalPositionRetrievalService.java b/src/main/java/page/clab/api/external/memberManagement/position/application/service/ExternalPositionRetrievalService.java index 3d8b22177..6861eb65c 100644 --- a/src/main/java/page/clab/api/external/memberManagement/position/application/service/ExternalPositionRetrievalService.java +++ b/src/main/java/page/clab/api/external/memberManagement/position/application/service/ExternalPositionRetrievalService.java @@ -1,5 +1,6 @@ package page.clab.api.external.memberManagement.position.application.service; +import java.util.Optional; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -8,8 +9,6 @@ import page.clab.api.domain.memberManagement.position.domain.PositionType; import page.clab.api.external.memberManagement.position.application.port.ExternalRetrievePositionUseCase; -import java.util.Optional; - @Service @RequiredArgsConstructor public class ExternalPositionRetrievalService implements ExternalRetrievePositionUseCase { @@ -18,7 +17,8 @@ public class ExternalPositionRetrievalService implements ExternalRetrievePositio @Transactional(readOnly = true) @Override - public Optional findByMemberIdAndYearAndPositionType(String memberId, String year, PositionType positionType) { + public Optional findByMemberIdAndYearAndPositionType(String memberId, String year, + PositionType positionType) { return retrievePositionPort.findByMemberIdAndYearAndPositionType(memberId, year, positionType); } } diff --git a/src/main/java/page/clab/api/global/auth/application/CustomUserDetailsService.java b/src/main/java/page/clab/api/global/auth/application/CustomUserDetailsService.java index 4d58ce25c..09e56f0b4 100644 --- a/src/main/java/page/clab/api/global/auth/application/CustomUserDetailsService.java +++ b/src/main/java/page/clab/api/global/auth/application/CustomUserDetailsService.java @@ -17,8 +17,8 @@ public class CustomUserDetailsService implements UserDetailsService { @Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { return externalRetrieveMemberUseCase.findById(username) - .map(this::createUserDetails) - .orElseThrow(() -> new UsernameNotFoundException("해당하는 멤버를 찾을 수 없습니다.")); + .map(this::createUserDetails) + .orElseThrow(() -> new UsernameNotFoundException("해당하는 멤버를 찾을 수 없습니다.")); } private UserDetails createUserDetails(Member member) { diff --git a/src/main/java/page/clab/api/global/auth/filter/CustomBasicAuthenticationFilter.java b/src/main/java/page/clab/api/global/auth/filter/CustomBasicAuthenticationFilter.java index ed2287c8e..2863c9428 100644 --- a/src/main/java/page/clab/api/global/auth/filter/CustomBasicAuthenticationFilter.java +++ b/src/main/java/page/clab/api/global/auth/filter/CustomBasicAuthenticationFilter.java @@ -51,11 +51,11 @@ public class CustomBasicAuthenticationFilter extends BasicAuthenticationFilter { private final ApplicationEventPublisher eventPublisher; public CustomBasicAuthenticationFilter( - AuthenticationManager authenticationManager, - IpWhitelistValidator ipWhitelistValidator, - ExternalCheckIpBlockedUseCase externalCheckIpBlockedUseCase, - ExternalRetrieveBlacklistIpUseCase externalRetrieveBlacklistIpUseCase, - ApplicationEventPublisher eventPublisher + AuthenticationManager authenticationManager, + IpWhitelistValidator ipWhitelistValidator, + ExternalCheckIpBlockedUseCase externalCheckIpBlockedUseCase, + ExternalRetrieveBlacklistIpUseCase externalRetrieveBlacklistIpUseCase, + ApplicationEventPublisher eventPublisher ) { super(authenticationManager); this.externalCheckIpBlockedUseCase = externalCheckIpBlockedUseCase; @@ -73,7 +73,7 @@ private static String[] decodeCredentials(String authorizationHeader) { @Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) - throws IOException, ServletException { + throws IOException, ServletException { String path = request.getRequestURI(); if (!WhitelistPathMatcher.isWhitelistRequest(path)) { chain.doFilter(request, response); @@ -89,7 +89,7 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse } private boolean authenticateUserCredentials(HttpServletRequest request, HttpServletResponse response) - throws IOException { + throws IOException { String authorizationHeader = request.getHeader("Authorization"); if (authorizationHeader == null || !authorizationHeader.startsWith("Basic ")) { response.setHeader("WWW-Authenticate", "Basic realm=\"Please enter your username and password\""); @@ -119,8 +119,8 @@ private boolean authenticateUserCredentials(HttpServletRequest request, HttpServ private boolean verifyIpAddressAccess(HttpServletResponse response) throws IOException { String clientIpAddress = HttpReqResUtil.getClientIpAddressIfServletRequestExist(); if (!ipWhitelistValidator.isIpWhitelisted(clientIpAddress) || - externalRetrieveBlacklistIpUseCase.existsByIpAddress(clientIpAddress) || - externalCheckIpBlockedUseCase.isIpBlocked(clientIpAddress) + externalRetrieveBlacklistIpUseCase.existsByIpAddress(clientIpAddress) || + externalCheckIpBlockedUseCase.isIpBlocked(clientIpAddress) ) { log.info("[{}] : 정책에 의해 차단된 IP입니다.", clientIpAddress); ResponseUtil.sendErrorResponse(response, HttpServletResponse.SC_UNAUTHORIZED); @@ -134,11 +134,11 @@ private void sendAuthenticationSuccessAlertSlackMessage(HttpServletRequest reque if (WhitelistPathMatcher.isSwaggerIndexEndpoint(path)) { String apiDocsAccessMessage = "API 문서에 대한 접근이 허가되었습니다."; eventPublisher.publishEvent( - new NotificationEvent(this, SecurityAlertType.API_DOCS_ACCESS, request, apiDocsAccessMessage)); + new NotificationEvent(this, SecurityAlertType.API_DOCS_ACCESS, request, apiDocsAccessMessage)); } else if (WhitelistPathMatcher.isActuatorRequest(path)) { String actuatorAccessMessage = "Actuator에 대한 접근이 허가되었습니다."; eventPublisher.publishEvent( - new NotificationEvent(this, SecurityAlertType.ACTUATOR_ACCESS, request, actuatorAccessMessage)); + new NotificationEvent(this, SecurityAlertType.ACTUATOR_ACCESS, request, actuatorAccessMessage)); } } @@ -147,11 +147,11 @@ private void sendAuthenticationFailureAlertSlackMessage(HttpServletRequest reque if (WhitelistPathMatcher.isSwaggerIndexEndpoint(path)) { String apiDocsAccessMessage = "API 문서에 대한 접근이 거부되었습니다."; eventPublisher.publishEvent( - new NotificationEvent(this, SecurityAlertType.API_DOCS_ACCESS, request, apiDocsAccessMessage)); + new NotificationEvent(this, SecurityAlertType.API_DOCS_ACCESS, request, apiDocsAccessMessage)); } else if (WhitelistPathMatcher.isActuatorRequest(path)) { String actuatorAccessMessage = "Actuator에 대한 접근이 거부되었습니다."; eventPublisher.publishEvent( - new NotificationEvent(this, SecurityAlertType.ACTUATOR_ACCESS, request, actuatorAccessMessage)); + new NotificationEvent(this, SecurityAlertType.ACTUATOR_ACCESS, request, actuatorAccessMessage)); } } } diff --git a/src/main/java/page/clab/api/global/auth/filter/FileAccessControlFilter.java b/src/main/java/page/clab/api/global/auth/filter/FileAccessControlFilter.java index 169a5e119..3afc70741 100644 --- a/src/main/java/page/clab/api/global/auth/filter/FileAccessControlFilter.java +++ b/src/main/java/page/clab/api/global/auth/filter/FileAccessControlFilter.java @@ -16,8 +16,7 @@ * {@code FileAccessControlFilter}는 파일 접근 요청에 대한 접근 제어를 수행하는 필터입니다. * *

특정 URL로 시작하는 요청에 대해 사용자의 인증 정보를 검증하여, 접근 권한이 있는지 확인합니다. - * 파일에 대한 접근 권한이 없는 경우 401 Unauthorized 응답을 반환하며, 권한이 있는 경우 요청을 - * 필터 체인에서 계속 처리합니다.

+ * 파일에 대한 접근 권한이 없는 경우 401 Unauthorized 응답을 반환하며, 권한이 있는 경우 요청을 필터 체인에서 계속 처리합니다.

* *

이 필터는 주로 파일 다운로드 또는 이미지 접근 등 특정 파일 URL에 대한 접근 제어가 필요한 * 상황에서 사용됩니다.

@@ -31,7 +30,8 @@ public class FileAccessControlFilter extends OncePerRequestFilter { private final String fileURL; @Override - protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { + protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) + throws ServletException, IOException { String requestURI = request.getRequestURI(); if (requestURI.startsWith(fileURL)) { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); diff --git a/src/main/java/page/clab/api/global/auth/filter/InvalidEndpointAccessFilter.java b/src/main/java/page/clab/api/global/auth/filter/InvalidEndpointAccessFilter.java index 5f7548fd1..0a4826c4b 100644 --- a/src/main/java/page/clab/api/global/auth/filter/InvalidEndpointAccessFilter.java +++ b/src/main/java/page/clab/api/global/auth/filter/InvalidEndpointAccessFilter.java @@ -50,7 +50,7 @@ public class InvalidEndpointAccessFilter extends GenericFilterBean { @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) - throws IOException, ServletException { + throws IOException, ServletException { HttpServletRequest httpRequest = (HttpServletRequest) request; String path = httpRequest.getRequestURI(); boolean isUploadedFileAccess = path.startsWith(fileURL); @@ -76,7 +76,7 @@ private void handleSuspiciousAccess(HttpServletRequest request, HttpServletRespo private void logSuspiciousAccess(HttpServletRequest request, String clientIpAddress) { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); String id = - (authentication == null || authentication.getName() == null) ? "anonymous" : authentication.getName(); + (authentication == null || authentication.getName() == null) ? "anonymous" : authentication.getName(); String requestUrl = request.getRequestURI(); String httpMethod = request.getMethod(); int statusCode = HttpServletResponse.SC_FORBIDDEN; @@ -88,7 +88,7 @@ private void logSuspiciousAccess(HttpServletRequest request, String clientIpAddr private void sendSecurityAlertIfNotBlacklisted(HttpServletRequest request, String clientIpAddress) { if (!externalRetrieveBlacklistIpUseCase.existsByIpAddress(clientIpAddress)) { externalRegisterBlacklistIpUseCase.save( - BlacklistIp.create(clientIpAddress, "서버 내부 파일 및 디렉토리에 대한 접근 시도") + BlacklistIp.create(clientIpAddress, "서버 내부 파일 및 디렉토리에 대한 접근 시도") ); sendSecurityAlerts(request, clientIpAddress); } @@ -99,8 +99,8 @@ private void sendSecurityAlerts(HttpServletRequest request, String clientIpAddre String blacklistAddedMessage = "Added IP: " + clientIpAddress; eventPublisher.publishEvent(new NotificationEvent(this, SecurityAlertType.ABNORMAL_ACCESS, request, - abnormalAccessMessage)); + abnormalAccessMessage)); eventPublisher.publishEvent(new NotificationEvent(this, SecurityAlertType.BLACKLISTED_IP_ADDED, request, - blacklistAddedMessage)); + blacklistAddedMessage)); } } diff --git a/src/main/java/page/clab/api/global/auth/filter/IpAuthenticationFilter.java b/src/main/java/page/clab/api/global/auth/filter/IpAuthenticationFilter.java index b34382ad6..92e68638e 100644 --- a/src/main/java/page/clab/api/global/auth/filter/IpAuthenticationFilter.java +++ b/src/main/java/page/clab/api/global/auth/filter/IpAuthenticationFilter.java @@ -8,16 +8,15 @@ import jakarta.servlet.ServletException; import jakarta.servlet.ServletRequest; import jakarta.servlet.ServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Objects; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import page.clab.api.global.config.IPInfoConfig; import page.clab.api.global.util.HttpReqResUtil; -import java.io.IOException; -import java.util.List; -import java.util.Objects; - /** * {@code IpAuthenticationFilter}는 IP 주소를 기반으로 클라이언트의 접근 권한을 검증하는 필터입니다. * @@ -25,8 +24,7 @@ * 접근을 차단합니다. 주로 국가별 접근 제한이 필요한 상황에서 사용됩니다.

* *

이 필터는 IP 정보를 조회하기 위해 외부 IP 조회 서비스(IPinfo)를 사용하며, - * 국가 정보를 확인하여 허용된 국가 목록과 비교합니다. 허용되지 않은 국가에서 접근 시 - * 로그 경고 메시지를 기록하고 요청 체인을 종료합니다.

+ * 국가 정보를 확인하여 허용된 국가 목록과 비교합니다. 허용되지 않은 국가에서 접근 시 로그 경고 메시지를 기록하고 요청 체인을 종료합니다.

* *

필터는 다음과 같은 주요 기능을 수행합니다:

*
    @@ -57,7 +55,8 @@ public void init(FilterConfig filterConfig) { } @Override - public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException { String clientIpAddress = HttpReqResUtil.getClientIpAddressIfServletRequestExist(); try { IPResponse ipResponse = ipInfo.lookupIP(clientIpAddress); diff --git a/src/main/java/page/clab/api/global/auth/filter/JwtAuthenticationFilter.java b/src/main/java/page/clab/api/global/auth/filter/JwtAuthenticationFilter.java index fba999b53..b91148e74 100644 --- a/src/main/java/page/clab/api/global/auth/filter/JwtAuthenticationFilter.java +++ b/src/main/java/page/clab/api/global/auth/filter/JwtAuthenticationFilter.java @@ -53,7 +53,7 @@ public class JwtAuthenticationFilter extends GenericFilterBean { @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) - throws IOException, ServletException { + throws IOException, ServletException { HttpServletRequest httpServletRequest = (HttpServletRequest) request; HttpServletResponse httpServletResponse = (HttpServletResponse) response; String path = httpServletRequest.getRequestURI(); @@ -73,7 +73,7 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha private boolean verifyIpAddressAccess(HttpServletResponse response, String clientIpAddress) throws IOException { if (externalRetrieveBlacklistIpUseCase.existsByIpAddress(clientIpAddress) - || externalCheckIpBlockedUseCase.isIpBlocked(clientIpAddress)) { + || externalCheckIpBlockedUseCase.isIpBlocked(clientIpAddress)) { log.info("[{}] : 서비스 이용이 제한된 IP입니다.", clientIpAddress); ResponseUtil.sendErrorResponse(response, HttpServletResponse.SC_UNAUTHORIZED); return false; @@ -82,14 +82,14 @@ private boolean verifyIpAddressAccess(HttpServletResponse response, String clien } private boolean authenticateToken(HttpServletRequest request, HttpServletResponse response, String clientIpAddress) - throws IOException { + throws IOException { String token = jwtTokenProvider.resolveToken(request); // 토큰이 존재하고 유효한 경우 if (token != null && jwtTokenProvider.validateToken(token)) { RedisToken redisToken = - jwtTokenProvider.isRefreshToken(token) ? externalManageRedisTokenUseCase.findByRefreshToken(token) - : externalManageRedisTokenUseCase.findByAccessToken(token); + jwtTokenProvider.isRefreshToken(token) ? externalManageRedisTokenUseCase.findByRefreshToken(token) + : externalManageRedisTokenUseCase.findByAccessToken(token); if (redisToken == null) { log.warn("존재하지 않는 토큰입니다."); ResponseUtil.sendErrorResponse(response, HttpServletResponse.SC_UNAUTHORIZED); @@ -115,7 +115,7 @@ private void sendSecurityAlertSlackMessage(HttpServletRequest request, RedisToke request.setAttribute("member", redisToken.getId()); String duplicateLoginMessage = "토큰 발급 IP와 다른 IP에서 접속하여 토큰을 삭제하였습니다."; eventPublisher.publishEvent( - new NotificationEvent(this, SecurityAlertType.DUPLICATE_LOGIN, request, duplicateLoginMessage)); + new NotificationEvent(this, SecurityAlertType.DUPLICATE_LOGIN, request, duplicateLoginMessage)); } } } diff --git a/src/main/java/page/clab/api/global/auth/jwt/JwtTokenProvider.java b/src/main/java/page/clab/api/global/auth/jwt/JwtTokenProvider.java index 6fb92006d..04598ba86 100644 --- a/src/main/java/page/clab/api/global/auth/jwt/JwtTokenProvider.java +++ b/src/main/java/page/clab/api/global/auth/jwt/JwtTokenProvider.java @@ -7,6 +7,11 @@ import io.jsonwebtoken.UnsupportedJwtException; import io.jsonwebtoken.security.Keys; import jakarta.servlet.http.HttpServletRequest; +import java.security.Key; +import java.util.Arrays; +import java.util.Collection; +import java.util.Date; +import javax.crypto.SecretKey; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; @@ -21,12 +26,6 @@ import page.clab.api.domain.memberManagement.member.domain.Role; import page.clab.api.global.auth.exception.TokenValidateException; -import javax.crypto.SecretKey; -import java.security.Key; -import java.util.Arrays; -import java.util.Collection; -import java.util.Date; - @Component @Slf4j public class JwtTokenProvider { @@ -36,9 +35,9 @@ public class JwtTokenProvider { private final long refreshTokenDuration; public JwtTokenProvider( - @Value("${security.jwt.secret-key}") String secretKey, - @Value("${security.jwt.token-validity-in-seconds.access-token}") long accessTokenDuration, - @Value("${security.jwt.token-validity-in-seconds.refresh-token}") long refreshTokenDuration + @Value("${security.jwt.secret-key}") String secretKey, + @Value("${security.jwt.token-validity-in-seconds.access-token}") long accessTokenDuration, + @Value("${security.jwt.token-validity-in-seconds.refresh-token}") long refreshTokenDuration ) { this.key = Keys.hmacShaKeyFor(secretKey.getBytes()); this.accessTokenDuration = accessTokenDuration; @@ -49,21 +48,21 @@ public TokenInfo generateToken(String id, Role role) { Date expiry = new Date(); Date accessTokenExpiry = new Date(expiry.getTime() + (accessTokenDuration)); String accessToken = Jwts.builder() - .subject(id) - .claim("role", role) - .issuedAt(expiry) - .expiration(accessTokenExpiry) - .signWith(key) - .compact(); + .subject(id) + .claim("role", role) + .issuedAt(expiry) + .expiration(accessTokenExpiry) + .signWith(key) + .compact(); Date refreshTokenExpiry = new Date(expiry.getTime() + (refreshTokenDuration)); String refreshToken = Jwts.builder() - .subject(id) - .claim("role", role) - .issuedAt(expiry) - .expiration(refreshTokenExpiry) - .signWith(key) - .compact(); + .subject(id) + .claim("role", role) + .issuedAt(expiry) + .expiration(refreshTokenExpiry) + .signWith(key) + .compact(); return TokenInfo.create(accessToken, refreshToken); } @@ -91,10 +90,10 @@ public Authentication getAuthentication(String token) { } Collection authorities = - Arrays.stream(claims.get("role").toString().split(",")) - .map(r -> Role.valueOf(r).getKey()) - .map(SimpleGrantedAuthority::new) - .toList(); + Arrays.stream(claims.get("role").toString().split(",")) + .map(r -> Role.valueOf(r).getKey()) + .map(SimpleGrantedAuthority::new) + .toList(); UserDetails principal = new User(claims.getSubject(), "", authorities); return new UsernamePasswordAuthenticationToken(principal, "", authorities); @@ -111,9 +110,9 @@ public String resolveToken(HttpServletRequest request) { public boolean validateToken(String token) { try { Jwts.parser() - .verifyWith((SecretKey) key) - .build() - .parseSignedClaims(token); + .verifyWith((SecretKey) key) + .build() + .parseSignedClaims(token); return true; } catch (io.jsonwebtoken.security.SecurityException | MalformedJwtException e) { log.info("Invalid JWT Token"); @@ -130,9 +129,9 @@ public boolean validateToken(String token) { public boolean validateTokenSilently(String token) { try { Jwts.parser() - .verifyWith((SecretKey) key) - .build() - .parseSignedClaims(token); + .verifyWith((SecretKey) key) + .build() + .parseSignedClaims(token); return true; } catch (Exception e) { return false; @@ -142,10 +141,10 @@ public boolean validateTokenSilently(String token) { public Claims parseClaims(String token) { try { return Jwts.parser() - .verifyWith((SecretKey) key) - .build() - .parseSignedClaims(token) - .getPayload(); + .verifyWith((SecretKey) key) + .build() + .parseSignedClaims(token) + .getPayload(); } catch (ExpiredJwtException e) { return e.getClaims(); } diff --git a/src/main/java/page/clab/api/global/auth/util/AuthUtil.java b/src/main/java/page/clab/api/global/auth/util/AuthUtil.java index 9dea70925..10c43ff82 100644 --- a/src/main/java/page/clab/api/global/auth/util/AuthUtil.java +++ b/src/main/java/page/clab/api/global/auth/util/AuthUtil.java @@ -39,6 +39,7 @@ public static String getAuthenticationInfoMemberId() { } public static Boolean isUserUnAuthenticated(Authentication authentication) { - return (authentication == null || authentication.getAuthorities() == null || authentication.getAuthorities().isEmpty()); + return (authentication == null || authentication.getAuthorities() == null || authentication.getAuthorities() + .isEmpty()); } } diff --git a/src/main/java/page/clab/api/global/auth/util/IpWhitelistValidator.java b/src/main/java/page/clab/api/global/auth/util/IpWhitelistValidator.java index 2f7787816..363e498cd 100644 --- a/src/main/java/page/clab/api/global/auth/util/IpWhitelistValidator.java +++ b/src/main/java/page/clab/api/global/auth/util/IpWhitelistValidator.java @@ -1,13 +1,12 @@ package page.clab.api.global.auth.util; +import java.util.List; +import java.util.Objects; import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import page.clab.api.global.util.IpAddressUtil; -import java.util.List; -import java.util.Objects; - /** * {@code IpWhitelistValidator}는 요청된 IP 주소가 화이트리스트에 포함되는지 확인하는 유틸리티 클래스입니다. * @@ -34,6 +33,7 @@ public class IpWhitelistValidator { /** * 요청된 IP가 화이트리스트에 포함되는지 확인합니다. + * * @param ipAddress 확인하려는 IP 주소 * @return IP가 화이트리스트에 포함되면 true, 그렇지 않으면 false */ @@ -49,7 +49,7 @@ public boolean isIpWhitelisted(String ipAddress) { } return whitelistIps.stream() - .filter(Objects::nonNull) - .anyMatch(ip -> "*".equals(ip) || IpAddressUtil.isIpInRange(ipAddress, ip)); + .filter(Objects::nonNull) + .anyMatch(ip -> "*".equals(ip) || IpAddressUtil.isIpInRange(ipAddress, ip)); } } diff --git a/src/main/java/page/clab/api/global/auth/util/WhitelistFileLoader.java b/src/main/java/page/clab/api/global/auth/util/WhitelistFileLoader.java index a6a93eeb3..9ae4ad37e 100644 --- a/src/main/java/page/clab/api/global/auth/util/WhitelistFileLoader.java +++ b/src/main/java/page/clab/api/global/auth/util/WhitelistFileLoader.java @@ -1,12 +1,5 @@ package page.clab.api.global.auth.util; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; -import org.springframework.util.CollectionUtils; -import org.yaml.snakeyaml.Yaml; - import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; @@ -17,6 +10,12 @@ import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; import java.util.stream.Stream; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; +import org.yaml.snakeyaml.Yaml; /** * {@code WhitelistFileLoader}는 지정된 경로의 YAML 파일에서 IP 화이트리스트 목록을 로드하는 클래스입니다. @@ -48,6 +47,7 @@ public class WhitelistFileLoader { /** * 화이트리스트 YAML 파일에서 IP 목록을 로드합니다. + * * @return 화이트리스트에 포함된 IP 목록 */ public List loadWhitelistIps() { @@ -70,6 +70,7 @@ public List loadWhitelistIps() { /** * 기본 화이트리스트 YAML 파일을 생성합니다. + * * @param path 파일 경로 * @param yaml Yaml 객체 * @throws IOException 파일 생성 중 오류 발생 시 @@ -77,10 +78,10 @@ public List loadWhitelistIps() { private void createDefaultWhitelistFile(Path path, Yaml yaml) throws IOException { Files.createDirectories(path.getParent()); Map>> defaultContent = Map.of( - "whitelist", Map.of( - "fixedIps", List.of(""), - "temporaryIps", List.of("*") - ) + "whitelist", Map.of( + "fixedIps", List.of(""), + "temporaryIps", List.of("*") + ) ); yaml.dump(defaultContent, Files.newBufferedWriter(path)); log.info("Whitelist YAML file created at {}", whitelistPath); @@ -88,6 +89,7 @@ private void createDefaultWhitelistFile(Path path, Yaml yaml) throws IOException /** * YAML 파일을 파싱하여 화이트리스트 IP 목록을 반환합니다. + * * @param yaml Yaml 객체 * @param path YAML 파일 경로 * @return 화이트리스트에 포함된 IP 목록 @@ -108,8 +110,8 @@ private List parseWhitelistFile(Yaml yaml, Path path) throws IOException List temporaryIps = whitelist.getOrDefault("temporaryIps", List.of()); return Stream.concat( - fixedIps != null ? fixedIps.stream() : Stream.empty(), - temporaryIps != null ? temporaryIps.stream() : Stream.empty() + fixedIps != null ? fixedIps.stream() : Stream.empty(), + temporaryIps != null ? temporaryIps.stream() : Stream.empty() ).toList(); } catch (Exception e) { log.error("Failed to parse IP whitelist", e); diff --git a/src/main/java/page/clab/api/global/common/domain/BaseEntity.java b/src/main/java/page/clab/api/global/common/domain/BaseEntity.java index 029726e46..949d25508 100644 --- a/src/main/java/page/clab/api/global/common/domain/BaseEntity.java +++ b/src/main/java/page/clab/api/global/common/domain/BaseEntity.java @@ -3,13 +3,12 @@ import jakarta.persistence.Column; import jakarta.persistence.EntityListeners; import jakarta.persistence.MappedSuperclass; +import java.time.LocalDateTime; import lombok.Getter; import org.springframework.data.annotation.CreatedDate; import org.springframework.data.annotation.LastModifiedDate; import org.springframework.data.jpa.domain.support.AuditingEntityListener; -import java.time.LocalDateTime; - @Getter @EntityListeners(AuditingEntityListener.class) @MappedSuperclass diff --git a/src/main/java/page/clab/api/global/common/dto/ApiResponse.java b/src/main/java/page/clab/api/global/common/dto/ApiResponse.java index a522c8dec..162458591 100644 --- a/src/main/java/page/clab/api/global/common/dto/ApiResponse.java +++ b/src/main/java/page/clab/api/global/common/dto/ApiResponse.java @@ -14,26 +14,26 @@ public class ApiResponse { private T data; public static ApiResponse success() { - return ApiResponse. builder().build(); + return ApiResponse.builder().build(); } public static ApiResponse success(T data) { - return ApiResponse. builder() - .data(data) - .build(); + return ApiResponse.builder() + .data(data) + .build(); } public static ApiResponse failure() { - return ApiResponse. builder() - .success(false) - .build(); + return ApiResponse.builder() + .success(false) + .build(); } public static ApiResponse failure(T data) { - return ApiResponse. builder() - .success(false) - .data(data) - .build(); + return ApiResponse.builder() + .success(false) + .data(data) + .build(); } public String toJson() { diff --git a/src/main/java/page/clab/api/global/common/dto/ErrorResponse.java b/src/main/java/page/clab/api/global/common/dto/ErrorResponse.java index eaa43fe43..b1316c70d 100644 --- a/src/main/java/page/clab/api/global/common/dto/ErrorResponse.java +++ b/src/main/java/page/clab/api/global/common/dto/ErrorResponse.java @@ -16,9 +16,9 @@ public class ErrorResponse { public static ErrorResponse failure(Exception e) { String exceptionName = e.getClass().getSimpleName(); - return ErrorResponse. builder() - .errorMessage(exceptionName.toUpperCase()) - .build(); + return ErrorResponse.builder() + .errorMessage(exceptionName.toUpperCase()) + .build(); } public String toJson() { diff --git a/src/main/java/page/clab/api/global/common/dto/PagedResponseDto.java b/src/main/java/page/clab/api/global/common/dto/PagedResponseDto.java index 37a0d02b2..86402a17a 100644 --- a/src/main/java/page/clab/api/global/common/dto/PagedResponseDto.java +++ b/src/main/java/page/clab/api/global/common/dto/PagedResponseDto.java @@ -1,17 +1,15 @@ package page.clab.api.global.common.dto; +import java.util.Comparator; +import java.util.List; import lombok.Getter; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; import page.clab.api.global.exception.InvalidColumnException; -import java.util.Comparator; -import java.util.List; - /** - * 페이지네이션 응답을 위한 제네릭 DTO 클래스입니다. 현재 페이지, 총 아이템 수 및 - * 페이지 관련 정보와 실제 콘텐츠를 제공합니다. + * 페이지네이션 응답을 위한 제네릭 DTO 클래스입니다. 현재 페이지, 총 아이템 수 및 페이지 관련 정보와 실제 콘텐츠를 제공합니다. * * @param 페이지네이션 응답의 콘텐츠 타입 */ @@ -71,8 +69,8 @@ public PagedResponseDto(Page page) { /** * totalItems 및 numberOfElements를 추가로 설정할 수 있는 생성자입니다. * - * @param page 페이지네이션된 데이터를 포함하는 Page 객체 - * @param totalItems 전체 아이템 수 + * @param page 페이지네이션된 데이터를 포함하는 Page 객체 + * @param totalItems 전체 아이템 수 * @param numberOfElements 현재 페이지의 아이템 수 */ public PagedResponseDto(Page page, long totalItems, int numberOfElements) { @@ -86,13 +84,11 @@ public PagedResponseDto(Page page, long totalItems, int numberOfElements) { } /** - * List와 Pageable 객체를 사용하여 PagedResponseDto를 생성하는 생성자입니다. - * 페이지네이션과 정렬이 적용됩니다. + * List와 Pageable 객체를 사용하여 PagedResponseDto를 생성하는 생성자입니다. 페이지네이션과 정렬이 적용됩니다. * - * @param ts 콘텐츠 아이템 리스트 + * @param ts 콘텐츠 아이템 리스트 * @param pageable 페이지네이션 정보와 정렬 기준을 포함하는 Pageable 객체 - * @param size 전체 아이템 수 - * + * @param size 전체 아이템 수 * @deprecated 슬라이싱과 정렬을 담당하는 새로운 Util 클래스의 도입으로 사라질 메서드입니다. */ @Deprecated @@ -109,9 +105,9 @@ public PagedResponseDto(List ts, Pageable pageable, int size) { /** * List와 Pageable 객체를 사용하여 PagedResponseDto를 생성하는 생성자입니다. * - * @param ts 콘텐츠 아이템 리스트 + * @param ts 콘텐츠 아이템 리스트 * @param totalItems 전체 아이템 수 - * @param pageable 페이지네이션 정보와 정렬 기준을 포함하는 Pageable 객체 + * @param pageable 페이지네이션 정보와 정렬 기준을 포함하는 Pageable 객체 */ public PagedResponseDto(List ts, int totalItems, Pageable pageable) { this.currentPage = pageable.getPageNumber(); @@ -127,9 +123,8 @@ public PagedResponseDto(List ts, int totalItems, Pageable pageable) { * 정렬이 필요한 경우 아이템 리스트에 정렬을 적용하는 메서드입니다. * * @param items 정렬되지 않은 아이템 리스트 - * @param sort 정렬 기준을 포함한 Sort 객체 + * @param sort 정렬 기준을 포함한 Sort 객체 * @return 정렬된 아이템 리스트 - * * @deprecated 슬라이싱과 정렬을 담당하는 새로운 Util 클래스의 도입으로 사라질 메서드입니다. */ @Deprecated @@ -144,41 +139,39 @@ private List applySortingIfNecessary(List items, Sort sort) { * Sort 객체를 사용하여 아이템 리스트를 정렬하는 메서드입니다. * * @param items 정렬되지 않은 아이템 리스트 - * @param sort 정렬 기준을 포함한 Sort 객체 + * @param sort 정렬 기준을 포함한 Sort 객체 * @return 정렬된 아이템 리스트 - * * @deprecated 슬라이싱과 정렬을 담당하는 새로운 Util 클래스의 도입으로 사라질 메서드입니다. */ @Deprecated private List sortItems(List items, Sort sort) { Comparator comparator = sort.stream() - .map(order -> { - Comparator itemComparator = Comparator.comparing( - item -> { - try { - return (Comparable) extractFieldValue(item, order.getProperty()); - } catch (InvalidColumnException e) { - throw new RuntimeException(e); - } - } - ); - return order.isAscending() ? itemComparator : itemComparator.reversed(); - }) - .reduce(Comparator::thenComparing) - .orElseThrow(IllegalArgumentException::new); + .map(order -> { + Comparator itemComparator = Comparator.comparing( + item -> { + try { + return (Comparable) extractFieldValue(item, order.getProperty()); + } catch (InvalidColumnException e) { + throw new RuntimeException(e); + } + } + ); + return order.isAscending() ? itemComparator : itemComparator.reversed(); + }) + .reduce(Comparator::thenComparing) + .orElseThrow(IllegalArgumentException::new); return items.stream() - .sorted(comparator) - .toList(); + .sorted(comparator) + .toList(); } /** * 리플렉션을 사용하여 객체의 특정 필드 값을 추출하는 메서드입니다. * - * @param item 값을 추출할 객체 + * @param item 값을 추출할 객체 * @param fieldName 추출할 필드 이름 * @return 추출된 필드 값 - * * @deprecated 슬라이싱과 정렬을 담당하는 새로운 Util 클래스의 도입으로 사라질 메서드입니다. */ @Deprecated diff --git a/src/main/java/page/clab/api/global/common/email/application/EmailAsyncService.java b/src/main/java/page/clab/api/global/common/email/application/EmailAsyncService.java index 34b2f377a..7dd4b93b4 100644 --- a/src/main/java/page/clab/api/global/common/email/application/EmailAsyncService.java +++ b/src/main/java/page/clab/api/global/common/email/application/EmailAsyncService.java @@ -3,6 +3,13 @@ import jakarta.mail.MessagingException; import jakarta.mail.internet.MimeMessage; import jakarta.mail.internet.MimeUtility; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.LinkedBlockingQueue; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; @@ -16,20 +23,12 @@ import page.clab.api.global.common.email.domain.EmailTemplateType; import page.clab.api.global.util.LogSanitizerUtil; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.LinkedBlockingQueue; - /** * {@code EmailAsyncService}는 비동기적으로 이메일을 전송하고 이메일 대기열을 관리하는 서비스 클래스입니다. * *

    이 클래스는 Spring의 JavaMailSender를 사용하여 이메일을 전송하며, 대용량 이메일 전송을 위해 배치 처리를 지원합니다. * 이메일은 일정 간격으로 대기열에서 가져와 전송됩니다. 또한, 이메일 템플릿에 포함된 이미지를 지원하며 첨부 파일도 추가할 수 있습니다.

    - * + *

    * 주요 기능: *

      *
    • {@link #sendEmailAsync(String, String, String, List, EmailTemplateType)} - 비동기적으로 이메일을 대기열에 추가합니다.
    • @@ -56,15 +55,16 @@ public class EmailAsyncService { /** * 비동기적으로 이메일을 대기열에 추가합니다. * - * @param to 수신자 이메일 주소 - * @param subject 이메일 제목 - * @param content 이메일 본문 내용 (HTML 지원) - * @param files 첨부 파일 목록 (선택 사항) + * @param to 수신자 이메일 주소 + * @param subject 이메일 제목 + * @param content 이메일 본문 내용 (HTML 지원) + * @param files 첨부 파일 목록 (선택 사항) * @param emailTemplateType 이메일 템플릿 유형 * @throws MessagingException 이메일 생성 중 오류 발생 시 */ @Async - public void sendEmailAsync(String to, String subject, String content, List files, EmailTemplateType emailTemplateType) throws MessagingException { + public void sendEmailAsync(String to, String subject, String content, List files, + EmailTemplateType emailTemplateType) throws MessagingException { log.debug("Sending email to: {}", LogSanitizerUtil.sanitizeForLog(to)); emailQueue.add(new EmailTask(to, subject, content, files, emailTemplateType)); } @@ -101,7 +101,7 @@ public void processEmailQueue() { * * @param emailTasks 전송할 이메일 작업 목록 * @throws MessagingException 이메일 생성 중 오류 발생 시 - * @throws IOException 첨부 파일 처리 중 오류 발생 시 + * @throws IOException 첨부 파일 처리 중 오류 발생 시 */ public void sendBatchEmail(List emailTasks) throws MessagingException, IOException { MimeMessage[] mimeMessages = new MimeMessage[emailTasks.size()]; @@ -136,10 +136,11 @@ public void sendBatchEmail(List emailTasks) throws MessagingException * 이메일 템플릿에 맞는 이미지를 추가합니다. * * @param messageHelper MimeMessageHelper 객체, 이메일 생성에 사용 - * @param templateType 템플릿 유형을 나타내는 {@link EmailTemplateType} 객체 + * @param templateType 템플릿 유형을 나타내는 {@link EmailTemplateType} 객체 * @throws MessagingException 이미지 삽입 중 오류 발생 시 */ - private void setImageInTemplate(MimeMessageHelper messageHelper, EmailTemplateType templateType) throws MessagingException { + private void setImageInTemplate(MimeMessageHelper messageHelper, EmailTemplateType templateType) + throws MessagingException { if (Objects.equals(templateType.getTemplateName(), "clabEmail.html")) { messageHelper.addInline("image-1", new ClassPathResource("images/image-1.png")); } diff --git a/src/main/java/page/clab/api/global/common/email/application/EmailService.java b/src/main/java/page/clab/api/global/common/email/application/EmailService.java index 0e4045e47..b9d499ed0 100644 --- a/src/main/java/page/clab/api/global/common/email/application/EmailService.java +++ b/src/main/java/page/clab/api/global/common/email/application/EmailService.java @@ -1,6 +1,7 @@ package page.clab.api.global.common.email.application; import jakarta.mail.MessagingException; +import java.util.List; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -13,14 +14,12 @@ import page.clab.api.global.common.email.exception.MessageSendingFailedException; import page.clab.api.global.config.EmailTemplateProperties; -import java.util.List; - /** * {@code EmailService}는 사용자의 계정 생성, 비밀번호 재설정, 새 비밀번호 전송을 포함한 이메일 전송을 관리하는 서비스입니다. * *

      이 클래스는 템플릿을 기반으로 이메일 콘텐츠를 생성하고, 비동기적으로 이메일을 전송하는 {@link EmailAsyncService}를 활용하여 * 이메일을 전송합니다. 각 이메일 유형에 대해 적절한 템플릿을 적용하여 이메일의 제목과 내용을 동적으로 설정합니다.

      - * + *

      * 주요 기능: *

        *
      • {@link #sendAccountCreationEmail(Member, String)} - 계정 생성 시 계정 정보가 포함된 이메일을 전송합니다.
      • @@ -42,22 +41,23 @@ public class EmailService { /** * 계정 생성 안내 이메일을 전송합니다. * - * @param member 생성된 계정의 멤버 정보 + * @param member 생성된 계정의 멤버 정보 * @param password 생성된 비밀번호 */ public void sendAccountCreationEmail(Member member, String password) { - EmailTemplateProperties.Template template = emailTemplateProperties.getTemplate(EmailTemplateType.ACCOUNT_CREATION); + EmailTemplateProperties.Template template = emailTemplateProperties.getTemplate( + EmailTemplateType.ACCOUNT_CREATION); String subject = template.getSubject(); String content = template.getContent() - .replace("{{id}}", member.getId()) - .replace("{{password}}", password); + .replace("{{id}}", member.getId()) + .replace("{{password}}", password); EmailDto emailDto = mapper.of( - List.of(member.getEmail()), - subject, - content, - EmailTemplateType.ACCOUNT_CREATION + List.of(member.getEmail()), + subject, + content, + EmailTemplateType.ACCOUNT_CREATION ); sendEmail(emailDto, member, " 계정 발급 안내 메일 전송에 실패했습니다."); @@ -67,20 +67,21 @@ public void sendAccountCreationEmail(Member member, String password) { * 비밀번호 재설정 코드가 포함된 이메일을 전송합니다. * * @param member 비밀번호 재설정을 요청한 멤버 정보 - * @param code 비밀번호 재설정 인증 코드 + * @param code 비밀번호 재설정 인증 코드 */ public void sendPasswordResetCodeEmail(Member member, String code) { - EmailTemplateProperties.Template template = emailTemplateProperties.getTemplate(EmailTemplateType.PASSWORD_RESET_CODE); + EmailTemplateProperties.Template template = emailTemplateProperties.getTemplate( + EmailTemplateType.PASSWORD_RESET_CODE); String subject = template.getSubject(); String content = template.getContent() - .replace("{{code}}", code); + .replace("{{code}}", code); EmailDto emailDto = mapper.of( - List.of(member.getEmail()), - subject, - content, - EmailTemplateType.PASSWORD_RESET_CODE + List.of(member.getEmail()), + subject, + content, + EmailTemplateType.PASSWORD_RESET_CODE ); sendEmail(emailDto, member, " 비밀번호 재발급 인증 메일 전송에 실패했습니다."); @@ -89,7 +90,7 @@ public void sendPasswordResetCodeEmail(Member member, String code) { /** * 새 비밀번호가 포함된 이메일을 전송합니다. * - * @param member 비밀번호가 재설정된 멤버 정보 + * @param member 비밀번호가 재설정된 멤버 정보 * @param newPassword 새 비밀번호 */ public void sendNewPasswordEmail(Member member, String newPassword) { @@ -97,14 +98,14 @@ public void sendNewPasswordEmail(Member member, String newPassword) { String subject = template.getSubject(); String content = template.getContent() - .replace("{{id}}", member.getId()) - .replace("{{password}}", newPassword); + .replace("{{id}}", member.getId()) + .replace("{{password}}", newPassword); EmailDto emailDto = mapper.of( - List.of(member.getEmail()), - subject, - content, - EmailTemplateType.NEW_PASSWORD + List.of(member.getEmail()), + subject, + content, + EmailTemplateType.NEW_PASSWORD ); sendEmail(emailDto, member, " 비밀번호 재설정 안내 메일 전송에 실패했습니다."); @@ -114,13 +115,14 @@ public void sendNewPasswordEmail(Member member, String newPassword) { * 이메일 전송을 위한 정보를 기반으로 이메일을 생성하여 비동기 전송합니다. * * @param emailDto 이메일 전송 정보 객체 - * @param member 전송 대상 멤버 - * @param message 예외 발생 시 로깅될 메시지 + * @param member 전송 대상 멤버 + * @param message 예외 발생 시 로깅될 메시지 */ private void sendEmail(EmailDto emailDto, Member member, String message) { try { String emailContent = generateEmailContent(emailDto, member.getName()); - emailAsyncService.sendEmailAsync(member.getEmail(), emailDto.getSubject(), emailContent, null, emailDto.getEmailTemplateType()); + emailAsyncService.sendEmailAsync(member.getEmail(), emailDto.getSubject(), emailContent, null, + emailDto.getEmailTemplateType()); } catch (MessagingException e) { throw new MessageSendingFailedException(member.getEmail() + message); } @@ -130,7 +132,7 @@ private void sendEmail(EmailDto emailDto, Member member, String message) { * 이메일 템플릿을 사용하여 이메일 콘텐츠를 생성합니다. * * @param emailDto 이메일 정보를 포함한 객체 - * @param name 수신자의 이름 + * @param name 수신자의 이름 * @return 생성된 이메일 콘텐츠 */ private String generateEmailContent(EmailDto emailDto, String name) { diff --git a/src/main/java/page/clab/api/global/common/email/domain/EmailTask.java b/src/main/java/page/clab/api/global/common/email/domain/EmailTask.java index 334a02573..e4062f773 100644 --- a/src/main/java/page/clab/api/global/common/email/domain/EmailTask.java +++ b/src/main/java/page/clab/api/global/common/email/domain/EmailTask.java @@ -1,10 +1,9 @@ package page.clab.api.global.common.email.domain; -import lombok.AllArgsConstructor; -import lombok.Getter; - import java.io.File; import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Getter; @Getter @AllArgsConstructor diff --git a/src/main/java/page/clab/api/global/common/email/dto/mapper/EmailDtoMapper.java b/src/main/java/page/clab/api/global/common/email/dto/mapper/EmailDtoMapper.java index b27020309..5dfff105e 100644 --- a/src/main/java/page/clab/api/global/common/email/dto/mapper/EmailDtoMapper.java +++ b/src/main/java/page/clab/api/global/common/email/dto/mapper/EmailDtoMapper.java @@ -1,20 +1,19 @@ package page.clab.api.global.common.email.dto.mapper; +import java.util.List; import org.springframework.stereotype.Component; import page.clab.api.global.common.email.domain.EmailTemplateType; import page.clab.api.global.common.email.dto.request.EmailDto; -import java.util.List; - @Component public class EmailDtoMapper { public EmailDto of(List to, String subject, String content, EmailTemplateType emailTemplateType) { return EmailDto.builder() - .to(to) - .subject(subject) - .content(content) - .emailTemplateType(emailTemplateType) - .build(); + .to(to) + .subject(subject) + .content(content) + .emailTemplateType(emailTemplateType) + .build(); } } diff --git a/src/main/java/page/clab/api/global/common/email/dto/request/EmailDto.java b/src/main/java/page/clab/api/global/common/email/dto/request/EmailDto.java index 138032563..af07e5ee5 100644 --- a/src/main/java/page/clab/api/global/common/email/dto/request/EmailDto.java +++ b/src/main/java/page/clab/api/global/common/email/dto/request/EmailDto.java @@ -2,20 +2,20 @@ import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotNull; +import java.util.List; import lombok.Builder; import lombok.Getter; import lombok.Setter; import page.clab.api.global.common.email.domain.EmailTemplateType; -import java.util.List; - @Getter @Setter @Builder public class EmailDto { @NotNull(message = "{notNull.email.to}") - @Schema(description = "받는 사람 이메일 리스트", example = "[\"" + "clab.coreteam@gmail.com" + "\", \"" + "clab.coreteam@gmail.com" + "\"]") + @Schema(description = "받는 사람 이메일 리스트", example = "[\"" + "clab.coreteam@gmail.com" + "\", \"" + + "clab.coreteam@gmail.com" + "\"]") private List to; @NotNull(message = "{notNull.email.subject}") diff --git a/src/main/java/page/clab/api/global/common/file/api/FileController.java b/src/main/java/page/clab/api/global/common/file/api/FileController.java index 5b75eb894..b2c2e607d 100644 --- a/src/main/java/page/clab/api/global/common/file/api/FileController.java +++ b/src/main/java/page/clab/api/global/common/file/api/FileController.java @@ -2,6 +2,8 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import java.io.IOException; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.http.MediaType; import org.springframework.security.access.prepost.PreAuthorize; @@ -20,9 +22,6 @@ import page.clab.api.global.exception.NotFoundException; import page.clab.api.global.exception.PermissionDeniedException; -import java.io.IOException; -import java.util.List; - @RestController @RequestMapping("/api/v1/files") @RequiredArgsConstructor @@ -35,8 +34,8 @@ public class FileController { @PreAuthorize("hasRole('USER')") @PostMapping(value = "/boards", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) public ApiResponse> boardUpload( - @RequestParam(name = "multipartFile") List multipartFiles, - @RequestParam(name = "storagePeriod") long storagePeriod + @RequestParam(name = "multipartFile") List multipartFiles, + @RequestParam(name = "storagePeriod") long storagePeriod ) throws IOException, PermissionDeniedException { String path = fileService.buildPath("boards"); List responseDtos = fileService.saveFiles(multipartFiles, path, storagePeriod); @@ -47,8 +46,8 @@ public ApiResponse> boardUpload( @PreAuthorize("hasRole('USER')") @PostMapping(value = "/profiles", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) public ApiResponse profileUpload( - @RequestParam(name = "multipartFile") MultipartFile multipartFile, - @RequestParam(name = "storagePeriod") long storagePeriod + @RequestParam(name = "multipartFile") MultipartFile multipartFile, + @RequestParam(name = "storagePeriod") long storagePeriod ) throws IOException, PermissionDeniedException { String path = fileService.buildPath("profiles"); UploadedFileResponseDto responseDto = fileService.saveFile(multipartFile, path, storagePeriod); @@ -59,8 +58,8 @@ public ApiResponse profileUpload( @PreAuthorize("hasRole('ADMIN')") @PostMapping(value = "/activity-photos", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) public ApiResponse> activityUpload( - @RequestParam(name = "multipartFile") List multipartFiles, - @RequestParam(name = "storagePeriod") long storagePeriod + @RequestParam(name = "multipartFile") List multipartFiles, + @RequestParam(name = "storagePeriod") long storagePeriod ) throws IOException, PermissionDeniedException { String path = fileService.buildPath("activity-photos"); List responseDtos = fileService.saveFiles(multipartFiles, path, storagePeriod); @@ -71,8 +70,8 @@ public ApiResponse> activityUpload( @PreAuthorize("hasRole('USER')") @PostMapping(value = "/members", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) public ApiResponse> memberCloudUpload( - @RequestParam(name = "multipartFile") List multipartFiles, - @RequestParam(name = "storagePeriod") long storagePeriod + @RequestParam(name = "multipartFile") List multipartFiles, + @RequestParam(name = "storagePeriod") long storagePeriod ) throws IOException, PermissionDeniedException { String path = fileService.buildPath("members"); List responseDtos = fileService.saveFiles(multipartFiles, path, storagePeriod); @@ -83,8 +82,8 @@ public ApiResponse> memberCloudUpload( @PreAuthorize("hasRole('USER')") @PostMapping(value = "/membership-fee", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) public ApiResponse> assignmentUpload( - @RequestParam(name = "multipartFile") List multipartFiles, - @RequestParam(name = "storagePeriod") long storagePeriod + @RequestParam(name = "multipartFile") List multipartFiles, + @RequestParam(name = "storagePeriod") long storagePeriod ) throws PermissionDeniedException, IOException, NotFoundException { String path = fileService.buildPath("membership-fees"); List responseDtos = fileService.saveFiles(multipartFiles, path, storagePeriod); @@ -95,9 +94,9 @@ public ApiResponse> assignmentUpload( @PreAuthorize("hasRole('USER')") @PostMapping(value = "/notices/{activityGroupId}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) public ApiResponse> noticeUpload( - @PathVariable(name = "activityGroupId") Long activityGroupId, - @RequestParam(name = "multipartFile") List multipartFiles, - @RequestParam(name = "storagePeriod") long storagePeriod + @PathVariable(name = "activityGroupId") Long activityGroupId, + @RequestParam(name = "multipartFile") List multipartFiles, + @RequestParam(name = "storagePeriod") long storagePeriod ) throws PermissionDeniedException, IOException { String path = fileService.buildPath("notices", activityGroupId); List responseDtos = fileService.saveFiles(multipartFiles, path, storagePeriod); @@ -108,9 +107,9 @@ public ApiResponse> noticeUpload( @PreAuthorize("hasRole('USER')") @PostMapping(value = "/weekly-activities/{activityGroupId}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) public ApiResponse> weeklyActivityUpload( - @PathVariable(name = "activityGroupId") Long activityGroupId, - @RequestParam(name = "multipartFile") List multipartFiles, - @RequestParam(name = "storagePeriod") long storagePeriod + @PathVariable(name = "activityGroupId") Long activityGroupId, + @RequestParam(name = "multipartFile") List multipartFiles, + @RequestParam(name = "storagePeriod") long storagePeriod ) throws IOException, PermissionDeniedException { String path = fileService.buildPath("weekly-activities", activityGroupId); List responseDtos = fileService.saveFiles(multipartFiles, path, storagePeriod); @@ -121,24 +120,25 @@ public ApiResponse> weeklyActivityUpload( @PreAuthorize("hasRole('USER')") @PostMapping(value = "/assignments/{activityGroupId}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) public ApiResponse> assignmentUpload( - @PathVariable(name = "activityGroupId") Long activityGroupId, - @RequestParam(name = "multipartFile") List multipartFiles, - @RequestParam(name = "storagePeriod") long storagePeriod + @PathVariable(name = "activityGroupId") Long activityGroupId, + @RequestParam(name = "multipartFile") List multipartFiles, + @RequestParam(name = "storagePeriod") long storagePeriod ) throws PermissionDeniedException, IOException, NotFoundException { String path = fileService.buildPath("assignments", activityGroupId); List responseDtos = fileService.saveFiles(multipartFiles, path, storagePeriod); return ApiResponse.success(responseDtos); } - @Operation(summary = "[U] 활동 그룹 제출 파일 업로드", description = "ROLE_USER 이상의 권한이 필요함
        그룹원이 SUBMIT 게시판에 올릴 파일을 업로드할 때 사용하는 API 입니다." + + @Operation(summary = "[U] 활동 그룹 제출 파일 업로드", description = + "ROLE_USER 이상의 권한이 필요함
        그룹원이 SUBMIT 게시판에 올릴 파일을 업로드할 때 사용하는 API 입니다." + "
        activityGroupBoardId는 ASSIGNMENT 게시판의 id를 입력하도록 합니다.") @PreAuthorize("hasRole('USER')") @PostMapping(value = "/submits/{activityGroupId}/{parentBoardId}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) public ApiResponse> submitUpload( - @PathVariable(name = "activityGroupId") Long activityGroupId, - @PathVariable(name = "parentBoardId") Long parentBoardId, - @RequestParam(name = "multipartFile") List multipartFiles, - @RequestParam(name = "storagePeriod") long storagePeriod + @PathVariable(name = "activityGroupId") Long activityGroupId, + @PathVariable(name = "parentBoardId") Long parentBoardId, + @RequestParam(name = "multipartFile") List multipartFiles, + @RequestParam(name = "storagePeriod") long storagePeriod ) throws PermissionDeniedException, IOException, NotFoundException { String path = fileService.buildPath("submits", activityGroupId, parentBoardId); List responseDtos = fileService.saveFiles(multipartFiles, path, storagePeriod); @@ -146,11 +146,11 @@ public ApiResponse> submitUpload( } @Operation(summary = "[U] 파일 삭제", description = "ROLE_USER 이상의 권한이 필요함
        " + - "본인 외의 정보는 ROLE_SUPER만 가능
        " + "/resources/files/~를 입력. 즉 생성시 전달받은 url을 입력.") + "본인 외의 정보는 ROLE_SUPER만 가능
        " + "/resources/files/~를 입력. 즉 생성시 전달받은 url을 입력.") @PreAuthorize("hasRole('USER')") @DeleteMapping("") public ApiResponse deleteFile(@RequestBody DeleteFileRequestDto deleteFileRequestDto) - throws PermissionDeniedException { + throws PermissionDeniedException { String deletedFileUrl = fileService.deleteFile(deleteFileRequestDto); return ApiResponse.success(deletedFileUrl); } diff --git a/src/main/java/page/clab/api/global/common/file/application/AutoDeleteService.java b/src/main/java/page/clab/api/global/common/file/application/AutoDeleteService.java index 5652be81c..31952ef9a 100644 --- a/src/main/java/page/clab/api/global/common/file/application/AutoDeleteService.java +++ b/src/main/java/page/clab/api/global/common/file/application/AutoDeleteService.java @@ -1,5 +1,9 @@ package page.clab.api.global.common.file.application; +import java.io.File; +import java.time.LocalDateTime; +import java.util.Arrays; +import java.util.List; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; @@ -8,18 +12,12 @@ import page.clab.api.global.common.file.dao.UploadFileRepository; import page.clab.api.global.common.file.domain.UploadedFile; -import java.io.File; -import java.time.LocalDateTime; -import java.util.Arrays; -import java.util.List; - /** * {@code AutoDeleteService}는 지정된 경로의 파일을 자동으로 삭제하는 서비스입니다. * *

        이 서비스는 매일 자정에 스케줄된 작업을 수행하며, 파일의 유효 기간이 만료되었거나 - * 데이터베이스에서 해당 파일의 정보가 존재하지 않는 경우 해당 파일을 삭제합니다. - * 파일 삭제 작업은 다양한 카테고리에 대해 수행되며, 이를 통해 불필요한 파일을 자동으로 정리합니다.

        - * + * 데이터베이스에서 해당 파일의 정보가 존재하지 않는 경우 해당 파일을 삭제합니다. 파일 삭제 작업은 다양한 카테고리에 대해 수행되며, 이를 통해 불필요한 파일을 자동으로 정리합니다.

        + *

        * 주요 기능: *

          *
        • {@link #autoDeleteExpiredFiles()} - 스케줄에 따라 만료된 파일 또는 데이터베이스 정보가 없는 파일을 자동으로 삭제합니다.
        • @@ -43,13 +41,13 @@ public class AutoDeleteService { public void autoDeleteExpiredFiles() { LocalDateTime currentDate = LocalDateTime.now(); List categoryPaths = Arrays.asList( - "boards", "news", "books", "profiles", - "activity-photos", "members", "forms", "attendance" + "boards", "news", "books", "profiles", + "activity-photos", "members", "forms", "attendance" ); categoryPaths.stream() - .map(category -> filePath + File.separator + category) - .forEach(directoryPath -> deleteUselessFilesInDirectory(new File(directoryPath), currentDate)); + .map(category -> filePath + File.separator + category) + .forEach(directoryPath -> deleteUselessFilesInDirectory(new File(directoryPath), currentDate)); } private void deleteUselessFilesInDirectory(File directory, LocalDateTime currentDate) { diff --git a/src/main/java/page/clab/api/global/common/file/application/FileHandler.java b/src/main/java/page/clab/api/global/common/file/application/FileHandler.java index 45eee5bc6..c3208b2c5 100644 --- a/src/main/java/page/clab/api/global/common/file/application/FileHandler.java +++ b/src/main/java/page/clab/api/global/common/file/application/FileHandler.java @@ -1,5 +1,13 @@ package page.clab.api.global.common.file.application; +import java.awt.image.BufferedImage; +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Objects; +import java.util.Set; import javax.imageio.ImageIO; import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.FilenameUtils; @@ -12,20 +20,11 @@ import page.clab.api.global.util.ImageUtil; import page.clab.api.global.util.LogSanitizerUtil; -import java.awt.image.BufferedImage; -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.IOException; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Objects; -import java.util.Set; - /** * {@code FileHandler}는 파일 처리 기능을 담당하는 클래스입니다. * *

          이 클래스는 파일의 저장, 삭제, 이미지 압축 등을 수행하며, 파일 관련 속성 및 경로를 구성합니다.

          - * + *

          * 주요 기능: *

            *
          • {@link #saveQRCodeImage(byte[], String, String, String, String)} - QR 코드 이미지를 파일로 저장합니다.
          • @@ -49,8 +48,8 @@ public class FileHandler { private float imageQuality; public FileHandler( - @Value("${resource.file.disallow-extension}") String[] disallowExtensions, - @Value("${resource.file.compressible-image-extension}") String[] compressibleImageExtensions + @Value("${resource.file.disallow-extension}") String[] disallowExtensions, + @Value("${resource.file.compressible-image-extension}") String[] compressibleImageExtensions ) { this.disallowExtensions.addAll(Arrays.asList(disallowExtensions)); this.compressibleImageExtensions.addAll(Arrays.asList(compressibleImageExtensions)); @@ -60,7 +59,8 @@ public void init() { filePath = filePath.replace("/", File.separator).replace("\\", File.separator); } - public void saveQRCodeImage(byte[] image, String category, String saveFilename, String extension, String baseDirectory) throws IOException { + public void saveQRCodeImage(byte[] image, String category, String saveFilename, String extension, + String baseDirectory) throws IOException { init(); String savePath = filePath + File.separator + category + File.separator + saveFilename; ByteArrayInputStream inputStream = new ByteArrayInputStream(image); diff --git a/src/main/java/page/clab/api/global/common/file/application/FileService.java b/src/main/java/page/clab/api/global/common/file/application/FileService.java index 925b0a3a9..e1bb00c16 100644 --- a/src/main/java/page/clab/api/global/common/file/application/FileService.java +++ b/src/main/java/page/clab/api/global/common/file/application/FileService.java @@ -1,9 +1,15 @@ package page.clab.api.global.common.file.application; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.function.BiFunction; +import java.util.regex.Pattern; import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Value; import org.springframework.security.core.Authentication; @@ -15,9 +21,9 @@ import page.clab.api.domain.activity.activitygroup.dao.ActivityGroupRepository; import page.clab.api.domain.activity.activitygroup.dao.GroupMemberRepository; import page.clab.api.domain.activity.activitygroup.domain.ActivityGroupBoard; +import page.clab.api.domain.activity.activitygroup.domain.GroupMemberStatus; import page.clab.api.domain.activity.activitygroup.exception.InvalidParentBoardException; import page.clab.api.domain.activity.activitygroup.exception.MemberNotPartOfActivityException; -import page.clab.api.domain.activity.activitygroup.domain.GroupMemberStatus; import page.clab.api.domain.memberManagement.member.application.dto.shared.MemberDetailedInfoDto; import page.clab.api.domain.memberManagement.member.domain.Member; import page.clab.api.domain.memberManagement.member.domain.Role; @@ -35,19 +41,12 @@ import page.clab.api.global.util.FileSystemUtil; import page.clab.api.global.util.FileUtil; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.regex.Pattern; - /** * {@code FileService}는 파일 저장, 삭제, 경로 검증 및 파일 접근 권한 관리와 같은 파일 관리 기능을 제공하는 클래스입니다. * *

            이 서비스는 다양한 카테고리에 대해 파일 업로드 및 QR 코드 이미지 저장, 파일 삭제, 멤버의 클라우드 사용량 검증 등의 기능을 수행합니다. * 또한 파일 접근 권한을 역할(Role) 및 경로에 따라 관리하여 안전한 파일 접근을 보장합니다.

            - * + *

            * 주요 기능: *

              *
            • {@link #saveQRCodeImage(byte[], String, long, String)} - QR 코드 이미지를 파일로 저장합니다.
            • @@ -83,25 +82,32 @@ public class FileService { private String maxFileSize; private static final Map> roleCategoryMap = Map.of( - Role.GUEST, Set.of("boards", "profiles", "activity-photos", "membership-fees"), - Role.USER, Set.of("boards", "profiles", "activity-photos", "membership-fees" , "notices", "weekly-activities", "members", "assignments", "submits"), - Role.ADMIN, Set.of("boards", "profiles", "activity-photos", "membership-fees", "notices", "weekly-activities", "members", "assignments", "submits"), - Role.SUPER, Set.of("boards", "profiles", "activity-photos", "membership-fees", "notices", "weekly-activities", "members", "assignments", "submits") + Role.GUEST, Set.of("boards", "profiles", "activity-photos", "membership-fees"), + Role.USER, + Set.of("boards", "profiles", "activity-photos", "membership-fees", "notices", "weekly-activities", "members", + "assignments", "submits"), + Role.ADMIN, + Set.of("boards", "profiles", "activity-photos", "membership-fees", "notices", "weekly-activities", "members", + "assignments", "submits"), + Role.SUPER, + Set.of("boards", "profiles", "activity-photos", "membership-fees", "notices", "weekly-activities", "members", + "assignments", "submits") ); private final Map> categoryAccessMap = Map.of( - "boards", (url, auth) -> true, - "profiles", (url, auth) -> true, - "activity-photos", (url, auth) -> true, - "membership-fees", (url, auth) -> true, - "notices", this::isNonSubmitCategoryAccessible, - "weekly-activities", this::isNonSubmitCategoryAccessible, - "assignments", this::isNonSubmitCategoryAccessible, - "members", this::isMemberAccessible, - "submits", this::isSubmitAccessible + "boards", (url, auth) -> true, + "profiles", (url, auth) -> true, + "activity-photos", (url, auth) -> true, + "membership-fees", (url, auth) -> true, + "notices", this::isNonSubmitCategoryAccessible, + "weekly-activities", this::isNonSubmitCategoryAccessible, + "assignments", this::isNonSubmitCategoryAccessible, + "members", this::isMemberAccessible, + "submits", this::isSubmitAccessible ); - public String saveQRCodeImage(byte[] QRCodeImage, String path, long storagePeriod, String nowDateTime) throws IOException { + public String saveQRCodeImage(byte[] QRCodeImage, String path, long storagePeriod, String nowDateTime) + throws IOException { String currentMemberId = externalRetrieveMemberUseCase.getCurrentMemberId(); String extension = "png"; String originalFileName = path.replace(File.separator, "-") + nowDateTime; @@ -110,12 +116,14 @@ public String saveQRCodeImage(byte[] QRCodeImage, String path, long storagePerio String url = fileURL + "/" + path.replace(File.separator, "/") + "/" + saveFilename; fileHandler.saveQRCodeImage(QRCodeImage, path, saveFilename, extension, filePath); - UploadedFile uploadedFile = UploadedFile.create(currentMemberId, originalFileName, saveFilename, savePath, url, (long) QRCodeImage.length, "image/png", storagePeriod, path); + UploadedFile uploadedFile = UploadedFile.create(currentMemberId, originalFileName, saveFilename, savePath, url, + (long) QRCodeImage.length, "image/png", storagePeriod, path); uploadedFileService.saveUploadedFile(uploadedFile); return url; } - public List saveFiles(List multipartFiles, String path, long storagePeriod) throws IOException, PermissionDeniedException { + public List saveFiles(List multipartFiles, String path, long storagePeriod) + throws IOException, PermissionDeniedException { List uploadedFileResponseDtos = new ArrayList<>(); for (MultipartFile multipartFile : multipartFiles) { UploadedFileResponseDto responseDto = saveFile(multipartFile, path, storagePeriod); @@ -124,7 +132,8 @@ public List saveFiles(List multipartFile return uploadedFileResponseDtos; } - public UploadedFileResponseDto saveFile(MultipartFile multipartFile, String path, long storagePeriod) throws IOException, PermissionDeniedException { + public UploadedFileResponseDto saveFile(MultipartFile multipartFile, String path, long storagePeriod) + throws IOException, PermissionDeniedException { String currentMemberId = externalRetrieveMemberUseCase.getCurrentMemberId(); validatePathVariable(path); @@ -135,7 +144,8 @@ public UploadedFileResponseDto saveFile(MultipartFile multipartFile, String path String fileName = new File(savedFilePath).getName(); String url = fileURL + "/" + path.replace(File.separator, "/") + "/" + fileName; - UploadedFile uploadedFile = UploadedFile.create(currentMemberId, multipartFile.getOriginalFilename(), fileName, savedFilePath, url, multipartFile.getSize(), multipartFile.getContentType(), storagePeriod, path); + UploadedFile uploadedFile = UploadedFile.create(currentMemberId, multipartFile.getOriginalFilename(), fileName, + savedFilePath, url, multipartFile.getSize(), multipartFile.getContentType(), storagePeriod, path); uploadedFileService.saveUploadedFile(uploadedFile); return mapper.toDto(uploadedFile); } @@ -194,7 +204,8 @@ private void validateNoticePath(String[] pathParts) throws InvalidPathVariableEx validateIsMemberGroupLeader(activityGroupId, memberId, "활동의 공지 관련 파일은 리더만 등록할 수 있습니다."); } - private void validateWeeklyActivityPath(String[] pathParts) throws InvalidPathVariableException, PermissionDeniedException { + private void validateWeeklyActivityPath(String[] pathParts) + throws InvalidPathVariableException, PermissionDeniedException { Long activityGroupId = parseId(pathParts[1], "활동 ID가 유효하지 않습니다."); String memberId = externalRetrieveMemberUseCase.getCurrentMemberId(); @@ -203,7 +214,8 @@ private void validateWeeklyActivityPath(String[] pathParts) throws InvalidPathVa validateIsMemberGroupLeader(activityGroupId, memberId, "활동의 주차별 활동 관련 파일은 리더만 등록할 수 있습니다."); } - private void validateAssignmentPath(String[] pathParts) throws InvalidPathVariableException, PermissionDeniedException { + private void validateAssignmentPath(String[] pathParts) + throws InvalidPathVariableException, PermissionDeniedException { Long activityGroupId = parseId(pathParts[1], "활동 ID가 유효하지 않습니다."); String memberId = externalRetrieveMemberUseCase.getCurrentMemberId(); @@ -219,7 +231,8 @@ private void validateSubmitPath(String[] pathParts) throws InvalidPathVariableEx validateActivityGroupExist(activityGroupId); validateIsMemberPartOfActivity(memberId, activityGroupId); - ActivityGroupBoard activityGroupBoard = activityGroupBoardService.getActivityGroupBoardById(activityGroupBoardId); + ActivityGroupBoard activityGroupBoard = activityGroupBoardService.getActivityGroupBoardById( + activityGroupBoardId); validateIsParentBoardAssignment(activityGroupBoard); } @@ -235,7 +248,8 @@ private void validateIsMemberPartOfActivity(String memberId, Long activityGroupI } } - private void validateIsMemberGroupLeader(Long activityGroupId, String memberId, String exceptionMessage) throws PermissionDeniedException { + private void validateIsMemberGroupLeader(Long activityGroupId, String memberId, String exceptionMessage) + throws PermissionDeniedException { if (!activityGroupAdminService.isMemberGroupLeaderRole(activityGroupId, memberId)) { throw new PermissionDeniedException(exceptionMessage); } @@ -279,8 +293,9 @@ private void checkAndRemoveExistingFile(String path) { public boolean isUserAccessibleAtFile(Authentication authentication, String url) { String category = getCategoryByUrl(url); - if (category == null || category.isEmpty()) + if (category == null || category.isEmpty()) { return false; + } return isUserAccessibleByCategory(category, url, authentication); } @@ -310,7 +325,8 @@ private boolean isNonSubmitCategoryAccessible(String url, Authentication authent Long activityGroupId = Long.parseLong(parts[4]); return member.isSuperAdminRole() || - groupMemberRepository.existsByActivityGroupIdAndMemberIdAndStatus(activityGroupId, memberId, GroupMemberStatus.ACCEPTED); + groupMemberRepository.existsByActivityGroupIdAndMemberIdAndStatus(activityGroupId, memberId, + GroupMemberStatus.ACCEPTED); } private boolean isMemberAccessible(String url, Authentication authentication) { @@ -328,7 +344,7 @@ private boolean isSubmitAccessible(String url, Authentication authentication) { Long activityGroupId = Long.parseLong(parts[4]); return memberId.equals(uploaderId) || member.isSuperAdminRole() || - activityGroupAdminService.isMemberGroupLeaderRole(activityGroupId, authentication.getName()); + activityGroupAdminService.isMemberGroupLeaderRole(activityGroupId, authentication.getName()); } private String getCategoryByUrl(String url) { diff --git a/src/main/java/page/clab/api/global/common/file/application/UploadedFileService.java b/src/main/java/page/clab/api/global/common/file/application/UploadedFileService.java index 55bc28f68..89c8fe942 100644 --- a/src/main/java/page/clab/api/global/common/file/application/UploadedFileService.java +++ b/src/main/java/page/clab/api/global/common/file/application/UploadedFileService.java @@ -1,5 +1,7 @@ package page.clab.api.global.common.file.application; +import java.util.ArrayList; +import java.util.List; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -7,15 +9,12 @@ import page.clab.api.global.common.file.domain.UploadedFile; import page.clab.api.global.exception.NotFoundException; -import java.util.ArrayList; -import java.util.List; - /** * {@code UploadedFileService}는 업로드된 파일을 저장, 조회, 및 유효성 검사를 수행하는 서비스입니다. * *

              이 서비스는 파일의 URL을 기반으로 파일을 조회하거나, 특정 카테고리에 속하는 최신 파일을 조회하며, * 여러 URL 목록을 받아 해당하는 파일들을 검색하는 등의 기능을 제공합니다.

              - * + *

              * 주요 기능: *

                *
              • {@link #saveUploadedFile(UploadedFile)} - 파일 정보를 데이터베이스에 저장합니다.
              • @@ -40,7 +39,7 @@ public UploadedFile saveUploadedFile(UploadedFile uploadedFile) { public UploadedFile getUploadedFileByUrl(String url) { return uploadFileRepository.findByUrl(url) - .orElseThrow(() -> new NotFoundException("파일을 찾을 수 없습니다.")); + .orElseThrow(() -> new NotFoundException("파일을 찾을 수 없습니다.")); } public UploadedFile getUniqueUploadedFileByCategory(String category) { diff --git a/src/main/java/page/clab/api/global/common/file/dao/UploadFileRepository.java b/src/main/java/page/clab/api/global/common/file/dao/UploadFileRepository.java index b6d0af06d..e6d6c9e94 100644 --- a/src/main/java/page/clab/api/global/common/file/dao/UploadFileRepository.java +++ b/src/main/java/page/clab/api/global/common/file/dao/UploadFileRepository.java @@ -1,10 +1,9 @@ package page.clab.api.global.common.file.dao; -import org.springframework.data.jpa.repository.JpaRepository; -import page.clab.api.global.common.file.domain.UploadedFile; - import java.util.List; import java.util.Optional; +import org.springframework.data.jpa.repository.JpaRepository; +import page.clab.api.global.common.file.domain.UploadedFile; public interface UploadFileRepository extends JpaRepository { diff --git a/src/main/java/page/clab/api/global/common/file/domain/UploadedFile.java b/src/main/java/page/clab/api/global/common/file/domain/UploadedFile.java index 261bdb2dd..276210c36 100644 --- a/src/main/java/page/clab/api/global/common/file/domain/UploadedFile.java +++ b/src/main/java/page/clab/api/global/common/file/domain/UploadedFile.java @@ -53,18 +53,19 @@ public class UploadedFile extends BaseEntity { private Long storagePeriod; - public static UploadedFile create(String uploader, String originalFileName, String saveFileName, String savedPath, String url, Long fileSize, String contentType, Long storagePeriod, String category) { + public static UploadedFile create(String uploader, String originalFileName, String saveFileName, String savedPath, + String url, Long fileSize, String contentType, Long storagePeriod, String category) { return UploadedFile.builder() - .uploader(uploader) - .originalFileName(originalFileName) - .saveFileName(saveFileName) - .savedPath(savedPath) - .url(url) - .fileSize(fileSize) - .contentType(contentType) - .storagePeriod(storagePeriod) - .category(category) - .build(); + .uploader(uploader) + .originalFileName(originalFileName) + .saveFileName(saveFileName) + .savedPath(savedPath) + .url(url) + .fileSize(fileSize) + .contentType(contentType) + .storagePeriod(storagePeriod) + .category(category) + .build(); } public boolean isOwner(String memberId) { diff --git a/src/main/java/page/clab/api/global/common/file/dto/mapper/FileDtoMapper.java b/src/main/java/page/clab/api/global/common/file/dto/mapper/FileDtoMapper.java index 554bb25aa..a80413341 100644 --- a/src/main/java/page/clab/api/global/common/file/dto/mapper/FileDtoMapper.java +++ b/src/main/java/page/clab/api/global/common/file/dto/mapper/FileDtoMapper.java @@ -1,37 +1,36 @@ package page.clab.api.global.common.file.dto.mapper; +import java.io.File; +import java.util.Date; +import java.util.List; import org.springframework.stereotype.Component; import page.clab.api.global.common.file.domain.UploadedFile; import page.clab.api.global.common.file.dto.request.DeleteFileRequestDto; import page.clab.api.global.common.file.dto.response.FileInfo; import page.clab.api.global.common.file.dto.response.UploadedFileResponseDto; -import java.io.File; -import java.util.Date; -import java.util.List; - @Component public class FileDtoMapper { public List toDto(List uploadedFiles) { return uploadedFiles.stream() - .map(this::toDto) - .toList(); + .map(this::toDto) + .toList(); } public UploadedFileResponseDto toDto(UploadedFile uploadedFile) { return UploadedFileResponseDto.builder() - .fileUrl(uploadedFile.getUrl()) - .originalFileName(uploadedFile.getOriginalFileName()) - .storagePeriod(uploadedFile.getStoragePeriod()) - .createdAt(uploadedFile.getCreatedAt()) - .build(); + .fileUrl(uploadedFile.getUrl()) + .originalFileName(uploadedFile.getOriginalFileName()) + .storagePeriod(uploadedFile.getStoragePeriod()) + .createdAt(uploadedFile.getCreatedAt()) + .build(); } public DeleteFileRequestDto of(String url) { return DeleteFileRequestDto.builder() - .url(url) - .build(); + .url(url) + .build(); } public FileInfo create(File file) { @@ -40,10 +39,10 @@ public FileInfo create(File file) { } return FileInfo.builder() - .fileName(file.getName()) - .fileSizeInBytes(file.length()) - .creationDate(new Date(file.lastModified())) - .modificationDate(new Date(file.lastModified())) - .build(); + .fileName(file.getName()) + .fileSizeInBytes(file.length()) + .creationDate(new Date(file.lastModified())) + .modificationDate(new Date(file.lastModified())) + .build(); } } diff --git a/src/main/java/page/clab/api/global/common/file/dto/response/FileInfo.java b/src/main/java/page/clab/api/global/common/file/dto/response/FileInfo.java index f3279ad60..2f062c1fe 100644 --- a/src/main/java/page/clab/api/global/common/file/dto/response/FileInfo.java +++ b/src/main/java/page/clab/api/global/common/file/dto/response/FileInfo.java @@ -1,10 +1,9 @@ package page.clab.api.global.common.file.dto.response; +import java.util.Date; import lombok.Builder; import lombok.Getter; -import java.util.Date; - @Getter @Builder public class FileInfo { diff --git a/src/main/java/page/clab/api/global/common/file/dto/response/UploadedFileResponseDto.java b/src/main/java/page/clab/api/global/common/file/dto/response/UploadedFileResponseDto.java index d05313c0e..7f3af06a7 100644 --- a/src/main/java/page/clab/api/global/common/file/dto/response/UploadedFileResponseDto.java +++ b/src/main/java/page/clab/api/global/common/file/dto/response/UploadedFileResponseDto.java @@ -1,10 +1,9 @@ package page.clab.api.global.common.file.dto.response; +import java.time.LocalDateTime; import lombok.Builder; import lombok.Getter; -import java.time.LocalDateTime; - @Getter @Builder public class UploadedFileResponseDto { diff --git a/src/main/java/page/clab/api/global/common/notificationSetting/adapter/in/web/NotificationSettingToggleController.java b/src/main/java/page/clab/api/global/common/notificationSetting/adapter/in/web/NotificationSettingToggleController.java index 74023a6bc..8769fc5a8 100644 --- a/src/main/java/page/clab/api/global/common/notificationSetting/adapter/in/web/NotificationSettingToggleController.java +++ b/src/main/java/page/clab/api/global/common/notificationSetting/adapter/in/web/NotificationSettingToggleController.java @@ -25,7 +25,7 @@ public class NotificationSettingToggleController { @PreAuthorize("hasRole('SUPER')") @PutMapping("") public ApiResponse toggleNotificationSetting( - @Valid @RequestBody NotificationSettingToggleRequestDto requestDto + @Valid @RequestBody NotificationSettingToggleRequestDto requestDto ) { manageNotificationSettingUseCase.toggleNotificationSetting(requestDto.getAlertType(), requestDto.isEnabled()); return ApiResponse.success(); diff --git a/src/main/java/page/clab/api/global/common/notificationSetting/adapter/out/persistence/NotificationSettingPersistenceAdapter.java b/src/main/java/page/clab/api/global/common/notificationSetting/adapter/out/persistence/NotificationSettingPersistenceAdapter.java index 4bae839c3..afb0b8ba4 100644 --- a/src/main/java/page/clab/api/global/common/notificationSetting/adapter/out/persistence/NotificationSettingPersistenceAdapter.java +++ b/src/main/java/page/clab/api/global/common/notificationSetting/adapter/out/persistence/NotificationSettingPersistenceAdapter.java @@ -12,8 +12,8 @@ @Component @RequiredArgsConstructor public class NotificationSettingPersistenceAdapter implements - RetrieveNotificationSettingPort, - UpdateNotificationSettingPort { + RetrieveNotificationSettingPort, + UpdateNotificationSettingPort { private final NotificationSettingRepository repository; diff --git a/src/main/java/page/clab/api/global/common/notificationSetting/adapter/out/webhook/AbstractWebhookClient.java b/src/main/java/page/clab/api/global/common/notificationSetting/adapter/out/webhook/AbstractWebhookClient.java index d67f0a17f..51614d84e 100644 --- a/src/main/java/page/clab/api/global/common/notificationSetting/adapter/out/webhook/AbstractWebhookClient.java +++ b/src/main/java/page/clab/api/global/common/notificationSetting/adapter/out/webhook/AbstractWebhookClient.java @@ -12,6 +12,6 @@ public abstract class AbstractWebhookClient implements WebhookClient { @Override public abstract CompletableFuture sendMessage(String webhookUrl, AlertType alertType, - HttpServletRequest request, - Object additionalData); + HttpServletRequest request, + Object additionalData); } diff --git a/src/main/java/page/clab/api/global/common/notificationSetting/adapter/out/webhook/DiscordNotificationSender.java b/src/main/java/page/clab/api/global/common/notificationSetting/adapter/out/webhook/DiscordNotificationSender.java index b6bfedf51..eae67d1af 100644 --- a/src/main/java/page/clab/api/global/common/notificationSetting/adapter/out/webhook/DiscordNotificationSender.java +++ b/src/main/java/page/clab/api/global/common/notificationSetting/adapter/out/webhook/DiscordNotificationSender.java @@ -20,6 +20,6 @@ public String getPlatformName() { @Override public void sendNotification(NotificationEvent event, String webhookUrl) { discordWebhookClient.sendMessage(webhookUrl, event.getAlertType(), event.getRequest(), - event.getAdditionalData()); + event.getAdditionalData()); } } diff --git a/src/main/java/page/clab/api/global/common/notificationSetting/adapter/out/webhook/DiscordWebhookClient.java b/src/main/java/page/clab/api/global/common/notificationSetting/adapter/out/webhook/DiscordWebhookClient.java index fb1c443d3..c90a4af12 100644 --- a/src/main/java/page/clab/api/global/common/notificationSetting/adapter/out/webhook/DiscordWebhookClient.java +++ b/src/main/java/page/clab/api/global/common/notificationSetting/adapter/out/webhook/DiscordWebhookClient.java @@ -61,10 +61,10 @@ public class DiscordWebhookClient extends AbstractWebhookClient { private final WebhookCommonService webhookCommonService; public DiscordWebhookClient( - NotificationConfigProperties notificationConfigProperties, - ObjectMapper objectMapper, - Environment environment, - WebhookCommonService webhookCommonService + NotificationConfigProperties notificationConfigProperties, + ObjectMapper objectMapper, + Environment environment, + WebhookCommonService webhookCommonService ) { this.httpClient = HttpClient.newHttpClient(); this.objectMapper = objectMapper; @@ -83,7 +83,7 @@ public DiscordWebhookClient( * @return 메시지 전송 성공 여부를 나타내는 CompletableFuture */ public CompletableFuture sendMessage(String webhookUrl, AlertType alertType, - HttpServletRequest request, Object additionalData) { + HttpServletRequest request, Object additionalData) { Map payload = createPayload(alertType, request, additionalData); return CompletableFuture.supplyAsync(() -> { @@ -91,10 +91,10 @@ public CompletableFuture sendMessage(String webhookUrl, AlertType alert String jsonPayload = objectMapper.writeValueAsString(payload); HttpRequest httpRequest = HttpRequest.newBuilder() - .uri(URI.create(webhookUrl)) - .header("Content-Type", MediaType.APPLICATION_JSON_VALUE) - .POST(HttpRequest.BodyPublishers.ofString(jsonPayload)) - .build(); + .uri(URI.create(webhookUrl)) + .header("Content-Type", MediaType.APPLICATION_JSON_VALUE) + .POST(HttpRequest.BodyPublishers.ofString(jsonPayload)) + .build(); HttpResponse response = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString()); @@ -137,7 +137,7 @@ public Map createPayload(AlertType alertType, HttpServletRequest * @return 생성된 임베드 목록 */ public List> createEmbeds(AlertType alertType, HttpServletRequest request, - Object additionalData) { + Object additionalData) { switch (alertType) { case SecurityAlertType securityAlertType -> { return createSecurityAlertEmbeds(request, alertType, additionalData.toString()); @@ -156,7 +156,7 @@ public List> createEmbeds(AlertType alertType, HttpServletRe } private List> createGeneralAlertEmbeds(GeneralAlertType alertType, HttpServletRequest request, - Object additionalData) { + Object additionalData) { switch (alertType) { case ADMIN_LOGIN: if (additionalData instanceof MemberLoginInfoDto) { @@ -177,7 +177,7 @@ private List> createGeneralAlertEmbeds(GeneralAlertType aler } private List> createExecutivesAlertEmbeds(ExecutivesAlertType alertType, - Object additionalData) { + Object additionalData) { switch (alertType) { case NEW_APPLICATION: if (additionalData instanceof ApplicationRequestDto) { @@ -218,17 +218,17 @@ private List> createErrorEmbeds(HttpServletRequest request, embed.put("title", ":firecracker: Server Error"); embed.put("color", commonProperties.getColorAsInt()); embed.put("fields", Arrays.asList( - createField("User", username, true), - createField("Endpoint", "[" + httpMethod + "] " + fullUrl, true), - createField("Error Message", errorMessage, false), - createField("Stack Trace", "```" + stackTrace + "```", false) + createField("User", username, true), + createField("Endpoint", "[" + httpMethod + "] " + fullUrl, true), + createField("Error Message", errorMessage, false), + createField("Stack Trace", "```" + stackTrace + "```", false) )); return Collections.singletonList(embed); } private List> createSecurityAlertEmbeds(HttpServletRequest request, AlertType alertType, - String additionalMessage) { + String additionalMessage) { String clientIp = HttpReqResUtil.getClientIpAddressIfServletRequestExist(); String fullUrl = webhookCommonService.getFullUrl(request); String username = webhookCommonService.getUsername(request); @@ -238,18 +238,18 @@ private List> createSecurityAlertEmbeds(HttpServletRequest r embed.put("title", ":imp: " + alertType.getTitle()); embed.put("color", commonProperties.getColorAsInt()); embed.put("fields", Arrays.asList( - createField("User", username, true), - createField("IP Address", clientIp, true), - createField("Location", location, true), - createField("Endpoint", fullUrl, true), - createField("Details", alertType.getDefaultMessage() + "\n" + additionalMessage, false) + createField("User", username, true), + createField("IP Address", clientIp, true), + createField("Location", location, true), + createField("Endpoint", fullUrl, true), + createField("Details", alertType.getDefaultMessage() + "\n" + additionalMessage, false) )); return Collections.singletonList(embed); } private List> createAdminLoginEmbeds(HttpServletRequest request, - MemberLoginInfoDto loginMember) { + MemberLoginInfoDto loginMember) { String clientIp = HttpReqResUtil.getClientIpAddressIfServletRequestExist(); String location = webhookCommonService.getLocation(request); @@ -257,9 +257,9 @@ private List> createAdminLoginEmbeds(HttpServletRequest requ embed.put("title", ":mechanic: " + loginMember.getRole().getDescription() + " Login"); embed.put("color", commonProperties.getColorAsInt()); embed.put("fields", Arrays.asList( - createField("User", loginMember.getMemberId() + " " + loginMember.getMemberName(), true), - createField("IP Address", clientIp, true), - createField("Location", location, true) + createField("User", loginMember.getMemberId() + " " + loginMember.getMemberName(), true), + createField("IP Address", clientIp, true), + createField("Location", location, true) )); return Collections.singletonList(embed); @@ -270,11 +270,11 @@ private List> createApplicationEmbeds(ApplicationRequestDto embed.put("title", ":sparkles: 동아리 지원"); embed.put("color", commonProperties.getColorAsInt()); embed.put("fields", Arrays.asList( - createField("구분", requestDto.getApplicationType().getDescription(), true), - createField("학번", requestDto.getStudentId(), true), - createField("이름", requestDto.getName(), true), - createField("학년", requestDto.getGrade() + "학년", true), - createField("관심 분야", requestDto.getInterests(), false) + createField("구분", requestDto.getApplicationType().getDescription(), true), + createField("학번", requestDto.getStudentId(), true), + createField("이름", requestDto.getName(), true), + createField("학년", requestDto.getGrade() + "학년", true), + createField("관심 분야", requestDto.getInterests(), false) )); if (requestDto.getGithubUrl() != null && !requestDto.getGithubUrl().isEmpty()) { @@ -289,9 +289,9 @@ private List> createBoardEmbeds(BoardNotificationInfo board) embed.put("title", ":writing_hand: 새 게시글"); embed.put("color", commonProperties.getColorAsInt()); embed.put("fields", Arrays.asList( - createField("제목", board.getTitle(), true), - createField("분류", board.getCategory(), true), - createField("작성자", board.getUsername(), true) + createField("제목", board.getTitle(), true), + createField("분류", board.getCategory(), true), + createField("작성자", board.getUsername(), true) )); return Collections.singletonList(embed); @@ -304,10 +304,10 @@ private List> createMembershipFeeEmbeds(MembershipFeeNotific embed.put("title", ":dollar: 회비 신청"); embed.put("color", commonProperties.getColorAsInt()); embed.put("fields", Arrays.asList( - createField("신청자", username, true), - createField("분류", data.getCategory(), true), - createField("금액", data.getAmount() + "원", true), - createField("Content", data.getContent(), false) + createField("신청자", username, true), + createField("분류", data.getCategory(), true), + createField("금액", data.getAmount() + "원", true), + createField("Content", data.getContent(), false) )); return Collections.singletonList(embed); @@ -320,10 +320,10 @@ private List> createBookLoanRecordEmbeds(BookLoanRecordNotif embed.put("title", ":books: 도서 대여 신청"); embed.put("color", commonProperties.getColorAsInt()); embed.put("fields", Arrays.asList( - createField("도서명", data.getBookTitle(), true), - createField("분류", data.getCategory(), true), - createField("신청자", username, true), - createField("상태", data.isAvailable() ? "대여 가능" : "대여 중", true) + createField("도서명", data.getBookTitle(), true), + createField("분류", data.getCategory(), true), + createField("신청자", username, true), + createField("상태", data.isAvailable() ? "대여 가능" : "대여 중", true) )); return Collections.singletonList(embed); @@ -339,15 +339,15 @@ private List> createServerStartEmbeds() { embed.put("title", ":battery: Server Started"); embed.put("color", commonProperties.getColorAsInt()); embed.put("fields", Arrays.asList( - createField("Environment", environment.getProperty("spring.profiles.active"), true), - createField("OS", osInfo, true), - createField("JDK Version", jdkVersion, true), - createField("CPU Usage", String.format("%.2f%%", cpuUsage), true), - createField("Memory Usage", memoryUsage, true) + createField("Environment", environment.getProperty("spring.profiles.active"), true), + createField("OS", osInfo, true), + createField("JDK Version", jdkVersion, true), + createField("CPU Usage", String.format("%.2f%%", cpuUsage), true), + createField("Memory Usage", memoryUsage, true) )); embed.put("description", - "[Web](" + commonProperties.getWebUrl() + ") | [API Docs](" + commonProperties.getApiUrl() + ")"); + "[Web](" + commonProperties.getWebUrl() + ") | [API Docs](" + commonProperties.getApiUrl() + ")"); return Collections.singletonList(embed); } diff --git a/src/main/java/page/clab/api/global/common/notificationSetting/adapter/out/webhook/SlackNotificationSender.java b/src/main/java/page/clab/api/global/common/notificationSetting/adapter/out/webhook/SlackNotificationSender.java index 3a993dc57..ff44f4e5b 100644 --- a/src/main/java/page/clab/api/global/common/notificationSetting/adapter/out/webhook/SlackNotificationSender.java +++ b/src/main/java/page/clab/api/global/common/notificationSetting/adapter/out/webhook/SlackNotificationSender.java @@ -20,6 +20,6 @@ public String getPlatformName() { @Override public void sendNotification(NotificationEvent event, String webhookUrl) { slackWebhookClient.sendMessage(webhookUrl, event.getAlertType(), event.getRequest(), - event.getAdditionalData()); + event.getAdditionalData()); } } diff --git a/src/main/java/page/clab/api/global/common/notificationSetting/adapter/out/webhook/SlackWebhookClient.java b/src/main/java/page/clab/api/global/common/notificationSetting/adapter/out/webhook/SlackWebhookClient.java index 291bfd047..8242e43ac 100644 --- a/src/main/java/page/clab/api/global/common/notificationSetting/adapter/out/webhook/SlackWebhookClient.java +++ b/src/main/java/page/clab/api/global/common/notificationSetting/adapter/out/webhook/SlackWebhookClient.java @@ -65,9 +65,9 @@ public class SlackWebhookClient extends AbstractWebhookClient { private final WebhookCommonService webhookCommonService; public SlackWebhookClient( - NotificationConfigProperties notificationConfigProperties, - Environment environment, - WebhookCommonService webhookCommonService + NotificationConfigProperties notificationConfigProperties, + Environment environment, + WebhookCommonService webhookCommonService ) { this.slack = Slack.getInstance(); this.commonProperties = notificationConfigProperties.getCommon(); @@ -88,19 +88,19 @@ public SlackWebhookClient( * @return 메시지 전송 성공 여부를 나타내는 CompletableFuture */ public CompletableFuture sendMessage(String webhookUrl, AlertType alertType, - HttpServletRequest request, Object additionalData) { + HttpServletRequest request, Object additionalData) { List blocks = createBlocks(alertType, request, additionalData); return CompletableFuture.supplyAsync(() -> { Payload payload = Payload.builder() - .blocks(Collections.singletonList(blocks.getFirst())) - .attachments(Collections.singletonList( - Attachment.builder() - .color(commonProperties.getColor()) - .blocks(blocks.subList(1, blocks.size())) - .build() - )) - .build(); + .blocks(Collections.singletonList(blocks.getFirst())) + .attachments(Collections.singletonList( + Attachment.builder() + .color(commonProperties.getColor()) + .blocks(blocks.subList(1, blocks.size())) + .build() + )) + .build(); try { WebhookResponse response = slack.send(webhookUrl, payload); @@ -146,7 +146,7 @@ public List createBlocks(AlertType alertType, HttpServletRequest re } private List createGeneralAlertBlocks(GeneralAlertType alertType, HttpServletRequest request, - Object additionalData) { + Object additionalData) { switch (alertType) { case ADMIN_LOGIN: if (additionalData instanceof MemberLoginInfoDto) { @@ -204,33 +204,33 @@ private List createErrorBlocks(HttpServletRequest request, Exceptio log.error("Server Error: {}", errorMessage); return Arrays.asList( - section(s -> s.text(markdownText(":firecracker: *Server Error*"))), - section(s -> s.fields(Arrays.asList( - markdownText("*User:*\n" + username), - markdownText("*Endpoint:*\n[" + httpMethod + "] " + fullUrl) - ))), - section(s -> s.text(markdownText("*Error Message:*\n" + errorMessage))), - section(s -> s.text(markdownText("*Stack Trace:*\n```" + stackTrace + "```"))) + section(s -> s.text(markdownText(":firecracker: *Server Error*"))), + section(s -> s.fields(Arrays.asList( + markdownText("*User:*\n" + username), + markdownText("*Endpoint:*\n[" + httpMethod + "] " + fullUrl) + ))), + section(s -> s.text(markdownText("*Error Message:*\n" + errorMessage))), + section(s -> s.text(markdownText("*Stack Trace:*\n```" + stackTrace + "```"))) ); } private List createSecurityAlertBlocks(HttpServletRequest request, AlertType alertType, - String additionalMessage) { + String additionalMessage) { String clientIp = HttpReqResUtil.getClientIpAddressIfServletRequestExist(); String fullUrl = webhookCommonService.getFullUrl(request); String username = webhookCommonService.getUsername(request); String location = webhookCommonService.getLocation(request); return Arrays.asList( - section(s -> s.text(markdownText(":imp: *" + alertType.getTitle() + "*"))), - section(s -> s.fields(Arrays.asList( - markdownText("*User:*\n" + username), - markdownText("*IP Address:*\n" + clientIp), - markdownText("*Location:*\n" + location), - markdownText("*Endpoint:*\n" + fullUrl) - ))), - section(s -> s.text( - markdownText("*Details:*\n" + alertType.getDefaultMessage() + "\n" + additionalMessage))) + section(s -> s.text(markdownText(":imp: *" + alertType.getTitle() + "*"))), + section(s -> s.fields(Arrays.asList( + markdownText("*User:*\n" + username), + markdownText("*IP Address:*\n" + clientIp), + markdownText("*Location:*\n" + location), + markdownText("*Endpoint:*\n" + fullUrl) + ))), + section(s -> s.text( + markdownText("*Details:*\n" + alertType.getDefaultMessage() + "\n" + additionalMessage))) ); } @@ -239,12 +239,12 @@ private List createAdminLoginBlocks(HttpServletRequest request, Mem String location = webhookCommonService.getLocation(request); return Arrays.asList( - section(s -> s.text(markdownText(":mechanic: *" + loginMember.getRole().getDescription() + " Login*"))), - section(s -> s.fields(Arrays.asList( - markdownText("*User:*\n" + loginMember.getMemberId() + " " + loginMember.getMemberName()), - markdownText("*IP Address:*\n" + clientIp), - markdownText("*Location:*\n" + location) - ))) + section(s -> s.text(markdownText(":mechanic: *" + loginMember.getRole().getDescription() + " Login*"))), + section(s -> s.fields(Arrays.asList( + markdownText("*User:*\n" + loginMember.getMemberId() + " " + loginMember.getMemberName()), + markdownText("*IP Address:*\n" + clientIp), + markdownText("*Location:*\n" + location) + ))) ); } @@ -253,18 +253,18 @@ private List createApplicationBlocks(ApplicationRequestDto requestD blocks.add(section(s -> s.text(markdownText(":sparkles: *동아리 지원*")))); blocks.add(section(s -> s.fields(Arrays.asList( - markdownText("*구분:*\n" + requestDto.getApplicationType().getDescription()), - markdownText("*학번:*\n" + requestDto.getStudentId()), - markdownText("*이름:*\n" + requestDto.getName()), - markdownText("*학년:*\n" + requestDto.getGrade() + "학년"), - markdownText("*관심 분야:*\n" + requestDto.getInterests()) + markdownText("*구분:*\n" + requestDto.getApplicationType().getDescription()), + markdownText("*학번:*\n" + requestDto.getStudentId()), + markdownText("*이름:*\n" + requestDto.getName()), + markdownText("*학년:*\n" + requestDto.getGrade() + "학년"), + markdownText("*관심 분야:*\n" + requestDto.getInterests()) )))); if (requestDto.getGithubUrl() != null && !requestDto.getGithubUrl().isEmpty()) { blocks.add(actions(a -> a.elements(asElements( - button(b -> b.text(plainText(pt -> pt.emoji(true).text("Github"))) - .url(requestDto.getGithubUrl()) - .actionId("click_github")) + button(b -> b.text(plainText(pt -> pt.emoji(true).text("Github"))) + .url(requestDto.getGithubUrl()) + .actionId("click_github")) )))); } @@ -273,12 +273,12 @@ private List createApplicationBlocks(ApplicationRequestDto requestD private List createBoardBlocks(BoardNotificationInfo board) { return Arrays.asList( - section(s -> s.text(markdownText(":writing_hand: *새 게시글*"))), - section(s -> s.fields(Arrays.asList( - markdownText("*제목:*\n" + board.getTitle()), - markdownText("*분류:*\n" + board.getCategory()), - markdownText("*작성자:*\n" + board.getUsername()) - ))) + section(s -> s.text(markdownText(":writing_hand: *새 게시글*"))), + section(s -> s.fields(Arrays.asList( + markdownText("*제목:*\n" + board.getTitle()), + markdownText("*분류:*\n" + board.getCategory()), + markdownText("*작성자:*\n" + board.getUsername()) + ))) ); } @@ -286,13 +286,13 @@ private List createMembershipFeeBlocks(MembershipFeeNotificationInf String username = data.getMemberId() + " " + data.getMemberName(); return Arrays.asList( - section(s -> s.text(markdownText(":dollar: *회비 신청*"))), - section(s -> s.fields(Arrays.asList( - markdownText("*신청자:*\n" + username), - markdownText("*분류:*\n" + data.getCategory()), - markdownText("*금액:*\n" + data.getAmount() + "원") - ))), - section(s -> s.text(markdownText("*Content:*\n" + data.getContent()))) + section(s -> s.text(markdownText(":dollar: *회비 신청*"))), + section(s -> s.fields(Arrays.asList( + markdownText("*신청자:*\n" + username), + markdownText("*분류:*\n" + data.getCategory()), + markdownText("*금액:*\n" + data.getAmount() + "원") + ))), + section(s -> s.text(markdownText("*Content:*\n" + data.getContent()))) ); } @@ -300,13 +300,13 @@ private List createBookLoanRecordBlocks(BookLoanRecordNotificationI String username = data.getMemberId() + " " + data.getMemberName(); return Arrays.asList( - section(s -> s.text(markdownText(":books: *도서 대여 신청*"))), - section(s -> s.fields(Arrays.asList( - markdownText("*도서명:*\n" + data.getBookTitle()), - markdownText("*분류:*\n" + data.getCategory()), - markdownText("*신청자:*\n" + username), - markdownText("*상태:*\n" + (data.isAvailable() ? "대여 가능" : "대여 중")) - ))) + section(s -> s.text(markdownText(":books: *도서 대여 신청*"))), + section(s -> s.fields(Arrays.asList( + markdownText("*도서명:*\n" + data.getBookTitle()), + markdownText("*분류:*\n" + data.getCategory()), + markdownText("*신청자:*\n" + username), + markdownText("*상태:*\n" + (data.isAvailable() ? "대여 가능" : "대여 중")) + ))) ); } @@ -317,22 +317,22 @@ private List createServerStartBlocks() { String memoryUsage = webhookCommonService.getMemoryUsage(); return Arrays.asList( - section(s -> s.text(markdownText(":battery: *Server Started*"))), - section(s -> s.fields(Arrays.asList( - markdownText("*Environment:* \n" + environment.getProperty("spring.profiles.active")), - markdownText("*OS:* \n" + osInfo), - markdownText("*JDK Version:* \n" + jdkVersion), - markdownText("*CPU Usage:* \n" + String.format("%.2f%%", cpuUsage)), - markdownText("*Memory Usage:* \n" + memoryUsage) - ))), - actions(a -> a.elements(asElements( - button(b -> b.text(plainText(pt -> pt.emoji(true).text("Web"))) - .url(commonProperties.getWebUrl()) - .value("click_web")), - button(b -> b.text(plainText(pt -> pt.emoji(true).text("API Docs"))) - .url(commonProperties.getApiUrl()) - .value("click_apiDocs")) - ))) + section(s -> s.text(markdownText(":battery: *Server Started*"))), + section(s -> s.fields(Arrays.asList( + markdownText("*Environment:* \n" + environment.getProperty("spring.profiles.active")), + markdownText("*OS:* \n" + osInfo), + markdownText("*JDK Version:* \n" + jdkVersion), + markdownText("*CPU Usage:* \n" + String.format("%.2f%%", cpuUsage)), + markdownText("*Memory Usage:* \n" + memoryUsage) + ))), + actions(a -> a.elements(asElements( + button(b -> b.text(plainText(pt -> pt.emoji(true).text("Web"))) + .url(commonProperties.getWebUrl()) + .value("click_web")), + button(b -> b.text(plainText(pt -> pt.emoji(true).text("API Docs"))) + .url(commonProperties.getApiUrl()) + .value("click_apiDocs")) + ))) ); } } diff --git a/src/main/java/page/clab/api/global/common/notificationSetting/application/dto/mapper/NotificationSettingDtoMapper.java b/src/main/java/page/clab/api/global/common/notificationSetting/application/dto/mapper/NotificationSettingDtoMapper.java index 4b092100a..661ec92c7 100644 --- a/src/main/java/page/clab/api/global/common/notificationSetting/application/dto/mapper/NotificationSettingDtoMapper.java +++ b/src/main/java/page/clab/api/global/common/notificationSetting/application/dto/mapper/NotificationSettingDtoMapper.java @@ -9,8 +9,8 @@ public class NotificationSettingDtoMapper { public NotificationSettingResponseDto toDto(NotificationSetting setting) { return NotificationSettingResponseDto.builder() - .alertType(setting.getAlertType().getTitle()) - .enabled(setting.isEnabled()) - .build(); + .alertType(setting.getAlertType().getTitle()) + .enabled(setting.isEnabled()) + .build(); } } diff --git a/src/main/java/page/clab/api/global/common/notificationSetting/application/dto/notification/BoardNotificationInfo.java b/src/main/java/page/clab/api/global/common/notificationSetting/application/dto/notification/BoardNotificationInfo.java index 4cf0a3442..e5d4f9585 100644 --- a/src/main/java/page/clab/api/global/common/notificationSetting/application/dto/notification/BoardNotificationInfo.java +++ b/src/main/java/page/clab/api/global/common/notificationSetting/application/dto/notification/BoardNotificationInfo.java @@ -15,10 +15,10 @@ public class BoardNotificationInfo { public static BoardNotificationInfo create(Board board, MemberDetailedInfoDto memberInfo) { return BoardNotificationInfo.builder() - .title(board.getTitle()) - .category(board.getCategory().getDescription()) - .username(board.isWantAnonymous() ? board.getNickname() - : memberInfo.getMemberId() + " " + memberInfo.getMemberName()) - .build(); + .title(board.getTitle()) + .category(board.getCategory().getDescription()) + .username(board.isWantAnonymous() ? board.getNickname() + : memberInfo.getMemberId() + " " + memberInfo.getMemberName()) + .build(); } } diff --git a/src/main/java/page/clab/api/global/common/notificationSetting/application/dto/notification/BookLoanRecordNotificationInfo.java b/src/main/java/page/clab/api/global/common/notificationSetting/application/dto/notification/BookLoanRecordNotificationInfo.java index 036f1de32..6ed669e76 100644 --- a/src/main/java/page/clab/api/global/common/notificationSetting/application/dto/notification/BookLoanRecordNotificationInfo.java +++ b/src/main/java/page/clab/api/global/common/notificationSetting/application/dto/notification/BookLoanRecordNotificationInfo.java @@ -17,11 +17,11 @@ public class BookLoanRecordNotificationInfo { public static BookLoanRecordNotificationInfo create(Book book, MemberBorrowerInfoDto borrowerInfo) { return BookLoanRecordNotificationInfo.builder() - .memberId(borrowerInfo.getMemberId()) - .memberName(borrowerInfo.getMemberName()) - .bookTitle(book.getTitle()) - .category(book.getCategory()) - .isAvailable(book.getBorrowerId() == null) - .build(); + .memberId(borrowerInfo.getMemberId()) + .memberName(borrowerInfo.getMemberName()) + .bookTitle(book.getTitle()) + .category(book.getCategory()) + .isAvailable(book.getBorrowerId() == null) + .build(); } } diff --git a/src/main/java/page/clab/api/global/common/notificationSetting/application/dto/notification/MembershipFeeNotificationInfo.java b/src/main/java/page/clab/api/global/common/notificationSetting/application/dto/notification/MembershipFeeNotificationInfo.java index 65b6ed8f3..2b37a6a66 100644 --- a/src/main/java/page/clab/api/global/common/notificationSetting/application/dto/notification/MembershipFeeNotificationInfo.java +++ b/src/main/java/page/clab/api/global/common/notificationSetting/application/dto/notification/MembershipFeeNotificationInfo.java @@ -17,11 +17,11 @@ public class MembershipFeeNotificationInfo { public static MembershipFeeNotificationInfo create(MembershipFee membershipFee, MemberBasicInfoDto memberInfo) { return MembershipFeeNotificationInfo.builder() - .memberId(memberInfo.getMemberId()) - .memberName(memberInfo.getMemberName()) - .category(membershipFee.getCategory()) - .content(membershipFee.getContent()) - .amount(membershipFee.getAmount()) - .build(); + .memberId(memberInfo.getMemberId()) + .memberName(memberInfo.getMemberName()) + .category(membershipFee.getCategory()) + .content(membershipFee.getContent()) + .amount(membershipFee.getAmount()) + .build(); } } diff --git a/src/main/java/page/clab/api/global/common/notificationSetting/application/event/ApplicationStartupListener.java b/src/main/java/page/clab/api/global/common/notificationSetting/application/event/ApplicationStartupListener.java index 0f9f08a6d..78bdbbbba 100644 --- a/src/main/java/page/clab/api/global/common/notificationSetting/application/event/ApplicationStartupListener.java +++ b/src/main/java/page/clab/api/global/common/notificationSetting/application/event/ApplicationStartupListener.java @@ -18,6 +18,6 @@ public ApplicationStartupListener(ApplicationEventPublisher eventPublisher) { @EventListener(ContextRefreshedEvent.class) public void onApplicationEvent(ContextRefreshedEvent event) { eventPublisher.publishEvent( - new NotificationEvent(this, GeneralAlertType.SERVER_START, null, null)); + new NotificationEvent(this, GeneralAlertType.SERVER_START, null, null)); } } diff --git a/src/main/java/page/clab/api/global/common/notificationSetting/application/event/NotificationListener.java b/src/main/java/page/clab/api/global/common/notificationSetting/application/event/NotificationListener.java index 56c2eda22..a695d2c0b 100644 --- a/src/main/java/page/clab/api/global/common/notificationSetting/application/event/NotificationListener.java +++ b/src/main/java/page/clab/api/global/common/notificationSetting/application/event/NotificationListener.java @@ -25,13 +25,13 @@ public class NotificationListener { private final NotificationConfigProperties notificationConfigProperties; public NotificationListener( - ManageNotificationSettingUseCase manageNotificationSettingUseCase, - List notificationSenderList, - NotificationConfigProperties notificationConfigProperties) { + ManageNotificationSettingUseCase manageNotificationSettingUseCase, + List notificationSenderList, + NotificationConfigProperties notificationConfigProperties) { this.manageNotificationSettingUseCase = manageNotificationSettingUseCase; this.notificationConfigProperties = notificationConfigProperties; this.notificationSenders = notificationSenderList.stream() - .collect(Collectors.toMap(NotificationSender::getPlatformName, Function.identity())); + .collect(Collectors.toMap(NotificationSender::getPlatformName, Function.identity())); } @EventListener @@ -49,7 +49,7 @@ public void handleNotificationEvent(NotificationEvent event) { } mappings.forEach(mapping -> getWebhookUrl(mapping) - .ifPresent(webhookUrl -> sendNotification(mapping.getPlatform(), event, webhookUrl))); + .ifPresent(webhookUrl -> sendNotification(mapping.getPlatform(), event, webhookUrl))); } private List getMappingsForAlertType(AlertType alertType) { @@ -57,8 +57,8 @@ private List getMappingsForAlertType(AlertType alertType) { Map> categoryMappings = notificationConfigProperties.getCategoryMappings(); return Optional.ofNullable(categoryMappings.get(categoryName)) - .filter(list -> !list.isEmpty()) - .orElseGet(notificationConfigProperties::getDefaultMappings); + .filter(list -> !list.isEmpty()) + .orElseGet(notificationConfigProperties::getDefaultMappings); } private Optional getWebhookUrl(PlatformMapping mapping) { @@ -67,15 +67,15 @@ private Optional getWebhookUrl(PlatformMapping mapping) { Map platforms = notificationConfigProperties.getPlatforms(); return Optional.ofNullable(platforms.get(platform)) - .map(platformConfig -> platformConfig.getWebhooks().get(webhookKey)) - .map(url -> { - log.debug("Found webhook URL for platform '{}', key '{}': {}", platform, webhookKey, url); - return url; - }) - .or(() -> { - log.warn("No webhook URL found for platform '{}', key '{}'", platform, webhookKey); - return Optional.empty(); - }); + .map(platformConfig -> platformConfig.getWebhooks().get(webhookKey)) + .map(url -> { + log.debug("Found webhook URL for platform '{}', key '{}': {}", platform, webhookKey, url); + return url; + }) + .or(() -> { + log.warn("No webhook URL found for platform '{}', key '{}'", platform, webhookKey); + return Optional.empty(); + }); } private void sendNotification(String platform, NotificationEvent event, String webhookUrl) { diff --git a/src/main/java/page/clab/api/global/common/notificationSetting/application/port/out/WebhookClient.java b/src/main/java/page/clab/api/global/common/notificationSetting/application/port/out/WebhookClient.java index c85e5776d..c6c8ebaa1 100644 --- a/src/main/java/page/clab/api/global/common/notificationSetting/application/port/out/WebhookClient.java +++ b/src/main/java/page/clab/api/global/common/notificationSetting/application/port/out/WebhookClient.java @@ -19,5 +19,5 @@ public interface WebhookClient { * @return 메시지 전송 성공 여부를 나타내는 CompletableFuture */ CompletableFuture sendMessage(String webhookUrl, AlertType alertType, HttpServletRequest request, - Object additionalData); + Object additionalData); } diff --git a/src/main/java/page/clab/api/global/common/notificationSetting/application/service/ManageNotificationSettingService.java b/src/main/java/page/clab/api/global/common/notificationSetting/application/service/ManageNotificationSettingService.java index d42337ddf..76370712f 100644 --- a/src/main/java/page/clab/api/global/common/notificationSetting/application/service/ManageNotificationSettingService.java +++ b/src/main/java/page/clab/api/global/common/notificationSetting/application/service/ManageNotificationSettingService.java @@ -42,7 +42,7 @@ public void toggleNotificationSetting(String alertTypeName, boolean enabled) { @Transactional public NotificationSetting getOrCreateDefaultSetting(AlertType alertType) { return retrieveNotificationSettingPort.findByAlertType(alertType) - .orElseGet(() -> createAndSaveDefaultSetting(alertType)); + .orElseGet(() -> createAndSaveDefaultSetting(alertType)); } private NotificationSetting createAndSaveDefaultSetting(AlertType alertType) { diff --git a/src/main/java/page/clab/api/global/common/notificationSetting/application/service/RetrieveNotificationSettingService.java b/src/main/java/page/clab/api/global/common/notificationSetting/application/service/RetrieveNotificationSettingService.java index 3d4d6bc32..1289ddffa 100644 --- a/src/main/java/page/clab/api/global/common/notificationSetting/application/service/RetrieveNotificationSettingService.java +++ b/src/main/java/page/clab/api/global/common/notificationSetting/application/service/RetrieveNotificationSettingService.java @@ -30,7 +30,7 @@ public class RetrieveNotificationSettingService implements RetrieveNotificationS @Override public List retrieveNotificationSettings() { return retrieveNotificationSettingPort.findAll().stream() - .map(mapper::toDto) - .toList(); + .map(mapper::toDto) + .toList(); } } diff --git a/src/main/java/page/clab/api/global/common/notificationSetting/application/service/WebhookCommonService.java b/src/main/java/page/clab/api/global/common/notificationSetting/application/service/WebhookCommonService.java index 0cb574aa0..5775bb71d 100644 --- a/src/main/java/page/clab/api/global/common/notificationSetting/application/service/WebhookCommonService.java +++ b/src/main/java/page/clab/api/global/common/notificationSetting/application/service/WebhookCommonService.java @@ -39,9 +39,9 @@ public String extractMessageAfterException(Exception e) { public String getStackTraceSummary(Exception e) { return Arrays.stream(e.getStackTrace()) - .limit(10) - .map(StackTraceElement::toString) - .collect(Collectors.joining("\n")); + .limit(10) + .map(StackTraceElement::toString) + .collect(Collectors.joining("\n")); } public String getOperatingSystemInfo() { @@ -74,10 +74,10 @@ public String getMemoryUsage() { public String getUsername(HttpServletRequest request) { Authentication auth = SecurityContextHolder.getContext().getAuthentication(); return Optional.ofNullable(request.getAttribute("member")) - .map(Object::toString) - .orElseGet(() -> Optional.ofNullable(auth) - .map(Authentication::getName) - .orElse("anonymous")); + .map(Object::toString) + .orElseGet(() -> Optional.ofNullable(auth) + .map(Authentication::getName) + .orElse("anonymous")); } public String getLocation(HttpServletRequest request) { diff --git a/src/main/java/page/clab/api/global/common/notificationSetting/config/NotificationConfigProperties.java b/src/main/java/page/clab/api/global/common/notificationSetting/config/NotificationConfigProperties.java index a052ac17e..63b8f5841 100644 --- a/src/main/java/page/clab/api/global/common/notificationSetting/config/NotificationConfigProperties.java +++ b/src/main/java/page/clab/api/global/common/notificationSetting/config/NotificationConfigProperties.java @@ -21,6 +21,7 @@ public class NotificationConfigProperties { @Getter @Setter public static class CommonProperties { + private String webUrl; private String apiUrl; private String color; @@ -33,12 +34,14 @@ public int getColorAsInt() { @Getter @Setter public static class PlatformConfig { + private Map webhooks; } @Getter @Setter public static class PlatformMapping { + private String platform; private String webhook; } diff --git a/src/main/java/page/clab/api/global/common/notificationSetting/domain/NotificationSetting.java b/src/main/java/page/clab/api/global/common/notificationSetting/domain/NotificationSetting.java index d9bd8f47f..95bbf0b9c 100644 --- a/src/main/java/page/clab/api/global/common/notificationSetting/domain/NotificationSetting.java +++ b/src/main/java/page/clab/api/global/common/notificationSetting/domain/NotificationSetting.java @@ -31,9 +31,9 @@ public class NotificationSetting { public static NotificationSetting createDefault(AlertType alertType) { return NotificationSetting.builder() - .alertType(alertType) - .enabled(true) - .build(); + .alertType(alertType) + .enabled(true) + .build(); } public void updateEnabled(boolean enabled) { diff --git a/src/main/java/page/clab/api/global/common/verification/application/VerificationService.java b/src/main/java/page/clab/api/global/common/verification/application/VerificationService.java index 0af2c02e3..4d07c7162 100644 --- a/src/main/java/page/clab/api/global/common/verification/application/VerificationService.java +++ b/src/main/java/page/clab/api/global/common/verification/application/VerificationService.java @@ -1,5 +1,6 @@ package page.clab.api.global.common.verification.application; +import java.security.SecureRandom; import lombok.RequiredArgsConstructor; import org.apache.tomcat.util.codec.binary.Base64; import org.springframework.stereotype.Service; @@ -9,14 +10,12 @@ import page.clab.api.global.common.verification.dto.request.VerificationRequestDto; import page.clab.api.global.exception.NotFoundException; -import java.security.SecureRandom; - /** * {@code VerificationService}는 회원 인증 코드 생성, 저장, 검증 및 삭제 기능을 제공하는 서비스입니다. * *

                인증 코드는 사용자의 이메일 또는 전화번호 인증을 위한 임시 코드로, * 생성된 코드는 데이터베이스에 저장되고, 유효성 검사를 통해 해당 사용자의 인증을 검증합니다.

                - * + *

                * 주요 기능: *

                  *
                • {@link #getVerificationCode(String)} - 주어진 코드로 데이터베이스에서 인증 코드를 조회합니다.
                • @@ -34,7 +33,7 @@ public class VerificationService { public Verification getVerificationCode(String verificationCode) { return verificationRepository.findByVerificationCode(verificationCode) - .orElseThrow(() -> new NotFoundException("존재하지 않는 인증코드입니다.")); + .orElseThrow(() -> new NotFoundException("존재하지 않는 인증코드입니다.")); } public void saveVerificationCode(String memberId, String verificationCode) { @@ -44,7 +43,7 @@ public void saveVerificationCode(String memberId, String verificationCode) { public void deleteVerificationCode(String verificationCode) { verificationRepository.findByVerificationCode(verificationCode) - .ifPresent(verificationRepository::delete); + .ifPresent(verificationRepository::delete); } public Verification validateVerificationCode(VerificationRequestDto verificationRequestDto, Member member) { diff --git a/src/main/java/page/clab/api/global/common/verification/dao/VerificationRepository.java b/src/main/java/page/clab/api/global/common/verification/dao/VerificationRepository.java index 87017d9d5..86ea1ec8a 100644 --- a/src/main/java/page/clab/api/global/common/verification/dao/VerificationRepository.java +++ b/src/main/java/page/clab/api/global/common/verification/dao/VerificationRepository.java @@ -1,12 +1,12 @@ package page.clab.api.global.common.verification.dao; +import java.util.Optional; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; import page.clab.api.global.common.verification.domain.Verification; -import java.util.Optional; - @Repository public interface VerificationRepository extends CrudRepository { + Optional findByVerificationCode(String verificationCode); } diff --git a/src/main/java/page/clab/api/global/common/verification/domain/Verification.java b/src/main/java/page/clab/api/global/common/verification/domain/Verification.java index 86f34a029..5ea372344 100644 --- a/src/main/java/page/clab/api/global/common/verification/domain/Verification.java +++ b/src/main/java/page/clab/api/global/common/verification/domain/Verification.java @@ -31,9 +31,9 @@ public class Verification { public static Verification create(String memberId, String verificationCode) { return Verification.builder() - .id(memberId) - .verificationCode(verificationCode) - .build(); + .id(memberId) + .verificationCode(verificationCode) + .build(); } public boolean isOwner(String memberId) { diff --git a/src/main/java/page/clab/api/global/config/AppConfig.java b/src/main/java/page/clab/api/global/config/AppConfig.java index 4aef72b81..2c8d1b7c9 100644 --- a/src/main/java/page/clab/api/global/config/AppConfig.java +++ b/src/main/java/page/clab/api/global/config/AppConfig.java @@ -15,9 +15,9 @@ public class AppConfig { @Primary public ObjectMapper objectMapper() { return new Jackson2ObjectMapperBuilder() - .featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) - .modules(new JavaTimeModule()) - .timeZone("Asia/Seoul") - .build(); + .featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) + .modules(new JavaTimeModule()) + .timeZone("Asia/Seoul") + .build(); } } diff --git a/src/main/java/page/clab/api/global/config/AsyncConfig.java b/src/main/java/page/clab/api/global/config/AsyncConfig.java index 5e52aa70b..05476a820 100644 --- a/src/main/java/page/clab/api/global/config/AsyncConfig.java +++ b/src/main/java/page/clab/api/global/config/AsyncConfig.java @@ -1,5 +1,6 @@ package page.clab.api.global.config; +import java.util.concurrent.Executor; import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler; import org.springframework.aop.interceptor.SimpleAsyncUncaughtExceptionHandler; import org.springframework.context.annotation.Configuration; @@ -7,8 +8,6 @@ import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; -import java.util.concurrent.Executor; - @Configuration @EnableAsync public class AsyncConfig implements AsyncConfigurer { diff --git a/src/main/java/page/clab/api/global/config/AuthenticationConfig.java b/src/main/java/page/clab/api/global/config/AuthenticationConfig.java index d3de9b6e0..cd7bf3380 100644 --- a/src/main/java/page/clab/api/global/config/AuthenticationConfig.java +++ b/src/main/java/page/clab/api/global/config/AuthenticationConfig.java @@ -1,5 +1,6 @@ package page.clab.api.global.config; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -13,8 +14,6 @@ import org.springframework.security.provisioning.InMemoryUserDetailsManager; import page.clab.api.global.auth.application.CustomUserDetailsService; -import java.util.List; - @Configuration @RequiredArgsConstructor public class AuthenticationConfig { @@ -31,9 +30,9 @@ public AuthenticationManager authenticationManager() throws Exception { @Bean public InMemoryUserDetailsManager userDetailsService() { UserDetails user = User.withUsername(whitelistAccountProperties.getUsername()) - .password(passwordEncoder().encode(whitelistAccountProperties.getPassword())) - .roles(whitelistAccountProperties.getRole()) - .build(); + .password(passwordEncoder().encode(whitelistAccountProperties.getPassword())) + .roles(whitelistAccountProperties.getRole()) + .build(); return new InMemoryUserDetailsManager(user); } diff --git a/src/main/java/page/clab/api/global/config/CorsConfig.java b/src/main/java/page/clab/api/global/config/CorsConfig.java index 3b0cd4727..e9a05cae5 100644 --- a/src/main/java/page/clab/api/global/config/CorsConfig.java +++ b/src/main/java/page/clab/api/global/config/CorsConfig.java @@ -1,5 +1,6 @@ package page.clab.api.global.config; +import java.util.List; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -7,8 +8,6 @@ import org.springframework.web.cors.CorsConfigurationSource; import org.springframework.web.cors.UrlBasedCorsConfigurationSource; -import java.util.List; - @Configuration public class CorsConfig { @@ -35,7 +34,7 @@ public CorsConfigurationSource corsConfigurationSource() { CorsConfiguration corsConfiguration = new CorsConfiguration(); corsConfiguration.setAllowedOriginPatterns( - List.of(corsAllowedOrigins) + List.of(corsAllowedOrigins) ); corsConfiguration.setAllowedMethods(List.of(corsAllowedMethods)); corsConfiguration.setAllowedHeaders(List.of(corsAllowedHeaders)); diff --git a/src/main/java/page/clab/api/global/config/EmailTemplateProperties.java b/src/main/java/page/clab/api/global/config/EmailTemplateProperties.java index f198a2d52..870febac0 100644 --- a/src/main/java/page/clab/api/global/config/EmailTemplateProperties.java +++ b/src/main/java/page/clab/api/global/config/EmailTemplateProperties.java @@ -1,13 +1,12 @@ package page.clab.api.global.config; +import java.util.Map; import lombok.Getter; import lombok.Setter; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; import page.clab.api.global.common.email.domain.EmailTemplateType; -import java.util.Map; - @Getter @Setter @Component @@ -27,6 +26,7 @@ public Template getTemplate(EmailTemplateType templateType) { @Getter @Setter public static class Template { + private String subject; private String content; } diff --git a/src/main/java/page/clab/api/global/config/IPInfoConfig.java b/src/main/java/page/clab/api/global/config/IPInfoConfig.java index f22177a5a..2d8cabb5c 100644 --- a/src/main/java/page/clab/api/global/config/IPInfoConfig.java +++ b/src/main/java/page/clab/api/global/config/IPInfoConfig.java @@ -26,11 +26,11 @@ public class IPInfoConfig { @Bean public IPinfoSpring ipinfoSpring() { return new IPinfoSpring.Builder() - .setIPinfo(ipInfo()) - .interceptorStrategy(interceptorStrategy()) - .ipStrategy(ipStrategy()) - .attributeStrategy(attributeStrategy()) - .build(); + .setIPinfo(ipInfo()) + .interceptorStrategy(interceptorStrategy()) + .ipStrategy(ipStrategy()) + .attributeStrategy(attributeStrategy()) + .build(); } @Bean diff --git a/src/main/java/page/clab/api/global/config/JpaConfig.java b/src/main/java/page/clab/api/global/config/JpaConfig.java index 3895ee3d7..7da99609a 100644 --- a/src/main/java/page/clab/api/global/config/JpaConfig.java +++ b/src/main/java/page/clab/api/global/config/JpaConfig.java @@ -6,4 +6,5 @@ @Configuration @EnableJpaAuditing public class JpaConfig { + } diff --git a/src/main/java/page/clab/api/global/config/OpenApiConfig.java b/src/main/java/page/clab/api/global/config/OpenApiConfig.java index 27365df5e..a652a61aa 100644 --- a/src/main/java/page/clab/api/global/config/OpenApiConfig.java +++ b/src/main/java/page/clab/api/global/config/OpenApiConfig.java @@ -8,13 +8,12 @@ import io.swagger.v3.oas.models.security.SecurityRequirement; import io.swagger.v3.oas.models.security.SecurityScheme; import io.swagger.v3.oas.models.servers.Server; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import java.util.List; - @Configuration @RequiredArgsConstructor public class OpenApiConfig { @@ -22,28 +21,29 @@ public class OpenApiConfig { @Bean public OpenAPI openAPI(@Value("${springdoc.version}") String appVersion) { Info info = new Info().title("C-Lab Page").version(appVersion) - .description("C-Lab Page API Document") - .termsOfService("http://swagger.io/terms/") - .contact(new Contact().name("한관희").url("https://github.com/limehee").email("noop103@naver.com")) - .license(new License().name("C-Lab Page License Version 1.0").url("https://github.com/KGU-C-Lab/Clab-Server")); + .description("C-Lab Page API Document") + .termsOfService("http://swagger.io/terms/") + .contact(new Contact().name("한관희").url("https://github.com/limehee").email("noop103@naver.com")) + .license( + new License().name("C-Lab Page License Version 1.0").url("https://github.com/KGU-C-Lab/Clab-Server")); final String securitySchemeName = "bearerAuth"; Server server = new Server().url("/"); return new OpenAPI() - .servers(List.of(server)) - .addSecurityItem(new SecurityRequirement().addList(securitySchemeName)) - .components( - new Components() - .addSecuritySchemes(securitySchemeName, - new SecurityScheme() - .name(securitySchemeName) - .type(SecurityScheme.Type.HTTP) - .scheme("bearer") - .bearerFormat("JWT") - .in(SecurityScheme.In.HEADER) - ) - ) - .info(info); + .servers(List.of(server)) + .addSecurityItem(new SecurityRequirement().addList(securitySchemeName)) + .components( + new Components() + .addSecuritySchemes(securitySchemeName, + new SecurityScheme() + .name(securitySchemeName) + .type(SecurityScheme.Type.HTTP) + .scheme("bearer") + .bearerFormat("JWT") + .in(SecurityScheme.In.HEADER) + ) + ) + .info(info); } } diff --git a/src/main/java/page/clab/api/global/config/RoleHierarchyConfig.java b/src/main/java/page/clab/api/global/config/RoleHierarchyConfig.java index 1dae2197c..09199ff87 100644 --- a/src/main/java/page/clab/api/global/config/RoleHierarchyConfig.java +++ b/src/main/java/page/clab/api/global/config/RoleHierarchyConfig.java @@ -11,9 +11,9 @@ public class RoleHierarchyConfig { @Bean public RoleHierarchy roleHierarchy() { return RoleHierarchyImpl.fromHierarchy(""" - ROLE_SUPER > ROLE_ADMIN - ROLE_ADMIN > ROLE_USER - ROLE_USER > ROLE_GUEST - """); + ROLE_SUPER > ROLE_ADMIN + ROLE_ADMIN > ROLE_USER + ROLE_USER > ROLE_GUEST + """); } } diff --git a/src/main/java/page/clab/api/global/config/SecurityConfig.java b/src/main/java/page/clab/api/global/config/SecurityConfig.java index d31e1ce21..882a2c9db 100644 --- a/src/main/java/page/clab/api/global/config/SecurityConfig.java +++ b/src/main/java/page/clab/api/global/config/SecurityConfig.java @@ -71,64 +71,64 @@ public class SecurityConfig { public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { AuthenticationManager authenticationManager = authenticationConfig.authenticationManager(); http - .csrf(AbstractHttpConfigurer::disable) - .sessionManagement(sessionManagement -> - sessionManagement.sessionCreationPolicy(SessionCreationPolicy.STATELESS) - ) - .cors(cors -> - cors.configurationSource(corsConfigurationSource) - ) - .authorizeHttpRequests( - getAuthorizeHttpRequestsCustomizer() - ) - .authenticationProvider(authenticationConfig.authenticationProvider()) - .addFilterBefore( - new IPinfoSpringFilter(ipInfoConfig), - UsernamePasswordAuthenticationFilter.class - ) - .addFilterBefore( - new IpAuthenticationFilter(ipInfoConfig), - UsernamePasswordAuthenticationFilter.class - ) - .addFilterBefore( - new InvalidEndpointAccessFilter(fileURL, externalRegisterBlacklistIpUseCase, - externalRetrieveBlacklistIpUseCase, eventPublisher), - UsernamePasswordAuthenticationFilter.class - ) - .addFilterBefore( - new CustomBasicAuthenticationFilter(authenticationManager, ipWhitelistValidator, - externalCheckIpBlockedUseCase, externalRetrieveBlacklistIpUseCase, eventPublisher), - UsernamePasswordAuthenticationFilter.class - ) - .addFilterBefore( - new JwtAuthenticationFilter(jwtTokenProvider, eventPublisher, externalManageRedisTokenUseCase, - externalCheckIpBlockedUseCase, externalRetrieveBlacklistIpUseCase), - UsernamePasswordAuthenticationFilter.class - ) + .csrf(AbstractHttpConfigurer::disable) + .sessionManagement(sessionManagement -> + sessionManagement.sessionCreationPolicy(SessionCreationPolicy.STATELESS) + ) + .cors(cors -> + cors.configurationSource(corsConfigurationSource) + ) + .authorizeHttpRequests( + getAuthorizeHttpRequestsCustomizer() + ) + .authenticationProvider(authenticationConfig.authenticationProvider()) + .addFilterBefore( + new IPinfoSpringFilter(ipInfoConfig), + UsernamePasswordAuthenticationFilter.class + ) + .addFilterBefore( + new IpAuthenticationFilter(ipInfoConfig), + UsernamePasswordAuthenticationFilter.class + ) + .addFilterBefore( + new InvalidEndpointAccessFilter(fileURL, externalRegisterBlacklistIpUseCase, + externalRetrieveBlacklistIpUseCase, eventPublisher), + UsernamePasswordAuthenticationFilter.class + ) + .addFilterBefore( + new CustomBasicAuthenticationFilter(authenticationManager, ipWhitelistValidator, + externalCheckIpBlockedUseCase, externalRetrieveBlacklistIpUseCase, eventPublisher), + UsernamePasswordAuthenticationFilter.class + ) + .addFilterBefore( + new JwtAuthenticationFilter(jwtTokenProvider, eventPublisher, externalManageRedisTokenUseCase, + externalCheckIpBlockedUseCase, externalRetrieveBlacklistIpUseCase), + UsernamePasswordAuthenticationFilter.class + ) // .addFilterBefore( // new FileAccessControlFilter(fileService, fileURL), // UsernamePasswordAuthenticationFilter.class // ) - .exceptionHandling(httpSecurityExceptionHandlingConfigurer -> - httpSecurityExceptionHandlingConfigurer - .authenticationEntryPoint(this::handleException) - .accessDeniedHandler(this::handleException) - ); + .exceptionHandling(httpSecurityExceptionHandlingConfigurer -> + httpSecurityExceptionHandlingConfigurer + .authenticationEntryPoint(this::handleException) + .accessDeniedHandler(this::handleException) + ); return http.build(); } private @NotNull Customizer.AuthorizationManagerRequestMatcherRegistry> getAuthorizeHttpRequestsCustomizer() { return (authorize) -> authorize - .requestMatchers(SecurityConstants.PERMIT_ALL).permitAll() - .requestMatchers(HttpMethod.GET, SecurityConstants.PERMIT_ALL_API_ENDPOINTS_GET).permitAll() - .requestMatchers(HttpMethod.POST, SecurityConstants.PERMIT_ALL_API_ENDPOINTS_POST).permitAll() - .requestMatchers(whitelistPatternsProperties.getWhitelistPatterns()) - .hasRole(whitelistAccountProperties.getRole()) - .anyRequest().authenticated(); + .requestMatchers(SecurityConstants.PERMIT_ALL).permitAll() + .requestMatchers(HttpMethod.GET, SecurityConstants.PERMIT_ALL_API_ENDPOINTS_GET).permitAll() + .requestMatchers(HttpMethod.POST, SecurityConstants.PERMIT_ALL_API_ENDPOINTS_POST).permitAll() + .requestMatchers(whitelistPatternsProperties.getWhitelistPatterns()) + .hasRole(whitelistAccountProperties.getRole()) + .anyRequest().authenticated(); } private void handleException(HttpServletRequest request, HttpServletResponse response, Exception exception) - throws IOException { + throws IOException { String clientIpAddress = HttpReqResUtil.getClientIpAddressIfServletRequestExist(); String message; int statusCode; diff --git a/src/main/java/page/clab/api/global/config/SecurityConstants.java b/src/main/java/page/clab/api/global/config/SecurityConstants.java index 66f20b7f4..a98dcf50e 100644 --- a/src/main/java/page/clab/api/global/config/SecurityConstants.java +++ b/src/main/java/page/clab/api/global/config/SecurityConstants.java @@ -3,35 +3,35 @@ public class SecurityConstants { public static final String[] PERMIT_ALL = { - "/api/v1/login/**", - "/static/**", - "/actuator/health", - "/resources/files/**", - "/configuration/ui", - "/configuration/security", - "/favicon.ico", - "/webjars/**", - "/error", - "/" + "/api/v1/login/**", + "/static/**", + "/actuator/health", + "/resources/files/**", + "/configuration/ui", + "/configuration/security", + "/favicon.ico", + "/webjars/**", + "/error", + "/" }; public static final String[] PERMIT_ALL_API_ENDPOINTS_GET = { - "/api/v1/applications/{recruitmentId}/{studentId}", - "/api/v1/recruitments", "/api/v1/recruitments/recent-week", - "/api/v1/news", "/api/v1/news/**", - "/api/v1/blogs", "/api/v1/blogs/**", - "/api/v1/positions", "/api/v1/positions/**", - "/api/v1/awards", "/api/v1/awards/**", - "/api/v1/activity-group", "/api/v1/activity-group/**", - "/api/v1/work-experiences", "/api/v1/work-experiences/**", - "/api/v1/products", "/api/v1/products/**", - "/api/v1/reviews", "/api/v1/reviews/**", - "/api/v1/activity-photos", "/api/v1/activity-photos/**" + "/api/v1/applications/{recruitmentId}/{studentId}", + "/api/v1/recruitments", "/api/v1/recruitments/recent-week", + "/api/v1/news", "/api/v1/news/**", + "/api/v1/blogs", "/api/v1/blogs/**", + "/api/v1/positions", "/api/v1/positions/**", + "/api/v1/awards", "/api/v1/awards/**", + "/api/v1/activity-group", "/api/v1/activity-group/**", + "/api/v1/work-experiences", "/api/v1/work-experiences/**", + "/api/v1/products", "/api/v1/products/**", + "/api/v1/reviews", "/api/v1/reviews/**", + "/api/v1/activity-photos", "/api/v1/activity-photos/**" }; public static final String[] PERMIT_ALL_API_ENDPOINTS_POST = { - "/api/v1/applications", - "/api/v1/members/password-reset-requests", - "/api/v1/members/password-reset-verifications", + "/api/v1/applications", + "/api/v1/members/password-reset-requests", + "/api/v1/members/password-reset-verifications", }; } diff --git a/src/main/java/page/clab/api/global/config/ThymeleafConfig.java b/src/main/java/page/clab/api/global/config/ThymeleafConfig.java index 2fd6c94ee..c0e1b3137 100644 --- a/src/main/java/page/clab/api/global/config/ThymeleafConfig.java +++ b/src/main/java/page/clab/api/global/config/ThymeleafConfig.java @@ -1,19 +1,19 @@ package page.clab.api.global.config; +import java.util.Objects; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.thymeleaf.spring6.templateresolver.SpringResourceTemplateResolver; import org.thymeleaf.templatemode.TemplateMode; -import java.util.Objects; - @Configuration public class ThymeleafConfig { @Bean public SpringResourceTemplateResolver springResourceTemplateResolver() { SpringResourceTemplateResolver springResourceTemplateResolver = new SpringResourceTemplateResolver(); - springResourceTemplateResolver.setPrefix(Objects.requireNonNull(getClass().getResource("/templates/")).toString()); + springResourceTemplateResolver.setPrefix( + Objects.requireNonNull(getClass().getResource("/templates/")).toString()); springResourceTemplateResolver.setCharacterEncoding("UTF-8"); springResourceTemplateResolver.setTemplateMode(TemplateMode.HTML); springResourceTemplateResolver.setCacheable(false); diff --git a/src/main/java/page/clab/api/global/config/WebConfig.java b/src/main/java/page/clab/api/global/config/WebConfig.java index 6ee723508..bf89ee6fd 100644 --- a/src/main/java/page/clab/api/global/config/WebConfig.java +++ b/src/main/java/page/clab/api/global/config/WebConfig.java @@ -1,6 +1,9 @@ package page.clab.api.global.config; import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.time.Duration; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.jetbrains.annotations.NotNull; @@ -17,10 +20,6 @@ import page.clab.api.global.handler.ApiLoggingInterceptor; import page.clab.api.global.util.HtmlCharacterEscapes; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.time.Duration; - @Configuration @RequiredArgsConstructor @Slf4j @@ -39,24 +38,25 @@ public class WebConfig implements WebMvcConfigurer { public void addResourceHandlers(ResourceHandlerRegistry registry) { log.info("Resource UploadedFile Mapped : {} -> {}", fileURL, filePath); CacheControl cacheControl = CacheControl.maxAge(Duration.ofDays(1)) - .mustRevalidate() - .cachePrivate(); + .mustRevalidate() + .cachePrivate(); registry - .addResourceHandler(fileURL + "/**") - .addResourceLocations("file://" + filePath + "/") - .setCacheControl(cacheControl) - .resourceChain(true) - .addResolver(new PathResourceResolver() { - @Override - protected Resource getResource(@NotNull String resourcePath, @NotNull Resource location) throws IOException { - Resource resource = location.createRelative(resourcePath); - if (resource.exists() && resource.isReadable()) { - return resource; - } - throw new FileNotFoundException("Resource not found: " + resourcePath); + .addResourceHandler(fileURL + "/**") + .addResourceLocations("file://" + filePath + "/") + .setCacheControl(cacheControl) + .resourceChain(true) + .addResolver(new PathResourceResolver() { + @Override + protected Resource getResource(@NotNull String resourcePath, @NotNull Resource location) + throws IOException { + Resource resource = location.createRelative(resourcePath); + if (resource.exists() && resource.isReadable()) { + return resource; } - }); + throw new FileNotFoundException("Resource not found: " + resourcePath); + } + }); } @Bean diff --git a/src/main/java/page/clab/api/global/config/WhitelistPatternsProperties.java b/src/main/java/page/clab/api/global/config/WhitelistPatternsProperties.java index 33ef866fe..ccb52ea10 100644 --- a/src/main/java/page/clab/api/global/config/WhitelistPatternsProperties.java +++ b/src/main/java/page/clab/api/global/config/WhitelistPatternsProperties.java @@ -1,13 +1,12 @@ package page.clab.api.global.config; +import java.util.Arrays; +import java.util.stream.Stream; import lombok.Getter; import lombok.Setter; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Configuration; -import java.util.Arrays; -import java.util.stream.Stream; - @Setter @Getter @Configuration @@ -19,7 +18,7 @@ public class WhitelistPatternsProperties { public String[] getWhitelistPatterns() { return Stream.of(apiDocs, actuator) - .flatMap(Arrays::stream) - .toArray(String[]::new); + .flatMap(Arrays::stream) + .toArray(String[]::new); } } diff --git a/src/main/java/page/clab/api/global/filter/IPinfoSpringFilter.java b/src/main/java/page/clab/api/global/filter/IPinfoSpringFilter.java index 704982677..e0556bfe3 100644 --- a/src/main/java/page/clab/api/global/filter/IPinfoSpringFilter.java +++ b/src/main/java/page/clab/api/global/filter/IPinfoSpringFilter.java @@ -12,15 +12,13 @@ import jakarta.servlet.ServletRequest; import jakarta.servlet.ServletResponse; import jakarta.servlet.http.HttpServletRequest; -import lombok.extern.slf4j.Slf4j; -import page.clab.api.global.config.IPInfoConfig; - import java.io.IOException; import java.util.Objects; +import lombok.extern.slf4j.Slf4j; +import page.clab.api.global.config.IPInfoConfig; /** - * {@code IPinfoSpringFilter}는 IP 정보 조회 및 관리 기능을 제공하는 필터로, - * 클라이언트의 IP 주소를 기반으로 IP 정보 조회 API를 통해 세부 정보를 가져와 요청에 저장합니다. + * {@code IPinfoSpringFilter}는 IP 정보 조회 및 관리 기능을 제공하는 필터로, 클라이언트의 IP 주소를 기반으로 IP 정보 조회 API를 통해 세부 정보를 가져와 요청에 저장합니다. * *

                  이 필터는 요청이 IP 정보가 필요한 경우에만 IP 정보를 조회하며, * 요청 객체에 IP 정보를 속성으로 저장하여 이후 처리 로직에서 사용할 수 있도록 합니다.

                  @@ -46,7 +44,8 @@ public void init(FilterConfig filterConfig) { } @Override - public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException { HttpServletRequest httpRequest = (HttpServletRequest) request; String clientIpAddress = ipStrategy.getIPAddress(httpRequest); @@ -67,8 +66,8 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha private boolean shouldProcessRequest(HttpServletRequest httpRequest, String clientIpAddress) { return !interceptorStrategy.shouldRun(httpRequest) - || attributeStrategy.hasAttribute(httpRequest) - || Objects.isNull(clientIpAddress); + || attributeStrategy.hasAttribute(httpRequest) + || Objects.isNull(clientIpAddress); } @Override diff --git a/src/main/java/page/clab/api/global/filter/PostResponseFilter.java b/src/main/java/page/clab/api/global/filter/PostResponseFilter.java index 20bed42a4..b6907fcea 100644 --- a/src/main/java/page/clab/api/global/filter/PostResponseFilter.java +++ b/src/main/java/page/clab/api/global/filter/PostResponseFilter.java @@ -8,11 +8,10 @@ import jakarta.servlet.annotation.WebFilter; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import java.io.IOException; import org.springframework.http.HttpMethod; import org.springframework.stereotype.Component; -import java.io.IOException; - /** * {@code PostResponseFilter}는 특정 API 요청에 대해 POST 요청의 응답 상태 코드를 수정하는 서블릿 필터입니다. * @@ -24,12 +23,14 @@ public class PostResponseFilter implements Filter { @Override - public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException { HttpServletRequest httpRequest = (HttpServletRequest) request; HttpServletResponse httpResponse = (HttpServletResponse) response; // POST 요청이고 상태 코드가 200인 경우 상태 코드를 201로 변경 - if (HttpMethod.POST.name().equalsIgnoreCase(httpRequest.getMethod()) && httpResponse.getStatus() == HttpServletResponse.SC_OK) { + if (HttpMethod.POST.name().equalsIgnoreCase(httpRequest.getMethod()) + && httpResponse.getStatus() == HttpServletResponse.SC_OK) { httpResponse.setStatus(HttpServletResponse.SC_CREATED); } diff --git a/src/main/java/page/clab/api/global/handler/ApiLoggingInterceptor.java b/src/main/java/page/clab/api/global/handler/ApiLoggingInterceptor.java index 28acdcde2..2a16c0850 100644 --- a/src/main/java/page/clab/api/global/handler/ApiLoggingInterceptor.java +++ b/src/main/java/page/clab/api/global/handler/ApiLoggingInterceptor.java @@ -17,13 +17,15 @@ public class ApiLoggingInterceptor implements HandlerInterceptor { private final ApiLogger apiLogger; @Override - public boolean preHandle(HttpServletRequest request, @NotNull HttpServletResponse response, @NotNull Object handler) throws Exception { + public boolean preHandle(HttpServletRequest request, @NotNull HttpServletResponse response, @NotNull Object handler) + throws Exception { request.setAttribute("startTime", System.currentTimeMillis()); return true; } @Override - public void afterCompletion(HttpServletRequest request, HttpServletResponse response, @NotNull Object handler, Exception ex) throws Exception { + public void afterCompletion(HttpServletRequest request, HttpServletResponse response, @NotNull Object handler, + Exception ex) throws Exception { apiLogger.logRequestDuration(request, response, ex); } } diff --git a/src/main/java/page/clab/api/global/handler/GlobalExceptionHandler.java b/src/main/java/page/clab/api/global/handler/GlobalExceptionHandler.java index 3bc92ca24..7c2e20030 100644 --- a/src/main/java/page/clab/api/global/handler/GlobalExceptionHandler.java +++ b/src/main/java/page/clab/api/global/handler/GlobalExceptionHandler.java @@ -102,32 +102,32 @@ public class GlobalExceptionHandler { private final ApplicationEventPublisher eventPublisher; @ExceptionHandler({ - InvalidInformationException.class, - InvalidParentBoardException.class, - InvalidCategoryException.class, - InvalidDateRangeException.class, - InvalidColumnException.class, - InvalidEmojiException.class, - InvalidRoleChangeException.class, - InvalidRoleException.class, - InvalidFileAttributeException.class, - InvalidGithubUrlException.class, - InactiveMemberException.class, - DuplicateRoleException.class, - RecruitmentNotActiveException.class, - RecruitmentEndDateExceededException.class, - StringIndexOutOfBoundsException.class, - MissingServletRequestParameterException.class, - MalformedJsonException.class, - HttpMessageNotReadableException.class, - MethodArgumentTypeMismatchException.class, - IllegalAccessException.class, - NumberFormatException.class, - SortingArgumentException.class, - UnknownPathException.class, - AssignmentBoardHasNoDueDateTimeException.class, - FeedbackBoardHasNoContentException.class, - InvalidBoardCategoryHashtagException.class + InvalidInformationException.class, + InvalidParentBoardException.class, + InvalidCategoryException.class, + InvalidDateRangeException.class, + InvalidColumnException.class, + InvalidEmojiException.class, + InvalidRoleChangeException.class, + InvalidRoleException.class, + InvalidFileAttributeException.class, + InvalidGithubUrlException.class, + InactiveMemberException.class, + DuplicateRoleException.class, + RecruitmentNotActiveException.class, + RecruitmentEndDateExceededException.class, + StringIndexOutOfBoundsException.class, + MissingServletRequestParameterException.class, + MalformedJsonException.class, + HttpMessageNotReadableException.class, + MethodArgumentTypeMismatchException.class, + IllegalAccessException.class, + NumberFormatException.class, + SortingArgumentException.class, + UnknownPathException.class, + AssignmentBoardHasNoDueDateTimeException.class, + FeedbackBoardHasNoContentException.class, + InvalidBoardCategoryHashtagException.class }) public ErrorResponse badRequestException(HttpServletResponse response, Exception e) { response.setStatus(HttpServletResponse.SC_OK); @@ -135,17 +135,17 @@ public ErrorResponse badRequestException(HttpServletResponse response } @ExceptionHandler({ - AuthenticationException.class, - AuthenticationInfoNotFoundException.class, - UnAuthorizeException.class, - LoginFailedException.class, - MemberLockedException.class, - BadCredentialsException.class, - TokenValidateException.class, - TokenNotFoundException.class, - TokenMisuseException.class, - TokenForgeryException.class, - MessagingException.class, + AuthenticationException.class, + AuthenticationInfoNotFoundException.class, + UnAuthorizeException.class, + LoginFailedException.class, + MemberLockedException.class, + BadCredentialsException.class, + TokenValidateException.class, + TokenNotFoundException.class, + TokenMisuseException.class, + TokenForgeryException.class, + MessagingException.class, }) public ApiResponse unAuthorizeException(HttpServletResponse response, Exception e) { response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); @@ -153,10 +153,10 @@ public ApiResponse unAuthorizeException(HttpServletResponse response, Exce } @ExceptionHandler({ - AccessDeniedException.class, - PermissionDeniedException.class, - InvalidBorrowerException.class, - MemberNotPartOfActivityException.class, + AccessDeniedException.class, + PermissionDeniedException.class, + InvalidBorrowerException.class, + MemberNotPartOfActivityException.class, }) public ApiResponse deniedException(HttpServletResponse response, Exception e) { response.setStatus(HttpServletResponse.SC_FORBIDDEN); @@ -164,10 +164,10 @@ public ApiResponse deniedException(HttpServletResponse response, Exception } @ExceptionHandler({ - NullPointerException.class, - NotFoundException.class, - NoSuchElementException.class, - FileNotFoundException.class, + NullPointerException.class, + NotFoundException.class, + NoSuchElementException.class, + FileNotFoundException.class, }) public ErrorResponse notFoundException(HttpServletResponse response, Exception e) { response.setStatus(HttpServletResponse.SC_OK); @@ -175,7 +175,7 @@ public ErrorResponse notFoundException(HttpServletResponse response, } @ExceptionHandler({ - InvalidPathVariableException.class + InvalidPathVariableException.class }) public ApiResponse notFoundException(HttpServletResponse response, InvalidPathVariableException e) { response.setStatus(HttpServletResponse.SC_OK); @@ -183,29 +183,29 @@ public ApiResponse notFoundException(HttpServletResponse response, Invalid } @ExceptionHandler({ - AccuseTargetTypeIncorrectException.class, - NotApprovedApplicationException.class, - DuplicateMemberIdException.class, - DuplicateMemberContactException.class, - DuplicateMemberEmailException.class, - CloudStorageNotEnoughException.class, - ActivityGroupNotFinishedException.class, - ActivityGroupNotProgressingException.class, - AlreadySubmittedThisWeekAssignmentException.class, - LeaderStatusChangeNotAllowedException.class, - SingleLeaderModificationException.class, - AlreadyAppliedException.class, - DuplicateReportException.class, - DuplicateAttendanceException.class, - DuplicateAbsentExcuseException.class, - AlreadyReviewedException.class, - BookAlreadyBorrowedException.class, - BookAlreadyReturnedException.class, - BookAlreadyAppliedForLoanException.class, - MaxBorrowLimitExceededException.class, - OverdueException.class, - LoanSuspensionException.class, - LoanNotPendingException.class, + AccuseTargetTypeIncorrectException.class, + NotApprovedApplicationException.class, + DuplicateMemberIdException.class, + DuplicateMemberContactException.class, + DuplicateMemberEmailException.class, + CloudStorageNotEnoughException.class, + ActivityGroupNotFinishedException.class, + ActivityGroupNotProgressingException.class, + AlreadySubmittedThisWeekAssignmentException.class, + LeaderStatusChangeNotAllowedException.class, + SingleLeaderModificationException.class, + AlreadyAppliedException.class, + DuplicateReportException.class, + DuplicateAttendanceException.class, + DuplicateAbsentExcuseException.class, + AlreadyReviewedException.class, + BookAlreadyBorrowedException.class, + BookAlreadyReturnedException.class, + BookAlreadyAppliedForLoanException.class, + MaxBorrowLimitExceededException.class, + OverdueException.class, + LoanSuspensionException.class, + LoanNotPendingException.class, }) public ErrorResponse conflictException(HttpServletResponse response, Exception e) { response.setStatus(HttpServletResponse.SC_OK); @@ -213,37 +213,37 @@ public ErrorResponse conflictException(HttpServletResponse response, } @ExceptionHandler({ - IllegalStateException.class, - FileUploadFailException.class, - FilePermissionException.class, - DirectoryCreationException.class, - DataIntegrityViolationException.class, - IncorrectResultSizeDataAccessException.class, - ArrayIndexOutOfBoundsException.class, - IOException.class, - WebClientRequestException.class, - TransactionSystemException.class, - SecurityException.class, - CustomOptimisticLockingFailureException.class, - CompletionException.class, - EncryptionException.class, - DecryptionException.class, - InvalidDataAccessApiUsageException.class, - ImageProcessingException.class, - MetadataException.class, - Exception.class + IllegalStateException.class, + FileUploadFailException.class, + FilePermissionException.class, + DirectoryCreationException.class, + DataIntegrityViolationException.class, + IncorrectResultSizeDataAccessException.class, + ArrayIndexOutOfBoundsException.class, + IOException.class, + WebClientRequestException.class, + TransactionSystemException.class, + SecurityException.class, + CustomOptimisticLockingFailureException.class, + CompletionException.class, + EncryptionException.class, + DecryptionException.class, + InvalidDataAccessApiUsageException.class, + ImageProcessingException.class, + MetadataException.class, + Exception.class }) public ApiResponse serverException(HttpServletRequest request, HttpServletResponse response, Exception e) { eventPublisher.publishEvent( - new NotificationEvent(this, GeneralAlertType.SERVER_ERROR, request, e)); + new NotificationEvent(this, GeneralAlertType.SERVER_ERROR, request, e)); log.warn(e.getMessage()); response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return ApiResponse.failure(); } @ExceptionHandler({ - MethodArgumentNotValidException.class, - ConstraintViolationException.class + MethodArgumentNotValidException.class, + ConstraintViolationException.class }) public ApiResponse handleValidationException(HttpServletResponse response, Exception e) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); diff --git a/src/main/java/page/clab/api/global/util/ApiLogger.java b/src/main/java/page/clab/api/global/util/ApiLogger.java index 3e0ce7d14..ad2b0e701 100644 --- a/src/main/java/page/clab/api/global/util/ApiLogger.java +++ b/src/main/java/page/clab/api/global/util/ApiLogger.java @@ -8,8 +8,8 @@ import org.springframework.stereotype.Component; /** - * {@code ApiLogger}는 API 요청 및 응답 로깅을 담당하는 유틸리티 클래스입니다. - * 클라이언트 IP 주소, 사용자 정보, 요청 URL, HTTP 메서드, 상태 코드 등의 정보를 포함하여 로그를 출력합니다. + * {@code ApiLogger}는 API 요청 및 응답 로깅을 담당하는 유틸리티 클래스입니다. 클라이언트 IP 주소, 사용자 정보, 요청 URL, HTTP 메서드, 상태 코드 등의 정보를 포함하여 로그를 + * 출력합니다. * *

                  주요 기능: *

                    @@ -21,9 +21,11 @@ @Slf4j public class ApiLogger { - public void logRequest(HttpServletRequest request, HttpServletResponse response, String clientIpAddress, String message) { + public void logRequest(HttpServletRequest request, HttpServletResponse response, String clientIpAddress, + String message) { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); - String id = (authentication == null || authentication.getName() == null) ? "anonymous" : authentication.getName(); + String id = + (authentication == null || authentication.getName() == null) ? "anonymous" : authentication.getName(); String requestUrl = request.getRequestURI(); String queryString = request.getQueryString(); @@ -37,7 +39,8 @@ public void logRequest(HttpServletRequest request, HttpServletResponse response, public void logRequestDuration(HttpServletRequest request, HttpServletResponse response, Exception ex) { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); - String id = (authentication == null || authentication.getName() == null) ? "anonymous" : authentication.getName(); + String id = + (authentication == null || authentication.getName() == null) ? "anonymous" : authentication.getName(); String clientIpAddress = HttpReqResUtil.getClientIpAddressIfServletRequestExist(); String requestUrl = request.getRequestURI(); @@ -54,7 +57,8 @@ public void logRequestDuration(HttpServletRequest request, HttpServletResponse r if (ex == null) { log.info("[{}:{}] {} {} {} {}ms", clientIpAddress, id, fullUrl, httpMethod, statusCode, duration); } else { - log.error("[{}:{}] {} {} {} {}ms, Exception: {}", clientIpAddress, id, fullUrl, httpMethod, statusCode, duration, ex.getMessage()); + log.error("[{}:{}] {} {} {} {}ms, Exception: {}", clientIpAddress, id, fullUrl, httpMethod, statusCode, + duration, ex.getMessage()); } } } diff --git a/src/main/java/page/clab/api/global/util/ColumnValidator.java b/src/main/java/page/clab/api/global/util/ColumnValidator.java index 1b88e2f0b..9bf19d83a 100644 --- a/src/main/java/page/clab/api/global/util/ColumnValidator.java +++ b/src/main/java/page/clab/api/global/util/ColumnValidator.java @@ -1,13 +1,12 @@ package page.clab.api.global.util; -import org.springframework.stereotype.Component; - import java.lang.reflect.Field; import java.util.Arrays; +import org.springframework.stereotype.Component; /** - * {@code ColumnValidator}는 주어진 클래스에 특정 필드(컬럼)가 존재하는지 검증하는 유틸리티 클래스입니다. - * 리플렉션을 사용하여 클래스의 모든 필드를 조회하고, 입력된 필드 이름과 일치하는 필드가 있는지 확인합니다. + * {@code ColumnValidator}는 주어진 클래스에 특정 필드(컬럼)가 존재하는지 검증하는 유틸리티 클래스입니다. 리플렉션을 사용하여 클래스의 모든 필드를 조회하고, 입력된 필드 이름과 일치하는 필드가 + * 있는지 확인합니다. * *

                    주요 기능: *

                      @@ -20,6 +19,6 @@ public class ColumnValidator { public boolean isValidColumn(Class domainClass, String columnName) { Field[] fields = domainClass.getDeclaredFields(); return Arrays.stream(fields) - .anyMatch(field -> field.getName().equals(columnName)); + .anyMatch(field -> field.getName().equals(columnName)); } } diff --git a/src/main/java/page/clab/api/global/util/EmojiUtils.java b/src/main/java/page/clab/api/global/util/EmojiUtils.java index 4c451c663..e65c21bce 100644 --- a/src/main/java/page/clab/api/global/util/EmojiUtils.java +++ b/src/main/java/page/clab/api/global/util/EmojiUtils.java @@ -2,12 +2,10 @@ import com.ibm.icu.lang.UCharacter; import com.ibm.icu.lang.UProperty; - import java.text.BreakIterator; /** - * {@code EmojiUtils}는 주어진 텍스트가 이모지인지 여부를 확인하는 유틸리티 클래스입니다. - * ICU 라이브러리를 사용하여 텍스트 내 코드 포인트가 이모지 속성에 해당하는지 검증합니다. + * {@code EmojiUtils}는 주어진 텍스트가 이모지인지 여부를 확인하는 유틸리티 클래스입니다. ICU 라이브러리를 사용하여 텍스트 내 코드 포인트가 이모지 속성에 해당하는지 검증합니다. * *

                      주요 기능: *

                        @@ -29,15 +27,16 @@ public static boolean isEmoji(String text) { if (end != BreakIterator.DONE && it.next() == BreakIterator.DONE) { String grapheme = text.substring(start, end); - if (grapheme.length() == 1 && UCharacter.isDigit(grapheme.codePointAt(0))) + if (grapheme.length() == 1 && UCharacter.isDigit(grapheme.codePointAt(0))) { return false; + } for (int i = 0; i < grapheme.length(); ) { int codePoint = grapheme.codePointAt(i); if (UCharacter.hasBinaryProperty(codePoint, UProperty.EMOJI) || - UCharacter.hasBinaryProperty(codePoint, UProperty.EMOJI_PRESENTATION) || - UCharacter.hasBinaryProperty(codePoint, UProperty.EXTENDED_PICTOGRAPHIC)) { + UCharacter.hasBinaryProperty(codePoint, UProperty.EMOJI_PRESENTATION) || + UCharacter.hasBinaryProperty(codePoint, UProperty.EXTENDED_PICTOGRAPHIC)) { return true; } i += Character.charCount(codePoint); diff --git a/src/main/java/page/clab/api/global/util/EncryptionUtil.java b/src/main/java/page/clab/api/global/util/EncryptionUtil.java index c4219389c..b62583e52 100644 --- a/src/main/java/page/clab/api/global/util/EncryptionUtil.java +++ b/src/main/java/page/clab/api/global/util/EncryptionUtil.java @@ -1,5 +1,10 @@ package page.clab.api.global.util; +import java.nio.charset.StandardCharsets; +import java.security.InvalidKeyException; +import java.security.SecureRandom; +import java.util.Arrays; +import java.util.Base64; import javax.crypto.BadPaddingException; import javax.crypto.Cipher; import javax.crypto.IllegalBlockSizeException; @@ -9,15 +14,9 @@ import page.clab.api.global.exception.DecryptionException; import page.clab.api.global.exception.EncryptionException; -import java.nio.charset.StandardCharsets; -import java.security.InvalidKeyException; -import java.security.SecureRandom; -import java.util.Arrays; -import java.util.Base64; - /** - * {@code EncryptionUtil}은 AES/GCM 암호화 및 복호화 작업을 수행하는 유틸리티 클래스입니다. - * 암호화와 복호화에 필요한 키와 IV(초기화 벡터)를 생성하고, AES 암호화 표준을 사용하여 문자열을 암호화하고 복호화하는 기능을 제공합니다. + * {@code EncryptionUtil}은 AES/GCM 암호화 및 복호화 작업을 수행하는 유틸리티 클래스입니다. 암호화와 복호화에 필요한 키와 IV(초기화 벡터)를 생성하고, AES 암호화 표준을 사용하여 + * 문자열을 암호화하고 복호화하는 기능을 제공합니다. * *

                        주요 기능: *

                          @@ -38,7 +37,8 @@ private EncryptionUtil(String secretKey, int ivLengthBytes, int gcmTagLengthBits } public static EncryptionUtil create(AesConfig aesConfig) { - return new EncryptionUtil(aesConfig.getSecretKey(), aesConfig.getIvLengthBytes(), aesConfig.getGcmTagLengthBits()); + return new EncryptionUtil(aesConfig.getSecretKey(), aesConfig.getIvLengthBytes(), + aesConfig.getGcmTagLengthBits()); } public String encrypt(String strToEncrypt) { diff --git a/src/main/java/page/clab/api/global/util/FileSystemUtil.java b/src/main/java/page/clab/api/global/util/FileSystemUtil.java index 05a7df80d..333d45f1f 100644 --- a/src/main/java/page/clab/api/global/util/FileSystemUtil.java +++ b/src/main/java/page/clab/api/global/util/FileSystemUtil.java @@ -6,8 +6,8 @@ import java.util.List; /** - * {@code FileSystemUtil}은 파일 시스템 관련 작업을 지원하는 유틸리티 클래스입니다. - * 디렉토리의 크기를 계산하고, 디렉토리에 포함된 파일 목록을 반환하며, 크기 문자열을 바이트 단위로 변환하는 기능을 제공합니다. + * {@code FileSystemUtil}은 파일 시스템 관련 작업을 지원하는 유틸리티 클래스입니다. 디렉토리의 크기를 계산하고, 디렉토리에 포함된 파일 목록을 반환하며, 크기 문자열을 바이트 단위로 변환하는 + * 기능을 제공합니다. * *

                          주요 기능: *

                            diff --git a/src/main/java/page/clab/api/global/util/FileUtil.java b/src/main/java/page/clab/api/global/util/FileUtil.java index a00be629a..a8d445bfc 100644 --- a/src/main/java/page/clab/api/global/util/FileUtil.java +++ b/src/main/java/page/clab/api/global/util/FileUtil.java @@ -1,10 +1,5 @@ package page.clab.api.global.util; -import org.apache.commons.io.FilenameUtils; -import page.clab.api.global.common.file.exception.DirectoryCreationException; -import page.clab.api.global.common.file.exception.FilePermissionException; -import page.clab.api.global.common.file.exception.InvalidFileAttributeException; - import java.io.File; import java.io.IOException; import java.nio.file.Files; @@ -15,10 +10,13 @@ import java.util.EnumSet; import java.util.Set; import java.util.UUID; +import org.apache.commons.io.FilenameUtils; +import page.clab.api.global.common.file.exception.DirectoryCreationException; +import page.clab.api.global.common.file.exception.FilePermissionException; +import page.clab.api.global.common.file.exception.InvalidFileAttributeException; /** - * {@code FileUtil}은 파일 및 디렉토리와 관련된 유틸리티 기능을 제공합니다. - * 파일 경로 검증, 파일 권한 설정, 고유 파일명 생성, 디렉토리 생성 등의 기능을 수행합니다. + * {@code FileUtil}은 파일 및 디렉토리와 관련된 유틸리티 기능을 제공합니다. 파일 경로 검증, 파일 권한 설정, 고유 파일명 생성, 디렉토리 생성 등의 기능을 수행합니다. * *

                            주요 기능: *

                              @@ -35,7 +33,7 @@ public class FileUtil { /** * 주어진 파일 경로가 기본 디렉토리 내에 포함되는지 확인하고, 정상적인 경로를 반환합니다. * - * @param filePath 검증할 파일 경로 + * @param filePath 검증할 파일 경로 * @param baseDirectory 기본 디렉토리 * @return 정상적인 파일 경로일 경우 Path 객체를 반환 * @throws InvalidPathException 잘못된 경로일 경우 발생 @@ -92,11 +90,12 @@ public static void ensureParentDirectoryExists(File file, String baseDirectory) /** * 파일명과 확장자를 검증합니다. * - * @param originalFilename 파일명 + * @param originalFilename 파일명 * @param disallowExtensions 허용되지 않은 확장자 목록 * @throws IllegalArgumentException 유효하지 않은 파일명이나 확장자일 경우 발생 */ - public static void validateFileAttributes(String originalFilename, Set disallowExtensions) throws IllegalArgumentException { + public static void validateFileAttributes(String originalFilename, Set disallowExtensions) + throws IllegalArgumentException { String extension = FilenameUtils.getExtension(originalFilename); if (!validateFilename(originalFilename)) { throw new InvalidFileAttributeException("Invalid file name: " + originalFilename); @@ -122,7 +121,7 @@ public static boolean validateFilename(String fileName) { /** * 확장자가 허용된 것인지 확인합니다. * - * @param extension 파일 확장자 + * @param extension 파일 확장자 * @param disallowExtensions 허용되지 않은 확장자 목록 * @return 허용된 확장자일 경우 true, 그렇지 않을 경우 false */ @@ -133,7 +132,7 @@ public static boolean validateExtension(String extension, Set disallowEx /** * 파일의 읽기 전용 권한을 설정합니다. OS에 따라 적절한 권한을 설정합니다. * - * @param file 파일 객체 + * @param file 파일 객체 * @param savePath 파일 경로 * @throws FilePermissionException 파일 권한 설정에 실패한 경우 발생 */ @@ -146,21 +145,23 @@ public static void setFilePermissions(File file, String savePath, String baseDir FileUtil.setReadOnlyPermissionsUnix(savePath, baseDirectory); } } catch (Exception e) { - throw new FilePermissionException("Failed to set file permissions: " + LogSanitizerUtil.sanitizeForLog(savePath)); + throw new FilePermissionException( + "Failed to set file permissions: " + LogSanitizerUtil.sanitizeForLog(savePath)); } } /** * 윈도우 시스템에서 파일을 읽기 전용으로 설정합니다. * - * @param file 파일 객체 + * @param file 파일 객체 * @param savePath 파일 경로 * @throws FilePermissionException 파일 권한 설정에 실패한 경우 발생 */ public static void setReadOnlyPermissionsWindows(File file, String savePath, String baseDirectory) { FileUtil.validateFilePath(file.getPath(), baseDirectory); if (!file.setReadOnly()) { - throw new FilePermissionException("Failed to set file read-only: " + LogSanitizerUtil.sanitizeForLog(savePath)); + throw new FilePermissionException( + "Failed to set file read-only: " + LogSanitizerUtil.sanitizeForLog(savePath)); } } @@ -176,7 +177,7 @@ public static void setReadOnlyPermissionsUnix(String filePath, String baseDirect // POSIX 파일 권한을 소유자에게만 읽기 권한을 부여하도록 설정 Set permissions = EnumSet.of( - PosixFilePermission.OWNER_READ + PosixFilePermission.OWNER_READ ); Files.setPosixFilePermissions(path, permissions); } diff --git a/src/main/java/page/clab/api/global/util/HtmlCharacterEscapes.java b/src/main/java/page/clab/api/global/util/HtmlCharacterEscapes.java index 1bc53051e..5075a3fca 100644 --- a/src/main/java/page/clab/api/global/util/HtmlCharacterEscapes.java +++ b/src/main/java/page/clab/api/global/util/HtmlCharacterEscapes.java @@ -6,8 +6,7 @@ import org.apache.commons.text.StringEscapeUtils; /** - * {@code HtmlCharacterEscapes}는 HTML 특수 문자를 JSON에서 안전하게 사용할 수 있도록 - * 이스케이프 처리를 담당하는 클래스입니다. + * {@code HtmlCharacterEscapes}는 HTML 특수 문자를 JSON에서 안전하게 사용할 수 있도록 이스케이프 처리를 담당하는 클래스입니다. * *

                              특히 JSON 내에서 HTML 관련 특수 문자가 안전하게 사용될 수 있도록 다음과 같은 문자들을 * 커스텀 이스케이프 처리합니다: @@ -51,7 +50,7 @@ public SerializableString getEscapeSequence(int ch) { char charAt = (char) ch; if (Character.isHighSurrogate(charAt) || Character.isLowSurrogate(charAt) || charAt == ZERO_WIDTH_JOINER) { String sb = "\\u" + - String.format("%04x", ch); + String.format("%04x", ch); return new SerializedString(sb); } else { return new SerializedString(StringEscapeUtils.escapeHtml4(Character.toString(charAt))); diff --git a/src/main/java/page/clab/api/global/util/HttpReqResUtil.java b/src/main/java/page/clab/api/global/util/HttpReqResUtil.java index f768881a0..2aa2d76d0 100644 --- a/src/main/java/page/clab/api/global/util/HttpReqResUtil.java +++ b/src/main/java/page/clab/api/global/util/HttpReqResUtil.java @@ -2,90 +2,89 @@ import io.ipinfo.api.request.IPRequest; import jakarta.servlet.http.HttpServletRequest; +import java.util.Arrays; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; -import java.util.Arrays; - /** - * {@code HttpReqResUtil}은 HTTP 요청 및 응답에 관련된 유틸리티 메서드를 제공하는 클래스입니다. - * 이 클래스는 클라이언트 IP 주소를 가져오거나, IP 주소가 비공개 IP 대역인지 확인하는 등의 기능을 포함합니다. + * {@code HttpReqResUtil}은 HTTP 요청 및 응답에 관련된 유틸리티 메서드를 제공하는 클래스입니다. 이 클래스는 클라이언트 IP 주소를 가져오거나, IP 주소가 비공개 IP 대역인지 확인하는 + * 등의 기능을 포함합니다. */ public class HttpReqResUtil { private static final IPRequest.IpAddressMatcher[] IpAddressMatcherList = { - // IPv4 - new IPRequest.IpAddressMatcher("0.0.0.0/8"), - new IPRequest.IpAddressMatcher("10.0.0.0/8"), - new IPRequest.IpAddressMatcher("100.64.0.0/10"), - new IPRequest.IpAddressMatcher("127.0.0.0/8"), - new IPRequest.IpAddressMatcher("169.254.0.0/16"), - new IPRequest.IpAddressMatcher("172.16.0.0/12"), - new IPRequest.IpAddressMatcher("192.0.0.0/24"), - new IPRequest.IpAddressMatcher("192.0.2.0/24"), - new IPRequest.IpAddressMatcher("192.168.0.0/16"), - new IPRequest.IpAddressMatcher("198.18.0.0/15"), - new IPRequest.IpAddressMatcher("198.51.100.0/24"), - new IPRequest.IpAddressMatcher("203.0.113.0/24"), - new IPRequest.IpAddressMatcher("224.0.0.0/4"), - new IPRequest.IpAddressMatcher("240.0.0.0/4"), - new IPRequest.IpAddressMatcher("255.255.255.255/32"), - // IPv6 - new IPRequest.IpAddressMatcher("::/128"), - new IPRequest.IpAddressMatcher("::1/128"), - new IPRequest.IpAddressMatcher("::ffff:0:0/96"), - new IPRequest.IpAddressMatcher("::/96"), - new IPRequest.IpAddressMatcher("100::/64"), - new IPRequest.IpAddressMatcher("2001:10::/28"), - new IPRequest.IpAddressMatcher("2001:db8::/32"), - new IPRequest.IpAddressMatcher("fc00::/7"), - new IPRequest.IpAddressMatcher("fe80::/10"), - new IPRequest.IpAddressMatcher("fec0::/10"), - new IPRequest.IpAddressMatcher("ff00::/8"), - // 6to4 - new IPRequest.IpAddressMatcher("2002::/24"), - new IPRequest.IpAddressMatcher("2002:a00::/24"), - new IPRequest.IpAddressMatcher("2002:7f00::/24"), - new IPRequest.IpAddressMatcher("2002:a9fe::/32"), - new IPRequest.IpAddressMatcher("2002:ac10::/28"), - new IPRequest.IpAddressMatcher("2002:c000::/40"), - new IPRequest.IpAddressMatcher("2002:c000:200::/40"), - new IPRequest.IpAddressMatcher("2002:c0a8::/32"), - new IPRequest.IpAddressMatcher("2002:c612::/31"), - new IPRequest.IpAddressMatcher("2002:c633:6400::/40"), - new IPRequest.IpAddressMatcher("2002:cb00:7100::/40"), - new IPRequest.IpAddressMatcher("2002:e000::/20"), - new IPRequest.IpAddressMatcher("2002:f000::/20"), - new IPRequest.IpAddressMatcher("2002:ffff:ffff::/48"), - // Teredo - new IPRequest.IpAddressMatcher("2001::/40"), - new IPRequest.IpAddressMatcher("2001:0:a00::/40"), - new IPRequest.IpAddressMatcher("2001:0:7f00::/40"), - new IPRequest.IpAddressMatcher("2001:0:a9fe::/48"), - new IPRequest.IpAddressMatcher("2001:0:ac10::/44"), - new IPRequest.IpAddressMatcher("2001:0:c000::/56"), - new IPRequest.IpAddressMatcher("2001:0:c000:200::/56"), - new IPRequest.IpAddressMatcher("2001:0:c0a8::/48"), - new IPRequest.IpAddressMatcher("2001:0:c612::/47"), - new IPRequest.IpAddressMatcher("2001:0:c633:6400::/56"), - new IPRequest.IpAddressMatcher("2001:0:cb00:7100::/56"), - new IPRequest.IpAddressMatcher("2001:0:e000::/36"), - new IPRequest.IpAddressMatcher("2001:0:f000::/36"), - new IPRequest.IpAddressMatcher("2001:0:ffff:ffff::/64") + // IPv4 + new IPRequest.IpAddressMatcher("0.0.0.0/8"), + new IPRequest.IpAddressMatcher("10.0.0.0/8"), + new IPRequest.IpAddressMatcher("100.64.0.0/10"), + new IPRequest.IpAddressMatcher("127.0.0.0/8"), + new IPRequest.IpAddressMatcher("169.254.0.0/16"), + new IPRequest.IpAddressMatcher("172.16.0.0/12"), + new IPRequest.IpAddressMatcher("192.0.0.0/24"), + new IPRequest.IpAddressMatcher("192.0.2.0/24"), + new IPRequest.IpAddressMatcher("192.168.0.0/16"), + new IPRequest.IpAddressMatcher("198.18.0.0/15"), + new IPRequest.IpAddressMatcher("198.51.100.0/24"), + new IPRequest.IpAddressMatcher("203.0.113.0/24"), + new IPRequest.IpAddressMatcher("224.0.0.0/4"), + new IPRequest.IpAddressMatcher("240.0.0.0/4"), + new IPRequest.IpAddressMatcher("255.255.255.255/32"), + // IPv6 + new IPRequest.IpAddressMatcher("::/128"), + new IPRequest.IpAddressMatcher("::1/128"), + new IPRequest.IpAddressMatcher("::ffff:0:0/96"), + new IPRequest.IpAddressMatcher("::/96"), + new IPRequest.IpAddressMatcher("100::/64"), + new IPRequest.IpAddressMatcher("2001:10::/28"), + new IPRequest.IpAddressMatcher("2001:db8::/32"), + new IPRequest.IpAddressMatcher("fc00::/7"), + new IPRequest.IpAddressMatcher("fe80::/10"), + new IPRequest.IpAddressMatcher("fec0::/10"), + new IPRequest.IpAddressMatcher("ff00::/8"), + // 6to4 + new IPRequest.IpAddressMatcher("2002::/24"), + new IPRequest.IpAddressMatcher("2002:a00::/24"), + new IPRequest.IpAddressMatcher("2002:7f00::/24"), + new IPRequest.IpAddressMatcher("2002:a9fe::/32"), + new IPRequest.IpAddressMatcher("2002:ac10::/28"), + new IPRequest.IpAddressMatcher("2002:c000::/40"), + new IPRequest.IpAddressMatcher("2002:c000:200::/40"), + new IPRequest.IpAddressMatcher("2002:c0a8::/32"), + new IPRequest.IpAddressMatcher("2002:c612::/31"), + new IPRequest.IpAddressMatcher("2002:c633:6400::/40"), + new IPRequest.IpAddressMatcher("2002:cb00:7100::/40"), + new IPRequest.IpAddressMatcher("2002:e000::/20"), + new IPRequest.IpAddressMatcher("2002:f000::/20"), + new IPRequest.IpAddressMatcher("2002:ffff:ffff::/48"), + // Teredo + new IPRequest.IpAddressMatcher("2001::/40"), + new IPRequest.IpAddressMatcher("2001:0:a00::/40"), + new IPRequest.IpAddressMatcher("2001:0:7f00::/40"), + new IPRequest.IpAddressMatcher("2001:0:a9fe::/48"), + new IPRequest.IpAddressMatcher("2001:0:ac10::/44"), + new IPRequest.IpAddressMatcher("2001:0:c000::/56"), + new IPRequest.IpAddressMatcher("2001:0:c000:200::/56"), + new IPRequest.IpAddressMatcher("2001:0:c0a8::/48"), + new IPRequest.IpAddressMatcher("2001:0:c612::/47"), + new IPRequest.IpAddressMatcher("2001:0:c633:6400::/56"), + new IPRequest.IpAddressMatcher("2001:0:cb00:7100::/56"), + new IPRequest.IpAddressMatcher("2001:0:e000::/36"), + new IPRequest.IpAddressMatcher("2001:0:f000::/36"), + new IPRequest.IpAddressMatcher("2001:0:ffff:ffff::/64") }; private static final String[] IP_HEADER_CANDIDATES = { - "X-Forwarded-For", - "Proxy-Client-IP", - "WL-Proxy-Client-IP", - "HTTP_X_FORWARDED_FOR", - "HTTP_X_FORWARDED", - "HTTP_X_CLUSTER_CLIENT_IP", - "HTTP_CLIENT_IP", - "HTTP_FORWARDED_FOR", - "HTTP_FORWARDED", - "HTTP_VIA", - "REMOTE_ADDR" + "X-Forwarded-For", + "Proxy-Client-IP", + "WL-Proxy-Client-IP", + "HTTP_X_FORWARDED_FOR", + "HTTP_X_FORWARDED", + "HTTP_X_CLUSTER_CLIENT_IP", + "HTTP_CLIENT_IP", + "HTTP_FORWARDED_FOR", + "HTTP_FORWARDED", + "HTTP_VIA", + "REMOTE_ADDR" }; public static String getClientIpAddressIfServletRequestExist() { @@ -104,6 +103,6 @@ public static String getClientIpAddressIfServletRequestExist() { public static boolean isBogonRequest(String ip) { return Arrays.stream(IpAddressMatcherList) - .anyMatch(ipAddressMatcher -> ipAddressMatcher.matches(ip)); + .anyMatch(ipAddressMatcher -> ipAddressMatcher.matches(ip)); } } diff --git a/src/main/java/page/clab/api/global/util/IPInfoUtil.java b/src/main/java/page/clab/api/global/util/IPInfoUtil.java index 4904b93cf..5a2f0bcba 100644 --- a/src/main/java/page/clab/api/global/util/IPInfoUtil.java +++ b/src/main/java/page/clab/api/global/util/IPInfoUtil.java @@ -12,8 +12,8 @@ import page.clab.api.global.config.IPInfoConfig; /** - * {@code IPInfoUtil} 클래스는 IP 주소에 대한 정보를 가져오기 위한 유틸리티 메서드를 제공합니다. - * IP 정보를 가져오기 위해 IPInfo API를 호출하고, IP 기반 위치 데이터를 요청으로부터 가져옵니다. + * {@code IPInfoUtil} 클래스는 IP 주소에 대한 정보를 가져오기 위한 유틸리티 메서드를 제공합니다. IP 정보를 가져오기 위해 IPInfo API를 호출하고, IP 기반 위치 데이터를 요청으로부터 + * 가져옵니다. */ @Component @Slf4j @@ -31,13 +31,13 @@ public IPInfoUtil(IPInfoConfig ipInfoConfig) { public static IPInfoResponse getIpInfo(String ipAddress) { return restClient.get() - .uri(ipAddress) - .header("Authorization", "Bearer " + accessToken) - .accept(MediaType.APPLICATION_JSON) - .retrieve() - .onStatus(HttpStatusCode::is4xxClientError, ((request, response) -> - log.warn("4xx error occurred while getting ip info. Status code: {}", response.getStatusCode()))) - .body(IPInfoResponse.class); + .uri(ipAddress) + .header("Authorization", "Bearer " + accessToken) + .accept(MediaType.APPLICATION_JSON) + .retrieve() + .onStatus(HttpStatusCode::is4xxClientError, ((request, response) -> + log.warn("4xx error occurred while getting ip info. Status code: {}", response.getStatusCode()))) + .body(IPInfoResponse.class); } public static IPResponse getIpInfo(HttpServletRequest request) { diff --git a/src/main/java/page/clab/api/global/util/ImageUtil.java b/src/main/java/page/clab/api/global/util/ImageUtil.java index 99345069f..00f51dfb9 100644 --- a/src/main/java/page/clab/api/global/util/ImageUtil.java +++ b/src/main/java/page/clab/api/global/util/ImageUtil.java @@ -6,16 +6,6 @@ import com.drew.metadata.Metadata; import com.drew.metadata.MetadataException; import com.drew.metadata.exif.ExifIFD0Directory; -import javax.imageio.ImageIO; -import javax.imageio.ImageWriteParam; -import javax.imageio.ImageWriter; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.io.FilenameUtils; -import org.imgscalr.Scalr; -import org.springframework.security.core.parameters.P; -import org.springframework.web.multipart.MultipartFile; -import page.clab.api.global.exception.ImageCompressionException; - import java.awt.image.BufferedImage; import java.awt.image.BufferedImageOp; import java.io.File; @@ -24,10 +14,17 @@ import java.io.OutputStream; import java.nio.file.Path; import java.util.Iterator; +import javax.imageio.ImageIO; +import javax.imageio.ImageWriteParam; +import javax.imageio.ImageWriter; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.io.FilenameUtils; +import org.imgscalr.Scalr; +import org.springframework.web.multipart.MultipartFile; +import page.clab.api.global.exception.ImageCompressionException; /** - * {@code ImageUtil}은 이미지 파일의 처리와 관련된 유틸리티 메서드를 제공합니다. - * 이미지의 방향을 조정하거나, 압축을 수행하는 등의 기능을 포함합니다. + * {@code ImageUtil}은 이미지 파일의 처리와 관련된 유틸리티 메서드를 제공합니다. 이미지의 방향을 조정하거나, 압축을 수행하는 등의 기능을 포함합니다. */ @Slf4j public class ImageUtil { @@ -114,15 +111,12 @@ public static boolean isImageFile(MultipartFile file) { /** * 지정된 품질 수준으로 이미지 파일을 압축합니다. - * - * 이 메서드는 지정된 파일 경로에서 이미지를 읽어와, 주어진 품질 설정을 사용하여 압축한 후, - * 압축된 이미지를 원본 파일에 덮어씁니다. 압축은 이미지 포맷에 따라 다르게 적용되며, 이미지의 - * 형식(JPEG, PNG 등)은 파일 확장자에 의해 결정됩니다. + *

                              + * 이 메서드는 지정된 파일 경로에서 이미지를 읽어와, 주어진 품질 설정을 사용하여 압축한 후, 압축된 이미지를 원본 파일에 덮어씁니다. 압축은 이미지 포맷에 따라 다르게 적용되며, 이미지의 형식(JPEG, + * PNG 등)은 파일 확장자에 의해 결정됩니다. * * @param filePath 압축할 이미지 파일의 경로. - * @param quality 압축 품질 수준으로, 0.0(높은 압축률, 낮은 품질)에서 1.0(낮은 압축률, 높은 품질) 사이의 값을 가집니다. - * 이 값의 정확한 효과는 이미지 포맷에 따라 달라집니다. - * + * @param quality 압축 품질 수준으로, 0.0(높은 압축률, 낮은 품질)에서 1.0(낮은 압축률, 높은 품질) 사이의 값을 가집니다. 이 값의 정확한 효과는 이미지 포맷에 따라 달라집니다. * @throws ImageCompressionException 이미지 압축이 실패한 경우 예외가 발생합니다. */ public static void compressImage(String baseDirectory, String filePath, float quality) { diff --git a/src/main/java/page/clab/api/global/util/IpAddressUtil.java b/src/main/java/page/clab/api/global/util/IpAddressUtil.java index c12820052..18c0c3a58 100644 --- a/src/main/java/page/clab/api/global/util/IpAddressUtil.java +++ b/src/main/java/page/clab/api/global/util/IpAddressUtil.java @@ -9,8 +9,9 @@ public class IpAddressUtil { /** * 주어진 IP가 특정 서브넷이나 IP 주소와 일치하는지 확인합니다. + * * @param ipAddress 확인하려는 대상 IP 주소 - * @param ipOrCidr 서브넷 마스크를 포함한 IP 주소 (예: 192.168.1.0/24 또는 단일 IP 주소) + * @param ipOrCidr 서브넷 마스크를 포함한 IP 주소 (예: 192.168.1.0/24 또는 단일 IP 주소) * @return 주어진 IP가 서브넷 내에 있거나 IP 주소와 일치하면 true, 그렇지 않으면 false */ public static boolean isIpInRange(String ipAddress, String ipOrCidr) { diff --git a/src/main/java/page/clab/api/global/util/LogSanitizerUtil.java b/src/main/java/page/clab/api/global/util/LogSanitizerUtil.java index a804d8fc7..eb80fd26c 100644 --- a/src/main/java/page/clab/api/global/util/LogSanitizerUtil.java +++ b/src/main/java/page/clab/api/global/util/LogSanitizerUtil.java @@ -1,14 +1,13 @@ package page.clab.api.global.util; /** - * {@code LogSanitizerUtil} 클래스는 로그에 기록하기 전 문자열을 안전하게 변환하기 위한 유틸리티 메서드를 제공합니다. - * 이 클래스는 잠재적으로 해로운 특수 문자를 제거하여 로그의 안전성을 보장합니다. + * {@code LogSanitizerUtil} 클래스는 로그에 기록하기 전 문자열을 안전하게 변환하기 위한 유틸리티 메서드를 제공합니다. 이 클래스는 잠재적으로 해로운 특수 문자를 제거하여 로그의 안전성을 + * 보장합니다. */ public class LogSanitizerUtil { /** - * 로그에 기록하기 전에 입력 문자열을 안전하게 변환합니다. - * 새 줄, 캐리지 리턴 및 기타 특수 문자를 제거하거나 이스케이프 처리합니다. + * 로그에 기록하기 전에 입력 문자열을 안전하게 변환합니다. 새 줄, 캐리지 리턴 및 기타 특수 문자를 제거하거나 이스케이프 처리합니다. * * @param input 로그에 기록될 사용자 입력 * @return 안전한 로그 문자열 diff --git a/src/main/java/page/clab/api/global/util/OrderSpecifierUtil.java b/src/main/java/page/clab/api/global/util/OrderSpecifierUtil.java index 0843a03ce..77a7c1c18 100644 --- a/src/main/java/page/clab/api/global/util/OrderSpecifierUtil.java +++ b/src/main/java/page/clab/api/global/util/OrderSpecifierUtil.java @@ -9,17 +9,16 @@ import org.springframework.stereotype.Component; /** - * {@code OrderSpecifierUtil} 클래스는 QueryDSL을 사용하여 정렬 조건을 동적으로 생성하는 유틸리티 메서드를 제공합니다. - * 이 클래스는 {@link Pageable} 객체에서 제공된 정렬 정보를 바탕으로 {@link OrderSpecifier} 배열을 생성하여, - * QueryDSL 쿼리에 활용할 수 있도록 합니다. + * {@code OrderSpecifierUtil} 클래스는 QueryDSL을 사용하여 정렬 조건을 동적으로 생성하는 유틸리티 메서드를 제공합니다. 이 클래스는 {@link Pageable} 객체에서 제공된 정렬 + * 정보를 바탕으로 {@link OrderSpecifier} 배열을 생성하여, QueryDSL 쿼리에 활용할 수 있도록 합니다. */ @Component public class OrderSpecifierUtil { public static OrderSpecifier[] getOrderSpecifiers(Pageable pageable, EntityPathBase q) { return pageable.getSort().stream() - .map(order -> createOrderSpecifier(order, q)) - .toArray(OrderSpecifier[]::new); + .map(order -> createOrderSpecifier(order, q)) + .toArray(OrderSpecifier[]::new); } private static OrderSpecifier createOrderSpecifier(Sort.Order order, EntityPathBase q) { diff --git a/src/main/java/page/clab/api/global/util/PageableUtils.java b/src/main/java/page/clab/api/global/util/PageableUtils.java index 4cdbb72dc..8728fea35 100644 --- a/src/main/java/page/clab/api/global/util/PageableUtils.java +++ b/src/main/java/page/clab/api/global/util/PageableUtils.java @@ -1,5 +1,8 @@ package page.clab.api.global.util; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.IntStream; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; @@ -7,13 +10,9 @@ import page.clab.api.global.exception.InvalidColumnException; import page.clab.api.global.exception.SortingArgumentException; -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.IntStream; - /** - * {@code PageableUtils} 클래스는 정렬 및 페이지네이션 정보를 기반으로 {@link Pageable} 객체를 생성하는 유틸리티 클래스입니다. - * 이 클래스는 주어진 정렬 기준이 유효한지 검증하고, 유효하지 않은 경우 예외를 던집니다. + * {@code PageableUtils} 클래스는 정렬 및 페이지네이션 정보를 기반으로 {@link Pageable} 객체를 생성하는 유틸리티 클래스입니다. 이 클래스는 주어진 정렬 기준이 유효한지 검증하고, + * 유효하지 않은 경우 예외를 던집니다. */ @Component public class PageableUtils { @@ -24,7 +23,8 @@ public PageableUtils(ColumnValidator columnValidator) { this.columnValidator = columnValidator; } - public Pageable createPageable(int page, int size, List sortByList, List sortDirectionList, Class domainClass) throws SortingArgumentException, InvalidColumnException { + public Pageable createPageable(int page, int size, List sortByList, List sortDirectionList, + Class domainClass) throws SortingArgumentException, InvalidColumnException { if (sortByList.size() != sortDirectionList.size()) { throw new SortingArgumentException(); } @@ -42,9 +42,9 @@ public Pageable createPageable(int page, int size, List sortByList, List } Sort sort = Sort.by( - IntStream.range(0, sortByList.size()) - .mapToObj(i -> new Sort.Order(Sort.Direction.fromString(sortDirectionList.get(i)), sortByList.get(i))) - .collect(Collectors.toList()) + IntStream.range(0, sortByList.size()) + .mapToObj(i -> new Sort.Order(Sort.Direction.fromString(sortDirectionList.get(i)), sortByList.get(i))) + .collect(Collectors.toList()) ); return PageRequest.of(page, size, sort); diff --git a/src/main/java/page/clab/api/global/util/PaginationUtils.java b/src/main/java/page/clab/api/global/util/PaginationUtils.java index c7b106660..b2aa61b05 100644 --- a/src/main/java/page/clab/api/global/util/PaginationUtils.java +++ b/src/main/java/page/clab/api/global/util/PaginationUtils.java @@ -1,13 +1,12 @@ package page.clab.api.global.util; +import java.util.Comparator; +import java.util.List; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; import org.springframework.stereotype.Component; import page.clab.api.global.exception.InvalidColumnException; -import java.util.Comparator; -import java.util.List; - /** * {@code PaginationUtils} 클래스는 정렬 및 페이지네이션 기능을 통해 리스트에 대한 데이터를 처리하는 유틸리티 클래스입니다. */ @@ -18,7 +17,7 @@ public class PaginationUtils { * 아이템 리스트에 정렬을 적용하는 메서드입니다. * * @param items 정렬되지 않은 아이템 리스트 - * @param sort 정렬 기준을 포함한 Sort 객체 + * @param sort 정렬 기준을 포함한 Sort 객체 * @return 정렬된 아이템 리스트 */ public static List applySorting(List items, Sort sort) { @@ -27,44 +26,44 @@ public static List applySorting(List items, Sort sort) { } Comparator comparator = sort.stream() - .map(order -> { - Comparator itemComparator = Comparator.comparing( - item -> { - try { - return (Comparable) extractFieldValue(item, order.getProperty()); - } catch (InvalidColumnException e) { - throw new RuntimeException(e); - } - } - ); - return order.isAscending() ? itemComparator : itemComparator.reversed(); - }) - .reduce(Comparator::thenComparing) - .orElseThrow(IllegalArgumentException::new); + .map(order -> { + Comparator itemComparator = Comparator.comparing( + item -> { + try { + return (Comparable) extractFieldValue(item, order.getProperty()); + } catch (InvalidColumnException e) { + throw new RuntimeException(e); + } + } + ); + return order.isAscending() ? itemComparator : itemComparator.reversed(); + }) + .reduce(Comparator::thenComparing) + .orElseThrow(IllegalArgumentException::new); return items.stream() - .sorted(comparator) - .toList(); + .sorted(comparator) + .toList(); } /** * 아이템 리스트에 슬라이싱을 적용하는 메서드입니다. * - * @param items 슬라이싱되지 않은 아이템 리스트 + * @param items 슬라이싱되지 않은 아이템 리스트 * @param pageable 페이지네이션 정보를 포함하는 Pageable 객체 * @return 슬라이싱된 아이템 리스트 */ public static List applySlicing(List items, Pageable pageable) { return items.stream() - .skip(pageable.getOffset()) - .limit(pageable.getPageSize()) - .toList(); + .skip(pageable.getOffset()) + .limit(pageable.getPageSize()) + .toList(); } /** * 아이템 리스트에 정렬과 슬라이싱을 적용하는 메서드입니다. * - * @param items 정렬 및 슬라이싱 되지 않은 아이템 리스트 + * @param items 정렬 및 슬라이싱 되지 않은 아이템 리스트 * @param pageable 페이지네이션 정보와 정렬 기준을 포함하는 Pageable 객체 * @return 정렬 및 슬라이싱된 아이템 리스트 */ @@ -76,7 +75,7 @@ public static List applySortingAndSlicing(List items, Pageable pageabl /** * 리플렉션을 사용하여 객체의 특정 필드 값을 추출하는 메서드입니다. * - * @param item 값을 추출할 객체 + * @param item 값을 추출할 객체 * @param fieldName 추출할 필드 이름 * @return 추출된 필드 값 */ diff --git a/src/main/java/page/clab/api/global/util/QRCodeUtil.java b/src/main/java/page/clab/api/global/util/QRCodeUtil.java index a8bd0728e..ed81e4526 100644 --- a/src/main/java/page/clab/api/global/util/QRCodeUtil.java +++ b/src/main/java/page/clab/api/global/util/QRCodeUtil.java @@ -5,13 +5,11 @@ import com.google.zxing.client.j2se.MatrixToImageWriter; import com.google.zxing.common.BitMatrix; import com.google.zxing.qrcode.QRCodeWriter; - import java.io.ByteArrayOutputStream; import java.io.IOException; /** - * {@code QRCodeUtil} 클래스는 QR 코드 이미지를 생성하는 유틸리티 클래스입니다. - * 주어진 데이터를 인코딩하여 QR 코드 이미지를 생성하고, 바이트 배열로 반환합니다. + * {@code QRCodeUtil} 클래스는 QR 코드 이미지를 생성하는 유틸리티 클래스입니다. 주어진 데이터를 인코딩하여 QR 코드 이미지를 생성하고, 바이트 배열로 반환합니다. */ public class QRCodeUtil { diff --git a/src/main/java/page/clab/api/global/util/RandomNicknameUtil.java b/src/main/java/page/clab/api/global/util/RandomNicknameUtil.java index 3aac38e38..a64e97a5e 100644 --- a/src/main/java/page/clab/api/global/util/RandomNicknameUtil.java +++ b/src/main/java/page/clab/api/global/util/RandomNicknameUtil.java @@ -4,8 +4,7 @@ import java.util.List; /** - * {@code RandomNicknameUtil} 클래스는 임의의 닉네임을 생성하는 유틸리티 클래스입니다. - * 다양한 형용사, 색상, 명사 리스트에서 무작위로 선택하여 조합된 닉네임을 반환합니다. + * {@code RandomNicknameUtil} 클래스는 임의의 닉네임을 생성하는 유틸리티 클래스입니다. 다양한 형용사, 색상, 명사 리스트에서 무작위로 선택하여 조합된 닉네임을 반환합니다. */ public class RandomNicknameUtil { @@ -15,23 +14,23 @@ public class RandomNicknameUtil { public static String makeRandomNickname() { List adjectiveArray = Arrays.asList( - "행복한", "기쁜", "배고픈", "졸린", "신난", - "잠자는", "코딩하는", "밥먹는", "책읽는", "알바하는", - "데이트하는", "유튜브찍는", "공부하는", "멋진", "깔끔한" + "행복한", "기쁜", "배고픈", "졸린", "신난", + "잠자는", "코딩하는", "밥먹는", "책읽는", "알바하는", + "데이트하는", "유튜브찍는", "공부하는", "멋진", "깔끔한" ); List colorArray = Arrays.asList( - "빨간색", "주황색", "노란색", "초록색", "연두색", - "파란색", "하늘색", "보라색", "핑크색", "검은색", - "하얀색", "갈색", "회색", "카키색", "청록색" + "빨간색", "주황색", "노란색", "초록색", "연두색", + "파란색", "하늘색", "보라색", "핑크색", "검은색", + "하얀색", "갈색", "회색", "카키색", "청록색" ); List nounArray = Arrays.asList( - "책상", "키보드", "의자", "연필", "가방", - "손수건", "물병", "머리끈", "옷장", "액자", - "시계", "휴대폰", "마우스", "콘센트", "JAVA", - "C언어", "파이썬", "코틀린", "HTML", "CSS", - "어셈블리어", "SQL", "사탕", "떡볶이", "치킨" + "책상", "키보드", "의자", "연필", "가방", + "손수건", "물병", "머리끈", "옷장", "액자", + "시계", "휴대폰", "마우스", "콘센트", "JAVA", + "C언어", "파이썬", "코틀린", "HTML", "CSS", + "어셈블리어", "SQL", "사탕", "떡볶이", "치킨" ); String adjective = adjectiveArray.get((int) (Math.random() * ADJECTIVE_SIZE)); diff --git a/src/main/java/page/clab/api/global/util/ResponseUtil.java b/src/main/java/page/clab/api/global/util/ResponseUtil.java index ba0983303..cc86efd72 100644 --- a/src/main/java/page/clab/api/global/util/ResponseUtil.java +++ b/src/main/java/page/clab/api/global/util/ResponseUtil.java @@ -1,13 +1,11 @@ package page.clab.api.global.util; import jakarta.servlet.http.HttpServletResponse; -import page.clab.api.global.common.dto.ApiResponse; - import java.io.IOException; +import page.clab.api.global.common.dto.ApiResponse; /** - * {@code ResponseUtil} 클래스는 HTTP 응답에 대한 유틸리티 메서드를 제공합니다. - * 주로 오류 응답을 JSON 형식으로 전송하는 메서드를 포함하고 있습니다. + * {@code ResponseUtil} 클래스는 HTTP 응답에 대한 유틸리티 메서드를 제공합니다. 주로 오류 응답을 JSON 형식으로 전송하는 메서드를 포함하고 있습니다. */ public class ResponseUtil { diff --git a/src/main/java/page/clab/api/global/util/SecurityPatternChecker.java b/src/main/java/page/clab/api/global/util/SecurityPatternChecker.java index 24ea0f59f..98be4f212 100644 --- a/src/main/java/page/clab/api/global/util/SecurityPatternChecker.java +++ b/src/main/java/page/clab/api/global/util/SecurityPatternChecker.java @@ -4,99 +4,97 @@ import java.util.regex.Pattern; /** - * SecurityPatternChecker 클래스는 보안과 관련된 의심스러운 URL 패턴을 관리하고 검사하는 역할을 합니다. - * 이 클래스는 시스템 파일, 데이터베이스 백업, 또는 민감한 설정 파일에 대한 무단 접근을 시도하는 - * 의심스러운 URL 경로를 사전에 정의된 패턴과 비교하여 확인할 수 있는 유틸리티 메소드를 제공합니다. + * SecurityPatternChecker 클래스는 보안과 관련된 의심스러운 URL 패턴을 관리하고 검사하는 역할을 합니다. 이 클래스는 시스템 파일, 데이터베이스 백업, 또는 민감한 설정 파일에 대한 무단 + * 접근을 시도하는 의심스러운 URL 경로를 사전에 정의된 패턴과 비교하여 확인할 수 있는 유틸리티 메소드를 제공합니다. */ public class SecurityPatternChecker { /** - * 보안과 관련된 의심스러운 URL 경로를 나타내는 사전 정의된 패턴 목록입니다. - * 이 패턴들은 시스템 파일, 백업 파일, 설정 파일 및 일반적으로 사용되는 웹 쉘 스크립트(.php, .asp, .jsp 등)에 - * 대한 경로를 포함합니다. 해당 경로로의 무단 접근을 감지하는 데 사용됩니다. + * 보안과 관련된 의심스러운 URL 경로를 나타내는 사전 정의된 패턴 목록입니다. 이 패턴들은 시스템 파일, 백업 파일, 설정 파일 및 일반적으로 사용되는 웹 쉘 스크립트(.php, .asp, .jsp + * 등)에 대한 경로를 포함합니다. 해당 경로로의 무단 접근을 감지하는 데 사용됩니다. */ private static final List suspiciousPatterns = List.of( - // 일반적인 웹 쉘 및 백도어 - Pattern.compile(".*\\.php.*"), - Pattern.compile(".*\\.asp.*"), - Pattern.compile(".*\\.jsp.*"), - Pattern.compile(".*\\.sh.*"), - Pattern.compile(".*\\/cgi-bin\\/.*"), - - // 워드프레스 관련 경로 - Pattern.compile(".*\\/wp-(admin|login|config)\\.php.*"), - Pattern.compile(".*\\/wp-content\\/.*"), - - // 관리자 페이지 및 도구들 - Pattern.compile(".*\\/(phpmyadmin|pma|dbadmin|mysql|myadmin|phpMyAdmin).*"), - - // 개발 관련 파일과 디렉토리 - Pattern.compile(".*\\/(\\.git|\\.svn|\\.hg|\\.env|\\.idea|\\.vscode|\\.vs|\\.DS_Store).*"), - Pattern.compile(".*\\.(bak|config|yaml|yml|ini).*"), - - // 서버 및 시스템 파일 - Pattern.compile(".*\\/(etc\\/passwd|etc\\/shadow|etc\\/hosts|etc\\/group).*"), - - // 백업 파일 - Pattern.compile(".*\\.(sql|tar|gz|zip|rar|dump).*"), - Pattern.compile(".*\\/(sqlbackup|backup|backups|bck).*"), - - // 서버 상태 및 정보 - Pattern.compile(".*\\/server-(status|info).*"), - - // IDE 설정 및 파일 - Pattern.compile(".*\\/(sftp-config|sftp-settings|\\.editorconfig|\\.project).*"), - Pattern.compile(".*\\/(\\.npmrc|\\.dockerenv|Dockerfile|\\.kube|\\.yarn|\\.npm|\\.expo|\\.builddir).*"), - - // 특정 시스템 파일 - Pattern.compile(".*\\/(debug|trace\\.axd|config\\.json|settings\\.json|package\\.json|node_modules).*"), - Pattern.compile(".*\\/(\\.bash_history|\\.ssh|thumbs\\.db|desktop\\.ini|\\.Trashes|\\.Spotlight-V100|\\.vol).*"), - Pattern.compile(".*\\/(config|logs|tmp|temp|conf|backups).*"), - - // 환경 설정 파일 - Pattern.compile(".*\\.env\\.local$"), - Pattern.compile(".*\\.env\\.prod$"), - Pattern.compile(".*\\.env\\.dev$"), - - // 빌드 디렉토리 - Pattern.compile(".*\\/dist\\/.*"), - Pattern.compile(".*\\/build\\/.*"), - - // 기타 구성 파일 - Pattern.compile(".*\\.json$"), - Pattern.compile(".*\\.toml$"), - - // 관리 도구 경로 - Pattern.compile(".*\\/cpanel.*"), - Pattern.compile(".*\\/webmail.*"), - - // 서버 관리 도구 - Pattern.compile(".*\\/solr.*"), - Pattern.compile(".*\\/adminer.*"), - - // 데이터베이스 관리 경로 - Pattern.compile(".*\\/db\\.php$"), - Pattern.compile(".*\\/sqlmanager.*"), - - // 클라우드 스토리지 버킷 - Pattern.compile(".*\\/s3\\/.*"), - Pattern.compile(".*\\/azure\\/.*"), - - // API 키, 비밀번호 파일 - Pattern.compile(".*\\/api_keys.*"), - Pattern.compile(".*\\/passwords.*") + // 일반적인 웹 쉘 및 백도어 + Pattern.compile(".*\\.php.*"), + Pattern.compile(".*\\.asp.*"), + Pattern.compile(".*\\.jsp.*"), + Pattern.compile(".*\\.sh.*"), + Pattern.compile(".*\\/cgi-bin\\/.*"), + + // 워드프레스 관련 경로 + Pattern.compile(".*\\/wp-(admin|login|config)\\.php.*"), + Pattern.compile(".*\\/wp-content\\/.*"), + + // 관리자 페이지 및 도구들 + Pattern.compile(".*\\/(phpmyadmin|pma|dbadmin|mysql|myadmin|phpMyAdmin).*"), + + // 개발 관련 파일과 디렉토리 + Pattern.compile(".*\\/(\\.git|\\.svn|\\.hg|\\.env|\\.idea|\\.vscode|\\.vs|\\.DS_Store).*"), + Pattern.compile(".*\\.(bak|config|yaml|yml|ini).*"), + + // 서버 및 시스템 파일 + Pattern.compile(".*\\/(etc\\/passwd|etc\\/shadow|etc\\/hosts|etc\\/group).*"), + + // 백업 파일 + Pattern.compile(".*\\.(sql|tar|gz|zip|rar|dump).*"), + Pattern.compile(".*\\/(sqlbackup|backup|backups|bck).*"), + + // 서버 상태 및 정보 + Pattern.compile(".*\\/server-(status|info).*"), + + // IDE 설정 및 파일 + Pattern.compile(".*\\/(sftp-config|sftp-settings|\\.editorconfig|\\.project).*"), + Pattern.compile(".*\\/(\\.npmrc|\\.dockerenv|Dockerfile|\\.kube|\\.yarn|\\.npm|\\.expo|\\.builddir).*"), + + // 특정 시스템 파일 + Pattern.compile(".*\\/(debug|trace\\.axd|config\\.json|settings\\.json|package\\.json|node_modules).*"), + Pattern.compile( + ".*\\/(\\.bash_history|\\.ssh|thumbs\\.db|desktop\\.ini|\\.Trashes|\\.Spotlight-V100|\\.vol).*"), + Pattern.compile(".*\\/(config|logs|tmp|temp|conf|backups).*"), + + // 환경 설정 파일 + Pattern.compile(".*\\.env\\.local$"), + Pattern.compile(".*\\.env\\.prod$"), + Pattern.compile(".*\\.env\\.dev$"), + + // 빌드 디렉토리 + Pattern.compile(".*\\/dist\\/.*"), + Pattern.compile(".*\\/build\\/.*"), + + // 기타 구성 파일 + Pattern.compile(".*\\.json$"), + Pattern.compile(".*\\.toml$"), + + // 관리 도구 경로 + Pattern.compile(".*\\/cpanel.*"), + Pattern.compile(".*\\/webmail.*"), + + // 서버 관리 도구 + Pattern.compile(".*\\/solr.*"), + Pattern.compile(".*\\/adminer.*"), + + // 데이터베이스 관리 경로 + Pattern.compile(".*\\/db\\.php$"), + Pattern.compile(".*\\/sqlmanager.*"), + + // 클라우드 스토리지 버킷 + Pattern.compile(".*\\/s3\\/.*"), + Pattern.compile(".*\\/azure\\/.*"), + + // API 키, 비밀번호 파일 + Pattern.compile(".*\\/api_keys.*"), + Pattern.compile(".*\\/passwords.*") ); /** - * 주어진 경로(path)가 의심스러운 패턴과 일치하는지 확인하는 메소드입니다. - * 이 메소드는 사전에 정의된 패턴 목록을 기반으로 경로를 검사하고, - * 해당 경로가 의심스러운 패턴과 일치하면 true를 반환합니다. + * 주어진 경로(path)가 의심스러운 패턴과 일치하는지 확인하는 메소드입니다. 이 메소드는 사전에 정의된 패턴 목록을 기반으로 경로를 검사하고, 해당 경로가 의심스러운 패턴과 일치하면 true를 + * 반환합니다. * * @param path 요청된 URL 경로 * @return 경로가 의심스러운 패턴과 일치하는지 여부 (일치하면 true, 일치하지 않으면 false) */ public static boolean matchesSuspiciousPattern(String path) { return suspiciousPatterns.stream() - .anyMatch(pattern -> pattern.matcher(path).matches()); + .anyMatch(pattern -> pattern.matcher(path).matches()); } } diff --git a/src/main/java/page/clab/api/global/util/StringJsonConverter.java b/src/main/java/page/clab/api/global/util/StringJsonConverter.java index ba16c24eb..bb526dd4c 100644 --- a/src/main/java/page/clab/api/global/util/StringJsonConverter.java +++ b/src/main/java/page/clab/api/global/util/StringJsonConverter.java @@ -3,9 +3,8 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import jakarta.persistence.AttributeConverter; -import lombok.extern.slf4j.Slf4j; - import java.util.List; +import lombok.extern.slf4j.Slf4j; /** * {@code StringJsonConverter} 클래스는 JPA 엔티티 필드를 JSON 문자열로 변환하거나 JSON 문자열을 리스트로 변환하는 역할을 수행하는 컨버터입니다. diff --git a/src/main/java/page/clab/api/global/util/TempFileUtil.java b/src/main/java/page/clab/api/global/util/TempFileUtil.java index 81b7ef29f..383bbedfb 100644 --- a/src/main/java/page/clab/api/global/util/TempFileUtil.java +++ b/src/main/java/page/clab/api/global/util/TempFileUtil.java @@ -27,7 +27,7 @@ public static Path createSecureTempFile(String prefix, String suffix) throws IOE // 임시 파일에 대한 접근이 제한되어 다른 로컬 사용자가 파일에 접근하거나 파일 내용을 노출할 위험을 줄일 수 있음 if (tempFilePath.getFileSystem().supportedFileAttributeViews().contains("posix")) { EnumSet permissions = EnumSet.of( - PosixFilePermission.OWNER_READ + PosixFilePermission.OWNER_READ ); Files.setPosixFilePermissions(tempFilePath, permissions); } diff --git a/src/main/java/page/clab/api/global/util/WhitelistPathMatcher.java b/src/main/java/page/clab/api/global/util/WhitelistPathMatcher.java index ab1c2b148..2ed8e9ea0 100644 --- a/src/main/java/page/clab/api/global/util/WhitelistPathMatcher.java +++ b/src/main/java/page/clab/api/global/util/WhitelistPathMatcher.java @@ -1,16 +1,14 @@ package page.clab.api.global.util; +import java.util.regex.Pattern; import org.springframework.beans.factory.InitializingBean; import org.springframework.stereotype.Component; import page.clab.api.global.config.WhitelistPatternsProperties; -import java.util.regex.Pattern; - /** * {@code WhitelistPathMatcher} 클래스는 지정된 경로가 화이트리스트에 포함되는지 확인하는 유틸리티 클래스입니다. *

                              - * 이 클래스는 Swagger 및 Actuator와 같은 특정 요청 경로에 대한 화이트리스트 패턴을 관리하고, 주어진 경로가 - * 해당 패턴들과 일치하는지 검사하는 메서드를 제공합니다. + * 이 클래스는 Swagger 및 Actuator와 같은 특정 요청 경로에 대한 화이트리스트 패턴을 관리하고, 주어진 경로가 해당 패턴들과 일치하는지 검사하는 메서드를 제공합니다. */ @Component public class WhitelistPathMatcher implements InitializingBean { diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml index 9dad69843..65c0ac09e 100644 --- a/src/main/resources/logback-spring.xml +++ b/src/main/resources/logback-spring.xml @@ -1,57 +1,57 @@ - - - - - - %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - ${LOG_PATH}/stage/application.%d{yyyy-MM-dd}.log - - 30 - - - %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - ${LOG_PATH}/prod/application.%d{yyyy-MM-dd}.log - - 30 - - - %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - + + + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + ${LOG_PATH}/stage/application.%d{yyyy-MM-dd}.log + + 30 + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + ${LOG_PATH}/prod/application.%d{yyyy-MM-dd}.log + + 30 + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + + - + + + - - - - - - - - - - - - - + + + + + + diff --git a/src/main/resources/templates/clabEmail.html b/src/main/resources/templates/clabEmail.html index 64cdfa986..92eac5d83 100644 --- a/src/main/resources/templates/clabEmail.html +++ b/src/main/resources/templates/clabEmail.html @@ -1,4 +1,5 @@ - + + + + table, td { + color: #000000; + } + + #u_body a { + color: #0000ee; + text-decoration: underline; + } + @media (max-width: 480px) { + #u_content_image_1 .v-src-width { + width: auto !important; + } + #u_content_image_1 .v-src-max-width { + max-width: 40% !important; + } - + #u_content_heading_1 .v-font-size { + font-size: 38px !important; + } + + #u_content_text_5 .v-container-padding-padding { + padding: 10px 30px 11px 10px !important; + } + } + + + + + + - - - - + + + +
                              - - +
                              -
                              +
                              - - - -
                              + + + +
                              -
                              - - - - - - - - - - - - - - - -
                              - - - - - - - -
                              -   -
                              - -
                              - -
                              + +
                              + + + + + + + + + + + + + + + + +
                              + + + + + + + +
                              +   +
                              + +
                              + +
                              @@ -161,34 +224,54 @@
                              - - -
                              -
                              +
                              - - - -
                              -
                              -
                              - - - - - - - - - -
                              + + + +
                              +
                              + +
                              + + + + + + + + + + +
                              @@ -198,35 +281,54 @@

                              -
                              +
                              - - - -
                              -
                              -
                              - - - - - - - - - -
                              + + + +
                              +
                              + +
                              + + + + + + + + + + +
                              @@ -236,39 +338,63 @@

                              -
                              +
                              - - - -
                              -
                              -
                              - - - - - - - -
                              - - - - -
                              - -
                              + + + +
                              +
                              + +
                              + + + + + + + + +
                              + + + + +
                              + +
                              @@ -278,54 +404,73 @@

                              -
                              +
                              - - - -
                              -
                              -
                              - - - - - - - -
                              - - - - - - - -
                              -   -
                              - -
                              - - - - - - - -
                              - -
                              -

                              C-Lab  |  경기대학교 AI컴퓨터공학부 개발동아리

                              -
                              - -
                              - -
                              + + + +
                              +
                              + +
                              + + + + + + + + +
                              + + + + + + + +
                              +   +
                              + +
                              + + + + + + + +
                              + +
                              +

                              C-Lab  |  경기대학교 AI컴퓨터공학부 개발동아리

                              +
                              + +
                              + +
                              @@ -335,57 +480,77 @@

                              -
                              +
                              - - - -
                              -
                              -
                              - - - - - - - -
                              - - - - - - - -
                              -   -
                              - -
                              - - - - - - - -
                              - -
                              -

                              본 메일은 발신전용으로 회신 시 내용을 확인할 수 없습니다.

                              -

                              관련한 문의사항은 페이지 내 체널톡 또는 운영진을 통해 문의 바랍니다.

                              -

                               

                              -

                              © C-Lab. All Rights Reserved.

                              -
                              - -
                              - -
                              + + + +
                              +
                              + +
                              + + + + + + + + +
                              + + + + + + + +
                              +   +
                              + +
                              + + + + + + + +
                              + +
                              +

                              본 메일은 발신전용으로 회신 시 내용을 확인할 수 없습니다.

                              +

                              관련한 문의사항은 페이지 내 체널톡 또는 운영진을 통해 문의 바랍니다.

                              +

                               

                              +

                              © C-Lab. All Rights Reserved.

                              +
                              + +
                              + +
                              @@ -395,40 +560,55 @@

                              -
                              +
                              - - - -
                              -
                              -
                              - - - - - - - -
                              - - - - - - - -
                              -   -
                              - -
                              - -
                              + + + +
                              +
                              + +
                              + + + + + + + + +
                              + + + + + + + +
                              +   +
                              + +
                              + +
                              @@ -438,7 +618,6 @@