Skip to content

Commit

Permalink
refactor: 읽기 작업에 transactional readOnly 추가 (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
birdieHyun committed Jun 17, 2023
1 parent 30d5763 commit 9730028
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions be/src/main/java/com/secondhand/post/PostService.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

import javax.transaction.Transactional;
import java.util.ArrayList;
import java.util.List;

Expand All @@ -44,6 +44,7 @@ public class PostService {
private final BadgeRepository badgeRepository;
private final FileUploadService fileUploadService;

@Transactional(readOnly = true)
public MainPagePostsDto findMainPagePosts(Pageable pageable, SearchCondition searchCondition) {

return new MainPagePostsDto(postMetaRepository.findMainPage(pageable, searchCondition));
Expand All @@ -57,12 +58,13 @@ public CreatePostResponseDto createPost(PostSaveDto postSaveDto, LoggedInUser lo
return new CreatePostResponseDto(savedPostMeta.getId());
}

@Transactional(readOnly = true)
public Page<PostMetaDto> findInterestPosts(Pageable pageable, LoggedInUser loggedInUser) {

return interestRepository.findMyInterestsPosts(pageable, loggedInUser.getId());
}

@Transactional
@Transactional(readOnly = true)
public PostDetailPageDto findPostDetailPage(long postId, LoggedInUser loggedInUser) {

PostMeta postMeta = postMetaRepository.findById(postId).orElseThrow();
Expand Down

0 comments on commit 9730028

Please sign in to comment.