Skip to content

Commit

Permalink
[DPMBE-102] 이미지를 약속 모음집 상세 응답 값에 추가한다 (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdomo authored Jul 7, 2023
1 parent fb07499 commit 07e62b6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ 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.image.adapter.PromiseImageAdapter
import com.depromeet.whatnow.domains.interaction.adapter.InteractionAdapter
import com.depromeet.whatnow.domains.promise.adaptor.PromiseAdaptor
import com.depromeet.whatnow.domains.promise.domain.Promise
Expand All @@ -27,6 +28,7 @@ class PromiseReadUseCase(
val userAdapter: UserAdapter,
val userRepository: UserRepository,
val interactionAdapter: InteractionAdapter,
val promiseImageAdapter: PromiseImageAdapter,
) {
/**
* method desc: 유저가 참여한 약속들을 약속 종류(BEFORE, PAST)에 따라 분리해서 조회
Expand Down Expand Up @@ -116,6 +118,10 @@ class PromiseReadUseCase(
}
}

val promiseImagesUrls = promiseImageAdapter.findAllByPromiseId(promise.id!!)
.sortedByDescending { it.createdAt }
.map { it.uri }

val timeOverLocations = promiseUsers.mapNotNull { promiseUser ->
promiseUser.userLocation?.let { location ->
LocationCapture(userId = promiseUser.userId, coordinateVo = location)
Expand All @@ -127,7 +133,7 @@ class PromiseReadUseCase(
promise = promise,
promiseUsers = promiseUserInfoVos,
timeOverLocations = timeOverLocations,
promiseImageUrls = mutableListOf(),
promiseImageUrls = promiseImagesUrls,
),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.depromeet.whatnow.api.promise.usecase

import com.depromeet.whatnow.common.vo.CoordinateVo
import com.depromeet.whatnow.common.vo.PlaceVo
import com.depromeet.whatnow.domains.image.adapter.PromiseImageAdapter
import com.depromeet.whatnow.domains.interaction.adapter.InteractionAdapter
import com.depromeet.whatnow.domains.interaction.domain.Interaction
import com.depromeet.whatnow.domains.interaction.domain.InteractionType
Expand Down Expand Up @@ -49,6 +50,9 @@ class PromiseReadUseCaseTest {
@Mock
private lateinit var interactionAdapter: InteractionAdapter

@Mock
private lateinit var promiseImageAdapter: PromiseImageAdapter

@InjectMocks
private lateinit var promiseReadUseCase: PromiseReadUseCase

Expand All @@ -61,6 +65,7 @@ class PromiseReadUseCaseTest {
promiseAdaptor = promiseAdaptor,
userAdapter = userAdapter,
interactionAdapter = interactionAdapter,
promiseImageAdapter = promiseImageAdapter,
)
val securityContext = SecurityContextHolder.createEmptyContext()
val authentication = UsernamePasswordAuthenticationToken("1", null, setOf(SimpleGrantedAuthority("ROLE_USER")))
Expand Down

0 comments on commit 07e62b6

Please sign in to comment.