Skip to content

Commit

Permalink
Merge pull request #19 from ssafy-19-final-pjt/feature/#14-Board-paging
Browse files Browse the repository at this point in the history
Feature/#14 board paging
  • Loading branch information
chwangmin authored May 22, 2024
2 parents bf0b244 + feec88c commit 9c76ca0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,12 @@ public Board getBoard(Long boardId){
return boardRepository.findById(boardId)
.orElseThrow(()->new BadRequestException(ErrorCode.BOARD_NOT_FOUND, "게시글이 존재하지 않습니다 :" + boardId));
}

public Board getboardWithPessimisticLock(Long boardId) {
return boardRepository.findByIdPessimisticLock(boardId).orElseThrow();
}

public Board getBoardWithOptimisticLock(Long boardId) {
return boardRepository.findByIdOptimisticLock(boardId).orElseThrow();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
import com.ssafy.home.global.auth.dto.MemberDto;
import com.ssafy.home.global.error.ErrorCode;
import com.ssafy.home.global.error.exception.BadRequestException;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@RequiredArgsConstructor
public class CommentService {
Expand Down Expand Up @@ -64,7 +65,7 @@ public void createCommentWithOptimisticLock(MemberDto memberDto, Long boardId,
public void createCommentWithDistributedLock(MemberDto memberDto, Long boardId,
CommentRequestDto commentRequestDto) {
Member member = memberService.getMemberById(memberDto.getId());
Board board = boardReadService.getBoardWithDistributedLock(boardId);
Board board = boardReadService.getBoard(boardId);

commentWriteService.create(member, board, commentRequestDto);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import static org.assertj.core.api.Assertions.assertThatThrownBy;

@DisplayName("[회원가입, ...]")
@Transactional
class MemberServiceTest extends TestConfig {

private final MemberService memberService;
Expand Down

0 comments on commit 9c76ca0

Please sign in to comment.