diff --git a/Whatnow-Api/src/main/kotlin/com/depromeet/whatnow/api/image/controller/ImageController.kt b/Whatnow-Api/src/main/kotlin/com/depromeet/whatnow/api/image/controller/ImageController.kt index 94549e46..c213ce17 100644 --- a/Whatnow-Api/src/main/kotlin/com/depromeet/whatnow/api/image/controller/ImageController.kt +++ b/Whatnow-Api/src/main/kotlin/com/depromeet/whatnow/api/image/controller/ImageController.kt @@ -1,7 +1,9 @@ package com.depromeet.whatnow.api.image.controller +import com.depromeet.whatnow.api.image.dto.ImageCommentElement import com.depromeet.whatnow.api.image.dto.ImageUrlResponse import com.depromeet.whatnow.api.image.usecase.GetPresignedUrlUseCase +import com.depromeet.whatnow.api.image.usecase.ImageCommentReadUseCase import com.depromeet.whatnow.api.image.usecase.ImageUploadSuccessUseCase import com.depromeet.whatnow.common.vo.CoordinateVo import com.depromeet.whatnow.config.s3.ImageFileExtension @@ -25,6 +27,7 @@ import javax.validation.Valid class ImageController( val getPresignedUrlUseCase: GetPresignedUrlUseCase, val successUseCase: ImageUploadSuccessUseCase, + val imageCommentReadUseCase: ImageCommentReadUseCase, ) { @Operation(summary = "약속 이미지 업로드 Presigned URL 발급") @GetMapping("/images/promises/{promiseId}") @@ -60,4 +63,10 @@ class ImageController( fun userUploadImageSuccess(@PathVariable imageKey: String) { successUseCase.userUploadImageSuccess(imageKey) } + + @Operation(summary = "이미지 코멘트를 이넘으로 확인합니다. 주의!! 스웨거 이넘 예시 값과 실제 요청했을 때 값이 달라요 실제 요청값 기준으로 해주세요") + @GetMapping("/images/comments") + fun getImageCommentType(): List { + return imageCommentReadUseCase.execute() + } } diff --git a/Whatnow-Api/src/main/kotlin/com/depromeet/whatnow/api/image/dto/ImageCommentElement.kt b/Whatnow-Api/src/main/kotlin/com/depromeet/whatnow/api/image/dto/ImageCommentElement.kt new file mode 100644 index 00000000..c67085f1 --- /dev/null +++ b/Whatnow-Api/src/main/kotlin/com/depromeet/whatnow/api/image/dto/ImageCommentElement.kt @@ -0,0 +1,9 @@ +package com.depromeet.whatnow.api.image.dto + +import com.depromeet.whatnow.domains.image.domain.PromiseImageCommentType +import com.depromeet.whatnow.domains.promiseuser.domain.PromiseUserType + +data class ImageCommentElement( + val promiseUserType: PromiseUserType, + val comments: List, +) diff --git a/Whatnow-Api/src/main/kotlin/com/depromeet/whatnow/api/image/usecase/ImageCommentReadUseCase.kt b/Whatnow-Api/src/main/kotlin/com/depromeet/whatnow/api/image/usecase/ImageCommentReadUseCase.kt new file mode 100644 index 00000000..e1402cfc --- /dev/null +++ b/Whatnow-Api/src/main/kotlin/com/depromeet/whatnow/api/image/usecase/ImageCommentReadUseCase.kt @@ -0,0 +1,18 @@ +package com.depromeet.whatnow.api.image.usecase + +import com.depromeet.whatnow.annotation.UseCase +import com.depromeet.whatnow.api.image.dto.ImageCommentElement +import com.depromeet.whatnow.domains.image.domain.PromiseImageCommentType + +@UseCase +class ImageCommentReadUseCase { + fun execute(): List { + return PromiseImageCommentType.values().groupBy { + p -> + p.promiseUserType + }.map { + (k, value) -> + ImageCommentElement(k, value) + } + } +} diff --git a/Whatnow-Api/src/main/kotlin/com/depromeet/whatnow/api/promise/dto/PromiseUserInfoVo.kt b/Whatnow-Api/src/main/kotlin/com/depromeet/whatnow/api/promise/dto/PromiseUserInfoVo.kt index d10d9400..008a7c76 100644 --- a/Whatnow-Api/src/main/kotlin/com/depromeet/whatnow/api/promise/dto/PromiseUserInfoVo.kt +++ b/Whatnow-Api/src/main/kotlin/com/depromeet/whatnow/api/promise/dto/PromiseUserInfoVo.kt @@ -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 @@ -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 + val interactions: List, ) { - // 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): PromiseUserInfoVo { + val list = interactionDtoList.sortedByDescending { interactionDto -> interactionDto.count } + return PromiseUserInfoVo(user.profileImg, user.nickname, user.isDefaultImg, promiseUserType, list) } } } diff --git a/Whatnow-Api/src/main/kotlin/com/depromeet/whatnow/api/promise/usecase/PromiseReadUseCase.kt b/Whatnow-Api/src/main/kotlin/com/depromeet/whatnow/api/promise/usecase/PromiseReadUseCase.kt index 378845e2..7fa5f1a5 100644 --- a/Whatnow-Api/src/main/kotlin/com/depromeet/whatnow/api/promise/usecase/PromiseReadUseCase.kt +++ b/Whatnow-Api/src/main/kotlin/com/depromeet/whatnow/api/promise/usecase/PromiseReadUseCase.kt @@ -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 @@ -23,6 +25,7 @@ class PromiseReadUseCase( val promiseUserAdaptor: PromiseUserAdaptor, val userAdapter: UserAdapter, val userRepository: UserRepository, + val interactionAdapter: InteractionAdapter, ) { /** * method desc: 유저가 참여한 약속들을 약속 종류(BEFORE, PAST)에 따라 분리해서 조회 @@ -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 } - 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 -> diff --git a/Whatnow-Api/src/test/kotlin/com/depromeet/whatnow/api/image/controller/PromiseImageControllerTest.kt b/Whatnow-Api/src/test/kotlin/com/depromeet/whatnow/api/image/controller/PromiseImageControllerTest.kt index fbf5e548..88a26e1f 100644 --- a/Whatnow-Api/src/test/kotlin/com/depromeet/whatnow/api/image/controller/PromiseImageControllerTest.kt +++ b/Whatnow-Api/src/test/kotlin/com/depromeet/whatnow/api/image/controller/PromiseImageControllerTest.kt @@ -1,6 +1,7 @@ package com.depromeet.whatnow.api.image.controller import com.depromeet.whatnow.api.image.usecase.GetPresignedUrlUseCase +import com.depromeet.whatnow.api.image.usecase.ImageCommentReadUseCase import com.depromeet.whatnow.api.image.usecase.ImageUploadSuccessUseCase import com.depromeet.whatnow.common.vo.CoordinateVo import com.depromeet.whatnow.config.s3.ImageFileExtension @@ -28,6 +29,9 @@ class PromiseImageControllerTest { @MockBean lateinit var successUseCase: ImageUploadSuccessUseCase + @MockBean + lateinit var imageCommentReadUseCase: ImageCommentReadUseCase + @Autowired lateinit var mockMvc: MockMvc diff --git a/Whatnow-Api/src/test/kotlin/com/depromeet/whatnow/api/promise/usecase/PromiseReadUseCaseTest.kt b/Whatnow-Api/src/test/kotlin/com/depromeet/whatnow/api/promise/usecase/PromiseReadUseCaseTest.kt index 272baa33..c1478a6a 100644 --- a/Whatnow-Api/src/test/kotlin/com/depromeet/whatnow/api/promise/usecase/PromiseReadUseCaseTest.kt +++ b/Whatnow-Api/src/test/kotlin/com/depromeet/whatnow/api/promise/usecase/PromiseReadUseCaseTest.kt @@ -1,5 +1,8 @@ package com.depromeet.whatnow.api.promise.usecase +import com.depromeet.whatnow.domains.interaction.adapter.InteractionAdapter +import com.depromeet.whatnow.domains.interaction.domain.Interaction +import com.depromeet.whatnow.domains.interaction.domain.InteractionType import com.depromeet.whatnow.domains.promise.adaptor.PromiseAdaptor import com.depromeet.whatnow.domains.promise.domain.Promise import com.depromeet.whatnow.domains.promise.domain.PromiseType @@ -41,6 +44,9 @@ class PromiseReadUseCaseTest { @Mock private lateinit var userRepository: UserRepository + @Mock + private lateinit var interactionAdapter: InteractionAdapter + @InjectMocks private lateinit var promiseReadUseCase: PromiseReadUseCase @@ -52,6 +58,7 @@ class PromiseReadUseCaseTest { promiseUserAdaptor = promiseUserAdaptor, promiseAdaptor = promiseAdaptor, userAdapter = userAdapter, + interactionAdapter = interactionAdapter, ) val securityContext = SecurityContextHolder.createEmptyContext() val authentication = UsernamePasswordAuthenticationToken("1", null, setOf(SimpleGrantedAuthority("ROLE_USER"))) @@ -92,10 +99,17 @@ class PromiseReadUseCaseTest { id = 2, ), ) + val interactions = listOf( + Interaction(InteractionType.HEART, 1, 1, 242), + Interaction(InteractionType.MUSIC, 1, 1, 1234), + Interaction(InteractionType.POOP, 1, 1, 12), + Interaction(InteractionType.STEP, 1, 1, 2934), + ) Mockito.`when`(promiseUserAdaptor.findByUserId(userId)).thenReturn(promiseUsers) Mockito.`when`(promiseAdaptor.queryPromises(listOf(1, 2))).thenReturn(promises) Mockito.`when`(userAdapter.queryUsers(listOf(1))).thenReturn(users) + Mockito.`when`(interactionAdapter.queryAllInteraction(1, 1)).thenReturn(interactions) // When val result = promiseReadUseCase.findPromiseDetailByStatus(PromiseType.BEFORE) @@ -110,5 +124,8 @@ class PromiseReadUseCaseTest { Assertions.assertEquals("Promise 2", result[1].title) Assertions.assertEquals(promiseTime2, result[1].date) Assertions.assertEquals(1, result[1].promiseUsers.size) + + Assertions.assertEquals(2934, result[0].promiseUsers[0].interactions[0].count) + Assertions.assertEquals(1234, result[0].promiseUsers[0].interactions[1].count) } } diff --git a/Whatnow-Api/src/test/kotlin/com/depromeet/whatnow/api/promiseuser/usecase/PromiseUserDomainServiceTest.kt b/Whatnow-Api/src/test/kotlin/com/depromeet/whatnow/api/promiseuser/usecase/PromiseUserDomainServiceTest.kt new file mode 100644 index 00000000..6475b9e2 --- /dev/null +++ b/Whatnow-Api/src/test/kotlin/com/depromeet/whatnow/api/promiseuser/usecase/PromiseUserDomainServiceTest.kt @@ -0,0 +1,34 @@ +package com.depromeet.whatnow.api.promiseuser.usecase + +import com.depromeet.whatnow.common.vo.CoordinateVo +import com.depromeet.whatnow.domains.promiseuser.adaptor.PromiseUserAdaptor +import com.depromeet.whatnow.domains.promiseuser.domain.PromiseUser +import com.depromeet.whatnow.domains.promiseuser.service.PromiseUserDomainService +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test +import org.mockito.Mock +import org.mockito.MockitoAnnotations + +class PromiseUserDomainServiceTest { + @Mock + private lateinit var promiseUserAdaptor: PromiseUserAdaptor + + private lateinit var promiseUserDomainService: PromiseUserDomainService + + @BeforeEach + fun setUp() { + MockitoAnnotations.openMocks(this) + promiseUserDomainService = PromiseUserDomainService(promiseUserAdaptor = promiseUserAdaptor) + } + + @Test + fun `500미터 안에 인접해 있으면 도착했다 정의`() { + val a = PromiseUser(userLocation = CoordinateVo(35.866334, 127.146223), promiseId = 1L, userId = 1L) + val b = CoordinateVo(35.866355, 127.146230) + // 실제 거리 : 2.41878882096224 m +// when and return + val arrived = promiseUserDomainService.isArrived(a, b) + assertEquals(true, arrived) + } +} diff --git a/Whatnow-Common/src/main/kotlin/com/depromeet/whatnow/consts/WhatNowStatic.kt b/Whatnow-Common/src/main/kotlin/com/depromeet/whatnow/consts/WhatNowStatic.kt index 298684b6..795ce05f 100644 --- a/Whatnow-Common/src/main/kotlin/com/depromeet/whatnow/consts/WhatNowStatic.kt +++ b/Whatnow-Common/src/main/kotlin/com/depromeet/whatnow/consts/WhatNowStatic.kt @@ -25,8 +25,12 @@ const val PROD = "prod" const val DEV = "dev" const val LOCAL = "local" const val WITHDRAW_PREFIX = "withdraw" +const val RADIUS_WAIT_CONFIRM = 200 const val IMAGE_DOMAIN = "https://image.whatnow.kr" +const val ASSERT_IMAGE_DOMAIN = "https://image.whatnow.kr/assert" + +const val REDIS_EXPIRE_EVENT_PATTERN = "__keyevent@*__:expired" val SWAGGER_PATTERNS = arrayOf( "/swagger-resources/**", diff --git a/Whatnow-Domain/build.gradle.kts b/Whatnow-Domain/build.gradle.kts index 72b40ada..2e96fb4d 100644 --- a/Whatnow-Domain/build.gradle.kts +++ b/Whatnow-Domain/build.gradle.kts @@ -4,6 +4,7 @@ dependencies { api("org.springframework.boot:spring-boot-starter-data-jpa") api("org.springframework.boot:spring-boot-starter-data-redis") api("com.mysql:mysql-connector-j") + implementation("com.google.geometry:s2-geometry:2.0.0") implementation(project(":Whatnow-Infrastructure")) implementation(project(":Whatnow-Common")) api("com.h2database:h2") diff --git a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/config/RedisMessageListenerConfig.kt b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/config/RedisMessageListenerConfig.kt new file mode 100644 index 00000000..f8738b3f --- /dev/null +++ b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/config/RedisMessageListenerConfig.kt @@ -0,0 +1,23 @@ +package com.depromeet.whatnow.config + +import com.depromeet.whatnow.consts.REDIS_EXPIRE_EVENT_PATTERN +import com.depromeet.whatnow.domains.promiseactive.listener.RedisExpireEventRedisMessageListener +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration +import org.springframework.data.redis.connection.RedisConnectionFactory +import org.springframework.data.redis.listener.PatternTopic +import org.springframework.data.redis.listener.RedisMessageListenerContainer + +@Configuration +class RedisMessageListenerConfig { + @Bean + fun redisMessageListenerContainer( + redisConnectionFactory: RedisConnectionFactory, + redisExpireEventRedisMessageListener: RedisExpireEventRedisMessageListener, + ): RedisMessageListenerContainer { + val redisMessageListenerContainer = RedisMessageListenerContainer() + redisMessageListenerContainer.setConnectionFactory(redisConnectionFactory) + redisMessageListenerContainer.addMessageListener(redisExpireEventRedisMessageListener, PatternTopic(REDIS_EXPIRE_EVENT_PATTERN)) + return redisMessageListenerContainer + } +} diff --git a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/image/domain/PromiseImageCommentType.kt b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/image/domain/PromiseImageCommentType.kt index 5587c6df..3c0c00d5 100644 --- a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/image/domain/PromiseImageCommentType.kt +++ b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/image/domain/PromiseImageCommentType.kt @@ -1,19 +1,28 @@ package com.depromeet.whatnow.domains.image.domain +import com.depromeet.whatnow.consts.ASSERT_IMAGE_DOMAIN import com.depromeet.whatnow.domains.promiseuser.domain.PromiseUserType +import com.fasterxml.jackson.annotation.JsonFormat -enum class PromiseImageCommentType(val value: String, val promiseUserType: PromiseUserType?) { +@JsonFormat(shape = JsonFormat.Shape.OBJECT) +enum class PromiseImageCommentType( + val promiseUserType: PromiseUserType, + val kr: String, + val code: String, + val image: String, + val imageSmall: String, +) { // Can LATE - RUNNING("달려가는 중️", PromiseUserType.LATE), - GASPING("헐레벌떡", PromiseUserType.LATE), - LEAVE_SOME("남겨놔!", PromiseUserType.LATE), - WAIT_A_BIT("조금만 기다려", PromiseUserType.LATE), - SORRY_LATE("늦어서 미안해", PromiseUserType.LATE), + RUNNING(PromiseUserType.LATE, "달려가는 중️", "RUNNING", "$ASSERT_IMAGE_DOMAIN/comments/RUNNING.svg", "$ASSERT_IMAGE_DOMAIN/comments/RUNNING_SMALL.svg"), + GASPING(PromiseUserType.LATE, "헐레벌떡", "GASPING", "$ASSERT_IMAGE_DOMAIN/comments/GASPING.svg", "$ASSERT_IMAGE_DOMAIN/comments/GASPING_SMALL.svg"), + LEAVE_SOME(PromiseUserType.LATE, "남겨놔!", "LEAVE_SOME", "$ASSERT_IMAGE_DOMAIN/comments/LEAVE_SOME.svg", "$ASSERT_IMAGE_DOMAIN/comments/LEAVE_SOME_SMALL.svg"), + WAIT_A_BIT(PromiseUserType.LATE, "조금만 기다려", "WAIT_A_BIT", "$ASSERT_IMAGE_DOMAIN/comments/WAIT_A_BIT.svg", "$ASSERT_IMAGE_DOMAIN/comments/WAIT_A_BIT_SMALL.svg"), + SORRY_LATE(PromiseUserType.LATE, "늦어서 미안해", "SORRY_LATE", "$ASSERT_IMAGE_DOMAIN/comments/SORRY_LATE.svg", "$ASSERT_IMAGE_DOMAIN/comments/SORRY_LATE_SMALL.svg"), // Can WAIT - WHAT_ARE_YOU_DOING("뭐해 심심해", PromiseUserType.WAIT), - WHAT_TIME_IS_IT_NOW("지금이 몇시야!", PromiseUserType.WAIT), - DID_YOU_COME("왔나..?", PromiseUserType.WAIT), - I_LL_EAT_FIRST("먼저 먹을게~", PromiseUserType.WAIT), - WHERE_ARE_YOU("너 어디야?", PromiseUserType.WAIT), + WHAT_ARE_YOU_DOING(PromiseUserType.WAIT, "뭐해 심심해", "WHAT_ARE_YOU_DOING", "$ASSERT_IMAGE_DOMAIN/comments/WHAT_ARE_YOU_DOING.svg", "$ASSERT_IMAGE_DOMAIN/comments/WHAT_ARE_YOU_DOING_SMALL.svg"), + WHAT_TIME_IS_IT_NOW(PromiseUserType.WAIT, "지금이 몇시야!", "WHAT_TIME_IS_IT_NOW", "$ASSERT_IMAGE_DOMAIN/comments/WHAT_TIME_IS_IT_NOW.svg", "$ASSERT_IMAGE_DOMAIN/comments/WHAT_TIME_IS_IT_NOW_SMALL.svg"), + DID_YOU_COME(PromiseUserType.WAIT, "왔나..?", "DID_YOU_COME", "$ASSERT_IMAGE_DOMAIN/comments/DID_YOU_COME.svg", "$ASSERT_IMAGE_DOMAIN/comments/DID_YOU_COME_SMALL.svg"), + I_LL_EAT_FIRST(PromiseUserType.WAIT, "먼저 먹을게~", "I_LL_EAT_FIRST", "$ASSERT_IMAGE_DOMAIN/comments/I_LL_EAT_FIRST.svg", "$ASSERT_IMAGE_DOMAIN/comments/I_LL_EAT_FIRST_SMALL.svg"), + WHERE_ARE_YOU(PromiseUserType.WAIT, "너 어디야?", "WHERE_ARE_YOU", "$ASSERT_IMAGE_DOMAIN/comments/WHERE_ARE_YOU.svg", "$ASSERT_IMAGE_DOMAIN/comments/WHERE_ARE_YOU_SMALL.svg"), } diff --git a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/progresshistory/domain/PromiseProgress.kt b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/progresshistory/domain/PromiseProgress.kt index bc095d7d..aa10bbcc 100644 --- a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/progresshistory/domain/PromiseProgress.kt +++ b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/progresshistory/domain/PromiseProgress.kt @@ -1,5 +1,6 @@ package com.depromeet.whatnow.domains.progresshistory.domain +import com.depromeet.whatnow.consts.ASSERT_IMAGE_DOMAIN import com.fasterxml.jackson.annotation.JsonFormat @JsonFormat(shape = JsonFormat.Shape.OBJECT) @@ -7,18 +8,19 @@ enum class PromiseProgress( val progressGroup: PromiseProgressGroup, val kr: String, val code: String, + val image: String, ) { - SHOWER(PromiseProgressGroup.PREPARING, "씻는 중", "SHOWER"), - LEAVE_SOON(PromiseProgressGroup.PREPARING, "곧 나가", "LEAVE_SOON"), - BED(PromiseProgressGroup.PREPARING, "아직 침대", "BED"), - WALKING(PromiseProgressGroup.MOVING, "걸어가는 중", "WALKING"), - RUNNING(PromiseProgressGroup.MOVING, "뛰고 있어", "RUNNING"), - BOARDING(PromiseProgressGroup.MOVING, "탑승 중", "BOARDING"), - SORRY(PromiseProgressGroup.LATE, "미안해", "SORRY"), - TEAR(PromiseProgressGroup.LATE, "눈물 줄줄", "TEAR"), - URGENCY(PromiseProgressGroup.LATE, "급하다!!", "URGENCY"), - AFTER_SOON(PromiseProgressGroup.EXPECTED_TIME, "곧 도착", "AFTER_SOON"), - AFTER_5(PromiseProgressGroup.EXPECTED_TIME, "5분 뒤 도착", "AFTER_5"), - AFTER_10(PromiseProgressGroup.EXPECTED_TIME, "10분 뒤 도착", "AFTER_10"), - DEFAULT(PromiseProgressGroup.DEFAULT, "기본", "DEFAULT"), + SHOWER(PromiseProgressGroup.PREPARING, "씻는 중", "SHOWER", "$ASSERT_IMAGE_DOMAIN/progresses/SHOWER.svg"), + LEAVE_SOON(PromiseProgressGroup.PREPARING, "곧 나가", "LEAVE_SOON", "$ASSERT_IMAGE_DOMAIN/progresses/LEAVE_SOON.svg"), + BED(PromiseProgressGroup.PREPARING, "아직 침대", "BED", "$ASSERT_IMAGE_DOMAIN/progresses/BED.svg"), + WALKING(PromiseProgressGroup.MOVING, "걸어가는 중", "WALKING", "$ASSERT_IMAGE_DOMAIN/progresses/WALKING.svg"), + RUNNING(PromiseProgressGroup.MOVING, "뛰고 있어", "RUNNING", "$ASSERT_IMAGE_DOMAIN/progresses/RUNNING.svg"), + BOARDING(PromiseProgressGroup.MOVING, "탑승 중", "BOARDING", "$ASSERT_IMAGE_DOMAIN/progresses/BOARDING.svg"), + SORRY(PromiseProgressGroup.LATE, "미안해", "SORRY", "$ASSERT_IMAGE_DOMAIN/progresses/SORRY.svg"), + TEAR(PromiseProgressGroup.LATE, "눈물 줄줄", "TEAR", "$ASSERT_IMAGE_DOMAIN/progresses/TEAR.svg"), + URGENCY(PromiseProgressGroup.LATE, "급하다!!", "URGENCY", "$ASSERT_IMAGE_DOMAIN/progresses/URGENCY.svg"), + AFTER_SOON(PromiseProgressGroup.EXPECTED_TIME, "곧 도착", "AFTER_SOON", "$ASSERT_IMAGE_DOMAIN/progresses/AFTER_SOON.svg"), + AFTER_5(PromiseProgressGroup.EXPECTED_TIME, "5분 뒤 도착", "AFTER_5", "$ASSERT_IMAGE_DOMAIN/progresses/AFTER_5.svg"), + AFTER_10(PromiseProgressGroup.EXPECTED_TIME, "10분 뒤 도착", "AFTER_10", "$ASSERT_IMAGE_DOMAIN/progresses/AFTER_10.svg"), + DEFAULT(PromiseProgressGroup.DEFAULT, "기본", "DEFAULT", "$ASSERT_IMAGE_DOMAIN/progresses/DEFAULT.svg"), } diff --git a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/promise/service/PromiseDomainService.kt b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/promise/service/PromiseDomainService.kt index e61b819f..54625a47 100644 --- a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/promise/service/PromiseDomainService.kt +++ b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/promise/service/PromiseDomainService.kt @@ -13,7 +13,6 @@ import javax.transaction.Transactional class PromiseDomainService( val promiseAdaptor: PromiseAdaptor, ) { - fun registerPromise( endTime: LocalDateTime, title: String, diff --git a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/promiseactive/adapter/PromiseActiveAdapter.kt b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/promiseactive/adapter/PromiseActiveAdapter.kt new file mode 100644 index 00000000..6d84c06f --- /dev/null +++ b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/promiseactive/adapter/PromiseActiveAdapter.kt @@ -0,0 +1,14 @@ +package com.depromeet.whatnow.domains.promiseactive.adapter + +import com.depromeet.whatnow.annotation.Adapter +import com.depromeet.whatnow.domains.promiseactive.domain.PromiseActiveRedisEntity +import com.depromeet.whatnow.domains.promiseactive.repository.PromiseActiveRepository + +@Adapter +class PromiseActiveAdapter( + val promiseActiveRepository: PromiseActiveRepository, +) { + fun save(promiseActiveRedisEntity: PromiseActiveRedisEntity): PromiseActiveRedisEntity { + return promiseActiveRepository.save(promiseActiveRedisEntity) + } +} diff --git a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/promiseactive/domain/PromiseActiveRedisEntity.kt b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/promiseactive/domain/PromiseActiveRedisEntity.kt new file mode 100644 index 00000000..7675cd7a --- /dev/null +++ b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/promiseactive/domain/PromiseActiveRedisEntity.kt @@ -0,0 +1,14 @@ +package com.depromeet.whatnow.domains.promiseactive.domain + +import org.springframework.data.annotation.Id +import org.springframework.data.redis.core.RedisHash +import org.springframework.data.redis.core.TimeToLive + +@RedisHash(value = "promiseActive") +class PromiseActiveRedisEntity( + @Id + var key: String, + + @TimeToLive // TTL + var ttl: Long, +) diff --git a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/promiseactive/listener/RedisExpireEventRedisMessageListener.kt b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/promiseactive/listener/RedisExpireEventRedisMessageListener.kt new file mode 100644 index 00000000..589f304b --- /dev/null +++ b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/promiseactive/listener/RedisExpireEventRedisMessageListener.kt @@ -0,0 +1,42 @@ +package com.depromeet.whatnow.domains.promiseactive.listener + +import com.depromeet.whatnow.common.aop.event.Events +import com.depromeet.whatnow.events.domainEvent.PromiseTimeEndEvent +import com.depromeet.whatnow.events.domainEvent.PromiseTimeStartEvent +import com.depromeet.whatnow.events.domainEvent.PromiseTrackingTimeEndEvent +import org.springframework.data.redis.connection.Message +import org.springframework.data.redis.connection.MessageListener +import org.springframework.stereotype.Component +import org.springframework.transaction.annotation.Transactional + +@Component +class RedisExpireEventRedisMessageListener : MessageListener { + @Transactional + override fun onMessage(message: Message, pattern: ByteArray?) { + val event = message.toString() + val eventParts = event.split("_") + + if (!event.startsWith("EXPIRE_EVENT_") || eventParts.size < 6) { + return + } + + val promiseId = eventParts[5].toLong() + when (event) { + "EXPIRE_EVENT_PROMISE_TIME_START_$promiseId" -> handlePromiseTimeStart(promiseId) + "EXPIRE_EVENT_PROMISE_TIME_END_$promiseId" -> handlePromiseTimeEnd(promiseId) + "EXPIRE_EVENT_TRACKING_TIME_START_$promiseId" -> handleTrackingTimeEnd(promiseId) + } + } + + private fun handlePromiseTimeStart(key: Long) { + Events.raise(PromiseTimeStartEvent(key)) + } + + private fun handlePromiseTimeEnd(key: Long) { + Events.raise(PromiseTimeEndEvent(key)) + } + + private fun handleTrackingTimeEnd(key: Long) { + Events.raise(PromiseTrackingTimeEndEvent(key)) + } +} diff --git a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/promiseactive/repository/PromiseActiveRepository.kt b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/promiseactive/repository/PromiseActiveRepository.kt new file mode 100644 index 00000000..2ebb313d --- /dev/null +++ b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/promiseactive/repository/PromiseActiveRepository.kt @@ -0,0 +1,6 @@ +package com.depromeet.whatnow.domains.promiseactive.repository + +import com.depromeet.whatnow.domains.promiseactive.domain.PromiseActiveRedisEntity +import org.springframework.data.repository.CrudRepository + +interface PromiseActiveRepository : CrudRepository diff --git a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/promiseuser/domain/PromiseUser.kt b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/promiseuser/domain/PromiseUser.kt index 73f19e3a..cc1fe9a9 100644 --- a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/promiseuser/domain/PromiseUser.kt +++ b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/promiseuser/domain/PromiseUser.kt @@ -58,4 +58,10 @@ class PromiseUser( fun updatePromiseUserType(promiseUserType: PromiseUserType?) { this.promiseUserType = promiseUserType } + fun updatePromiseUserLocation(userLocation: CoordinateVo?) { + this.userLocation = userLocation + } + fun userLocationInit() { + this.userLocation = CoordinateVo(0.0, 0.0) + } } diff --git a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/promiseuser/service/PromiseUserDomainService.kt b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/promiseuser/service/PromiseUserDomainService.kt index e97091bb..a7cc56fa 100644 --- a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/promiseuser/service/PromiseUserDomainService.kt +++ b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/promiseuser/service/PromiseUserDomainService.kt @@ -1,8 +1,11 @@ package com.depromeet.whatnow.domains.promiseuser.service +import com.depromeet.whatnow.common.vo.CoordinateVo +import com.depromeet.whatnow.consts.RADIUS_WAIT_CONFIRM import com.depromeet.whatnow.domains.promiseuser.adaptor.PromiseUserAdaptor import com.depromeet.whatnow.domains.promiseuser.domain.PromiseUser import com.depromeet.whatnow.domains.promiseuser.domain.PromiseUserType +import com.google.common.geometry.S2LatLng import org.springframework.stereotype.Service import javax.transaction.Transactional @@ -42,8 +45,11 @@ class PromiseUserDomainService( fun findByPromiseId(promiseId: Long): List { return promiseUserAdaptor.findByPromiseId(promiseId) } + fun isArrived(promiseUser: PromiseUser, coordinate: CoordinateVo): Boolean { + val start = S2LatLng.fromDegrees(promiseUser.userLocation!!.latitude, promiseUser.userLocation!!.longitude) + val destination = S2LatLng.fromDegrees(coordinate.latitude, coordinate.longitude) + val distanceInMeters = start.getDistance(destination).radians() * 6371000.0 - fun findByUserId(userId: Long): List { - return promiseUserAdaptor.findByUserId(userId) + return distanceInMeters < RADIUS_WAIT_CONFIRM } } diff --git a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/events/domainEvent/PromiseTimeEndEvent.kt b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/events/domainEvent/PromiseTimeEndEvent.kt new file mode 100644 index 00000000..a701bb19 --- /dev/null +++ b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/events/domainEvent/PromiseTimeEndEvent.kt @@ -0,0 +1,7 @@ +package com.depromeet.whatnow.events.domainEvent + +import com.depromeet.whatnow.common.aop.event.DomainEvent + +class PromiseTimeEndEvent( + val promiseId: Long, +) : DomainEvent() diff --git a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/events/domainEvent/PromiseTimeStartEvent.kt b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/events/domainEvent/PromiseTimeStartEvent.kt new file mode 100644 index 00000000..862948b1 --- /dev/null +++ b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/events/domainEvent/PromiseTimeStartEvent.kt @@ -0,0 +1,7 @@ +package com.depromeet.whatnow.events.domainEvent + +import com.depromeet.whatnow.common.aop.event.DomainEvent + +class PromiseTimeStartEvent( + val promiseId: Long, +) : DomainEvent() diff --git a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/events/domainEvent/PromiseTrackingTimeEndEvent.kt b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/events/domainEvent/PromiseTrackingTimeEndEvent.kt new file mode 100644 index 00000000..3f4c583f --- /dev/null +++ b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/events/domainEvent/PromiseTrackingTimeEndEvent.kt @@ -0,0 +1,7 @@ +package com.depromeet.whatnow.events.domainEvent + +import com.depromeet.whatnow.common.aop.event.DomainEvent + +class PromiseTrackingTimeEndEvent( + val promiseId: Long, +) : DomainEvent() diff --git a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/events/handler/EndTimePromiseUserEventHandler.kt b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/events/handler/EndTimePromiseUserEventHandler.kt deleted file mode 100644 index 2fc06471..00000000 --- a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/events/handler/EndTimePromiseUserEventHandler.kt +++ /dev/null @@ -1,48 +0,0 @@ -package com.depromeet.whatnow.events.handler - -import com.depromeet.whatnow.domains.promise.service.PromiseDomainService -import com.depromeet.whatnow.domains.promiseuser.service.PromiseUserDomainService -import com.depromeet.whatnow.events.domainEvent.MeetPromiseUserEvent -import com.depromeet.whatnow.events.domainEvent.PromiseUpdateEndTimeEvent -import org.springframework.scheduling.annotation.Async -import org.springframework.stereotype.Component -import org.springframework.transaction.event.TransactionPhase -import org.springframework.transaction.event.TransactionalEventListener - -@Component -class EndTimePromiseUserEventHandler( - val promiseDomainService: PromiseDomainService, - val promiseUserDomainService: PromiseUserDomainService, -) { - @Async - @TransactionalEventListener(classes = [PromiseUpdateEndTimeEvent::class], phase = TransactionPhase.AFTER_COMMIT) - fun handleRegisterUserEvent(endTimePromiseEvent: PromiseUpdateEndTimeEvent) { - val promiseId: Long = endTimePromiseEvent.promiseId - val promiseUsers = promiseUserDomainService.findByPromiseId(promiseId) - for (promiseUser in promiseUsers) { - // 위치기반 서비스가 완성되면 그때 주석 해제 예정 - - /* if(promiseDomainService.isArrived(promiseId,promiseUser.userId)){ - // 유저가 위치가 약속 장소 도착이면 wait 로 상태 변경 - promiseUser.updatePromiseUserTypeToWait() - } - else{ - if(promiseUser.promiseUserType ==CANCEL) { - // 약속을 취소한 사람은 update 하지 않는다. - continue - } - // 유저가 위치가 약속 장소 도착이 아니면 late 로 상태 변경 - promiseUser.updatePromiseUserTypeToLate() - - }*/ - } - } - - @Async - @TransactionalEventListener(classes = [MeetPromiseUserEvent::class], phase = TransactionPhase.AFTER_COMMIT) - fun handleMeetPromiseUserEvent(meetPromiseUserEvent: MeetPromiseUserEvent) { -// 만났을 경우 -// for(promiseUser in promiseUsers){ -// } - } -} diff --git a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/events/handler/PromiseActivationEventHandler.kt b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/events/handler/PromiseActivationEventHandler.kt new file mode 100644 index 00000000..37ecf485 --- /dev/null +++ b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/events/handler/PromiseActivationEventHandler.kt @@ -0,0 +1,39 @@ +package com.depromeet.whatnow.events.handler + +import com.depromeet.whatnow.annotation.Handler +import com.depromeet.whatnow.domains.promise.service.PromiseDomainService +import com.depromeet.whatnow.domains.promiseactive.adapter.PromiseActiveAdapter +import com.depromeet.whatnow.domains.promiseactive.domain.PromiseActiveRedisEntity +import com.depromeet.whatnow.events.domainEvent.PromiseRegisterEvent +import org.springframework.scheduling.annotation.Async +import org.springframework.transaction.event.TransactionPhase +import org.springframework.transaction.event.TransactionalEventListener +import java.time.Duration +import java.time.LocalDateTime + +@Handler +class PromiseActivationEventHandler( + val promiseDomainService: PromiseDomainService, + val promiseActiveAdapter: PromiseActiveAdapter, +) { + @Async + @TransactionalEventListener(classes = [PromiseRegisterEvent::class], phase = TransactionPhase.AFTER_COMMIT) + fun handleRegisterPictureEvent(promiseRegisterEvent: PromiseRegisterEvent) { + val promise = promiseDomainService.findByPromiseId(promiseRegisterEvent.promiseId) + + val now = LocalDateTime.now() + + // 약속 시작 시간까지 남은 시간(초) + val promiseStartAndTrackingStartTime = Duration.between(now, promise.endTime.minusHours(1)).seconds + + // 약속 종료 시간까지 남은 시간(초) + val promiseEndTime = Duration.between(now, promise.endTime).seconds + + // 트래킹 종료 시간까지 남은 시간(초) + val trackingEndTime = Duration.between(now, promise.endTime.plusMinutes(30)).seconds + + promiseActiveAdapter.save(PromiseActiveRedisEntity("EXPIRE_EVENT_PROMISE_TIME_START_${promise.id}", promiseStartAndTrackingStartTime)) + promiseActiveAdapter.save(PromiseActiveRedisEntity("EXPIRE_EVENT_PROMISE_TIME_END_${promise.id}", promiseEndTime)) + promiseActiveAdapter.save(PromiseActiveRedisEntity("EXPIRE_EVENT_TRACKING_TIME_START_${promise.id}", trackingEndTime)) + } +} diff --git a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/events/handler/PromiseTimeEndEventHandler.kt b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/events/handler/PromiseTimeEndEventHandler.kt new file mode 100644 index 00000000..deee5851 --- /dev/null +++ b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/events/handler/PromiseTimeEndEventHandler.kt @@ -0,0 +1,51 @@ +package com.depromeet.whatnow.events.handler + +import com.depromeet.whatnow.domains.promise.adaptor.PromiseAdaptor +import com.depromeet.whatnow.domains.promiseuser.domain.PromiseUserType.CANCEL +import com.depromeet.whatnow.domains.promiseuser.service.PromiseUserDomainService +import com.depromeet.whatnow.events.domainEvent.MeetPromiseUserEvent +import com.depromeet.whatnow.events.domainEvent.PromiseTimeEndEvent +import org.springframework.scheduling.annotation.Async +import org.springframework.stereotype.Component +import org.springframework.transaction.annotation.Propagation.REQUIRES_NEW +import org.springframework.transaction.annotation.Transactional +import org.springframework.transaction.event.TransactionPhase +import org.springframework.transaction.event.TransactionalEventListener + +@Component +class PromiseTimeEndEventHandler( + val promiseAdaptor: PromiseAdaptor, + val promiseUserDomainService: PromiseUserDomainService, +) { + @Async + @Transactional(propagation = REQUIRES_NEW) + @TransactionalEventListener(classes = [PromiseTimeEndEvent::class], phase = TransactionPhase.AFTER_COMMIT) + fun handleRegisterUserEvent(endTimePromiseEvent: PromiseTimeEndEvent) { + val promiseId: Long = endTimePromiseEvent.promiseId + val promise = promiseAdaptor.queryPromise(promiseId) + val coordinate = promise.meetPlace?.coordinate + val promiseUsers = promiseUserDomainService.findByPromiseId(promiseId) + + promiseUsers.forEach { promiseUser -> + when (promiseUser.promiseUserType) { + CANCEL -> return@forEach // CANCEL 일 경우 넘어간다. + else -> { + val isArrived = promiseUserDomainService.isArrived(promiseUser, coordinate!!) + if (isArrived) { + promiseUser.updatePromiseUserTypeToWait() + } else { + promiseUser.updatePromiseUserTypeToLate() + } + } + } + } + } + + @Async + @TransactionalEventListener(classes = [MeetPromiseUserEvent::class], phase = TransactionPhase.AFTER_COMMIT) + fun handleMeetPromiseUserEvent(meetPromiseUserEvent: MeetPromiseUserEvent) { +// 만났을 경우 +// for(promiseUser in promiseUsers){ +// } + } +} diff --git a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/events/handler/PromiseTimeStartEventHandler.kt b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/events/handler/PromiseTimeStartEventHandler.kt new file mode 100644 index 00000000..34120ac2 --- /dev/null +++ b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/events/handler/PromiseTimeStartEventHandler.kt @@ -0,0 +1,27 @@ +package com.depromeet.whatnow.events.handler + +import com.depromeet.whatnow.domains.promiseuser.adaptor.PromiseUserAdaptor +import com.depromeet.whatnow.events.domainEvent.PromiseTimeStartEvent +import org.springframework.scheduling.annotation.Async +import org.springframework.stereotype.Component +import org.springframework.transaction.annotation.Transactional +import org.springframework.transaction.event.TransactionPhase +import org.springframework.transaction.event.TransactionalEventListener + +@Component +class PromiseTimeStartEventHandler( + val promiseUserAdaptor: PromiseUserAdaptor, +) { + @Async + @Transactional + @TransactionalEventListener(classes = [PromiseTimeStartEvent::class], phase = TransactionPhase.AFTER_COMMIT) + fun handleRegisterUserEvent(promiseTimeStartEvent: PromiseTimeStartEvent) { + val promiseId = promiseTimeStartEvent.promiseId + val promiseUsers = promiseUserAdaptor.findByPromiseId(promiseId) + + promiseUsers.forEach { promiseUser -> + promiseUser.updatePromiseUserTypeToWait() + promiseUser.userLocationInit() + } + } +} diff --git a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/events/handler/PromiseTrackingTimeEndEventHandler.kt b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/events/handler/PromiseTrackingTimeEndEventHandler.kt new file mode 100644 index 00000000..568bbfdd --- /dev/null +++ b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/events/handler/PromiseTrackingTimeEndEventHandler.kt @@ -0,0 +1,25 @@ +package com.depromeet.whatnow.events.handler + +import com.depromeet.whatnow.domains.promise.adaptor.PromiseAdaptor +import com.depromeet.whatnow.domains.promiseuser.adaptor.PromiseUserAdaptor +import com.depromeet.whatnow.events.domainEvent.PromiseTrackingTimeEndEvent +import org.springframework.scheduling.annotation.Async +import org.springframework.stereotype.Component +import org.springframework.transaction.annotation.Transactional +import org.springframework.transaction.event.TransactionPhase +import org.springframework.transaction.event.TransactionalEventListener + +@Component +class PromiseTrackingTimeEndEventHandler( + val promiseAdaptor: PromiseAdaptor, + val promiseUserAdaptor: PromiseUserAdaptor, +) { + @Async + @Transactional + @TransactionalEventListener(classes = [PromiseTrackingTimeEndEvent::class], phase = TransactionPhase.AFTER_COMMIT) + fun handleRegisterUserEvent(promiseTrackingTimeEndEvent: PromiseTrackingTimeEndEvent) { + val promiseId = promiseTrackingTimeEndEvent.promiseId + val promise = promiseAdaptor.queryPromise(promiseId) + promise.endPromise() + } +} diff --git a/Whatnow-Infrastructure/src/main/kotlin/com/depromeet/whatnow/api/dto/NcpMapInfoItem.kt b/Whatnow-Infrastructure/src/main/kotlin/com/depromeet/whatnow/api/dto/NcpMapInfoItem.kt index a3de7e22..2e46e032 100644 --- a/Whatnow-Infrastructure/src/main/kotlin/com/depromeet/whatnow/api/dto/NcpMapInfoItem.kt +++ b/Whatnow-Infrastructure/src/main/kotlin/com/depromeet/whatnow/api/dto/NcpMapInfoItem.kt @@ -12,6 +12,22 @@ class NcpMapInfoItem( val telephone: String, val address: String, val roadAddress: String ? = "", - val mapx: String, - val mapy: String, -) + val mapx: Double, + val mapy: Double, +) { + companion object { + fun from(ncpMapInfoResponse: NcpMapInfoItem): NcpMapInfoItem { + return NcpMapInfoItem( + title = ncpMapInfoResponse.title, + link = ncpMapInfoResponse.link, + category = ncpMapInfoResponse.category, + description = ncpMapInfoResponse.description, + telephone = ncpMapInfoResponse.telephone, + address = ncpMapInfoResponse.address, + roadAddress = ncpMapInfoResponse.roadAddress, + mapx = ncpMapInfoResponse.mapx, + mapy = ncpMapInfoResponse.mapy, + ) + } + } +} diff --git a/Whatnow-Infrastructure/src/main/resources/application-infrastructure.yml b/Whatnow-Infrastructure/src/main/resources/application-infrastructure.yml index 5749113e..035ec1f7 100644 --- a/Whatnow-Infrastructure/src/main/resources/application-infrastructure.yml +++ b/Whatnow-Infrastructure/src/main/resources/application-infrastructure.yml @@ -63,7 +63,7 @@ ncp: certification: ${NCP_LOCAL_CERTIFICATION} fcm: - certification: ${FCM_CERTIFICATION:} + certification: ${FCM_CERTIFICATION:\{\"key\"\:\"value\"\}} #ncp: # service-id: ${NCP_SERVICE_ID:} # access-key: ${NCP_ACCESS_KEY:} diff --git a/Whatnow-Infrastructure/src/test/kotlin/com/depromeet/whatnow/config/ncp/NcpLocalSearchClientTest.kt b/Whatnow-Infrastructure/src/test/kotlin/com/depromeet/whatnow/config/ncp/NcpLocalSearchClientTest.kt index 1308530d..662df355 100644 --- a/Whatnow-Infrastructure/src/test/kotlin/com/depromeet/whatnow/config/ncp/NcpLocalSearchClientTest.kt +++ b/Whatnow-Infrastructure/src/test/kotlin/com/depromeet/whatnow/config/ncp/NcpLocalSearchClientTest.kt @@ -53,6 +53,6 @@ class NcpLocalSearchClientTest() { ), ) val response = client.searchByKeyword(accessKey, secretKey, query) - assertEquals(response.items?.size, 1) + assertEquals(response.items.size, 1) } }