Skip to content

Commit

Permalink
[MERGE] #85 -> develop
Browse files Browse the repository at this point in the history
[FEAT/#85] μ•„μ›Œνˆ¬λ‘, λ§ˆμ΄νˆ¬λ‘ 정보 / μ„œλ²„ν†΅μ‹  κ΅¬ν˜„
  • Loading branch information
Marchbreeze authored Jan 12, 2024
2 parents 912cae5 + 2a85144 commit c36e641
Show file tree
Hide file tree
Showing 36 changed files with 346 additions and 92 deletions.
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<Any?>
suspend fun patchSignOut(): NonDataBaseResponse

suspend fun deleteWithDraw(): NonDataBaseResponse<Any?>
suspend fun deleteWithDraw(): NonDataBaseResponse
}
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<Any?>
suspend fun patchTendencyTest(result: TendencyTestRequestDto): NonDataBaseResponse
}
14 changes: 12 additions & 2 deletions data/src/main/java/com/going/data/datasource/TodoDataSource.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package com.going.data.datasource
import com.going.data.dto.BaseResponse
import com.going.data.dto.NonDataBaseResponse
import com.going.data.dto.request.TodoCreateRequestDto
import com.going.data.dto.response.MyTripInfoResponseDto
import com.going.data.dto.response.OurTripInfoResponseDto
import com.going.data.dto.response.TodoDetailResponseDto
import com.going.data.dto.response.TodoResponseDto

Expand All @@ -17,14 +19,22 @@ interface TodoDataSource {
suspend fun postToCreateTodoData(
tripId: Long,
request: TodoCreateRequestDto
): NonDataBaseResponse<Unit>
): NonDataBaseResponse

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

suspend fun getTodoDetailData(
todoId: Long
): BaseResponse<TodoDetailResponseDto>

suspend fun getMyTripInfo(
tripId: Long
): BaseResponse<MyTripInfoResponseDto>

suspend fun getOurTripInfo(
tripId: Long
): BaseResponse<OurTripInfoResponseDto>

}
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<Any?> = settingService.patchSignOut()
override suspend fun deleteWithDraw(): NonDataBaseResponse<Any?> = settingService.deleteWithDraw()
override suspend fun patchSignOut(): NonDataBaseResponse = settingService.patchSignOut()
override suspend fun deleteWithDraw(): NonDataBaseResponse = 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<Any?> =
override suspend fun patchTendencyTest(result: TendencyTestRequestDto): NonDataBaseResponse =
tendencyService.patchTendencyTest(result)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import com.going.data.datasource.TodoDataSource
import com.going.data.dto.BaseResponse
import com.going.data.dto.NonDataBaseResponse
import com.going.data.dto.request.TodoCreateRequestDto
import com.going.data.dto.response.MyTripInfoResponseDto
import com.going.data.dto.response.OurTripInfoResponseDto
import com.going.data.dto.response.TodoDetailResponseDto
import com.going.data.dto.response.TodoResponseDto
import com.going.data.service.TodoService
Expand All @@ -23,17 +25,27 @@ class TodoDataSourceImpl @Inject constructor(
override suspend fun postToCreateTodoData(
tripId: Long,
request: TodoCreateRequestDto
): NonDataBaseResponse<Unit> =
): NonDataBaseResponse =
todoService.postToCreateTodo(tripId, request)

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

override suspend fun getTodoDetailData(
todoId: Long
): BaseResponse<TodoDetailResponseDto> =
todoService.getTodoDetail(todoId)

override suspend fun getMyTripInfo(
tripId: Long
): BaseResponse<MyTripInfoResponseDto> =
todoService.getMyTripInfo(tripId)

