Skip to content

Commit 987e909

Browse files
committed
Feat: 오늘의 감정 API v2 적용 및 UI 반영
1 parent 190b37c commit 987e909

15 files changed

Lines changed: 121 additions & 60 deletions

File tree

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package com.threegap.bitnagil.data.emotion.datasource
22

33
import com.threegap.bitnagil.data.emotion.model.dto.EmotionDto
4-
import com.threegap.bitnagil.data.emotion.model.response.GetEmotionResponse
54
import com.threegap.bitnagil.data.emotion.model.response.RegisterEmotionResponse
5+
import com.threegap.bitnagil.data.emotion.model.response.TodayEmotionResponseDto
66

77
interface EmotionDataSource {
88
suspend fun getEmotions(): Result<List<EmotionDto>>
99
suspend fun registerEmotion(emotion: String): Result<RegisterEmotionResponse>
10-
suspend fun getEmotionMarble(currentDate: String): Result<GetEmotionResponse>
10+
suspend fun fetchTodayEmotion(currentDate: String): Result<TodayEmotionResponseDto>
1111
}

data/src/main/java/com/threegap/bitnagil/data/emotion/datasourceImpl/EmotionDataSourceImpl.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import com.threegap.bitnagil.data.common.safeApiCall
44
import com.threegap.bitnagil.data.emotion.datasource.EmotionDataSource
55
import com.threegap.bitnagil.data.emotion.model.dto.EmotionDto
66
import com.threegap.bitnagil.data.emotion.model.request.RegisterEmotionRequest
7-
import com.threegap.bitnagil.data.emotion.model.response.GetEmotionResponse
87
import com.threegap.bitnagil.data.emotion.model.response.RegisterEmotionResponse
8+
import com.threegap.bitnagil.data.emotion.model.response.TodayEmotionResponseDto
99
import com.threegap.bitnagil.data.emotion.service.EmotionService
1010
import javax.inject.Inject
1111

@@ -25,8 +25,8 @@ class EmotionDataSourceImpl @Inject constructor(
2525
}
2626
}
2727

28-
override suspend fun getEmotionMarble(currentDate: String): Result<GetEmotionResponse> =
28+
override suspend fun fetchTodayEmotion(currentDate: String): Result<TodayEmotionResponseDto> =
2929
safeApiCall {
30-
emotionService.getEmotionMarble(currentDate)
30+
emotionService.fetchTodayEmotion(currentDate)
3131
}
3232
}

data/src/main/java/com/threegap/bitnagil/data/emotion/model/response/GetEmotionResponse.kt renamed to data/src/main/java/com/threegap/bitnagil/data/emotion/model/response/TodayEmotionResponseDto.kt

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,28 @@
11
package com.threegap.bitnagil.data.emotion.model.response
22

3-
import com.threegap.bitnagil.domain.emotion.model.Emotion
3+
import com.threegap.bitnagil.domain.emotion.model.TodayEmotion
44
import kotlinx.serialization.SerialName
55
import kotlinx.serialization.Serializable
66

