@@ -4,6 +4,8 @@ import gogo.gogostage.domain.community.board.persistence.Board
44import gogo.gogostage.domain.community.board.persistence.BoardRepository
55import gogo.gogostage.domain.community.boardlike.persistence.BoardLike
66import gogo.gogostage.domain.community.boardlike.persistence.BoardLikeRepository
7+ import gogo.gogostage.domain.community.boardview.persistence.BoardView
8+ import gogo.gogostage.domain.community.boardview.persistence.BoardViewRepository
79import gogo.gogostage.domain.community.comment.persistence.Comment
810import gogo.gogostage.domain.community.comment.persistence.CommentRepository
911import gogo.gogostage.domain.community.commentlike.persistence.CommentLike
@@ -24,6 +26,7 @@ class CommunityProcessor(
2426 private val commentLikeRepository : CommentLikeRepository ,
2527 private val commentMapper : CommunityMapper ,
2628 private val boardRepository : BoardRepository ,
29+ private val boardViewRepository : BoardViewRepository ,
2730) {
2831
2932 fun likeBoard (studentId : Long , board : Board ): LikeResDto {
@@ -130,4 +133,19 @@ class CommunityProcessor(
130133
131134 commentRepository.save(comment)
132135 }
136+
137+ fun saveBoardView (board : Board , studentId : Long ) {
138+ if (! boardViewRepository.existsByBoardIdAndStudentId(board.id, studentId)) {
139+ val newBoardView = BoardView (
140+ board = board,
141+ studentId = studentId,
142+ )
143+
144+ boardViewRepository.save(newBoardView)
145+
146+ board.plusViewCount()
147+
148+ boardRepository.save(board)
149+ }
150+ }
133151}
0 commit comments