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

๐Ÿ”€ :: (#34) - write the logic main #35

Merged
merged 40 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
180d5ed
:sparkles: :: Response -> UiState
diejdkll Jan 28, 2024
3967753
:sparkles: :: = -> by
diejdkll Jan 28, 2024
67a8d15
:sparkles: :: Change success processing
diejdkll Jan 28, 2024
679030e
:truck: :: Move to main component
diejdkll Jan 28, 2024
3c348e9
:sparkles: :: Add profile response
diejdkll Jan 28, 2024
022f012
:sparkles: :: Add rank response
diejdkll Jan 28, 2024
a46dba4
:sparkles: :: Add outing response
diejdkll Jan 28, 2024
3e6b702
:sparkles: :: Add count response
diejdkll Jan 28, 2024
a5160d2
:sparkles: :: Add account api
diejdkll Jan 28, 2024
8693589
:sparkles: :: Add late api
diejdkll Jan 28, 2024
9096bde
:sparkles: :: Add outing api
diejdkll Jan 28, 2024
f06f498
:sparkles: :: Add account datasource
diejdkll Jan 28, 2024
278cb99
:sparkles: :: Add account repository
diejdkll Jan 28, 2024
1dfc782
:sparkles: :: Add GetProfileUseCase
diejdkll Jan 28, 2024
bd79453
:sparkles: :: Add late datasource
diejdkll Jan 28, 2024
8a065a0
:sparkles: :: Add late repository
diejdkll Jan 28, 2024
6c22cc7
:sparkles: :: Add GetLateRankListUseCase
diejdkll Jan 28, 2024
cf02b98
:sparkles: :: Add outing datasource
diejdkll Jan 28, 2024
64ff200
:sparkles: :: Add outing repository
diejdkll Jan 28, 2024
f385536
:sparkles: :: Add GetOutingListUseCase
diejdkll Jan 28, 2024
bfef221
:sparkles: :: Add GetOutingCountUseCase
diejdkll Jan 28, 2024
9fc096b
:sparkles: :: Add ui state
diejdkll Jan 28, 2024
f6a79c3
:sparkles: :: Add main viewmodel
diejdkll Jan 28, 2024
2d2169a
:sparkles: :: Add module
diejdkll Jan 28, 2024
3f2c7cf
:sparkles: :: Modify refreshToken
diejdkll Jan 28, 2024
56882b3
:sparkles: :: Write the logic get profile
diejdkll Jan 28, 2024
48ffab7
:fire: :: Remove proview
diejdkll Jan 28, 2024
552885a
:sparkles: :: Write the logic get late rank list
diejdkll Jan 28, 2024
4028750
:sparkles: :: Write the logic get outing
diejdkll Jan 28, 2024
7679b3a
:bug: :: Fix not add header bug
diejdkll Jan 29, 2024
30ebe2d
:sparkles: :: Connect role to main screen
diejdkll Jan 29, 2024
f9baee9
:sparkles: :: Create Major todate function
diejdkll Jan 29, 2024
a523a20
:lipstick: :: Add default profile image
diejdkll Jan 29, 2024
8b95c73
:bug: :: Fix a problem where a header was added to the auth
diejdkll Jan 30, 2024
02a659d
:sparkles: :: Change main movement logic
diejdkll Jan 30, 2024
16eca71
:sparkles: :: Maintain login status
diejdkll Jan 30, 2024
689c499
:sparkles: :: Add private
diejdkll Jan 30, 2024
bde55e1
:bug: :: Fix uuid -> string
diejdkll Jan 30, 2024
b465026
:sparkles: :: Change list items
diejdkll Jan 30, 2024
698d577
:bug: :: Fix createdAt -> createdTime
diejdkll Jan 30, 2024
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
21 changes: 21 additions & 0 deletions core/data/src/main/java/com/goms/data/di/RepositoryModule.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
package com.goms.data.di

import com.goms.data.repository.account.AccountRepository
import com.goms.data.repository.account.AccountRepositoryImpl
import com.goms.data.repository.auth.AuthRepository
import com.goms.data.repository.auth.AuthRepositoryImpl
import com.goms.data.repository.late.LateRepository
import com.goms.data.repository.late.LateRepositoryImpl
import com.goms.data.repository.outing.OutingRepository
import com.goms.data.repository.outing.OutingRepositoryImpl
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
Expand All @@ -14,4 +20,19 @@ abstract class RepositoryModule {
abstract fun bindAuthRepository(
authRepositoryImpl: AuthRepositoryImpl
): AuthRepository

@Binds
abstract fun bindAccountRepository(
accountRepositoryImpl: AccountRepositoryImpl
): AccountRepository

@Binds
abstract fun bindLateRepository(
lateRepositoryImpl: LateRepositoryImpl
): LateRepository

@Binds
abstract fun bindOutingRepository(
outingRepositoryImpl: OutingRepositoryImpl
): OutingRepository
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.goms.data.repository.account

import com.goms.model.response.account.ProfileResponse
import kotlinx.coroutines.flow.Flow

interface AccountRepository {
suspend fun getProfile(): Flow<ProfileResponse>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.goms.data.repository.account

import com.goms.model.response.account.ProfileResponse
import com.goms.network.datasource.account.AccountDataSource
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject

class AccountRepositoryImpl @Inject constructor(
private val remoteAccountDataSource: AccountDataSource
) : AccountRepository {
override suspend fun getProfile(): Flow<ProfileResponse> {
return remoteAccountDataSource.getProfile()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.goms.data.repository.late

import com.goms.model.response.late.RankResponse
import kotlinx.coroutines.flow.Flow

interface LateRepository {
suspend fun getLateRankList(): Flow<List<RankResponse>>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.goms.data.repository.late

import com.goms.model.response.late.RankResponse
import com.goms.network.datasource.late.LateDataSource
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject

class LateRepositoryImpl @Inject constructor(
private val remoteLateDataSource: LateDataSource
) : LateRepository {
override suspend fun getLateRankList(): Flow<List<RankResponse>> {
return remoteLateDataSource.getLateRankList()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.goms.data.repository.outing

import com.goms.model.response.outing.CountResponse
import com.goms.model.response.outing.OutingResponse
import kotlinx.coroutines.flow.Flow

interface OutingRepository {
suspend fun getOutingList(): Flow<List<OutingResponse>>

suspend fun getOutingCount(): Flow<CountResponse>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.goms.data.repository.outing

import com.goms.model.response.outing.CountResponse
import com.goms.model.response.outing.OutingResponse
import com.goms.network.datasource.outing.OutingDataSource
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject

class OutingRepositoryImpl @Inject constructor(
private val remoteOutingDataSource: OutingDataSource
) : OutingRepository {
override suspend fun getOutingList(): Flow<List<OutingResponse>> {
return remoteOutingDataSource.getOutingList()
}

override suspend fun getOutingCount(): Flow<CountResponse> {
return remoteOutingDataSource.getOutingCount()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class AuthTokenDataSource @Inject constructor(
suspend fun setRefreshTokenExp(refreshTokenExp: String) {
authToken.updateData {
it.toBuilder()
.setRefreshToken(refreshTokenExp)
.setRefreshExp(refreshTokenExp)
.build()
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.goms.domain.account

import com.goms.data.repository.account.AccountRepository
import com.goms.model.response.account.ProfileResponse
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject

class GetProfileUseCase @Inject constructor(
private val accountRepository: AccountRepository
) {
suspend operator fun invoke(): Flow<ProfileResponse> =
accountRepository.getProfile()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.goms.domain.late

import com.goms.data.repository.late.LateRepository
import com.goms.model.response.late.RankResponse
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject

class GetLateRankListUseCase @Inject constructor(
private val lateRepository: LateRepository
) {
suspend operator fun invoke(): Flow<List<RankResponse>> =
lateRepository.getLateRankList()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.goms.domain.outing

import com.goms.data.repository.outing.OutingRepository
import com.goms.model.response.outing.CountResponse
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject

class GetOutingCountUseCase @Inject constructor(
private val outingRepository: OutingRepository
) {
suspend operator fun invoke(): Flow<CountResponse> =
outingRepository.getOutingCount()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.goms.domain.outing

import com.goms.data.repository.outing.OutingRepository
import com.goms.model.response.outing.OutingResponse
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject

class GetOutingListUseCase @Inject constructor(
private val outingRepository: OutingRepository
) {
suspend operator fun invoke(): Flow<List<OutingResponse>> =
outingRepository.getOutingList()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.goms.model.response.account

import com.goms.model.enum.Authority
import com.goms.model.enum.Gender
import com.goms.model.enum.Major
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass

@JsonClass(generateAdapter = true)
data class ProfileResponse(
@Json(name = "name") val name: String,
@Json(name = "grade") val grade: Int,
@Json(name = "major") val major: Major,
@Json(name = "gender") val gender: Gender,
@Json(name = "authority") val authority: Authority,
@Json(name = "profileUrl") val profileUrl: String?,
@Json(name = "lateCount") val lateCount: Int,
@Json(name = "isOuting") val isOuting: Boolean,
@Json(name = "isBlackList") val isBlackList: Boolean
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.goms.model.response.late

import com.goms.model.enum.Gender
import com.goms.model.enum.Major
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import java.util.UUID

@JsonClass(generateAdapter = true)
data class RankResponse(
@Json(name = "accountIdx") val accountIdx: UUID,
@Json(name = "name") val name: String,
@Json(name = "grade") val grade: Int,
@Json(name = "major") val major: Major,
@Json(name = "gender") val gender: Gender,
@Json(name = "profileUrl") val profileUrl: String?
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.goms.model.response.outing

import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass

@JsonClass(generateAdapter = true)
data class CountResponse(
@Json(name = "outingCount") val outingCount: Int
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.goms.model.response.outing

import com.goms.model.enum.Gender
import com.goms.model.enum.Major
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import java.util.UUID

@JsonClass(generateAdapter = true)
data class OutingResponse(
@Json(name = "accountIdx") val accountIdx: UUID,
@Json(name = "name") val name: String,
@Json(name = "major") val major: Major,
@Json(name = "grade") val grade: Int,
@Json(name = "gender") val gender: Gender,
@Json(name = "profileUrl") val profileUrl: String?,
@Json(name = "createdAt") val createdAt: String
)
9 changes: 9 additions & 0 deletions core/network/src/main/java/com/goms/network/api/AccountAPI.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.goms.network.api

import com.goms.model.response.account.ProfileResponse
import retrofit2.http.GET

interface AccountAPI {
@GET("/api/v2/account/profile")
suspend fun getProfile(): ProfileResponse
}
9 changes: 9 additions & 0 deletions core/network/src/main/java/com/goms/network/api/LateAPI.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.goms.network.api

import com.goms.model.response.late.RankResponse
import retrofit2.http.GET

interface LateAPI {
@GET("/api/v2/late/rank")
suspend fun getLateRankList(): List<RankResponse>
}
13 changes: 13 additions & 0 deletions core/network/src/main/java/com/goms/network/api/OutingAPI.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.goms.network.api

import com.goms.model.response.outing.CountResponse
import com.goms.model.response.outing.OutingResponse
import retrofit2.http.GET

interface OutingAPI {
@GET("/api/v2/outing/")
suspend fun getOutingList(): List<OutingResponse>

@GET("/api/v2/outing/count")
suspend fun getOutingCount(): CountResponse
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.goms.network.datasource.account

import com.goms.model.response.account.ProfileResponse
import kotlinx.coroutines.flow.Flow

interface AccountDataSource {
suspend fun getProfile(): Flow<ProfileResponse>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.goms.network.datasource.account

import com.goms.model.response.account.ProfileResponse
import com.goms.network.api.AccountAPI
import com.goms.network.util.GomsApiHandler
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.flowOn
import javax.inject.Inject

class AccountDataSourceImpl @Inject constructor(
private val accountAPI: AccountAPI
) : AccountDataSource {
override suspend fun getProfile(): Flow<ProfileResponse> = flow {
emit(
GomsApiHandler<ProfileResponse>()
.httpRequest { accountAPI.getProfile() }
.sendRequest()
)
}.flowOn(Dispatchers.IO)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.goms.network.datasource.late

import com.goms.model.response.late.RankResponse
import kotlinx.coroutines.flow.Flow

interface LateDataSource {
suspend fun getLateRankList(): Flow<List<RankResponse>>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.goms.network.datasource.late

import com.goms.model.response.late.RankResponse
import com.goms.network.api.LateAPI
import com.goms.network.util.GomsApiHandler
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.flowOn
import javax.inject.Inject

class LateDataSourceImpl @Inject constructor(
private val lateAPI: LateAPI
) : LateDataSource {
override suspend fun getLateRankList(): Flow<List<RankResponse>> = flow {
emit(
GomsApiHandler<List<RankResponse>>()
.httpRequest { lateAPI.getLateRankList() }
.sendRequest()
)
}.flowOn(Dispatchers.IO)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.goms.network.datasource.outing

import com.goms.model.response.outing.CountResponse
import com.goms.model.response.outing.OutingResponse
import kotlinx.coroutines.flow.Flow

interface OutingDataSource {
suspend fun getOutingList(): Flow<List<OutingResponse>>

suspend fun getOutingCount(): Flow<CountResponse>
}
Loading
Loading