Skip to content

Commit

Permalink
fix: 대댓글 익명이 제대로 안되는 문제를 수정한다
Browse files Browse the repository at this point in the history
  • Loading branch information
devbelly committed Aug 16, 2024
1 parent ec241ae commit 3347afe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 3347afe

Please sign in to comment.