Skip to content

Commit

Permalink
[MERGE] #73 -> develop
Browse files Browse the repository at this point in the history
[FEAT/#73] 여행 대시 보드 뷰 / 서버 통신 구현
  • Loading branch information
leeeyubin authored Jan 12, 2024
2 parents dd0ae45 + 992a39d commit 912cae5
Show file tree
Hide file tree
Showing 44 changed files with 622 additions and 270 deletions.
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
android:screenOrientation="portrait" />

<activity
android:name="com.going.presentation.tripdashboard.TripDashBoardActivity"
android:name="com.going.presentation.dashboard.DashBoardActivity"
android:exported="false"
android:screenOrientation="portrait" />

Expand Down
7 changes: 7 additions & 0 deletions app/src/main/java/com/going/doorip/di/DataSourceModule.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.going.doorip.di

import com.going.data.datasource.AuthDataSource
import com.going.data.datasource.DashBoardDataSource
import com.going.data.datasource.EnterTripDataSource
import com.going.data.datasource.MockDataSource
import com.going.data.datasource.SettingDataSource
import com.going.data.datasource.TendencyDataSource
import com.going.data.datasource.TodoDataSource
import com.going.data.datasourceImpl.AuthDataSourceImpl
import com.going.data.datasourceImpl.DashBoardDataSourceImpl
import com.going.data.datasourceImpl.EnterTripDataSourceImpl
import com.going.data.datasourceImpl.MockDataSourceImpl
import com.going.data.datasourceImpl.SettingDataSourceImpl
Expand Down Expand Up @@ -42,6 +44,11 @@ object DataSourceModule {
fun provideTodoDataSource(todoDataSourceImpl: TodoDataSourceImpl): TodoDataSource =
todoDataSourceImpl

@Provides
@Singleton
fun provideDashBoardDataSource(dashBoardDataSourceImpl: DashBoardDataSourceImpl): DashBoardDataSource =
dashBoardDataSourceImpl

@Provides
@Singleton
fun provideTendencyDataSource(tendencyDataSourceImpl: TendencyDataSourceImpl): TendencyDataSource =
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/java/com/going/doorip/di/RepositoryModule.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package com.going.doorip.di

import com.going.data.repositoryImpl.AuthRepositoryImpl
import com.going.data.repositoryImpl.DashBoardRepositoryImpl
import com.going.data.repositoryImpl.EnterTripRepositoryImpl
import com.going.data.repositoryImpl.MockRepositoryImpl
import com.going.data.repositoryImpl.SettingRepositoryImpl
import com.going.data.repositoryImpl.TendencyRepositoryImpl
import com.going.data.repositoryImpl.TodoRepositoryImpl
import com.going.data.repositoryImpl.TokenRepositoryImpl
import com.going.domain.repository.AuthRepository
import com.going.domain.repository.DashBoardRepository
import com.going.domain.repository.EnterTripRepository
import com.going.domain.repository.MockRepository
import com.going.domain.repository.SettingRepository
Expand Down Expand Up @@ -49,6 +51,11 @@ object RepositoryModule {
fun provideTodoRepository(todoRepositoryImpl: TodoRepositoryImpl): TodoRepository =
todoRepositoryImpl

@Provides
@Singleton
fun providesDashBoardRepository(dashBoardRepositoryImpl: DashBoardRepositoryImpl): DashBoardRepository =
dashBoardRepositoryImpl

@Provides
@Singleton
fun provideEnterTripRepository(entertripRepositoryImpl: EnterTripRepositoryImpl): EnterTripRepository =
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/java/com/going/doorip/di/ServiceModule.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.going.doorip.di

import com.going.data.service.AuthService
import com.going.data.service.DashBoardService
import com.going.data.service.EnterTripService
import com.going.data.service.MockService
import com.going.data.service.SettingService
Expand Down Expand Up @@ -37,6 +38,11 @@ object ServiceModule {
fun provideTodoService(retrofit: Retrofit): TodoService =
retrofit.create(TodoService::class.java)

@Provides
@Singleton
fun provideDashBoardService(retrofit: Retrofit): DashBoardService =
retrofit.create(DashBoardService::class.java)

@Provides
@Singleton
fun provideEnterTripService(retrofit: Retrofit): EnterTripService =
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.going.data.datasource

import com.going.data.dto.BaseResponse
import com.going.data.dto.response.DashBoardResponseDto

interface DashBoardDataSource {

suspend fun getTripList(
progress: String
): BaseResponse<DashBoardResponseDto>

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.going.data.datasource
import com.going.data.dto.NonDataBaseResponse

interface SettingDataSource {
suspend fun patchSignOut(): NonDataBaseResponse
suspend fun patchSignOut(): NonDataBaseResponse<Any?>

suspend fun deleteWithDraw(): NonDataBaseResponse
suspend fun deleteWithDraw(): NonDataBaseResponse<Any?>
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import com.going.data.dto.NonDataBaseResponse
import com.going.data.dto.request.TendencyTestRequestDto

interface TendencyDataSource {
suspend fun patchTendencyTest(result: TendencyTestRequestDto): NonDataBaseResponse
suspend fun patchTendencyTest(result: TendencyTestRequestDto): NonDataBaseResponse<Any?>
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ interface TodoDataSource {
suspend fun postToCreateTodoData(
tripId: Long,
request: TodoCreateRequestDto
): NonDataBaseResponse
): NonDataBaseResponse<Unit>

suspend fun deleteTodoData(
todoId: Long
): NonDataBaseResponse
): NonDataBaseResponse<Unit>

suspend fun getTodoDetailData(
todoId: Long
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.going.data.datasourceImpl

import com.going.data.datasource.DashBoardDataSource
import com.going.data.dto.BaseResponse
import com.going.data.dto.response.DashBoardResponseDto
import com.going.data.service.DashBoardService
import javax.inject.Inject

class DashBoardDataSourceImpl @Inject constructor(
private val dashBoardService: DashBoardService
) : DashBoardDataSource {

override suspend fun getTripList(progress: String): BaseResponse<DashBoardResponseDto> =
dashBoardService.getTripList(progress)

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ import javax.inject.Inject
class SettingDataSourceImpl @Inject constructor(
private val settingService: SettingService,
) : SettingDataSource {
override suspend fun patchSignOut(): NonDataBaseResponse = settingService.patchSignOut()
override suspend fun deleteWithDraw(): NonDataBaseResponse = settingService.deleteWithDraw()
override suspend fun patchSignOut(): NonDataBaseResponse<Any?> = settingService.patchSignOut()
override suspend fun deleteWithDraw(): NonDataBaseResponse<Any?> = settingService.deleteWithDraw()
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ import javax.inject.Inject
class TendencyDataSourceImpl @Inject constructor(
private val tendencyService: TendencyService,
) : TendencyDataSource {
override suspend fun patchTendencyTest(result: TendencyTestRequestDto): NonDataBaseResponse =
override suspend fun patchTendencyTest(result: TendencyTestRequestDto): NonDataBaseResponse<Any?> =
tendencyService.patchTendencyTest(result)
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ class TodoDataSourceImpl @Inject constructor(
override suspend fun postToCreateTodoData(
tripId: Long,
request: TodoCreateRequestDto
): NonDataBaseResponse =
): NonDataBaseResponse<Unit> =
todoService.postToCreateTodo(tripId, request)

override suspend fun deleteTodoData(
todoId: Long
): NonDataBaseResponse =
): NonDataBaseResponse<Unit> =
todoService.deleteTodo(todoId)

override suspend fun getTodoDetailData(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class NonDataBaseResponse(
data class NonDataBaseResponse<T>(
@SerialName("status")
val status: Int,
@SerialName("code")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.going.data.dto.response

import com.going.domain.entity.response.DashBoardModel
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class DashBoardResponseDto(
@SerialName("name")
val name: String,
@SerialName("trips")
val trips: List<TripsResponseDto>

) {
@Serializable
data class TripsResponseDto(
@SerialName("tripId")
val tripId: Long,
@SerialName("title")
val title: String,
@SerialName("startDate")
val startDate: String,
@SerialName("endDate")
val endDate: String,
@SerialName("day")
val day: Int
) {
fun toTripsModel() =
DashBoardModel.DashBoardTripModel(tripId, title, startDate, endDate, day)
}

fun toDashBoardModel() =
DashBoardModel(name, trips.map {
it.toTripsModel()
})
}

Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class AuthInterceptor @Inject constructor(

Timber.d("GET ACCESS TOKEN : ${dataStore.accessToken}")


val authRequest = if (dataStore.accessToken.isNotBlank()) {
originalRequest.newAuthBuilder().build()
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.going.data.repositoryImpl

import com.going.data.datasource.DashBoardDataSource
import com.going.domain.entity.response.DashBoardModel
import com.going.domain.repository.DashBoardRepository
import javax.inject.Inject

class DashBoardRepositoryImpl @Inject constructor(
private val dashBoardSource: DashBoardDataSource
) : DashBoardRepository {

override suspend fun getDashBoardList(
progress: String
): Result<DashBoardModel> =
runCatching {
dashBoardSource.getTripList(progress).data.toDashBoardModel()
}

}
15 changes: 15 additions & 0 deletions data/src/main/java/com/going/data/service/DashBoardService.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.going.data.service

import com.going.data.dto.BaseResponse
import com.going.data.dto.response.DashBoardResponseDto
import retrofit2.http.GET
import retrofit2.http.Query

interface DashBoardService {

@GET("api/trips")
suspend fun getTripList(
@Query("progress") progress: String
) : BaseResponse<DashBoardResponseDto>

}
4 changes: 2 additions & 2 deletions data/src/main/java/com/going/data/service/SettingService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import retrofit2.http.PATCH

interface SettingService {
@PATCH("api/users/signout")
suspend fun patchSignOut(): NonDataBaseResponse
suspend fun patchSignOut(): NonDataBaseResponse<Any?>

@DELETE("api/users/withdraw")
suspend fun deleteWithDraw(): NonDataBaseResponse
suspend fun deleteWithDraw(): NonDataBaseResponse<Any?>
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ interface TendencyService {
@PATCH("api/users/test")
suspend fun patchTendencyTest(
@Body result: TendencyTestRequestDto,
): NonDataBaseResponse
): NonDataBaseResponse<Any?>
}
4 changes: 2 additions & 2 deletions data/src/main/java/com/going/data/service/TodoService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ interface TodoService {
suspend fun postToCreateTodo(
@Path("tripId") tripId: Long,
@Body request: TodoCreateRequestDto
): NonDataBaseResponse
): NonDataBaseResponse<Unit>

@DELETE("api/trips/todos/{todoId}")
suspend fun deleteTodo(
@Path("todoId") todoId: Long
): NonDataBaseResponse
): NonDataBaseResponse<Unit>

@GET("api/trips/todos/{todoId}")
suspend fun getTodoDetail(
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.going.domain.entity.response

data class DashBoardModel(
val name: String,
val trips: List<DashBoardTripModel>
){
data class DashBoardTripModel(
val tripId: Long,
val title: String,
val startDate: String,
val endDate: String,
val day: Int
)
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.going.domain.repository

import com.going.domain.entity.response.DashBoardModel

interface DashBoardRepository {
suspend fun getDashBoardList(
progress : String,
) : Result<DashBoardModel>
}
Loading

0 comments on commit 912cae5

Please sign in to comment.