diff --git a/src/main/java/com/moing/backend/domain/missionArchive/application/service/MissionArchiveDeleteUseCase.java b/src/main/java/com/moing/backend/domain/missionArchive/application/service/MissionArchiveDeleteUseCase.java index 362fec96..65e92852 100644 --- a/src/main/java/com/moing/backend/domain/missionArchive/application/service/MissionArchiveDeleteUseCase.java +++ b/src/main/java/com/moing/backend/domain/missionArchive/application/service/MissionArchiveDeleteUseCase.java @@ -12,6 +12,7 @@ import com.moing.backend.domain.missionArchive.domain.service.MissionArchiveQueryService; import com.moing.backend.domain.missionArchive.domain.service.MissionArchiveSaveService; import com.moing.backend.domain.missionArchive.exception.NoAccessMissionArchiveException; +import com.moing.backend.domain.missionComment.domain.service.MissionCommentDeleteService; import com.moing.backend.domain.missionHeart.domain.service.MissionHeartQueryService; import com.moing.backend.domain.team.domain.entity.Team; import com.moing.backend.domain.teamScore.application.service.TeamScoreUpdateUseCase; @@ -31,6 +32,7 @@ public class MissionArchiveDeleteUseCase { private final MissionArchiveQueryService missionArchiveQueryService; private final MissionArchiveDeleteService missionArchiveDeleteService; private final MissionQueryService missionQueryService; + private final MissionCommentDeleteService missionCommentDeleteService; private final MemberGetService memberGetService; private final TeamScoreUpdateUseCase teamScoreUpdateUseCase; @@ -61,6 +63,7 @@ public Long deleteArchive(String userSocialId, Long missionId,Long count) { updateUtils.deleteImgUrl(archive); } + missionCommentDeleteService.deleteAllCommentByMissionArchive(deleteArchive.getId()); missionArchiveDeleteService.deleteMissionArchive(deleteArchive); teamScoreUpdateUseCase.gainScoreOfArchive(mission, ScoreStatus.MINUS); diff --git a/src/main/java/com/moing/backend/domain/missionArchive/domain/service/MissionArchiveDeleteService.java b/src/main/java/com/moing/backend/domain/missionArchive/domain/service/MissionArchiveDeleteService.java index 3bb8f5c1..567f8ae9 100644 --- a/src/main/java/com/moing/backend/domain/missionArchive/domain/service/MissionArchiveDeleteService.java +++ b/src/main/java/com/moing/backend/domain/missionArchive/domain/service/MissionArchiveDeleteService.java @@ -2,6 +2,7 @@ import com.moing.backend.domain.missionArchive.domain.entity.MissionArchive; import com.moing.backend.domain.missionArchive.domain.repository.MissionArchiveRepository; +import com.moing.backend.domain.missionComment.domain.service.MissionCommentDeleteService; import com.moing.backend.global.annotation.DomainService; import lombok.RequiredArgsConstructor; import org.springframework.transaction.annotation.Transactional; diff --git a/src/main/java/com/moing/backend/domain/missionComment/domain/repository/MissionCommentRepository.java b/src/main/java/com/moing/backend/domain/missionComment/domain/repository/MissionCommentRepository.java index 8c7d8e35..160b39a7 100644 --- a/src/main/java/com/moing/backend/domain/missionComment/domain/repository/MissionCommentRepository.java +++ b/src/main/java/com/moing/backend/domain/missionComment/domain/repository/MissionCommentRepository.java @@ -3,10 +3,13 @@ import com.moing.backend.domain.missionComment.domain.entity.MissionComment; import org.springframework.data.jpa.repository.JpaRepository; +import java.util.List; import java.util.Optional; public interface MissionCommentRepository extends JpaRepository, MissionCommentCustomRepository { Optional findMissionCommentByMissionCommentId(Long missionCommentId); + void deleteAllMissionCommentsByMissionArchiveId(Long missionArchiveId); + } diff --git a/src/main/java/com/moing/backend/domain/missionComment/domain/service/MissionCommentDeleteService.java b/src/main/java/com/moing/backend/domain/missionComment/domain/service/MissionCommentDeleteService.java index b41f541a..4a9ff9ec 100644 --- a/src/main/java/com/moing/backend/domain/missionComment/domain/service/MissionCommentDeleteService.java +++ b/src/main/java/com/moing/backend/domain/missionComment/domain/service/MissionCommentDeleteService.java @@ -15,4 +15,8 @@ public class MissionCommentDeleteService implements CommentDeleteService