77
@Serializable
8-
data class GetEmotionResponse(
8+
data class TodayEmotionResponseDto(
99
@SerialName("emotionMarbleType")
1010
val emotionMarbleType: String?,
1111
@SerialName("emotionMarbleName")
1212
val emotionMarbleName: String?,
1313
@SerialName("imageUrl")
1414
val imageUrl: String?,
15+
@SerialName("emotionMarbleHomeMessage")
16+
val emotionMarbleHomeMessage: String?,
1517
)
1618

17-
fun GetEmotionResponse.toDomain(): Emotion? {
18-
return if (emotionMarbleType != null && emotionMarbleName != null && imageUrl != null) {
19-
Emotion(
20-
emotionType = emotionMarbleType,
21-
emotionMarbleName = emotionMarbleName,
19+
fun TodayEmotionResponseDto.toDomain(): TodayEmotion? {
20+
return if (emotionMarbleType != null && emotionMarbleName != null && imageUrl != null && emotionMarbleHomeMessage != null) {
21+
TodayEmotion(
22+
type = emotionMarbleType,
23+
name = emotionMarbleName,
2224
imageUrl = imageUrl,
25+
homeMessage = emotionMarbleHomeMessage,
2326
)
2427
} else {
2528
null

data/src/main/java/com/threegap/bitnagil/data/emotion/repositoryImpl/EmotionRepositoryImpl.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import com.threegap.bitnagil.data.emotion.model.response.toDomain
55
import com.threegap.bitnagil.domain.emotion.model.Emotion
66
import com.threegap.bitnagil.domain.emotion.model.EmotionChangeEvent
77
import com.threegap.bitnagil.domain.emotion.model.EmotionRecommendRoutine
8+
import com.threegap.bitnagil.domain.emotion.model.TodayEmotion
89
import com.threegap.bitnagil.domain.emotion.repository.EmotionRepository
910
import kotlinx.coroutines.flow.Flow
1011
import kotlinx.coroutines.flow.MutableSharedFlow
@@ -33,8 +34,8 @@ class EmotionRepositoryImpl @Inject constructor(
3334
}
3435
}
3536

36-
override suspend fun getEmotionMarble(currentDate: String): Result<Emotion?> =
37-
emotionDataSource.getEmotionMarble(currentDate).map { it.toDomain() }
37+
override suspend fun fetchTodayEmotion(currentDate: String): Result<TodayEmotion?> =
38+
emotionDataSource.fetchTodayEmotion(currentDate).map { it.toDomain() }
3839

3940
private val _emotionChangeEventFlow = MutableSharedFlow<EmotionChangeEvent>()
4041
override suspend fun getEmotionChangeEventFlow(): Flow<EmotionChangeEvent> = _emotionChangeEventFlow.asSharedFlow()

data/src/main/java/com/threegap/bitnagil/data/emotion/service/EmotionService.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package com.threegap.bitnagil.data.emotion.service
22

33
import com.threegap.bitnagil.data.emotion.model.dto.EmotionDto
44
import com.threegap.bitnagil.data.emotion.model.request.RegisterEmotionRequest
5-
import com.threegap.bitnagil.data.emotion.model.response.GetEmotionResponse
65
import com.threegap.bitnagil.data.emotion.model.response.RegisterEmotionResponse
6+
import com.threegap.bitnagil.data.emotion.model.response.TodayEmotionResponseDto
77
import com.threegap.bitnagil.network.model.BaseResponse
88
import retrofit2.http.Body
99
import retrofit2.http.GET
@@ -19,8 +19,8 @@ interface EmotionService {
1919
@Body request: RegisterEmotionRequest,
2020
): BaseResponse<RegisterEmotionResponse>
2121

22-
@GET("/api/v1/emotion-marbles/{searchDate}")
23-
suspend fun getEmotionMarble(
22+
@GET("/api/v2/{searchDate}")
23+
suspend fun fetchTodayEmotion(
2424
@Path("searchDate") date: String,
25-
): BaseResponse<GetEmotionResponse>
25+
): BaseResponse<TodayEmotionResponseDto>
2626
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.threegap.bitnagil.domain.emotion.model
2+
3+
data class TodayEmotion(
4+
val type: String,
5+
val name: String,
6+
val imageUrl: String,
7+
val homeMessage: String,
8+
)

domain/src/main/java/com/threegap/bitnagil/domain/emotion/repository/EmotionRepository.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ package com.threegap.bitnagil.domain.emotion.repository
33
import com.threegap.bitnagil.domain.emotion.model.Emotion
44
import com.threegap.bitnagil.domain.emotion.model.EmotionChangeEvent
55
import com.threegap.bitnagil.domain.emotion.model.EmotionRecommendRoutine
6+
import com.threegap.bitnagil.domain.emotion.model.TodayEmotion
67
import kotlinx.coroutines.flow.Flow
78

89
interface EmotionRepository {
910
suspend fun getEmotions(): Result<List<Emotion>>
1011
suspend fun registerEmotion(emotionMarbleType: String): Result<List<EmotionRecommendRoutine>>
11-
suspend fun getEmotionMarble(currentDate: String): Result<Emotion?>
12+
suspend fun fetchTodayEmotion(currentDate: String): Result<TodayEmotion?>
1213
suspend fun getEmotionChangeEventFlow(): Flow<EmotionChangeEvent>
1314
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.threegap.bitnagil.domain.emotion.usecase
2+
3+
import com.threegap.bitnagil.domain.emotion.model.TodayEmotion
4+
import com.threegap.bitnagil.domain.emotion.repository.EmotionRepository
5+
import javax.inject.Inject
6+
7+
class FetchTodayEmotionUseCase @Inject constructor(
8+
private val emotionRepository: EmotionRepository,
9+
) {
10+
suspend operator fun invoke(currentDate: String): Result<TodayEmotion?> =
11+
emotionRepository.fetchTodayEmotion(currentDate)
12+
}

domain/src/main/java/com/threegap/bitnagil/domain/emotion/usecase/GetEmotionUseCase.kt

Lines changed: 0 additions & 12 deletions
This file was deleted.

presentation/src/main/java/com/threegap/bitnagil/presentation/home/HomeScreen.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ fun HomeScreenContainer(
130130
},
131131
onShowMoreRoutinesClick = {
132132
// TODO: 루틴 리스트 화면으로 이동
133-
}
133+
},
134134
)
135135
}
136136

@@ -244,7 +244,7 @@ private fun HomeScreen(
244244

245245
CollapsibleHomeHeader(
246246
userName = uiState.userNickname,
247-
emotionBallType = uiState.myEmotion,
247+
todayEmotion = uiState.todayEmotion,
248248
collapsibleHeaderState = collapsibleHeaderState,
249249
onRegisterEmotion = onRegisterEmotionClick,
250250
)
@@ -263,6 +263,6 @@ private fun HomeScreenPreview() {
263263
onSubRoutineCompletionToggle = { _, _, _ -> },
264264
onRegisterRoutineClick = {},
265265
onRegisterEmotionClick = {},
266-
onShowMoreRoutinesClick = {}
266+
onShowMoreRoutinesClick = {},
267267
)
268268
}

0 commit comments

Comments
 (0)