From 3347afef85ce847107aaa903fb010ec50d2eefaa Mon Sep 17 00:00:00 2001 From: Woongbae Yun Date: Fri, 16 Aug 2024 09:23:17 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EB=8C=80=EB=8C=93=EA=B8=80=20=EC=9D=B5?= =?UTF-8?q?=EB=AA=85=EC=9D=B4=20=EC=A0=9C=EB=8C=80=EB=A1=9C=20=EC=95=88?= =?UTF-8?q?=EB=90=98=EB=8A=94=20=EB=AC=B8=EC=A0=9C=EB=A5=BC=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dclass/backend/application/RecruitmentReplyService.kt | 6 +++++- .../dclass/backend/application/dto/RecruitmentReplyDtos.kt | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/backend/src/main/kotlin/com/dclass/backend/application/RecruitmentReplyService.kt b/backend/src/main/kotlin/com/dclass/backend/application/RecruitmentReplyService.kt index e5a62edd49..814f8ae961 100644 --- a/backend/src/main/kotlin/com/dclass/backend/application/RecruitmentReplyService.kt +++ b/backend/src/main/kotlin/com/dclass/backend/application/RecruitmentReplyService.kt @@ -6,6 +6,7 @@ import com.dclass.backend.application.dto.RecruitmentReplyResponse import com.dclass.backend.application.dto.UpdateRecruitmentReplyRequest import com.dclass.backend.domain.recruitment.RecruitmentRepository import com.dclass.backend.domain.recruitment.findByIdOrThrow +import com.dclass.backend.domain.recruitmentanonymous.RecruitmentAnonymousRepository import com.dclass.backend.domain.recruitmentcomment.RecruitmentCommentRepository import com.dclass.backend.domain.recruitmentcomment.getByIdOrThrow import com.dclass.backend.domain.recruitmentreply.RecruitmentReplyRepository @@ -25,6 +26,7 @@ class RecruitmentReplyService( private val recruitmentRepository: RecruitmentRepository, private val commentRepository: RecruitmentCommentRepository, private val validator: CommentReplyValidator, + private val anonymousRepository: RecruitmentAnonymousRepository, ) { @Retryable( ObjectOptimisticLockingFailureException::class, @@ -44,7 +46,9 @@ class RecruitmentReplyService( val reply = replyRepository.save(request.toEntity(userId)) - // TODO : 익명 여부 + if (request.isAnonymous && !anonymousRepository.existsByUserIdAndRecruitmentId(userId, recruitment.id)) { + anonymousRepository.save(request.toAnonymousEntity(userId, recruitment.id)) + } comment.increaseReplyCount() recruitment.increaseCommentReplyCount() diff --git a/backend/src/main/kotlin/com/dclass/backend/application/dto/RecruitmentReplyDtos.kt b/backend/src/main/kotlin/com/dclass/backend/application/dto/RecruitmentReplyDtos.kt index 2f503d0edf..fd73cb3b44 100644 --- a/backend/src/main/kotlin/com/dclass/backend/application/dto/RecruitmentReplyDtos.kt +++ b/backend/src/main/kotlin/com/dclass/backend/application/dto/RecruitmentReplyDtos.kt @@ -1,5 +1,6 @@ package com.dclass.backend.application.dto +import com.dclass.backend.domain.recruitmentanonymous.RecruitmentAnonymous import com.dclass.backend.domain.recruitmentreply.RecruitmentReply import com.dclass.backend.domain.user.User import com.dclass.backend.domain.user.UserInformation @@ -28,6 +29,10 @@ data class CreateRecruitmentReplyRequest( fun toEntity(userId: Long): RecruitmentReply { return RecruitmentReply(userId, commentId, content, isAnonymous = isAnonymous) } + + fun toAnonymousEntity(userId: Long, postId: Long): RecruitmentAnonymous { + return RecruitmentAnonymous(userId, postId) + } } data class UpdateRecruitmentReplyRequest(