Skip to content

Commit

Permalink
bug :: delete feed apply
Browse files Browse the repository at this point in the history
  • Loading branch information
jyk1029 committed Jan 26, 2024
1 parent 88e22ab commit 5d778cd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ interface ApplyRepository : JpaRepository<Apply, UUID> {
fun findByUser(user: User): List<Apply>
fun findByFeed(feed: Feed): List<Apply>
fun deleteByUserAndFeed(user: User, feed: Feed)
fun existsByFeed(feed: Feed): Boolean
fun deleteByFeed(feed: Feed)
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.example.boheom.domain.feed.service

import com.example.boheom.domain.feed.domain.repository.ApplyRepository
import com.example.boheom.domain.feed.domain.repository.FeedRepository
import com.example.boheom.domain.feed.domain.repository.FeedTagRepository
import com.example.boheom.domain.feed.exception.IncorrectUserException
Expand All @@ -15,6 +16,7 @@ class DeleteFeedService(
private val userFacade: UserFacade,
private val feedRepository: FeedRepository,
private val feedTagRepository: FeedTagRepository,
private val applyRepository: ApplyRepository,
) {
@Transactional
fun execute(feedId: UUID) {
Expand All @@ -25,6 +27,10 @@ class DeleteFeedService(
throw IncorrectUserException
}

if (applyRepository.existsByFeed(feed)) {
applyRepository.deleteByFeed(feed)
}

feedTagRepository.deleteAllByFeed(feed)
feedRepository.delete(feed)
}
Expand Down

0 comments on commit 5d778cd

Please sign in to comment.