diff --git a/src/main/kotlin/mara/server/domain/share/ShareController.kt b/src/main/kotlin/mara/server/domain/share/ShareController.kt index 2d23928..973809f 100644 --- a/src/main/kotlin/mara/server/domain/share/ShareController.kt +++ b/src/main/kotlin/mara/server/domain/share/ShareController.kt @@ -46,7 +46,7 @@ class ShareController(private val shareService: ShareService) { @GetMapping("/{id}/applies") @Operation(summary = "나눔 신청 사용자 이름 조회 API") - fun getAllApplyUserList(@PathVariable(name = "id") shareId: Long): CommonResponse?> { + fun getAllApplyUserList(@PathVariable(name = "id") shareId: Long): CommonResponse?> { return success(shareService.getAllApplyUserList(shareId)) } diff --git a/src/main/kotlin/mara/server/domain/share/ShareDto.kt b/src/main/kotlin/mara/server/domain/share/ShareDto.kt index aa1a3d5..7d8a3a3 100644 --- a/src/main/kotlin/mara/server/domain/share/ShareDto.kt +++ b/src/main/kotlin/mara/server/domain/share/ShareDto.kt @@ -37,7 +37,7 @@ data class UpdateShareStatusRequest( ) data class ShareResponse( - val userName: String, + val nickname: String, val profileImage: ProfileImage, val shareId: Long, val title: String, @@ -53,7 +53,7 @@ data class ShareResponse( val thumbNailImage: String ) { constructor(share: Share) : this( - userName = share.user.nickname, + nickname = share.user.nickname, profileImage = share.user.profileImage, shareId = share.id, title = share.title, @@ -69,6 +69,20 @@ data class ShareResponse( ) } +data class AppliedUserDto( + val nickname: String, + val profileImage: ProfileImage, +) { + constructor(applyShare: ApplyShare) : this( + nickname = applyShare.user.nickname, + profileImage = applyShare.user.profileImage, + ) +} + fun Page.toShareResponseListPage(): Page { return this.map { ShareResponse(it) } } + +fun List.toApplyShareResponseList(): List { + return this.map { AppliedUserDto(it) } +} diff --git a/src/main/kotlin/mara/server/domain/share/ShareService.kt b/src/main/kotlin/mara/server/domain/share/ShareService.kt index 8325f2d..67af063 100644 --- a/src/main/kotlin/mara/server/domain/share/ShareService.kt +++ b/src/main/kotlin/mara/server/domain/share/ShareService.kt @@ -83,10 +83,9 @@ class ShareService( .toShareResponseListPage() } - fun getAllApplyUserList(shareId: Long): List? { + fun getAllApplyUserList(shareId: Long): List? { val share = getShare(shareId) - val applyShareList = share.applyShareList - return applyShareList.map { it.user.nickname }.toList() + return share.applyShareList.toApplyShareResponseList() } fun getAllMyAppliedShareList(pageable: Pageable, status: String): Page? {