diff --git a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/api/AuthenticationApi.kt b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/api/AuthenticationApi.kt index 9a29dccf..2dcdb6a0 100644 --- a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/api/AuthenticationApi.kt +++ b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/api/AuthenticationApi.kt @@ -7,8 +7,8 @@ import ac.dnd.bookkeeping.android.data.remote.network.environment.ErrorMessageMa import ac.dnd.bookkeeping.android.data.remote.network.model.authentication.GetAccessTokenRes import ac.dnd.bookkeeping.android.data.remote.network.model.authentication.LoginReq import ac.dnd.bookkeeping.android.data.remote.network.model.authentication.LoginRes -import ac.dnd.bookkeeping.android.data.remote.network.model.error.RegisterReq -import ac.dnd.bookkeeping.android.data.remote.network.model.error.RegisterRes +import ac.dnd.bookkeeping.android.data.remote.network.model.authentication.RegisterReq +import ac.dnd.bookkeeping.android.data.remote.network.model.authentication.RegisterRes import ac.dnd.bookkeeping.android.data.remote.network.util.convert import io.ktor.client.HttpClient import io.ktor.client.request.delete diff --git a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/authentication/LoginRes.kt b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/authentication/LoginRes.kt index 35338d21..43b4de64 100644 --- a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/authentication/LoginRes.kt +++ b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/authentication/LoginRes.kt @@ -1,5 +1,6 @@ package ac.dnd.bookkeeping.android.data.remote.network.model.authentication +import ac.dnd.bookkeeping.android.data.remote.mapper.DataMapper import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -11,4 +12,9 @@ data class LoginRes( val accessToken: String, @SerialName("refreshToken") val refreshToken: String -) +) : DataMapper { + override fun toDomain(): Boolean { + return isNew + } +} + diff --git a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/error/RegisterReq.kt b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/authentication/RegisterReq.kt similarity index 86% rename from data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/error/RegisterReq.kt rename to data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/authentication/RegisterReq.kt index 9a29cdd7..2ffac7b7 100644 --- a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/error/RegisterReq.kt +++ b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/authentication/RegisterReq.kt @@ -1,4 +1,4 @@ -package ac.dnd.bookkeeping.android.data.remote.network.model.error +package ac.dnd.bookkeeping.android.data.remote.network.model.authentication import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable diff --git a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/error/RegisterRes.kt b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/authentication/RegisterRes.kt similarity index 55% rename from data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/error/RegisterRes.kt rename to data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/authentication/RegisterRes.kt index 5960a62d..41cbd0a5 100644 --- a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/error/RegisterRes.kt +++ b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/authentication/RegisterRes.kt @@ -1,5 +1,6 @@ -package ac.dnd.bookkeeping.android.data.remote.network.model.error +package ac.dnd.bookkeeping.android.data.remote.network.model.authentication +import ac.dnd.bookkeeping.android.data.remote.mapper.DataMapper import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -11,4 +12,9 @@ data class RegisterRes( val accessToken: String, @SerialName("refreshToken") val refreshToken: String -) +) : DataMapper { + override fun toDomain(): Long { + return id + } +} + diff --git a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/group/AddGroupRes.kt b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/group/AddGroupRes.kt index 113267dd..b0485931 100644 --- a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/group/AddGroupRes.kt +++ b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/group/AddGroupRes.kt @@ -1,5 +1,6 @@ package ac.dnd.bookkeeping.android.data.remote.network.model.group +import ac.dnd.bookkeeping.android.data.remote.mapper.DataMapper import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -7,4 +8,8 @@ import kotlinx.serialization.Serializable data class AddGroupRes( @SerialName("result") val result: Long -) +) : DataMapper { + override fun toDomain(): Long { + return result + } +} diff --git a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/group/GetGroupListRes.kt b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/group/GetGroupListRes.kt index 1401881f..34f30e08 100644 --- a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/group/GetGroupListRes.kt +++ b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/group/GetGroupListRes.kt @@ -1,5 +1,7 @@ package ac.dnd.bookkeeping.android.data.remote.network.model.group +import ac.dnd.bookkeeping.android.data.remote.mapper.DataMapper +import ac.dnd.bookkeeping.android.domain.model.group.Group import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -7,7 +9,11 @@ import kotlinx.serialization.Serializable data class GetGroupListRes( @SerialName("result") val result: List -) +) : DataMapper> { + override fun toDomain(): List { + return result.map { it.toDomain() } + } +} @Serializable data class GetGroupItemRes( @@ -15,4 +21,11 @@ data class GetGroupItemRes( val id: Long, @SerialName("name") val name: String -) +) : DataMapper { + override fun toDomain(): Group { + return Group( + id = id, + name = name + ) + } +} diff --git a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/heart/AddHeartRes.kt b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/heart/AddHeartRes.kt index 54ca9488..4b43ca55 100644 --- a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/heart/AddHeartRes.kt +++ b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/heart/AddHeartRes.kt @@ -1,5 +1,6 @@ package ac.dnd.bookkeeping.android.data.remote.network.model.heart +import ac.dnd.bookkeeping.android.data.remote.mapper.DataMapper import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -7,4 +8,9 @@ import kotlinx.serialization.Serializable data class AddHeartRes( @SerialName("result") val result: Long -) +) : DataMapper { + override fun toDomain(): Long { + return result + } +} + diff --git a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/heart/AddUnrecordedHeartRes.kt b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/heart/AddUnrecordedHeartRes.kt index 8b045eb3..88351f12 100644 --- a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/heart/AddUnrecordedHeartRes.kt +++ b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/heart/AddUnrecordedHeartRes.kt @@ -1,5 +1,6 @@ package ac.dnd.bookkeeping.android.data.remote.network.model.heart +import ac.dnd.bookkeeping.android.data.remote.mapper.DataMapper import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -7,4 +8,9 @@ import kotlinx.serialization.Serializable data class AddUnrecordedHeartRes( @SerialName("result") val result: Long -) +) : DataMapper { + override fun toDomain(): Long { + return result + } +} + diff --git a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/heart/GetHeartListRes.kt b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/heart/GetHeartListRes.kt index bb04b3ac..91fbbb23 100644 --- a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/heart/GetHeartListRes.kt +++ b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/heart/GetHeartListRes.kt @@ -1,5 +1,8 @@ package ac.dnd.bookkeeping.android.data.remote.network.model.heart +import ac.dnd.bookkeeping.android.data.remote.mapper.DataMapper +import ac.dnd.bookkeeping.android.domain.model.heart.Heart +import ac.dnd.bookkeeping.android.domain.model.heart.HeartGroup import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -7,7 +10,12 @@ import kotlinx.serialization.Serializable data class GetHeartListRes( @SerialName("result") val result: List -) +) : DataMapper> { + override fun toDomain(): List { + return result.map { it.toDomain() } + } +} + @Serializable data class GetHeartItemRes( @@ -25,7 +33,19 @@ data class GetHeartItemRes( val giveHistories: List, @SerialName("takeHistories") val takeHistories: List -) +) : DataMapper { + override fun toDomain(): Heart { + return Heart( + id = id, + relationId = relationId, + give = give, + name = name, + group = group.toDomain(), + giveHistories = giveHistories, + takeHistories = takeHistories + ) + } +} @Serializable data class GetHeartItemGroupRes( @@ -33,5 +53,12 @@ data class GetHeartItemGroupRes( val id: Long, @SerialName("name") val name: String -) +) : DataMapper { + override fun toDomain(): HeartGroup { + return HeartGroup( + id = id, + name = name + ) + } +} diff --git a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/heart/GetRelatedHeartListRes.kt b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/heart/GetRelatedHeartListRes.kt index 3ede8d60..005a3e21 100644 --- a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/heart/GetRelatedHeartListRes.kt +++ b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/heart/GetRelatedHeartListRes.kt @@ -1,5 +1,7 @@ package ac.dnd.bookkeeping.android.data.remote.network.model.heart +import ac.dnd.bookkeeping.android.data.remote.mapper.DataMapper +import ac.dnd.bookkeeping.android.domain.model.heart.RelatedHeart import kotlinx.datetime.LocalDate import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -8,7 +10,11 @@ import kotlinx.serialization.Serializable data class GetRelatedHeartListRes( @SerialName("result") val result: List -) +) : DataMapper> { + override fun toDomain(): List { + return result.map { it.toDomain() } + } +} @Serializable data class GetRelatedHeartItemRes( @@ -26,5 +32,16 @@ data class GetRelatedHeartItemRes( val memo: String, @SerialName("tags") val tags: List -) - +) : DataMapper { + override fun toDomain(): RelatedHeart { + return RelatedHeart( + id = id, + give = give, + money = money, + day = day, + event = event, + memo = memo, + tags = tags + ) + } +} diff --git a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/member/CheckNicknameRes.kt b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/member/CheckNicknameRes.kt index 1d0bc95f..65a514b5 100644 --- a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/member/CheckNicknameRes.kt +++ b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/member/CheckNicknameRes.kt @@ -1,5 +1,6 @@ package ac.dnd.bookkeeping.android.data.remote.network.model.member +import ac.dnd.bookkeeping.android.data.remote.mapper.DataMapper import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -7,4 +8,8 @@ import kotlinx.serialization.Serializable data class CheckNicknameRes( @SerialName("result") val result: Boolean -) +) : DataMapper { + override fun toDomain(): Boolean { + return result + } +} diff --git a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/member/GetProfileRes.kt b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/member/GetProfileRes.kt index 62a0811e..956da0ad 100644 --- a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/member/GetProfileRes.kt +++ b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/member/GetProfileRes.kt @@ -1,5 +1,7 @@ package ac.dnd.bookkeeping.android.data.remote.network.model.member +import ac.dnd.bookkeeping.android.data.remote.mapper.DataMapper +import ac.dnd.bookkeeping.android.domain.model.member.Profile import kotlinx.datetime.LocalDate import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -14,4 +16,13 @@ data class GetProfileRes( val gender: String, @SerialName("birth") val birth: LocalDate -) +) : DataMapper { + override fun toDomain(): Profile { + return Profile( + name = name, + nickname = nickname, + gender = gender, + birth = birth + ) + } +} diff --git a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/relation/AddRelationRes.kt b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/relation/AddRelationRes.kt index eb9819fa..837cbddb 100644 --- a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/relation/AddRelationRes.kt +++ b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/relation/AddRelationRes.kt @@ -1,5 +1,6 @@ package ac.dnd.bookkeeping.android.data.remote.network.model.relation +import ac.dnd.bookkeeping.android.data.remote.mapper.DataMapper import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -7,4 +8,9 @@ import kotlinx.serialization.Serializable data class AddRelationRes( @SerialName("result") val result: Long -) +) : DataMapper { + override fun toDomain(): Long { + return result + } +} + diff --git a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/relation/GetRelationListRes.kt b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/relation/GetRelationListRes.kt index 4c1480f2..7f834279 100644 --- a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/relation/GetRelationListRes.kt +++ b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/relation/GetRelationListRes.kt @@ -1,5 +1,8 @@ package ac.dnd.bookkeeping.android.data.remote.network.model.relation +import ac.dnd.bookkeeping.android.data.remote.mapper.DataMapper +import ac.dnd.bookkeeping.android.domain.model.relation.RelationSimple +import ac.dnd.bookkeeping.android.domain.model.relation.RelationSimpleGroup import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -7,7 +10,11 @@ import kotlinx.serialization.Serializable data class GetRelationListRes( @SerialName("result") val result: List -) +) : DataMapper> { + override fun toDomain(): List { + return result.map { it.toDomain() } + } +} @Serializable data class GetRelationItemRes( @@ -17,7 +24,15 @@ data class GetRelationItemRes( val name: String, @SerialName("group") val group: GetRelationItemGroupRes, -) +) : DataMapper { + override fun toDomain(): RelationSimple { + return RelationSimple( + id = id, + name = name, + group = group.toDomain() + ) + } +} @Serializable data class GetRelationItemGroupRes( @@ -25,5 +40,11 @@ data class GetRelationItemGroupRes( val id: Long, @SerialName("name") val name: String -) - +) : DataMapper { + override fun toDomain(): RelationSimpleGroup { + return RelationSimpleGroup( + id = id, + name = name + ) + } +} diff --git a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/relation/GetRelationRes.kt b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/relation/GetRelationRes.kt index fe49bfe9..4a6f1077 100644 --- a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/relation/GetRelationRes.kt +++ b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/relation/GetRelationRes.kt @@ -1,5 +1,8 @@ package ac.dnd.bookkeeping.android.data.remote.network.model.relation +import ac.dnd.bookkeeping.android.data.remote.mapper.DataMapper +import ac.dnd.bookkeeping.android.domain.model.relation.RelationDetail +import ac.dnd.bookkeeping.android.domain.model.relation.RelationDetailGroup import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -15,7 +18,17 @@ data class GetRelationRes( val giveMoney: Long, @SerialName("takeMoney") val takeMoney: Long -) +) : DataMapper { + override fun toDomain(): RelationDetail { + return RelationDetail( + id = id, + name = name, + group = group.toDomain(), + giveMoney = giveMoney, + takeMoney = takeMoney + ) + } +} @Serializable data class GetRelationGroupRes( @@ -23,5 +36,11 @@ data class GetRelationGroupRes( val id: Long, @SerialName("name") val name: String -) - +) : DataMapper { + override fun toDomain(): RelationDetailGroup { + return RelationDetailGroup( + id = id, + name = name + ) + } +} diff --git a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/schedule/AddScheduleRes.kt b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/schedule/AddScheduleRes.kt index d399f070..ea5b664a 100644 --- a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/schedule/AddScheduleRes.kt +++ b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/schedule/AddScheduleRes.kt @@ -1,5 +1,6 @@ package ac.dnd.bookkeeping.android.data.remote.network.model.schedule +import ac.dnd.bookkeeping.android.data.remote.mapper.DataMapper import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -7,4 +8,9 @@ import kotlinx.serialization.Serializable data class AddScheduleRes( @SerialName("result") val result: Long -) +) : DataMapper { + override fun toDomain(): Long { + return result + } +} + diff --git a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/schedule/GetUnrecordedScheduleListRes.kt b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/schedule/GetUnrecordedScheduleListRes.kt index 122d116d..8450bf15 100644 --- a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/schedule/GetUnrecordedScheduleListRes.kt +++ b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/schedule/GetUnrecordedScheduleListRes.kt @@ -1,5 +1,8 @@ package ac.dnd.bookkeeping.android.data.remote.network.model.schedule +import ac.dnd.bookkeeping.android.data.remote.mapper.DataMapper +import ac.dnd.bookkeeping.android.domain.model.schedule.UnrecordedSchedule +import ac.dnd.bookkeeping.android.domain.model.schedule.UnrecordedScheduleRelation import kotlinx.datetime.LocalDate import kotlinx.datetime.LocalDateTime import kotlinx.datetime.LocalTime @@ -10,7 +13,11 @@ import kotlinx.serialization.Serializable data class GetUnrecordedScheduleListRes( @SerialName("result") val result: List -) +) : DataMapper> { + override fun toDomain(): List { + return result.map { it.toDomain() } + } +} @Serializable data class GetUnrecordedScheduleItemRes( @@ -30,7 +37,20 @@ data class GetUnrecordedScheduleItemRes( val link: String, @SerialName("location") val location: String -) +) : DataMapper { + override fun toDomain(): UnrecordedSchedule { + return UnrecordedSchedule( + id = id, + relation = relation.toDomain(), + day = day, + event = event, + alarm = alarm, + time = time, + link = link, + location = location + ) + } +} @Serializable data class GetUnrecordedScheduleItemRelationRes( @@ -38,5 +58,11 @@ data class GetUnrecordedScheduleItemRelationRes( val id: Long, @SerialName("name") val name: String -) - +) : DataMapper { + override fun toDomain(): UnrecordedScheduleRelation { + return UnrecordedScheduleRelation( + id = id, + name = name + ) + } +} diff --git a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/statistics/GetGroupStatisticsRes.kt b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/statistics/GetGroupStatisticsRes.kt index 09278fb0..0fb6382f 100644 --- a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/statistics/GetGroupStatisticsRes.kt +++ b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/statistics/GetGroupStatisticsRes.kt @@ -1,5 +1,7 @@ package ac.dnd.bookkeeping.android.data.remote.network.model.statistics +import ac.dnd.bookkeeping.android.data.remote.mapper.DataMapper +import ac.dnd.bookkeeping.android.domain.model.statistics.GroupStatistics import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -17,4 +19,15 @@ data class GetGroupStatisticsRes( val bizopen: Long, @SerialName("etc") val etc: Long, -) +) : DataMapper { + override fun toDomain(): GroupStatistics { + return GroupStatistics( + marriage = marriage, + birth = birth, + baby = baby, + babyBirth = babyBirth, + bizopen = bizopen, + etc = etc + ) + } +} diff --git a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/statistics/GetMyStatisticsRes.kt b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/statistics/GetMyStatisticsRes.kt index 8dd21f81..55fd9f54 100644 --- a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/statistics/GetMyStatisticsRes.kt +++ b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/remote/network/model/statistics/GetMyStatisticsRes.kt @@ -1,5 +1,10 @@ package ac.dnd.bookkeeping.android.data.remote.network.model.statistics +import ac.dnd.bookkeeping.android.data.remote.mapper.DataMapper +import ac.dnd.bookkeeping.android.domain.model.statistics.MyStatistics +import ac.dnd.bookkeeping.android.domain.model.statistics.MyStatisticsEvent +import ac.dnd.bookkeeping.android.domain.model.statistics.MyStatisticsGive +import ac.dnd.bookkeeping.android.domain.model.statistics.MyStatisticsTake import kotlinx.datetime.LocalDate import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -10,19 +15,38 @@ data class GetMyStatisticsRes( val give: GetMyStatisticsGiveRes, @SerialName("take") val take: GetMyStatisticsTakeRes -) +) : DataMapper { + override fun toDomain(): MyStatistics { + return MyStatistics( + give = give.toDomain(), + take = take.toDomain() + ) + } +} @Serializable data class GetMyStatisticsGiveRes( @SerialName("event") val event: List -) +) : DataMapper { + override fun toDomain(): MyStatisticsGive { + return MyStatisticsGive( + event = event.map { it.toDomain() } + ) + } +} @Serializable data class GetMyStatisticsTakeRes( @SerialName("event") val event: List -) +) : DataMapper { + override fun toDomain(): MyStatisticsTake { + return MyStatisticsTake( + event = event.map { it.toDomain() } + ) + } +} @Serializable data class GetMyStatisticsEventRes( @@ -34,4 +58,13 @@ data class GetMyStatisticsEventRes( val money: Long, @SerialName("day") val day: LocalDate -) +) : DataMapper { + override fun toDomain(): MyStatisticsEvent { + return MyStatisticsEvent( + name = name, + group = group, + money = money, + day = day + ) + } +} diff --git a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/repository/authentication/MockAuthenticationRepository.kt b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/repository/authentication/MockAuthenticationRepository.kt index 37eeaa87..868b7cb6 100644 --- a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/repository/authentication/MockAuthenticationRepository.kt +++ b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/repository/authentication/MockAuthenticationRepository.kt @@ -2,8 +2,8 @@ package ac.dnd.bookkeeping.android.data.repository.authentication import ac.dnd.bookkeeping.android.data.remote.local.SharedPreferencesManager import ac.dnd.bookkeeping.android.domain.model.authentication.JwtToken -import ac.dnd.bookkeeping.android.domain.model.authentication.Login -import ac.dnd.bookkeeping.android.domain.model.authentication.Register +import ac.dnd.bookkeeping.android.domain.model.legacy.Login +import ac.dnd.bookkeeping.android.domain.model.legacy.Register import ac.dnd.bookkeeping.android.domain.repository.AuthenticationRepository import kotlinx.coroutines.delay import javax.inject.Inject diff --git a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/repository/authentication/RealAuthenticationRepository.kt b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/repository/authentication/RealAuthenticationRepository.kt index 4085e963..4ad08a2d 100644 --- a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/repository/authentication/RealAuthenticationRepository.kt +++ b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/repository/authentication/RealAuthenticationRepository.kt @@ -3,8 +3,8 @@ package ac.dnd.bookkeeping.android.data.repository.authentication import ac.dnd.bookkeeping.android.data.remote.local.SharedPreferencesManager import ac.dnd.bookkeeping.android.data.remote.network.api.AuthenticationApi import ac.dnd.bookkeeping.android.domain.model.authentication.JwtToken -import ac.dnd.bookkeeping.android.domain.model.authentication.Login -import ac.dnd.bookkeeping.android.domain.model.authentication.Register +import ac.dnd.bookkeeping.android.domain.model.legacy.Login +import ac.dnd.bookkeeping.android.domain.model.legacy.Register import ac.dnd.bookkeeping.android.domain.repository.AuthenticationRepository import javax.inject.Inject diff --git a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/repository/group/MockGroupRepository.kt b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/repository/group/MockGroupRepository.kt new file mode 100644 index 00000000..ee018a17 --- /dev/null +++ b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/repository/group/MockGroupRepository.kt @@ -0,0 +1,56 @@ +package ac.dnd.bookkeeping.android.data.repository.group + +import ac.dnd.bookkeeping.android.domain.model.group.Group +import ac.dnd.bookkeeping.android.domain.repository.GroupRepository +import kotlinx.coroutines.delay +import javax.inject.Inject + +class MockGroupRepository @Inject constructor() : GroupRepository { + + override suspend fun addGroup( + name: String + ): Result { + randomShortDelay() + return Result.success(-1) + } + + override suspend fun editGroup( + id: Long, + name: String + ): Result { + randomShortDelay() + return Result.success(Unit) + } + + override suspend fun deleteGroup( + id: Long + ): Result { + randomShortDelay() + return Result.success(Unit) + } + + override suspend fun getGroupList(): Result> { + randomLongDelay() + return Result.success( + listOf( + Group(1, "Group 1"), + Group(2, "Group 2"), + Group(3, "Group 3"), + Group(4, "Group 4"), + Group(5, "Group 5"), + Group(6, "Group 6"), + Group(7, "Group 7"), + Group(8, "Group 8"), + Group(9, "Group 9") + ) + ) + } + + private suspend fun randomShortDelay() { + delay(LongRange(100, 500).random()) + } + + private suspend fun randomLongDelay() { + delay(LongRange(500, 2000).random()) + } +} diff --git a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/repository/group/RealGroupRepository.kt b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/repository/group/RealGroupRepository.kt new file mode 100644 index 00000000..97311240 --- /dev/null +++ b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/repository/group/RealGroupRepository.kt @@ -0,0 +1,43 @@ +package ac.dnd.bookkeeping.android.data.repository.group + +import ac.dnd.bookkeeping.android.data.remote.local.SharedPreferencesManager +import ac.dnd.bookkeeping.android.data.remote.network.api.GroupApi +import ac.dnd.bookkeeping.android.data.remote.network.util.toDomain +import ac.dnd.bookkeeping.android.domain.model.group.Group +import ac.dnd.bookkeeping.android.domain.repository.GroupRepository +import javax.inject.Inject + +class RealGroupRepository @Inject constructor( + private val groupApi: GroupApi, + private val sharedPreferencesManager: SharedPreferencesManager +) : GroupRepository { + override suspend fun addGroup( + name: String + ): Result { + return groupApi.addGroup( + name = name + ).toDomain() + } + + override suspend fun editGroup( + id: Long, + name: String + ): Result { + return groupApi.editGroup( + id = id, + name = name + ) + } + + override suspend fun deleteGroup( + id: Long + ): Result { + return groupApi.deleteGroup( + id = id + ) + } + + override suspend fun getGroupList(): Result> { + return groupApi.getGroupList().toDomain() + } +} diff --git a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/repository/heart/MockHeartRepository.kt b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/repository/heart/MockHeartRepository.kt new file mode 100644 index 00000000..9b63804f --- /dev/null +++ b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/repository/heart/MockHeartRepository.kt @@ -0,0 +1,120 @@ +package ac.dnd.bookkeeping.android.data.repository.heart + +import ac.dnd.bookkeeping.android.domain.model.heart.Heart +import ac.dnd.bookkeeping.android.domain.model.heart.HeartGroup +import ac.dnd.bookkeeping.android.domain.model.heart.RelatedHeart +import ac.dnd.bookkeeping.android.domain.repository.HeartRepository +import kotlinx.coroutines.delay +import kotlinx.datetime.LocalDate +import javax.inject.Inject + +class MockHeartRepository @Inject constructor() : HeartRepository { + + override suspend fun addHeart( + relationId: Long, + give: Boolean, + money: Long, + day: LocalDate, + event: String, + memo: String, + tags: List + ): Result { + randomShortDelay() + return Result.success(-1) + } + + override suspend fun editHeart( + id: Long, + money: Long, + day: LocalDate, + event: String, + memo: String, + tags: List + ): Result { + randomShortDelay() + return Result.success(Unit) + } + + override suspend fun deleteHeart( + id: Long + ): Result { + randomShortDelay() + return Result.success(Unit) + } + + override suspend fun addUnrecordedHeart( + scheduleId: Long, + money: Long, + tags: List + ): Result { + randomShortDelay() + return Result.success(-1) + } + + override suspend fun getHeartList( + sort: String, + name: String + ): Result { + randomShortDelay() + return Result.success( + Heart( + id = 2059, + relationId = 4920, + give = false, + name = "Lorie Adams", + group = HeartGroup( + id = 7435, + name = "Octavio Hayes" + ), + giveHistories = listOf( + 1_000L, + 2_000L, + 3_000L, + 10_000L, + 100_000L, + 1_000_000L + ), + takeHistories = listOf( + 1_000L, + 2_000L, + 3_000L, + 10_000L, + 100_000L, + 1_000_000L + ) + ) + ) + } + + override suspend fun getRelatedHeartList( + id: Long, + sort: String + ): Result { + randomShortDelay() + return Result.success( + RelatedHeart( + id = 7558, + give = false, + money = 7166, + day = LocalDate(2030, 1, 1), + event = "mediocritatem", + memo = "luptatum", + tags = listOf( + "tag1", + "tag2", + "tag3", + "tag4", + "tag5" + ) + ) + ) + } + + private suspend fun randomShortDelay() { + delay(LongRange(100, 500).random()) + } + + private suspend fun randomLongDelay() { + delay(LongRange(500, 2000).random()) + } +} diff --git a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/repository/heart/RealHeartRepository.kt b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/repository/heart/RealHeartRepository.kt new file mode 100644 index 00000000..2a402bc8 --- /dev/null +++ b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/repository/heart/RealHeartRepository.kt @@ -0,0 +1,95 @@ +package ac.dnd.bookkeeping.android.data.repository.heart + +import ac.dnd.bookkeeping.android.data.remote.local.SharedPreferencesManager +import ac.dnd.bookkeeping.android.data.remote.network.api.HeartApi +import ac.dnd.bookkeeping.android.data.remote.network.util.toDomain +import ac.dnd.bookkeeping.android.domain.model.group.Group +import ac.dnd.bookkeeping.android.domain.model.heart.Heart +import ac.dnd.bookkeeping.android.domain.model.heart.RelatedHeart +import ac.dnd.bookkeeping.android.domain.repository.GroupRepository +import ac.dnd.bookkeeping.android.domain.repository.HeartRepository +import kotlinx.datetime.LocalDate +import javax.inject.Inject + +class RealHeartRepository @Inject constructor( + private val heartApi: HeartApi, + private val sharedPreferencesManager: SharedPreferencesManager +) : HeartRepository { + override suspend fun addHeart( + relationId: Long, + give: Boolean, + money: Long, + day: LocalDate, + event: String, + memo: String, + tags: List + ): Result { + return heartApi.addHeart( + relationId = relationId, + give = give, + money = money, + day = day, + event = event, + memo = memo, + tags = tags + ).toDomain() + } + + override suspend fun editHeart( + id: Long, + money: Long, + day: LocalDate, + event: String, + memo: String, + tags: List + ): Result { + return heartApi.editHeart( + id = id, + money = money, + day = day, + event = event, + memo = memo, + tags = tags + ) + } + + override suspend fun deleteHeart( + id: Long + ): Result { + return heartApi.deleteHeart( + id = id + ) + } + + override suspend fun addUnrecordedHeart( + scheduleId: Long, + money: Long, + tags: List + ): Result { + return heartApi.addUnrecordedHeart( + scheduleId = scheduleId, + money = money, + tags = tags + ).toDomain() + } + + override suspend fun getHeartList( + sort: String, + name: String + ): Result> { + return heartApi.getHeartList( + sort = sort, + name = name + ).toDomain() + } + + override suspend fun getRelatedHeartList( + id: Long, + sort: String + ): Result> { + return heartApi.getRelatedHeartList( + id = id, + sort = sort + ).toDomain() + } +} diff --git a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/repository/relation/MockRelationRepository.kt b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/repository/relation/MockRelationRepository.kt new file mode 100644 index 00000000..1104d0ac --- /dev/null +++ b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/repository/relation/MockRelationRepository.kt @@ -0,0 +1,100 @@ +package ac.dnd.bookkeeping.android.data.repository.relation + +import ac.dnd.bookkeeping.android.domain.model.relation.RelationDetail +import ac.dnd.bookkeeping.android.domain.model.relation.RelationDetailGroup +import ac.dnd.bookkeeping.android.domain.model.relation.RelationSimple +import ac.dnd.bookkeeping.android.domain.model.relation.RelationSimpleGroup +import ac.dnd.bookkeeping.android.domain.repository.RelationRepository +import kotlinx.coroutines.delay +import javax.inject.Inject + +class MockRelationRepository @Inject constructor() : RelationRepository { + + override suspend fun addRelation( + groupId: Long, + name: String, + imageUrl: String, + memo: String + ): Result { + randomShortDelay() + return Result.success(-1) + } + + override suspend fun editRelation( + id: Long, + groupId: Long, + name: String, + imageUrl: String, + memo: String + ): Result { + randomShortDelay() + return Result.success(Unit) + } + + override suspend fun deleteRelation( + id: Long + ): Result { + randomShortDelay() + return Result.success(Unit) + } + + override suspend fun getRelation( + id: Long + ): Result { + randomShortDelay() + return Result.success( + RelationDetail( + id = 5902, + name = "Mandy Dillard", + group = RelationDetailGroup( + id = 6945, + name = "Alba Sargent" + ), + giveMoney = 5834, + takeMoney = 9884 + ) + ) + } + + override suspend fun getRelationList( + name: String + ): Result> { + randomLongDelay() + return Result.success( + listOf( + RelationSimple( + id = 2290, + name = "Concepcion Watts", + group = RelationSimpleGroup( + id = 7722, + name = "Enid Patton" + ) + ), + RelationSimple( + id = 5606, + name = "Lora Meadows", + group = RelationSimpleGroup( + id = 7709, + name = "Corinne Porter" + ) + ), + RelationSimple( + id = 5902, + name = "Mandy Dillard", + group = RelationSimpleGroup( + id = 6945, + name = "Alba Sargent" + ) + ) + ) + ) + } + + private suspend fun randomShortDelay() { + delay(LongRange(100, 500).random()) + } + + private suspend fun randomLongDelay() { + delay(LongRange(500, 2000).random()) + } +} diff --git a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/repository/relation/RealRelationRepository.kt b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/repository/relation/RealRelationRepository.kt new file mode 100644 index 00000000..dc4cfa91 --- /dev/null +++ b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/repository/relation/RealRelationRepository.kt @@ -0,0 +1,70 @@ +package ac.dnd.bookkeeping.android.data.repository.relation + +import ac.dnd.bookkeeping.android.data.remote.local.SharedPreferencesManager +import ac.dnd.bookkeeping.android.data.remote.network.api.RelationApi +import ac.dnd.bookkeeping.android.data.remote.network.util.toDomain +import ac.dnd.bookkeeping.android.domain.model.group.Group +import ac.dnd.bookkeeping.android.domain.model.relation.RelationDetail +import ac.dnd.bookkeeping.android.domain.model.relation.RelationSimple +import ac.dnd.bookkeeping.android.domain.repository.GroupRepository +import ac.dnd.bookkeeping.android.domain.repository.RelationRepository +import javax.inject.Inject + +class RealRelationRepository @Inject constructor( + private val relationApi: RelationApi, + private val sharedPreferencesManager: SharedPreferencesManager +) : RelationRepository { + override suspend fun addRelation( + groupId: Long, + name: String, + imageUrl: String, + memo: String + ): Result { + return relationApi.addRelation( + groupId = groupId, + name = name, + imageUrl = imageUrl, + memo = memo + ).toDomain() + } + + override suspend fun editRelation( + id: Long, + groupId: Long, + name: String, + imageUrl: String, + memo: String + ): Result { + return relationApi.editRelation( + id = id, + groupId = groupId, + name = name, + imageUrl = imageUrl, + memo = memo + ) + } + + override suspend fun deleteRelation( + id: Long + ): Result { + return relationApi.deleteRelation( + id = id + ) + } + + override suspend fun getRelation( + id: Long + ): Result { + return relationApi.getRelation( + id = id + ).toDomain() + } + + override suspend fun getRelationList( + name: String + ): Result> { + return relationApi.getRelationList( + name = name + ).toDomain() + } +} diff --git a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/repository/schedule/MockScheduleRepository.kt b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/repository/schedule/MockScheduleRepository.kt new file mode 100644 index 00000000..757f0664 --- /dev/null +++ b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/repository/schedule/MockScheduleRepository.kt @@ -0,0 +1,84 @@ +package ac.dnd.bookkeeping.android.data.repository.schedule + +import ac.dnd.bookkeeping.android.domain.model.schedule.UnrecordedSchedule +import ac.dnd.bookkeeping.android.domain.model.schedule.UnrecordedScheduleRelation +import ac.dnd.bookkeeping.android.domain.repository.ScheduleRepository +import kotlinx.coroutines.delay +import kotlinx.datetime.LocalDate +import kotlinx.datetime.LocalDateTime +import kotlinx.datetime.LocalTime +import javax.inject.Inject + +class MockScheduleRepository @Inject constructor() : ScheduleRepository { + + override suspend fun addSchedule( + relationId: Long, + day: LocalDate, + event: String, + repeatType: String, + repeatFinish: LocalDate, + alarm: LocalDateTime, + time: LocalTime, + link: String, + location: String, + memo: String + ): Result { + randomShortDelay() + return Result.success(-1) + } + + override suspend fun editSchedule( + id: Long, + relationId: Long, + day: LocalDate, + event: String, + repeatType: String, + repeatFinish: LocalDate, + alarm: LocalDateTime, + time: LocalTime, + link: String, + location: String, + memo: String + ): Result { + randomShortDelay() + return Result.success(Unit) + } + + override suspend fun deleteSchedule( + id: Long + ): Result { + randomShortDelay() + return Result.success(Unit) + } + + override suspend fun getUnrecordedScheduleList( + name: String + ): Result> { + randomLongDelay() + return Result.success( + listOf( + UnrecordedSchedule( + id = 2655, + relation = UnrecordedScheduleRelation( + id = 9178, + name = "Alphonse Berg" + ), + day = LocalDate(2024, 2, 25), + event = "velit", + alarm = LocalDateTime(2024, 2, 25, 8, 0), + time = LocalTime(8, 0), + link = "maximus", + location = "noster" + ) + ) + ) + } + + private suspend fun randomShortDelay() { + delay(LongRange(100, 500).random()) + } + + private suspend fun randomLongDelay() { + delay(LongRange(500, 2000).random()) + } +} diff --git a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/repository/schedule/RealScheduleRepository.kt b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/repository/schedule/RealScheduleRepository.kt new file mode 100644 index 00000000..3fa718f5 --- /dev/null +++ b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/repository/schedule/RealScheduleRepository.kt @@ -0,0 +1,88 @@ +package ac.dnd.bookkeeping.android.data.repository.schedule + +import ac.dnd.bookkeeping.android.data.remote.local.SharedPreferencesManager +import ac.dnd.bookkeeping.android.data.remote.network.api.ScheduleApi +import ac.dnd.bookkeeping.android.data.remote.network.util.toDomain +import ac.dnd.bookkeeping.android.domain.model.group.Group +import ac.dnd.bookkeeping.android.domain.model.schedule.UnrecordedSchedule +import ac.dnd.bookkeeping.android.domain.repository.GroupRepository +import ac.dnd.bookkeeping.android.domain.repository.ScheduleRepository +import kotlinx.datetime.LocalDate +import kotlinx.datetime.LocalDateTime +import kotlinx.datetime.LocalTime +import javax.inject.Inject + +class RealScheduleRepository @Inject constructor( + private val scheduleApi: ScheduleApi, + private val sharedPreferencesManager: SharedPreferencesManager +) : ScheduleRepository { + override suspend fun addSchedule( + relationId: Long, + day: LocalDate, + event: String, + repeatType: String, + repeatFinish: LocalDate, + alarm: LocalDateTime, + time: LocalTime, + link: String, + location: String, + memo: String + ): Result { + return scheduleApi.addSchedule( + relationId = relationId, + day = day, + event = event, + repeatType = repeatType, + repeatFinish = repeatFinish, + alarm = alarm, + time = time, + link = link, + location = location, + memo = memo + ).toDomain() + } + + override suspend fun editSchedule( + id: Long, + relationId: Long, + day: LocalDate, + event: String, + repeatType: String, + repeatFinish: LocalDate, + alarm: LocalDateTime, + time: LocalTime, + link: String, + location: String, + memo: String + ): Result { + return scheduleApi.editSchedule( + id = id, + relationId = relationId, + day = day, + event = event, + repeatType = repeatType, + repeatFinish = repeatFinish, + alarm = alarm, + time = time, + link = link, + location = location, + memo = memo + ) + } + + override suspend fun deleteSchedule( + id: Long + ): Result { + return scheduleApi.deleteSchedule( + id = id + ) + } + + override suspend fun getUnrecordedScheduleList( + name: String + ): Result> { + return scheduleApi.getUnrecordedScheduleList( + name = name + ).toDomain() + } +} diff --git a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/repository/statistics/MockStatisticsRepository.kt b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/repository/statistics/MockStatisticsRepository.kt new file mode 100644 index 00000000..b97009bf --- /dev/null +++ b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/repository/statistics/MockStatisticsRepository.kt @@ -0,0 +1,82 @@ +package ac.dnd.bookkeeping.android.data.repository.statistics + +import ac.dnd.bookkeeping.android.domain.model.statistics.GroupStatistics +import ac.dnd.bookkeeping.android.domain.model.statistics.MyStatistics +import ac.dnd.bookkeeping.android.domain.model.statistics.MyStatisticsEvent +import ac.dnd.bookkeeping.android.domain.model.statistics.MyStatisticsGive +import ac.dnd.bookkeeping.android.domain.model.statistics.MyStatisticsTake +import ac.dnd.bookkeeping.android.domain.repository.StatisticsRepository +import kotlinx.coroutines.delay +import kotlinx.datetime.LocalDate +import javax.inject.Inject + +class MockStatisticsRepository @Inject constructor() : StatisticsRepository { + + override suspend fun getMyStatistics( + year: Int, + month: Int? + ): Result { + randomLongDelay() + return Result.success( + MyStatistics( + give = MyStatisticsGive( + event = listOf( + MyStatisticsEvent( + name = "Deirdre Guerra", + group = "veri", + money = 4162, + day = LocalDate(2021, 10, 1) + ), + MyStatisticsEvent( + name = "Merritt Mccarthy", + group = "ex", + money = 9402, + day = LocalDate(2021, 10, 1) + ), + ) + ), + take = MyStatisticsTake( + event = listOf( + MyStatisticsEvent( + name = "Calvin Romero", + group = "ex", + money = 9402, + day = LocalDate(2021, 10, 1) + ), + MyStatisticsEvent( + name = "Merritt Mccarthy", + group = "ex", + money = 9402, + day = LocalDate(2021, 10, 1) + ), + ) + ) + ) + ) + } + + override suspend fun getGroupStatistics( + gender: String, + range: Int + ): Result { + randomShortDelay() + return Result.success( + GroupStatistics( + marriage = 3123, + birth = 7383, + baby = 9370, + babyBirth = 4026, + bizopen = 3068, + etc = 3819 + ) + ) + } + + private suspend fun randomShortDelay() { + delay(LongRange(100, 500).random()) + } + + private suspend fun randomLongDelay() { + delay(LongRange(500, 2000).random()) + } +} diff --git a/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/repository/statistics/RealStatisticsRepository.kt b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/repository/statistics/RealStatisticsRepository.kt new file mode 100644 index 00000000..97e920f2 --- /dev/null +++ b/data/src/main/kotlin/ac/dnd/bookkeeping/android/data/repository/statistics/RealStatisticsRepository.kt @@ -0,0 +1,36 @@ +package ac.dnd.bookkeeping.android.data.repository.statistics + +import ac.dnd.bookkeeping.android.data.remote.local.SharedPreferencesManager +import ac.dnd.bookkeeping.android.data.remote.network.api.StatisticsApi +import ac.dnd.bookkeeping.android.data.remote.network.util.toDomain +import ac.dnd.bookkeeping.android.domain.model.group.Group +import ac.dnd.bookkeeping.android.domain.model.statistics.GroupStatistics +import ac.dnd.bookkeeping.android.domain.model.statistics.MyStatistics +import ac.dnd.bookkeeping.android.domain.repository.GroupRepository +import ac.dnd.bookkeeping.android.domain.repository.StatisticsRepository +import javax.inject.Inject + +class RealStatisticsRepository @Inject constructor( + private val statisticsApi: StatisticsApi, + private val sharedPreferencesManager: SharedPreferencesManager +) : StatisticsRepository { + override suspend fun getMyStatistics( + year: Int, + month: Int? + ): Result { + return statisticsApi.getMyStatistics( + year = year, + month = month + ).toDomain() + } + + override suspend fun getGroupStatistics( + gender: String, + range: Int + ): Result { + return statisticsApi.getGroupStatistics( + gender = gender, + range = range + ).toDomain() + } +} diff --git a/domain/src/main/kotlin/ac/dnd/bookkeeping/android/domain/model/authentication/Login.kt b/domain/src/main/kotlin/ac/dnd/bookkeeping/android/domain/model/authentication/Login.kt deleted file mode 100644 index 87678d36..00000000 --- a/domain/src/main/kotlin/ac/dnd/bookkeeping/android/domain/model/authentication/Login.kt +++ /dev/null @@ -1,5 +0,0 @@ -package ac.dnd.bookkeeping.android.domain.model.authentication - -data class Login( - val isNew: Boolean -) diff --git a/domain/src/main/kotlin/ac/dnd/bookkeeping/android/domain/model/authentication/Register.kt b/domain/src/main/kotlin/ac/dnd/bookkeeping/android/domain/model/authentication/Register.kt deleted file mode 100644 index e778a572..00000000 --- a/domain/src/main/kotlin/ac/dnd/bookkeeping/android/domain/model/authentication/Register.kt +++ /dev/null @@ -1,5 +0,0 @@ -package ac.dnd.bookkeeping.android.domain.model.authentication - -data class Register( - val id: Long -) diff --git a/domain/src/main/kotlin/ac/dnd/bookkeeping/android/domain/model/legacy/Login.kt b/domain/src/main/kotlin/ac/dnd/bookkeeping/android/domain/model/legacy/Login.kt new file mode 100644 index 00000000..4fcac3ec --- /dev/null +++ b/domain/src/main/kotlin/ac/dnd/bookkeeping/android/domain/model/legacy/Login.kt @@ -0,0 +1,5 @@ +package ac.dnd.bookkeeping.android.domain.model.legacy + +data class Login( + val isNew: Boolean +) diff --git a/domain/src/main/kotlin/ac/dnd/bookkeeping/android/domain/model/legacy/Register.kt b/domain/src/main/kotlin/ac/dnd/bookkeeping/android/domain/model/legacy/Register.kt new file mode 100644 index 00000000..118fe259 --- /dev/null +++ b/domain/src/main/kotlin/ac/dnd/bookkeeping/android/domain/model/legacy/Register.kt @@ -0,0 +1,5 @@ +package ac.dnd.bookkeeping.android.domain.model.legacy + +data class Register( + val id: Long +) diff --git a/domain/src/main/kotlin/ac/dnd/bookkeeping/android/domain/repository/AuthenticationRepository.kt b/domain/src/main/kotlin/ac/dnd/bookkeeping/android/domain/repository/AuthenticationRepository.kt index e2e5ecdc..d5070c96 100644 --- a/domain/src/main/kotlin/ac/dnd/bookkeeping/android/domain/repository/AuthenticationRepository.kt +++ b/domain/src/main/kotlin/ac/dnd/bookkeeping/android/domain/repository/AuthenticationRepository.kt @@ -1,8 +1,8 @@ package ac.dnd.bookkeeping.android.domain.repository import ac.dnd.bookkeeping.android.domain.model.authentication.JwtToken -import ac.dnd.bookkeeping.android.domain.model.authentication.Login -import ac.dnd.bookkeeping.android.domain.model.authentication.Register +import ac.dnd.bookkeeping.android.domain.model.legacy.Login +import ac.dnd.bookkeeping.android.domain.model.legacy.Register interface AuthenticationRepository { diff --git a/domain/src/main/kotlin/ac/dnd/bookkeeping/android/domain/repository/HeartRepository.kt b/domain/src/main/kotlin/ac/dnd/bookkeeping/android/domain/repository/HeartRepository.kt index 71164752..163d6cf3 100644 --- a/domain/src/main/kotlin/ac/dnd/bookkeeping/android/domain/repository/HeartRepository.kt +++ b/domain/src/main/kotlin/ac/dnd/bookkeeping/android/domain/repository/HeartRepository.kt @@ -2,7 +2,7 @@ package ac.dnd.bookkeeping.android.domain.repository import ac.dnd.bookkeeping.android.domain.model.heart.Heart import ac.dnd.bookkeeping.android.domain.model.heart.RelatedHeart -import java.time.LocalDate +import kotlinx.datetime.LocalDate interface HeartRepository { @@ -38,10 +38,10 @@ interface HeartRepository { suspend fun getHeartList( sort: String = "recent", name: String = "" - ): Result + ): Result> suspend fun getRelatedHeartList( id: Long, sort: String = "recent" - ): Result + ): Result> } diff --git a/domain/src/main/kotlin/ac/dnd/bookkeeping/android/domain/usecase/authentication/LoginUseCase.kt b/domain/src/main/kotlin/ac/dnd/bookkeeping/android/domain/usecase/authentication/LoginUseCase.kt index 873ead8a..6c308088 100644 --- a/domain/src/main/kotlin/ac/dnd/bookkeeping/android/domain/usecase/authentication/LoginUseCase.kt +++ b/domain/src/main/kotlin/ac/dnd/bookkeeping/android/domain/usecase/authentication/LoginUseCase.kt @@ -1,6 +1,6 @@ package ac.dnd.bookkeeping.android.domain.usecase.authentication -import ac.dnd.bookkeeping.android.domain.model.authentication.Login +import ac.dnd.bookkeeping.android.domain.model.legacy.Login import ac.dnd.bookkeeping.android.domain.repository.AuthenticationRepository import javax.inject.Inject diff --git a/domain/src/main/kotlin/ac/dnd/bookkeeping/android/domain/usecase/authentication/RegistrationUseCase.kt b/domain/src/main/kotlin/ac/dnd/bookkeeping/android/domain/usecase/authentication/RegistrationUseCase.kt index 0508574b..f9f1e6fc 100644 --- a/domain/src/main/kotlin/ac/dnd/bookkeeping/android/domain/usecase/authentication/RegistrationUseCase.kt +++ b/domain/src/main/kotlin/ac/dnd/bookkeeping/android/domain/usecase/authentication/RegistrationUseCase.kt @@ -1,6 +1,6 @@ package ac.dnd.bookkeeping.android.domain.usecase.authentication -import ac.dnd.bookkeeping.android.domain.model.authentication.Register +import ac.dnd.bookkeeping.android.domain.model.legacy.Register import ac.dnd.bookkeeping.android.domain.repository.AuthenticationRepository import javax.inject.Inject