Skip to content

Commit

Permalink
refactor: 삭제된 데이터 조회에 대한 transactional read only 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
limehee committed Apr 28, 2024
1 parent 3b421da commit e5e18d5
Show file tree
Hide file tree
Showing 20 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public Long manageActivityGroup(Long activityGroupId, ActivityGroupStatus status
return activityGroup.getId();
}

@Transactional(readOnly = true)
public PagedResponseDto<ActivityGroupResponseDto> getDeletedActivityGroups(Pageable pageable) {
Page<ActivityGroup> activityGroups = activityGroupRepository.findAllByIsDeletedTrue(pageable);
return new PagedResponseDto<>(activityGroups.map(ActivityGroupResponseDto::toDto));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ public Long deleteActivityGroupBoard(Long activityGroupBoardId) throws Permissio
return board.getId();
}

@Transactional(readOnly = true)
public PagedResponseDto<ActivityGroupBoardResponseDto> getDeletedActivityGroupBoards(Pageable pageable) {
Page<ActivityGroupBoard> activityGroupBoards = activityGroupBoardRepository.findAllByIsDeletedTrue(pageable);
return new PagedResponseDto<>(activityGroupBoards.map(ActivityGroupBoardResponseDto::toDto));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public Long deleteReport(Long reportId) throws PermissionDeniedException {
return report.getId();
}

@Transactional(readOnly = true)
public PagedResponseDto<ActivityGroupReportResponseDto> getDeletedActivityGroupReports(Pageable pageable) {
Page<ActivityGroupReport> activityGroupReports = activityGroupReportRepository.findAllByIsDeletedTrue(pageable);
return new PagedResponseDto<>(activityGroupReports.map(ActivityGroupReportResponseDto::toDto));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public Long deleteAward(Long awardId) throws PermissionDeniedException {
return award.getId();
}

@Transactional(readOnly = true)
public PagedResponseDto<AwardResponseDto> getDeletedAwards(Pageable pageable) {
Page<Award> awards = awardRepository.findAllByIsDeletedTrue(pageable);
return new PagedResponseDto<>(awards.map(AwardResponseDto::toDto));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public BlogDetailsResponseDto getBlogDetails(Long blogId) {
return BlogDetailsResponseDto.toDto(blog, isOwner);
}

@Transactional(readOnly = true)
public PagedResponseDto<BlogDetailsResponseDto> getDeletedBlogs(Pageable pageable) {
Member currentMember = memberService.getCurrentMember();
Page<Blog> blogs = blogRepository.findAllByIsDeletedTrue(pageable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public Long toggleLikeStatus(Long boardId) {
return board.getLikes();
}

@Transactional(readOnly = true)
public PagedResponseDto<BoardListResponseDto> getDeletedBoards(Pageable pageable) {
Page<Board> boards = boardRepository.findAllByIsDeletedTrue(pageable);
return new PagedResponseDto<>(boards.map(this::mapToBoardListResponseDto));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public BookDetailsResponseDto getBookDetails(Long bookId) {
return mapToBookDetailsResponseDto(book);
}

@Transactional(readOnly = true)
public PagedResponseDto<BookDetailsResponseDto> getDeletedBooks(Pageable pageable) {
Page<Book> books = bookRepository.findAllByIsDeletedTrue(pageable);
return new PagedResponseDto<>(books.map(this::mapToBookDetailsResponseDto));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public PagedResponseDto<CommentMyResponseDto> getMyComments(Pageable pageable) {
return new PagedResponseDto<>(commentDtos);
}

@Transactional(readOnly = true)
public PagedResponseDto<DeletedCommentResponseDto> getDeletedComments(Long boardId, Pageable pageable) {
Member currentMember = memberService.getCurrentMember();
Page<Comment> comments = commentRepository.findAllByIsDeletedTrueAndBoardId(boardId, pageable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public PagedResponseDto<DonationResponseDto> getMyDonations(Pageable pageable) {
return new PagedResponseDto<>(donations.map(DonationResponseDto::toDto));
}

@Transactional(readOnly = true)
public PagedResponseDto<DonationResponseDto> getDeletedDonations(Pageable pageable) {
Page<Donation> donations = donationRepository.findAllByIsDeletedTrue(pageable);
return new PagedResponseDto<>(donations.map(DonationResponseDto::toDto));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public JobPostingDetailsResponseDto getJobPosting(Long jobPostingId) {
return JobPostingDetailsResponseDto.toDto(jobPosting);
}

@Transactional(readOnly = true)
public PagedResponseDto<JobPostingDetailsResponseDto> getDeletedJobPostings(Pageable pageable) {
Page<JobPosting> jobPostings = jobPostingRepository.findAllByIsDeletedTrue(pageable);
return new PagedResponseDto<>(jobPostings.map(JobPostingDetailsResponseDto::toDto));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public PagedResponseDto<MembershipFeeResponseDto> getMembershipFeesByConditions(
return new PagedResponseDto<>(membershipFeesPage.map(membershipFee -> MembershipFeeResponseDto.toDto(membershipFee, isAdminOrSuper)));
}

@Transactional(readOnly = true)
public PagedResponseDto<MembershipFeeResponseDto> getDeletedMembershipFees(Pageable pageable) {
Member currentMember = memberService.getCurrentMember();
boolean isAdminOrSuper = currentMember.isAdminRole();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public NewsDetailsResponseDto getNewsDetails(Long newsId) {
return NewsDetailsResponseDto.toDto(news);
}

@Transactional(readOnly = true)
public PagedResponseDto<NewsDetailsResponseDto> getDeletedNews(Pageable pageable) {
Page<News> newsPage = newsRepository.findAllByIsDeletedTrue(pageable);
return new PagedResponseDto<>(newsPage.map(NewsDetailsResponseDto::toDto));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public PagedResponseDto<NotificationResponseDto> getNotifications(Pageable pagea
return new PagedResponseDto<>(notifications.map(NotificationResponseDto::toDto));
}

@Transactional(readOnly = true)
public PagedResponseDto<NotificationResponseDto> getDeletedNotifications(Pageable pageable) {
Page<Notification> notifications = notificationRepository.findAllByIsDeletedTrue(pageable);
return new PagedResponseDto<>(notifications.map(NotificationResponseDto::toDto));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public PositionMyResponseDto getMyPositionsByYear(String year) {
return PositionMyResponseDto.toDto(positions);
}

@Transactional(readOnly = true)
public PagedResponseDto<PositionResponseDto> getDeletedPositions(Pageable pageable) {
Page<Position> positions = positionRepository.findAllByIsDeletedTrue(pageable);
return new PagedResponseDto<>(positions.map(PositionResponseDto::toDto));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public PagedResponseDto<ProductResponseDto> getProductsByConditions(String produ
return new PagedResponseDto<>(products.map(ProductResponseDto::toDto));
}

@Transactional(readOnly = true)
public PagedResponseDto<ProductResponseDto> getDeletedProducts(Pageable pageable) {
Page<Product> products = productRepository.findAllByIsDeletedTrue(pageable);
return new PagedResponseDto<>(products.map(ProductResponseDto::toDto));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public List<RecruitmentResponseDto> getRecentRecruitments() {
.toList();
}

@Transactional(readOnly = true)
public PagedResponseDto<RecruitmentResponseDto> getDeletedRecruitments(Pageable pageable) {
Page<Recruitment> recruitments = recruitmentRepository.findAllByIsDeletedTrue(pageable);
return new PagedResponseDto<>(recruitments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public PagedResponseDto<ReviewResponseDto> getMyReviews(Pageable pageable) {
return new PagedResponseDto<>(reviews.map(review -> ReviewResponseDto.toDto(review, currentMember)));
}

@Transactional(readOnly = true)
public PagedResponseDto<ReviewResponseDto> getDeletedReviews(Pageable pageable) {
Member currentMember = memberService.getCurrentMember();
Page<Review> reviews = reviewRepository.findAllByIsDeletedTrue(pageable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public PagedResponseDto<ScheduleResponseDto> getActivitySchedules(LocalDate star
return new PagedResponseDto<>(schedules.map(ScheduleResponseDto::toDto));
}

@Transactional(readOnly = true)
public PagedResponseDto<ScheduleResponseDto> getDeletedSchedules(Pageable pageable) {
Page<Schedule> schedules = scheduleRepository.findAllByIsDeletedTrue(pageable);
return new PagedResponseDto<>(schedules.map(ScheduleResponseDto::toDto));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public PagedResponseDto<SharedAccountResponseDto> getSharedAccounts(Pageable pag
return new PagedResponseDto<>(sharedAccounts.map(SharedAccountResponseDto::toDto));
}

@Transactional(readOnly = true)
public PagedResponseDto<SharedAccountResponseDto> getDeletedSharedAccounts(Pageable pageable) {
Page<SharedAccount> sharedAccounts = sharedAccountRepository.findAllByIsDeletedTrue(pageable);
return new PagedResponseDto<>(sharedAccounts.map(SharedAccountResponseDto::toDto));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public PagedResponseDto<WorkExperienceResponseDto> getWorkExperiencesByCondition
return new PagedResponseDto<>(workExperiences.map(WorkExperienceResponseDto::toDto));
}

@Transactional(readOnly = true)
public PagedResponseDto<WorkExperienceResponseDto> getDeletedWorkExperiences(Pageable pageable) {
Page<WorkExperience> workExperiences = workExperienceRepository.findAllByIsDeletedTrue(pageable);
return new PagedResponseDto<>(workExperiences.map(WorkExperienceResponseDto::toDto));
Expand Down

0 comments on commit e5e18d5

Please sign in to comment.