Skip to content

Commit

Permalink
update :: feed details dto
Browse files Browse the repository at this point in the history
  • Loading branch information
jyk1029 committed Jan 24, 2024
1 parent 9626073 commit f41fd08
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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)
}
}

0 comments on commit f41fd08

Please sign in to comment.