Skip to content

[DEMBE-90] 약속에 참여한 유저의 인터렉션 정보를 약속 모음집 상세 응답값에 추가한다 #147

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.depromeet.whatnow.api.promise.dto

import com.depromeet.whatnow.api.interaction.dto.InteractionDto
import com.depromeet.whatnow.domains.promiseuser.domain.PromiseUserType
import com.depromeet.whatnow.domains.user.domain.User

Expand All @@ -8,13 +9,12 @@ data class PromiseUserInfoVo(
val nickname: String,
val isDefaultImg: Boolean,
val promiseUserType: PromiseUserType,
// TODO : Interaction 리스트 ( ex. POOP : 1, MUSIC : 2, ... )
// val interactions: List<Interaction>
val interactions: List<InteractionDto>,
) {
// interaction 기능 추가시 함께 추가할게요.
companion object {
fun of(user: User, promiseUserType: PromiseUserType): PromiseUserInfoVo {
return PromiseUserInfoVo(user.profileImg, user.nickname, user.isDefaultImg, promiseUserType)
fun of(user: User, promiseUserType: PromiseUserType, interactionDtoList: List<InteractionDto>): PromiseUserInfoVo {
val list = interactionDtoList.sortedByDescending { interactionDto -> interactionDto.count }
return PromiseUserInfoVo(user.profileImg, user.nickname, user.isDefaultImg, promiseUserType, list)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.depromeet.whatnow.api.promise.usecase

import com.depromeet.whatnow.annotation.UseCase
import com.depromeet.whatnow.api.interaction.dto.InteractionDto
import com.depromeet.whatnow.api.promise.dto.LocationCapture
import com.depromeet.whatnow.api.promise.dto.PromiseDetailDto
import com.depromeet.whatnow.api.promise.dto.PromiseFindDto
import com.depromeet.whatnow.api.promise.dto.PromiseUserInfoVo
import com.depromeet.whatnow.common.vo.UserInfoVo
import com.depromeet.whatnow.config.security.SecurityUtils
import com.depromeet.whatnow.domains.interaction.adapter.InteractionAdapter
import com.depromeet.whatnow.domains.promise.adaptor.PromiseAdaptor
import com.depromeet.whatnow.domains.promise.domain.Promise
import com.depromeet.whatnow.domains.promise.domain.PromiseType
Expand All @@ -23,6 +25,7 @@ class PromiseReadUseCase(
val promiseUserAdaptor: PromiseUserAdaptor,
val userAdapter: UserAdapter,
val userRepository: UserRepository,
val interactionAdapter: InteractionAdapter,
) {
/**
* method desc: 유저가 참여한 약속들을 약속 종류(BEFORE, PAST)에 따라 분리해서 조회
Expand Down Expand Up @@ -115,7 +118,15 @@ class PromiseReadUseCase(
val promiseUsers = promiseUsersByPromiseId.filter { it.promiseId == promise.id }
val promiseUserInfoVos = promiseUsers.mapNotNull { promiseUser ->
val user = users.find { it.id == promiseUser.userId }
Comment on lines 119 to 120
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

promiseUser-> 를 썼는데 it 을 쓰는게 상관은 없지만 맥락상 통일하는게 좋지 않을까요?

user?.let { PromiseUserInfoVo.of(it, promiseUser.promiseUserType!!) }

// 유저의 Interaction 정보를 조회 (인터렉션 개수 순으로 내림차순 정렬)
val interactions =
interactionAdapter.queryAllInteraction(promiseUser.promiseId, promiseUser.userId)
.map { InteractionDto.from(it) }
.sortedByDescending { interactionDto -> interactionDto.count }
user?.let {
PromiseUserInfoVo.of(it, promiseUser.promiseUserType!!, interactions)
}
}

val timeOverLocations = promiseUsers.mapNotNull { promiseUser ->
Expand Down