diff --git a/src/main/kotlin/com/example/boheom/domain/feed/presentation/dto/response/FeedDetailsResponse.kt b/src/main/kotlin/com/example/boheom/domain/feed/presentation/dto/response/FeedDetailsResponse.kt index 5349318..2659940 100644 --- a/src/main/kotlin/com/example/boheom/domain/feed/presentation/dto/response/FeedDetailsResponse.kt +++ b/src/main/kotlin/com/example/boheom/domain/feed/presentation/dto/response/FeedDetailsResponse.kt @@ -16,5 +16,6 @@ data class FeedDetailsResponse( val view: Int, val recruitment: Int, val applyCount: Int, - val isMine: Boolean + val isApplied: Boolean, + val isMine: Boolean, ) diff --git a/src/main/kotlin/com/example/boheom/domain/feed/service/QueryFeedDetailsService.kt b/src/main/kotlin/com/example/boheom/domain/feed/service/QueryFeedDetailsService.kt index 7715135..3ea7b40 100644 --- a/src/main/kotlin/com/example/boheom/domain/feed/service/QueryFeedDetailsService.kt +++ b/src/main/kotlin/com/example/boheom/domain/feed/service/QueryFeedDetailsService.kt @@ -5,6 +5,7 @@ import com.example.boheom.domain.feed.domain.repository.ApplyRepository import com.example.boheom.domain.feed.domain.repository.FeedTagRepository import com.example.boheom.domain.feed.facade.FeedFacade import com.example.boheom.domain.feed.presentation.dto.response.FeedDetailsResponse +import com.example.boheom.domain.user.domain.User import com.example.boheom.domain.user.facade.UserFacade import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional @@ -19,10 +20,14 @@ class QueryFeedDetailsService( ) { @Transactional fun execute(feedId: UUID): FeedDetailsResponse { + val user = userFacade.getCurrentUser() val feed = feedFacade.getByFeedId(feedId) val tags = feedTagRepository.findAllByFeed(feed).map { it.name } val applyCount = applyRepository.countByFeed(feed) + val isApplied = applyRepository.existsByUserAndFeed(user, feed) + feed.plusView() + return FeedDetailsResponse( feed.id, feed.title, @@ -35,12 +40,12 @@ class QueryFeedDetailsService( feed.view, feed.recruitment, applyCount, - getIsMine(feed) + isApplied, + getIsMine(feed, user) ) } - fun getIsMine(feed: Feed): Boolean { - val user = userFacade.getCurrentUser() + fun getIsMine(feed: Feed, user: User): Boolean { return user.equals(feed.user) } } \ No newline at end of file