Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Repository 연결 #37

Merged
merged 5 commits into from
Feb 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,22 @@ package ac.dnd.bookkeeping.android.data.di

import ac.dnd.bookkeeping.android.data.repository.authentication.MockAuthenticationRepository
import ac.dnd.bookkeeping.android.data.repository.file.MockFileRepository
import ac.dnd.bookkeeping.android.data.repository.group.MockGroupRepository
import ac.dnd.bookkeeping.android.data.repository.heart.MockHeartRepository
import ac.dnd.bookkeeping.android.data.repository.member.MockMemberRepository
import ac.dnd.bookkeeping.android.data.repository.relation.MockRelationRepository
import ac.dnd.bookkeeping.android.data.repository.schedule.MockScheduleRepository
import ac.dnd.bookkeeping.android.data.repository.sociallogin.KakaoLoginRepositoryImpl
import ac.dnd.bookkeeping.android.data.repository.statistics.MockStatisticsRepository
import ac.dnd.bookkeeping.android.domain.repository.AuthenticationRepository
import ac.dnd.bookkeeping.android.domain.repository.FileRepository
import ac.dnd.bookkeeping.android.domain.repository.GroupRepository
import ac.dnd.bookkeeping.android.domain.repository.HeartRepository
import ac.dnd.bookkeeping.android.domain.repository.KakaoLoginRepository
import ac.dnd.bookkeeping.android.domain.repository.MemberRepository
import ac.dnd.bookkeeping.android.domain.repository.RelationRepository
import ac.dnd.bookkeeping.android.domain.repository.ScheduleRepository
import ac.dnd.bookkeeping.android.domain.repository.StatisticsRepository
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
Expand All @@ -24,6 +34,18 @@ internal abstract class RepositoryModule {
authenticationRepository: MockAuthenticationRepository
): AuthenticationRepository

@Binds
@Singleton
abstract fun bindsGroupRepository(
groupRepository: MockGroupRepository
): GroupRepository

@Binds
@Singleton
abstract fun bindsHeartRepository(
heartRepository: MockHeartRepository
): HeartRepository

@Binds
@Singleton
abstract fun bindsMemberRepository(
Expand All @@ -32,13 +54,31 @@ internal abstract class RepositoryModule {

@Binds
@Singleton
abstract fun bindsFileRepository(
fileRepository: MockFileRepository
): FileRepository
abstract fun bindsRelationRepository(
relationRepository: MockRelationRepository
): RelationRepository

@Binds
@Singleton
abstract fun bindsScheduleRepository(
scheduleRepository: MockScheduleRepository
): ScheduleRepository

@Binds
@Singleton
abstract fun bindsStatisticsRepository(
statisticsRepository: MockStatisticsRepository
): StatisticsRepository

@Binds
@Singleton
abstract fun bindsKakaoLoginRepository(
kakaoLoginRepositoryImpl: KakaoLoginRepositoryImpl
): KakaoLoginRepository

@Binds
@Singleton
abstract fun bindsFileRepository(
fileRepository: MockFileRepository
): FileRepository
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -11,4 +12,9 @@ data class LoginRes(
val accessToken: String,
@SerialName("refreshToken")
val refreshToken: String
)
) : DataMapper<Boolean> {
override fun toDomain(): Boolean {
return isNew
}
}

Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -11,4 +12,9 @@ data class RegisterRes(
val accessToken: String,
@SerialName("refreshToken")
val refreshToken: String
)
) : DataMapper<Long> {
override fun toDomain(): Long {
return id
}
}

Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
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

@Serializable
data class AddGroupRes(
@SerialName("result")
val result: Long
)
) : DataMapper<Long> {
override fun toDomain(): Long {
return result
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
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

@Serializable
data class GetGroupListRes(
@SerialName("result")
val result: List<GetGroupItemRes>
)
) : DataMapper<List<Group>> {
override fun toDomain(): List<Group> {
return result.map { it.toDomain() }
}
}

@Serializable
data class GetGroupItemRes(
@SerialName("id")
val id: Long,
@SerialName("name")
val name: String
)
) : DataMapper<Group> {
override fun toDomain(): Group {
return Group(
id = id,
name = name
)
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
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

@Serializable
data class AddHeartRes(
@SerialName("result")
val result: Long
)
) : DataMapper<Long> {
override fun toDomain(): Long {
return result
}
}

Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
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

@Serializable
data class AddUnrecordedHeartRes(
@SerialName("result")
val result: Long
)
) : DataMapper<Long> {
override fun toDomain(): Long {
return result
}
}

Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
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

@Serializable
data class GetHeartListRes(
@SerialName("result")
val result: List<GetHeartItemRes>
)
) : DataMapper<List<Heart>> {
override fun toDomain(): List<Heart> {
return result.map { it.toDomain() }
}
}


@Serializable
data class GetHeartItemRes(
Expand All @@ -25,13 +33,32 @@ data class GetHeartItemRes(
val giveHistories: List<Long>,
@SerialName("takeHistories")
val takeHistories: List<Long>
)
) : DataMapper<Heart> {
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(
@SerialName("id")
val id: Long,
@SerialName("name")
val name: String
)
) : DataMapper<HeartGroup> {
override fun toDomain(): HeartGroup {
return HeartGroup(
id = id,
name = name
)
}
}

Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -8,7 +10,11 @@ import kotlinx.serialization.Serializable
data class GetRelatedHeartListRes(
@SerialName("result")
val result: List<GetRelatedHeartItemRes>
)
) : DataMapper<List<RelatedHeart>> {
override fun toDomain(): List<RelatedHeart> {
return result.map { it.toDomain() }
}
}

@Serializable
data class GetRelatedHeartItemRes(
Expand All @@ -26,5 +32,16 @@ data class GetRelatedHeartItemRes(
val memo: String,
@SerialName("tags")
val tags: List<String>
)

) : DataMapper<RelatedHeart> {
override fun toDomain(): RelatedHeart {
return RelatedHeart(
id = id,
give = give,
money = money,
day = day,
event = event,
memo = memo,
tags = tags
)
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
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

@Serializable
data class CheckNicknameRes(
@SerialName("result")
val result: Boolean
)
) : DataMapper<Boolean> {
override fun toDomain(): Boolean {
return result
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -14,4 +16,13 @@ data class GetProfileRes(
val gender: String,
@SerialName("birth")
val birth: LocalDate
)
) : DataMapper<Profile> {
override fun toDomain(): Profile {
return Profile(
name = name,
nickname = nickname,
gender = gender,
birth = birth
)
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
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

@Serializable
data class AddRelationRes(
@SerialName("result")
val result: Long
)
) : DataMapper<Long> {
override fun toDomain(): Long {
return result
}
}

Loading
Loading