Skip to content

Commit

Permalink
refactor: 나눔 신청한 사용자 이름,프로필 이미지 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiwon-cho committed Feb 24, 2024
1 parent 33f84d5 commit 69e25b7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class ShareController(private val shareService: ShareService) {

@GetMapping("/{id}/applies")
@Operation(summary = "나눔 신청 사용자 이름 조회 API")
fun getAllApplyUserList(@PathVariable(name = "id") shareId: Long): CommonResponse<List<String>?> {
fun getAllApplyUserList(@PathVariable(name = "id") shareId: Long): CommonResponse<List<AppliedUserDto>?> {
return success(shareService.getAllApplyUserList(shareId))
}

Expand Down
18 changes: 16 additions & 2 deletions src/main/kotlin/mara/server/domain/share/ShareDto.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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<Share>.toShareResponseListPage(): Page<ShareResponse> {
return this.map { ShareResponse(it) }
}

fun List<ApplyShare>.toApplyShareResponseList(): List<AppliedUserDto> {
return this.map { AppliedUserDto(it) }
}
5 changes: 2 additions & 3 deletions src/main/kotlin/mara/server/domain/share/ShareService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,9 @@ class ShareService(
.toShareResponseListPage()
}

fun getAllApplyUserList(shareId: Long): List<String>? {
fun getAllApplyUserList(shareId: Long): List<AppliedUserDto>? {
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<ShareResponse>? {
Expand Down

0 comments on commit 69e25b7

Please sign in to comment.