Skip to content

Commit ab77f3a

Browse files
authored
[MERGE] #396 -> develop
[FEAT/#396] ν‘Έμ‹œμ•Œλ¦Ό μƒνƒœ λ³€κ²½ / μ„œλ²„ν†΅μ‹  κ΅¬ν˜„
2 parents f39e3a9 + da0c921 commit ab77f3a

File tree

19 files changed

+191
-25
lines changed

19 files changed

+191
-25
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.terning.core.designsystem.extension
2+
3+
import kotlinx.coroutines.channels.Channel
4+
import kotlinx.coroutines.channels.SendChannel
5+
import kotlinx.coroutines.flow.Flow
6+
import kotlinx.coroutines.flow.consumeAsFlow
7+
import kotlinx.coroutines.flow.flow
8+
9+
fun <T, K> Flow<T>.groupBy(getKey: (T) -> K): Flow<Pair<K, Flow<T>>> = flow {
10+
val storage = mutableMapOf<K, SendChannel<T>>()
11+
try {
12+
collect { t ->
13+
val key = getKey(t)
14+
val channel = storage.getOrPut(key) {
15+
Channel<T>(capacity = Channel.BUFFERED).also {
16+
emit(key to it.consumeAsFlow())
17+
}
18+
}
19+
channel.send(t)
20+
}
21+
} finally {
22+
storage.values.forEach { it.close() }
23+
}
24+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package com.terning.core.designsystem.type
2+
3+
enum class AlarmType(val value: String) {
4+
ENABLED("ENABLED"),
5+
DISABLED("DISABLED")
6+
}

β€Ždata/mypage/src/main/java/com/terning/data/mypage/datasource/MyPageDataSource.ktβ€Ž

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.terning.data.mypage.datasource
22

33
import com.terning.core.network.BaseResponse
44
import com.terning.core.network.NonDataBaseResponse
5+
import com.terning.data.mypage.dto.request.AlarmStatusRequestDto
56
import com.terning.data.mypage.dto.request.MyPageProfileEditRequestDto
67
import com.terning.data.mypage.dto.response.MyPageResponseDto
78

@@ -15,4 +16,8 @@ interface MyPageDataSource {
1516
suspend fun editProfile(
1617
request: MyPageProfileEditRequestDto
1718
): NonDataBaseResponse
18-
}
19+
20+
suspend fun updateAlarmState(
21+
request : AlarmStatusRequestDto
22+
) : NonDataBaseResponse
23+
}

β€Ždata/mypage/src/main/java/com/terning/data/mypage/datasourceimpl/MyPageDataSourceImpl.ktβ€Ž

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.terning.data.mypage.datasourceimpl
33
import com.terning.core.network.BaseResponse
44
import com.terning.core.network.NonDataBaseResponse
55
import com.terning.data.mypage.datasource.MyPageDataSource
6+
import com.terning.data.mypage.dto.request.AlarmStatusRequestDto
67
import com.terning.data.mypage.dto.request.MyPageProfileEditRequestDto
78
import com.terning.data.mypage.dto.response.MyPageResponseDto
89
import com.terning.data.mypage.service.MyPageService
@@ -20,4 +21,7 @@ class MyPageDataSourceImpl @Inject constructor(
2021
override suspend fun editProfile(
2122
request: MyPageProfileEditRequestDto
2223
): NonDataBaseResponse = myPageService.editProfile(request)
23-
}
24+
25+
override suspend fun updateAlarmState(request: AlarmStatusRequestDto): NonDataBaseResponse =
26+
myPageService.patchAlarmStatus(request)
27+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.terning.data.mypage.dto.request
2+
3+
import kotlinx.serialization.SerialName
4+
import kotlinx.serialization.Serializable
5+
6+
@Serializable
7+
data class AlarmStatusRequestDto(
8+
@SerialName("newStatus")
9+
val newStatus: String
10+
)

β€Ždata/mypage/src/main/java/com/terning/data/mypage/dto/response/MyPageResponseDto.ktβ€Ž

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,7 @@ data class MyPageResponseDto(
1010
@SerialName("profileImage")
1111
val profileImage: String,
1212
@SerialName("authType")
13-
val authType: String
14-
)
13+
val authType: String,
14+
@SerialName("pushStatus")
15+
val pushStatus: String
16+
)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.terning.data.mypage.mapper
2+
3+
import com.terning.data.mypage.dto.request.AlarmStatusRequestDto
4+
import com.terning.domain.mypage.entity.AlarmStatus
5+
6+
fun AlarmStatus.toAlarmStatusRequestDto(): AlarmStatusRequestDto =
7+
AlarmStatusRequestDto(
8+
newStatus = newStatus
9+
)

β€Ždata/mypage/src/main/java/com/terning/data/mypage/mapper/MyPageMapper.ktβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ fun MyPageResponseDto.toMyPageProfile() =
77
MyPageProfile(
88
name = name,
99
profileImage = profileImage,
10-
authType = authType
10+
authType = authType,
11+
alarmStatus = pushStatus
1112
)

β€Ždata/mypage/src/main/java/com/terning/data/mypage/repositoryimpl/MyPageRepositoryImpl.ktβ€Ž

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package com.terning.data.mypage.repositoryimpl
22

33
import com.terning.data.mypage.datasource.MyPageDataSource
4+
import com.terning.data.mypage.mapper.toAlarmStatusRequestDto
45
import com.terning.data.mypage.mapper.toMyPageProfile
56
import com.terning.data.mypage.mapper.toMyPageProfileEditRequestDto
7+
import com.terning.domain.mypage.entity.AlarmStatus
68
import com.terning.domain.mypage.entity.MyPageProfile
79
import com.terning.domain.mypage.entity.MyPageProfileEdit
810
import com.terning.domain.mypage.repository.MyPageRepository
@@ -34,4 +36,9 @@ class MyPageRepositoryImpl @Inject constructor(
3436
request.toMyPageProfileEditRequestDto()
3537
)
3638
}
37-
}
39+
40+
override suspend fun updateAlarmState(request: AlarmStatus): Result<Unit> =
41+
runCatching {
42+
myPageDataSource.updateAlarmState(request.toAlarmStatusRequestDto())
43+
}
44+
}

β€Ždata/mypage/src/main/java/com/terning/data/mypage/service/MyPageService.ktβ€Ž

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.terning.data.mypage.service
22

33
import com.terning.core.network.BaseResponse
44
import com.terning.core.network.NonDataBaseResponse
5+
import com.terning.data.mypage.dto.request.AlarmStatusRequestDto
56
import com.terning.data.mypage.dto.request.MyPageProfileEditRequestDto
67
import com.terning.data.mypage.dto.response.MyPageResponseDto
78
import retrofit2.http.Body
@@ -24,4 +25,9 @@ interface MyPageService {
2425
suspend fun editProfile(
2526
@Body body: MyPageProfileEditRequestDto
2627
): NonDataBaseResponse
28+
29+
@PATCH("api/v1/push-status")
30+
suspend fun patchAlarmStatus(
31+
@Body body: AlarmStatusRequestDto
32+
): NonDataBaseResponse
2733
}

0 commit comments

Comments
Β (0)