diff --git a/src/main/kotlin/com/example/boheom/domain/feed/domain/repository/ApplyRepository.kt b/src/main/kotlin/com/example/boheom/domain/feed/domain/repository/ApplyRepository.kt index 146e580..85bf5de 100644 --- a/src/main/kotlin/com/example/boheom/domain/feed/domain/repository/ApplyRepository.kt +++ b/src/main/kotlin/com/example/boheom/domain/feed/domain/repository/ApplyRepository.kt @@ -10,4 +10,5 @@ interface ApplyRepository : JpaRepository { fun existsByUserAndFeed(user: User, feed: Feed): Boolean fun countByFeed(feed: Feed): Int fun findByUser(user: User): List + fun findByFeed(feed: Feed): List } \ No newline at end of file diff --git a/src/main/kotlin/com/example/boheom/domain/feed/presentation/FeedController.kt b/src/main/kotlin/com/example/boheom/domain/feed/presentation/FeedController.kt index fd3ff4d..26c6cb8 100644 --- a/src/main/kotlin/com/example/boheom/domain/feed/presentation/FeedController.kt +++ b/src/main/kotlin/com/example/boheom/domain/feed/presentation/FeedController.kt @@ -5,6 +5,7 @@ import com.example.boheom.domain.feed.presentation.dto.request.UpdateFeedRequest import com.example.boheom.domain.feed.presentation.dto.response.FeedDetailsResponse import com.example.boheom.domain.feed.presentation.dto.response.FeedListResponse import com.example.boheom.domain.feed.presentation.dto.response.PageFeedListResponse +import com.example.boheom.domain.feed.presentation.dto.response.QueryApplyUserListResponse import com.example.boheom.domain.feed.service.CreateFeedService import com.example.boheom.domain.feed.service.DeleteFeedService import com.example.boheom.domain.feed.service.FeedApplyService @@ -16,6 +17,7 @@ import com.example.boheom.domain.feed.service.QueryPopularFeedListService import com.example.boheom.domain.feed.service.QueryRecentFeedService import com.example.boheom.domain.feed.service.SearchFeedService import com.example.boheom.domain.feed.service.CancelApplyService +import com.example.boheom.domain.feed.service.QueryApplyUserListService import com.example.boheom.domain.feed.service.UpdateFeedService import org.springframework.data.domain.Pageable import org.springframework.data.web.PageableDefault @@ -48,6 +50,7 @@ class FeedController( private val searchFeedService: SearchFeedService, private val queryApplyFeedService: QueryApplyFeedService, private val queryMyFeedService: QueryMyFeedService, + private val queryApplyUserListService: QueryApplyUserListService, ) { @ResponseStatus(CREATED) @PostMapping @@ -113,4 +116,9 @@ class FeedController( fun getMyFeed(): FeedListResponse { return queryMyFeedService.execute() } + + @GetMapping("/apply-user/{feed-id}") + fun getAppliedUserList(@PathVariable("feed-id") feedId: UUID): QueryApplyUserListResponse { + return queryApplyUserListService.execute(feedId) + } } \ No newline at end of file diff --git a/src/main/kotlin/com/example/boheom/domain/feed/presentation/dto/response/QueryApplyUserListResponse.kt b/src/main/kotlin/com/example/boheom/domain/feed/presentation/dto/response/QueryApplyUserListResponse.kt new file mode 100644 index 0000000..f4e8231 --- /dev/null +++ b/src/main/kotlin/com/example/boheom/domain/feed/presentation/dto/response/QueryApplyUserListResponse.kt @@ -0,0 +1,7 @@ +package com.example.boheom.domain.feed.presentation.dto.response + +import com.example.boheom.domain.user.presentation.dto.response.UserElement + +data class QueryApplyUserListResponse( + val users: List +) \ No newline at end of file diff --git a/src/main/kotlin/com/example/boheom/domain/feed/service/QueryApplyUserListService.kt b/src/main/kotlin/com/example/boheom/domain/feed/service/QueryApplyUserListService.kt new file mode 100644 index 0000000..17ea223 --- /dev/null +++ b/src/main/kotlin/com/example/boheom/domain/feed/service/QueryApplyUserListService.kt @@ -0,0 +1,31 @@ +package com.example.boheom.domain.feed.service + +import com.example.boheom.domain.feed.domain.repository.ApplyRepository +import com.example.boheom.domain.feed.exception.IncorrectUserException +import com.example.boheom.domain.feed.facade.FeedFacade +import com.example.boheom.domain.feed.presentation.dto.response.QueryApplyUserListResponse +import com.example.boheom.domain.user.presentation.dto.response.UserElement +import com.example.boheom.domain.user.facade.UserFacade +import org.springframework.stereotype.Service +import org.springframework.transaction.annotation.Transactional +import java.util.UUID + +@Service +class QueryApplyUserListService( + private val userFacade: UserFacade, + private val feedFacade: FeedFacade, + private val applyRepository: ApplyRepository, +) { + @Transactional(readOnly = true) + fun execute(feedId: UUID): QueryApplyUserListResponse { + val user = userFacade.getCurrentUser() + val feed = feedFacade.getByFeedId(feedId) + val applyUser = applyRepository.findByFeed(feed).map { it.user } + + if (user != feed.user) { + throw IncorrectUserException + } + + return QueryApplyUserListResponse(applyUser.map { UserElement(it.profile, it.nickname, it.accountId) }) + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/example/boheom/domain/user/presentation/dto/response/UserElement.kt b/src/main/kotlin/com/example/boheom/domain/user/presentation/dto/response/UserElement.kt new file mode 100644 index 0000000..0afa9bf --- /dev/null +++ b/src/main/kotlin/com/example/boheom/domain/user/presentation/dto/response/UserElement.kt @@ -0,0 +1,7 @@ +package com.example.boheom.domain.user.presentation.dto.response + +data class UserElement( + val profile: String, + val nickname: String, + val accountId: String, +) \ No newline at end of file