개발일지

개발일지 62일차

index.ys 2023. 5. 31. 21:20

북마크기능

  •  내가 북마크한 게시글이 존재하는지 확인
 const getExistPost = await this.bookmarkRepository.findPostById(postId);
  • 게시글이 존재할때 내가 북마크하려는 게시글을 북마크하지 않았을때 북마크 등록
 await this.bookmarkRepository.postBookmark(userId, postId);
 return { message: "게시글 북마크를 등록했습니다." }
  • 북마크하려는 게시글을 이미 북마크했을때 북마크를 취소
 await this.bookmarkRepository.cancelBookmark(userId, postId);
 return { message: "게시글 북마크를 취소했습니다." }

신고기능

  • 사용자가 신고요청post
  await this.reportPooRepository.postReportPoo(userId,pooId,reportContent)
  • reportCount 5이하일때는 increment로 post요청이 들어올대마다 reportCount를 1씩 증가시킴
  • reportCount가 5이상 일때는 해당 게시글을 삭제
   if (findOneReportPoo) {
                    await this.reportPooRepository.incrementReportCount(findOneReportPoo);
                    if (findOneReportPoo.reportCount >= 5) {
                        await this.reportPooRepository.destroyPoo(pooId);
                        return { msg: "게시글삭제 완료" };
                    }
                }