Skip to content

Commit

Permalink
Merge pull request #123 from mash-up-kr/junhyoung/fix-mypage-me-remov…
Browse files Browse the repository at this point in the history
…e-coin-field

fix: remove coin, 비즈니스 로직 UseCase로 이동
  • Loading branch information
toychip authored Aug 23, 2024
2 parents 2e55535 + 61a9ceb commit 34118ff
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 19 deletions.
27 changes: 10 additions & 17 deletions api/src/main/kotlin/com/mashup/dojo/MemberController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -133,26 +133,19 @@ class MemberController(
val memberId = MemberPrincipalContextHolder.current().id

logger.info { "read my profile, $memberId" }
val member = memberService.findMemberById(memberId) ?: throw DojoException.of(DojoExceptionType.MEMBER_NOT_FOUND)
val profileImage = imageService.load(member.profileImageId) ?: throw DojoException.of(DojoExceptionType.IMAGE_NOT_FOUND)
val currentCoin =
coinUseCase.getCurrentCoin(
CoinUseCase.GetCurrentCoinCommand(member.id)
)
val pickedCount = pickService.findPickedCountByMemberId(member.id)
val friendCount = memberRelationService.countFriend(member.id)

val response = memberUseCase.findMyProfile(memberId)

return DojoApiResponse.success(
MyProfileResponse(
memberId = member.id.value,
profileImageUrl = profileImage.url,
memberName = member.fullName,
platform = member.platform.name,
ordinal = member.ordinal,
pickCount = pickedCount,
pickedCount = pickedCount,
friendCount = friendCount,
coinCount = currentCoin.amount.toInt()
memberId = response.memberId,
profileImageUrl = response.profileImageUrl,
memberName = response.memberName,
platform = response.platform,
ordinal = response.ordinal,
pickCount = response.pickCount,
pickedCount = response.pickedCount,
friendCount = response.friendCount
)
)
}
Expand Down
2 changes: 0 additions & 2 deletions api/src/main/kotlin/com/mashup/dojo/dto/MyProfileResponse.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,4 @@ data class MyProfileResponse(
val pickedCount: Int,
@Schema(description = "유저의 친구 수")
val friendCount: Int,
@Schema(description = "소유한 코인 개수")
val coinCount: Int,
)
31 changes: 31 additions & 0 deletions service/src/main/kotlin/com/mashup/dojo/usecase/MemberUseCase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ interface MemberUseCase {
val isFriend: Boolean,
)

data class MyPageInfo(
val memberId: String,
val profileImageUrl: String,
val memberName: String,
val platform: String,
val ordinal: Int,
val pickCount: Int,
val pickedCount: Int,
val friendCount: Int,
)

fun create(command: CreateCommand): MemberId

fun update(command: UpdateCommand): MemberId
Expand All @@ -81,6 +92,8 @@ interface MemberUseCase {
): List<MemberSearchInfo>

fun receivedFriendSpacePicks(currentMemberId: MemberId): List<PickService.SpacePickDetail>

fun findMyProfile(memberId: MemberId): MyPageInfo
}

@Component
Expand Down Expand Up @@ -220,4 +233,22 @@ class DefaultMemberUseCase(
val mySpacePicks = pickService.getReceivedSpacePicks(currentMemberId)
return mySpacePicks.calculateRanks()
}

override fun findMyProfile(memberId: MemberId): MemberUseCase.MyPageInfo {
val member = memberService.findMemberById(memberId) ?: throw DojoException.of(DojoExceptionType.MEMBER_NOT_FOUND)
val profileImage = imageService.load(member.profileImageId) ?: throw DojoException.of(DojoExceptionType.IMAGE_NOT_FOUND)
val pickedCount = pickService.findPickedCountByMemberId(member.id)
val friendCount = memberRelationService.countFriend(member.id)

return MemberUseCase.MyPageInfo(
memberId = memberId.value,
profileImageUrl = profileImage.url,
memberName = member.fullName,
platform = member.platform.name,
ordinal = member.ordinal,
pickCount = pickedCount,
pickedCount = pickedCount,
friendCount = friendCount
)
}
}

0 comments on commit 34118ff

Please sign in to comment.