Skip to content

Commit

Permalink
Merge pull request #15 from gaeun5744/refactor/#68-allview-Dto
Browse files Browse the repository at this point in the history
Refactor/#68 allview dto
  • Loading branch information
gaeun5744 authored Sep 4, 2023
2 parents 38cc986 + d17ce8f commit 2afdfe1
Show file tree
Hide file tree
Showing 27 changed files with 188 additions and 168 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.puzzling.puzzlingaos.data.datasource.remote

import com.puzzling.puzzlingaos.data.model.request.RequestInvitationCode
import com.puzzling.puzzlingaos.data.model.request.RequestJoinProject
import com.puzzling.puzzlingaos.data.model.request.RequestProjectRegisterDto
import com.puzzling.puzzlingaos.data.model.response.ResponseInvitationCodeDto
import com.puzzling.puzzlingaos.data.model.response.ResponseJoinProjectDto
Expand All @@ -15,7 +15,7 @@ interface ProjectDataSource {

suspend fun joinProject(
memberId: Int,
request: RequestInvitationCode,
request: RequestJoinProject,
): ResponseJoinProjectDto

suspend fun isValidInvitationCode(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.puzzling.puzzlingaos.data.datasource.remote.impl

import com.puzzling.puzzlingaos.data.datasource.remote.ProjectDataSource
import com.puzzling.puzzlingaos.data.model.request.RequestInvitationCode
import com.puzzling.puzzlingaos.data.model.request.RequestJoinProject
import com.puzzling.puzzlingaos.data.model.request.RequestProjectRegisterDto
import com.puzzling.puzzlingaos.data.model.response.ResponseInvitationCodeDto
import com.puzzling.puzzlingaos.data.model.response.ResponseJoinProjectDto
Expand All @@ -22,7 +22,7 @@ class ProjectDataSourceImpl @Inject constructor(

override suspend fun joinProject(
memberId: Int,
request: RequestInvitationCode,
request: RequestJoinProject,
): ResponseJoinProjectDto = apiService.joinProject(memberId, request)

override suspend fun isValidInvitationCode(invitationCode: String): ResponseInvitationCodeDto =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
package com.puzzling.puzzlingaos.data.model.request

import com.puzzling.puzzlingaos.domain.entity.JoinProjectInfo
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class RequestInvitationCode(
data class RequestJoinProject(
@SerialName("projectId")
val projectId: Int,
@SerialName("memberProjectNickname")
val memberProjectNickname: String,
@SerialName("memberProjectRole")
val memberProjectRole: String,
)

fun JoinProjectInfo.toRequestJoinProjectDto() = RequestJoinProject(
projectId,
memberProjectNickname,
memberProjectRole,
)
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.puzzling.puzzlingaos.data.model.response

import com.puzzling.puzzlingaos.domain.entity.DetailRetro
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

Expand All @@ -12,7 +13,7 @@ data class ResponseDetailRetroDto(
@SerialName("message")
val message: String,
@SerialName("data")
val data: Data?,
val data: Data,
) {
@Serializable
data class Data(
Expand Down Expand Up @@ -42,5 +43,18 @@ data class ResponseDetailRetroDto(
val content: String,
)
}

fun toDetailRetro() = reviews.map { reviews ->
DetailRetro(
reviewId = reviews.reviewId,
reviewDay = reviews.reviewDay,
reviewDate = reviews.reviewDate,
reviewTemplateId = reviews.reviewTemplateId,
content = reviews.contents?.map { content ->
DetailRetro.Content(content.title, content.content)
},

)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.puzzling.puzzlingaos.data.model.response

import com.puzzling.puzzlingaos.domain.entity.InvitationCode
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

Expand All @@ -12,13 +13,15 @@ data class ResponseInvitationCodeDto(
@SerialName("message")
val message: String,
@SerialName("data")
val data: InvitationCodeData?,
val data: InvitationCodeData,
) {
@Serializable
data class InvitationCodeData(
@SerialName("projectId")
val projectId: Int,
@SerialName("projectName")
val projectName: String,
)
) {
fun toInvitationCode() = InvitationCode(projectId, projectName)
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.puzzling.puzzlingaos.data.model.response

import com.puzzling.puzzlingaos.domain.entity.ProjectReview
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

Expand All @@ -12,7 +13,7 @@ data class ResponseMyRetroListDto(
@SerialName("message")
val message: String,
@SerialName("data")
val data: List<ReviewData>?,
val data: List<ReviewData>,
) {
@Serializable
data class ReviewData(
Expand All @@ -23,5 +24,12 @@ data class ResponseMyRetroListDto(
@SerialName("contents")
val contents: String,
)
}

fun toProjectReview() = data.map { reviewData ->
ProjectReview(
reviewData.reviewId,
reviewData.reviewDate,
reviewData.contents,
)
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.puzzling.puzzlingaos.data.model.response

import com.puzzling.puzzlingaos.domain.entity.ReviewCycle
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

Expand All @@ -12,13 +13,15 @@ data class ResponseProjectRetroWeekDto(
@SerialName("message")
val message: String,
@SerialName("data")
val data: ProjectCycle?,
val data: ProjectCycle,
) {
@Serializable
data class ProjectCycle(
@SerialName("projectName")
val projectName: String,
@SerialName("projectReviewCycle")
val projectReviewCycle: String,
)
) {
fun toReviewCycle() = ReviewCycle(projectName, projectReviewCycle)
}
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
package com.puzzling.puzzlingaos.data.repository

import com.puzzling.puzzlingaos.data.datasource.remote.MyPageDataSource
import com.puzzling.puzzlingaos.data.model.response.ResponseDetailRetroDto
import com.puzzling.puzzlingaos.data.model.response.ResponseMyRetroListDto
import com.puzzling.puzzlingaos.domain.entity.DetailRetro
import com.puzzling.puzzlingaos.domain.entity.ProjectReview
import com.puzzling.puzzlingaos.domain.repository.MyPageRepository
import javax.inject.Inject

class MyPageRepositoryImpl @Inject constructor(private val myPageDataSource: MyPageDataSource) :
MyPageRepository {
override suspend fun getMyProjectReview(memberId: Int, projectId: Int): ResponseMyRetroListDto {
return myPageDataSource.getMyProjectReview(memberId, projectId)
}
override suspend fun getMyProjectReview(
memberId: Int,
projectId: Int,
): Result<List<ProjectReview>> =
runCatching {
myPageDataSource.getMyProjectReview(memberId, projectId).toProjectReview()
}

override suspend fun getMyDetailReview(
memberId: Int,
projectId: Int,
startDate: String,
endDate: String,
): ResponseDetailRetroDto {
return myPageDataSource.getMyDetailReview(memberId, projectId, startDate, endDate)
): Result<List<DetailRetro>> = runCatching {
myPageDataSource.getMyDetailReview(
memberId,
projectId,
startDate,
endDate,
).data.toDetailRetro()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package com.puzzling.puzzlingaos.data.repository

import android.util.Log
import com.puzzling.puzzlingaos.data.datasource.remote.ProjectDataSource
import com.puzzling.puzzlingaos.data.model.request.RequestInvitationCode
import com.puzzling.puzzlingaos.data.model.request.RequestProjectRegisterDto
import com.puzzling.puzzlingaos.data.model.response.ResponseInvitationCodeDto
import com.puzzling.puzzlingaos.data.model.request.toRequestJoinProjectDto
import com.puzzling.puzzlingaos.data.model.response.ResponseJoinProjectDto
import com.puzzling.puzzlingaos.data.model.response.ResponseProjectRegisterDto
import com.puzzling.puzzlingaos.data.model.response.ResponseProjectRetroWeekDto
import com.puzzling.puzzlingaos.domain.entity.InvitationCode
import com.puzzling.puzzlingaos.domain.entity.JoinProjectInfo
import com.puzzling.puzzlingaos.domain.entity.ReviewCycle
import com.puzzling.puzzlingaos.domain.repository.ProjectRepository
import javax.inject.Inject

Expand All @@ -28,16 +29,17 @@ class ProjectRepositoryImpl @Inject constructor(

override suspend fun joinProject(
memberId: Int,
request: RequestInvitationCode,
): ResponseJoinProjectDto {
return projectDataSource.joinProject(memberId, request)
request: JoinProjectInfo,
): Result<ResponseJoinProjectDto> = runCatching {
projectDataSource.joinProject(memberId, request.toRequestJoinProjectDto())
}

override suspend fun isValidInvitationCode(invitationCode: String): ResponseInvitationCodeDto {
return projectDataSource.isValidInvitationCode(invitationCode)
}
override suspend fun isValidInvitationCode(invitationCode: String): Result<InvitationCode> =
runCatching {
projectDataSource.isValidInvitationCode(invitationCode).data.toInvitationCode()
}

override suspend fun getProjectWeekCycle(projectId: Int): ResponseProjectRetroWeekDto {
return projectDataSource.getProjectWeekCycle(projectId)
override suspend fun getProjectWeekCycle(projectId: Int): Result<ReviewCycle> = runCatching {
projectDataSource.getProjectWeekCycle(projectId).data.toReviewCycle()
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.puzzling.puzzlingaos.data.service

import com.puzzling.puzzlingaos.data.model.request.RequestInvitationCode
import com.puzzling.puzzlingaos.data.model.request.RequestJoinProject
import com.puzzling.puzzlingaos.data.model.request.RequestProjectRegisterDto
import com.puzzling.puzzlingaos.data.model.response.ResponseInvitationCodeDto
import com.puzzling.puzzlingaos.data.model.response.ResponseJoinProjectDto
Expand All @@ -23,7 +23,7 @@ interface ProjectService {
@POST("api/v1/member/{memberId}/project/join")
suspend fun joinProject(
@Path("memberId") memberId: Int,
@Body request: RequestInvitationCode,
@Body request: RequestJoinProject,
): ResponseJoinProjectDto

@GET("api/v1/project/verify?")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.puzzling.puzzlingaos.domain.entity

data class DetailRetro(
val reviewId: Int?,
val reviewDay: String,
val reviewDate: String,
val reviewTemplateId: Int?,
val content: List<Content>?,
) {
data class Content(
val title: String,
val content: String,
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.puzzling.puzzlingaos.domain.entity

data class InvitationCode(
val projectId: Int,
val projectName: String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.puzzling.puzzlingaos.domain.entity

data class JoinProjectInfo(
val projectId: Int,
val memberProjectNickname: String,
val memberProjectRole: String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.puzzling.puzzlingaos.domain.entity

data class ProjectReview(
val reviewId: Int,
val reviewDate: String,
val contents: String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.puzzling.puzzlingaos.domain.entity

data class ReviewCycle(
val projectName: String,
val projectReviewCycle: String,
)
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package com.puzzling.puzzlingaos.domain.repository

import com.puzzling.puzzlingaos.data.model.response.ResponseDetailRetroDto
import com.puzzling.puzzlingaos.data.model.response.ResponseMyRetroListDto
import com.puzzling.puzzlingaos.domain.entity.DetailRetro
import com.puzzling.puzzlingaos.domain.entity.ProjectReview

interface MyPageRepository {

suspend fun getMyProjectReview(
memberId: Int,
projectId: Int,
): ResponseMyRetroListDto
): Result<List<ProjectReview>>

suspend fun getMyDetailReview(
memberId: Int,
projectId: Int,
startDate: String,
endDate: String,
): ResponseDetailRetroDto
): Result<List<DetailRetro>>
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.puzzling.puzzlingaos.domain.repository

import com.puzzling.puzzlingaos.data.model.request.RequestInvitationCode
import com.puzzling.puzzlingaos.data.model.request.RequestProjectRegisterDto
import com.puzzling.puzzlingaos.data.model.response.ResponseInvitationCodeDto
import com.puzzling.puzzlingaos.data.model.response.ResponseJoinProjectDto
import com.puzzling.puzzlingaos.data.model.response.ResponseProjectRegisterDto
import com.puzzling.puzzlingaos.data.model.response.ResponseProjectRetroWeekDto
import com.puzzling.puzzlingaos.domain.entity.InvitationCode
import com.puzzling.puzzlingaos.domain.entity.JoinProjectInfo
import com.puzzling.puzzlingaos.domain.entity.ReviewCycle

interface ProjectRepository {

Expand All @@ -18,14 +18,14 @@ interface ProjectRepository {

suspend fun joinProject(
memberId: Int,
request: RequestInvitationCode,
): ResponseJoinProjectDto
request: JoinProjectInfo,
): Result<ResponseJoinProjectDto>

suspend fun isValidInvitationCode(
invitationCode: String,
): ResponseInvitationCodeDto
): Result<InvitationCode>

suspend fun getProjectWeekCycle(
projectId: Int,
): ResponseProjectRetroWeekDto
): Result<ReviewCycle>
}
Loading

0 comments on commit 2afdfe1

Please sign in to comment.