override suspend fun getOurTripInfo(
tripId: Long
): BaseResponse<OurTripInfoResponseDto> =
todoService.getOurTripInfo(tripId)

}
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<T>(
data class NonDataBaseResponse(
@SerialName("status")
val status: Int,
@SerialName("code")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.going.data.dto.response

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

@Serializable
data class MyTripInfoResponseDto(
@SerialName("name")
val name: String,
@SerialName("count")
val count: Int
) {
fun toMyTripInfoModel() =
MyTripInfoModel(name, count)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.going.data.dto.response

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

@Serializable
data class OurTripInfoResponseDto(
@SerialName("title")
val title: String,
@SerialName("day")
val day: Int,
@SerialName("startDate")
val startDate: String,
@SerialName("endDate")
val endDate: String,
@SerialName("progress")
val progress: Int,
@SerialName("code")
val code: String,
@SerialName("isComplete")
val isComplete: Boolean,
@SerialName("participants")
val participants: List<TripParticipantResponseDto>
) {
fun toOurTripInfoModel() : OurTripInfoModel =
OurTripInfoModel(title, day, startDate, endDate, progress, code, isComplete, participants.map { it.toTripParticipantModel() })
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.going.data.dto.response

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

@Serializable
data class TodoAllocatorResponseDto(
@SerialName("name")
val name: String,
@SerialName("isOwner")
val isOwner: Boolean
) {
fun toTodoAllocatorModel() =
TodoAllocatorModel(name, isOwner)
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ data class TodoDetailResponseDto(
@SerialName("endDate")
val endDate: String,
@SerialName("allocators")
val allocators: List<TodoResponseDto.TodoAllocatorResponseDto>,
val allocators: List<TodoAllocatorResponseDto>,
@SerialName("memo")
val memo: String,
@SerialName("secret")
Expand Down
10 changes: 0 additions & 10 deletions data/src/main/java/com/going/data/dto/response/TodoResponseDto.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,6 @@ data class TodoResponseDto(
@SerialName("secret")
val secret: Boolean
) {
@Serializable
data class TodoAllocatorResponseDto(
@SerialName("name")
val name: String,
@SerialName("isOwner")
val isOwner: Boolean
) {
fun toTodoAllocatorModel() =
TodoAllocatorModel(name, isOwner)
}
fun toTodoModel() =
TodoModel(todoId, title, endDate, allocators.map { it.toTodoAllocatorModel() }, secret)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.going.data.dto.response

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

@Serializable
data class TripParticipantResponseDto(
@SerialName("participantId")
val participantId: Long,
@SerialName("name")
val name: String,
@SerialName("result")
val result: Int
) {
fun toTripParticipantModel() : TripParticipantModel =
TripParticipantModel(participantId, name, result)
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@ class AuthInterceptor @Inject constructor(

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


val authRequest = if (dataStore.accessToken.isNotBlank()) {
originalRequest.newAuthBuilder().build()
} else {
originalRequest
}


val response = chain.proceed(authRequest)

when (response.code) {
Expand Down Expand Up @@ -86,9 +84,8 @@ class AuthInterceptor @Inject constructor(
return response
}

private fun Request.newAuthBuilder() =
this.newBuilder().addHeader(AUTHORIZATION, "$BEARER ${dataStore.accessToken}")

private fun Request.newAuthBuilder() =
this.newBuilder().addHeader(AUTHORIZATION, "$BEARER ${dataStore.accessToken}")

companion object {
private const val CODE_TOKEN_EXPIRED = 401
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package com.going.data.repositoryImpl
import com.going.data.datasource.TodoDataSource
import com.going.data.dto.request.toTodoCreateRequestDto
import com.going.domain.entity.request.TodoCreateRequestModel
import com.going.domain.entity.response.MyTripInfoModel
import com.going.domain.entity.response.OurTripInfoModel
import com.going.domain.entity.response.TodoDetailModel
import com.going.domain.entity.response.TodoModel
import com.going.domain.repository.TodoRepository
Expand Down Expand Up @@ -43,4 +45,18 @@ class TodoRepositoryImpl @Inject constructor(
todoDataSource.getTodoDetailData(todoId).data.toTodoDetailModel()
}

override suspend fun getMyTripInfo(
tripId: Long
): Result<MyTripInfoModel> =
runCatching {
todoDataSource.getMyTripInfo(tripId).data.toMyTripInfoModel()
}

override suspend fun getOurTripInfo(
tripId: Long
): Result<OurTripInfoModel> =
runCatching {
todoDataSource.getOurTripInfo(tripId).data.toOurTripInfoModel()
}

}
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<Any?>
suspend fun patchSignOut(): NonDataBaseResponse

@DELETE("api/users/withdraw")
suspend fun deleteWithDraw(): NonDataBaseResponse<Any?>
suspend fun deleteWithDraw(): NonDataBaseResponse
}
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<Any?>
): NonDataBaseResponse
}
16 changes: 14 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 @@ -3,6 +3,8 @@ package com.going.data.service
import com.going.data.dto.BaseResponse
import com.going.data.dto.NonDataBaseResponse
import com.going.data.dto.request.TodoCreateRequestDto
import com.going.data.dto.response.MyTripInfoResponseDto
import com.going.data.dto.response.OurTripInfoResponseDto
import com.going.data.dto.response.TodoDetailResponseDto
import com.going.data.dto.response.TodoResponseDto
import retrofit2.http.Body
Expand All @@ -25,16 +27,26 @@ interface TodoService {
suspend fun postToCreateTodo(
@Path("tripId") tripId: Long,
@Body request: TodoCreateRequestDto
): NonDataBaseResponse<Unit>
): NonDataBaseResponse

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

@GET("api/trips/todos/{todoId}")
suspend fun getTodoDetail(
@Path("todoId") todoId: Long
): BaseResponse<TodoDetailResponseDto>

@GET("/api/trips/{tripId}/my")
suspend fun getMyTripInfo(
@Path("tripId") tripId: Long
): BaseResponse<MyTripInfoResponseDto>

@GET("/api/trips/{tripId}/our")
suspend fun getOurTripInfo(
@Path("tripId") tripId: Long
): BaseResponse<OurTripInfoResponseDto>

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

data class MyTripInfoModel(
val name: String,
val count: Int
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.going.domain.entity.response

data class OurTripInfoModel(
val title: String,
val day: Int,
val startDate: String,
val endDate: String,
val progress: Int,
val code: String,
val isComplete: Boolean,
val participants: List<TripParticipantModel>
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.going.domain.entity.response

data class TripParticipantModel(
val participantId: Long,
val name: String,
val result: Int
)
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,4 @@ data class TripParticipantsListModel(
val styleC: Int,
val styleD: Int,
val styleE: Int,
) {
data class TripParticipantModel(
val participantId: Long,
val name: String,
val result: Int
)
}
)
Loading

0 comments on commit c36e641

Please sign in to comment.