-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
57 changed files
with
929 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...now-Api/src/main/kotlin/com/depromeet/whatnow/api/image/dto/PromiseImageDetailResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.depromeet.whatnow.api.image.dto | ||
|
||
import com.depromeet.whatnow.domains.image.domain.PromiseImage | ||
import com.depromeet.whatnow.domains.image.domain.PromiseImageCommentType | ||
|
||
data class PromiseImageDetailResponse( | ||
val uploadUserId: Long, | ||
val promiseImageCommentType: PromiseImageCommentType, | ||
) { | ||
companion object { | ||
fun from(promiseImage: PromiseImage): PromiseImageDetailResponse { | ||
return PromiseImageDetailResponse(promiseImage.userId, promiseImage.promiseImageCommentType) | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
Whatnow-Api/src/main/kotlin/com/depromeet/whatnow/api/image/dto/PromiseImageDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.depromeet.whatnow.api.image.dto | ||
|
||
import com.depromeet.whatnow.domains.image.domain.PromiseImage | ||
|
||
data class PromiseImageDto( | ||
val imageKey: String, | ||
val imageUrl: String, | ||
val uploadUserId: Long, | ||
) { | ||
companion object { | ||
fun from(promiseImage: PromiseImage): PromiseImageDto { | ||
return PromiseImageDto(promiseImage.imageKey, promiseImage.uri, promiseImage.userId) | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Whatnow-Api/src/main/kotlin/com/depromeet/whatnow/api/image/dto/PromiseImageResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.depromeet.whatnow.api.image.dto | ||
|
||
import com.depromeet.whatnow.domains.promiseuser.domain.PromiseUserType | ||
import io.swagger.v3.oas.annotations.media.Schema | ||
|
||
data class PromiseImageResponse( | ||
@Schema(description = "조회한 유저의 약속 상태 (LATE=빨강, WAIT=파랑)", example = "LATE") | ||
val promiseUserType: PromiseUserType, | ||
@Schema(description = "약속에 참여한 유저들의 사진 목록 (LATE, WAIT로 구분. WAIT는 가장 최신 1개만 존재") | ||
val promiseImages: MutableMap<PromiseUserType, List<PromiseImageDto>>, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...-Api/src/main/kotlin/com/depromeet/whatnow/api/image/usecase/PromiseImageDeleteUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.depromeet.whatnow.api.image.usecase | ||
|
||
import com.depromeet.whatnow.annotation.UseCase | ||
import com.depromeet.whatnow.config.security.SecurityUtils | ||
import com.depromeet.whatnow.domains.image.service.ImageDomainService | ||
|
||
@UseCase | ||
class PromiseImageDeleteUseCase( | ||
val imageDomainService: ImageDomainService, | ||
) { | ||
fun execute(promiseId: Long, imageKey: String) { | ||
val userId = SecurityUtils.currentUserId | ||
imageDomainService.deleteForPromise(userId, promiseId, imageKey) | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
...ow-Api/src/main/kotlin/com/depromeet/whatnow/api/image/usecase/PromiseImageReadUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.depromeet.whatnow.api.image.usecase | ||
|
||
import com.depromeet.whatnow.annotation.UseCase | ||
import com.depromeet.whatnow.api.image.dto.PromiseImageDetailResponse | ||
import com.depromeet.whatnow.api.image.dto.PromiseImageDto | ||
import com.depromeet.whatnow.api.image.dto.PromiseImageResponse | ||
import com.depromeet.whatnow.config.security.SecurityUtils | ||
import com.depromeet.whatnow.domains.image.service.ImageDomainService | ||
import com.depromeet.whatnow.domains.promiseuser.domain.PromiseUserType | ||
import com.depromeet.whatnow.domains.promiseuser.service.PromiseUserDomainService | ||
|
||
@UseCase | ||
class PromiseImageReadUseCase( | ||
val imageDomainService: ImageDomainService, | ||
val promiseUserDomainService: PromiseUserDomainService, | ||
) { | ||
|
||
fun getLateAndWaitImagesByPromiseId(promiseId: Long): PromiseImageResponse { | ||
var userId = SecurityUtils.currentUserId | ||
|
||
// 사진을 조회하는 유저의 Late, Wait 상태를 조회하기 위해 | ||
val promiseUser = promiseUserDomainService.findByPromiseIdAndUserId(promiseId, userId) | ||
|
||
val result: MutableMap<PromiseUserType, List<PromiseImageDto>> = mutableMapOf() | ||
val promiseImages = imageDomainService.getImagesByPromiseId(promiseId) | ||
|
||
// LATE의 사진 | ||
result[PromiseUserType.LATE] = ( | ||
promiseImages.filter { promiseImage -> promiseUserDomainService.findByPromiseIdAndUserId(promiseId, promiseImage.userId).promiseUserType == PromiseUserType.LATE } | ||
.sortedByDescending { promiseImage -> promiseImage.createdAt } | ||
.map { promiseImage -> | ||
PromiseImageDto(promiseImage.imageKey, promiseImage.uri, promiseImage.userId) | ||
}.toList() | ||
) | ||
|
||
// WAIT의 사진 (가장 최신 1개) | ||
result[PromiseUserType.WAIT] = ( | ||
promiseImages.filter { promiseImage -> promiseUserDomainService.findByPromiseIdAndUserId(promiseId, promiseImage.userId).promiseUserType == PromiseUserType.WAIT } | ||
.sortedByDescending { promiseImage -> promiseImage.createdAt } | ||
).firstOrNull()?.let { promiseImage -> | ||
listOf( | ||
PromiseImageDto(promiseImage.imageKey, promiseImage.uri, promiseImage.userId), | ||
) | ||
} ?: listOf() | ||
|
||
return PromiseImageResponse(promiseUser.promiseUserType!!, result) | ||
} | ||
|
||
fun getImagesByPromiseId(promiseId: Long): List<PromiseImageDto> { | ||
return imageDomainService.getImagesByPromiseId(promiseId) | ||
.map { PromiseImageDto.from(it) } | ||
} | ||
|
||
fun getImageByImageKey(imageKey: String): PromiseImageDetailResponse { | ||
return imageDomainService.getImageByImageKey(imageKey) | ||
.let { PromiseImageDetailResponse.from(it) } | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...now-Api/src/main/kotlin/com/depromeet/whatnow/api/image/usecase/UserImageDeleteUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.depromeet.whatnow.api.image.usecase | ||
|
||
import com.depromeet.whatnow.annotation.UseCase | ||
import com.depromeet.whatnow.config.security.SecurityUtils | ||
import com.depromeet.whatnow.domains.image.service.ImageDomainService | ||
|
||
@UseCase | ||
class UserImageDeleteUseCase( | ||
val imageDomainService: ImageDomainService, | ||
) { | ||
fun execute(imageKey: String) { | ||
val userId = SecurityUtils.currentUserId | ||
imageDomainService.deleteForUser(userId, imageKey) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.