Skip to content

Commit

Permalink
Merge pull request #4 from Cat-JiYoung/feat/#38-write-review-api
Browse files Browse the repository at this point in the history
[FEAT] 회고 작성 api 연결
  • Loading branch information
amourxyoung authored Jul 19, 2023
2 parents b1db94e + 5d408cf commit 74dd8f1
Show file tree
Hide file tree
Showing 32 changed files with 705 additions and 203 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ data class ResponseMyPuzzleBoardDto(
val myPuzzle: MyPuzzle,
@SerialName("userPuzzleBoard")
val userPuzzleBoard: List<UserPuzzleBoard>,
@SerialName("puzzleBoardCount")
val puzzleBoardCount: Int,
@SerialName("isReviewDay")
val isReviewDay: Boolean,
@SerialName("hasTodayReview")
Expand Down
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.ReviewType
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

Expand All @@ -20,7 +21,15 @@ data class ResponseReviewTypeDto(
val reviewTemplateId: Int,
@SerialName("reviewTemplateName")
val reviewTemplateName: String,
@SerialName("reviewTempalteMeaning")
val reviewTempalteMeaning: Int,
@SerialName("reviewTemplateMeaning")
val reviewTemplateMeaning: String,
)

fun toReviewType() = data.map { type ->
ReviewType(
reviewTemplateId = type.reviewTemplateId,
reviewTemplateName = type.reviewTemplateName,
reviewTemplateMeaning = type.reviewTemplateMeaning,
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package com.puzzling.puzzlingaos.data.repository

import com.puzzling.puzzlingaos.data.model.request.RequestReview5FDto
import com.puzzling.puzzlingaos.data.model.request.RequestReviewAARDto
import com.puzzling.puzzlingaos.data.model.request.RequestReviewTILDto
import com.puzzling.puzzlingaos.data.model.response.ResponsePreviousTemplateDto
import com.puzzling.puzzlingaos.data.model.response.ResponseSaveReviewDto
import com.puzzling.puzzlingaos.data.source.remote.WriteReviewDataSource
import com.puzzling.puzzlingaos.domain.entity.ReviewType
import com.puzzling.puzzlingaos.domain.repository.WriteReviewRepository
import javax.inject.Inject

class WriteReviewRepositoryImpl @Inject constructor(
private val writeReviewDataSource: WriteReviewDataSource,
) : WriteReviewRepository {
override suspend fun getReviewType(): Result<List<ReviewType>> = runCatching {
writeReviewDataSource.getReviewTemplate().toReviewType()
}

override suspend fun uploadTIL(
memberId: Int,
projectId: Int,
requestReviewTIL: RequestReviewTILDto,

): Result<ResponseSaveReviewDto> = runCatching {
writeReviewDataSource.uploadReviewTIL(
memberId,
projectId,
requestReviewTIL,
)
}

override suspend fun upload5F(
memberId: Int,
projectId: Int,
requestReview5F: RequestReview5FDto,
): Result<ResponseSaveReviewDto> = runCatching {
writeReviewDataSource.uploadReview5F(
memberId,
projectId,
requestReview5F,
)
}

override suspend fun uploadAAR(
memberId: Int,
projectId: Int,
requestReviewAAR: RequestReviewAARDto,
): Result<ResponseSaveReviewDto> = runCatching {
writeReviewDataSource.uploadReviewAAR(
memberId,
projectId,
requestReviewAAR,
)
}

override suspend fun getPreviousTemplate(
memberId: Int,
projectId: Int,
): Result<ResponsePreviousTemplateDto> =
runCatching {
writeReviewDataSource.getPreviousTemplate(memberId, projectId)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ interface WriteReviewService {
[회고 글 작성 API(ARR)]
~/api/v1/member/{memberId}/project/{projectId}/review/ARR
*/
@POST("api/v1/member/{memberId}/project/{projectId}/review/ARR")
@POST("api/v1/member/{memberId}/project/{projectId}/review/AAR")
suspend fun postSaveReviewAAR(
@Path("memberId") memberId: Int,
@Path("projectId") projectId: Int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.puzzling.puzzlingaos.data.model.request.RequestReviewAARDto
import com.puzzling.puzzlingaos.data.model.request.RequestReviewTILDto
import com.puzzling.puzzlingaos.data.model.response.ResponsePreviousTemplateDto
import com.puzzling.puzzlingaos.data.model.response.ResponseReviewTypeDto
import com.puzzling.puzzlingaos.data.model.response.ResponseSaveReviewDto

interface WriteReviewDataSource {
suspend fun getReviewTemplate(): ResponseReviewTypeDto
Expand All @@ -13,19 +14,21 @@ interface WriteReviewDataSource {
memberId: Int,
projectId: Int,
requestReviewTIL: RequestReviewTILDto,
): RequestReviewTILDto
// requestTIL: TIL,

): ResponseSaveReviewDto

suspend fun uploadReview5F(
memberId: Int,
projectId: Int,
requestReview5F: RequestReview5FDto,
): RequestReview5FDto
): ResponseSaveReviewDto

suspend fun uploadReviewAAR(
memberId: Int,
projectId: Int,
requestReviewAAR: RequestReviewAARDto,
): RequestReviewAARDto
): ResponseSaveReviewDto

suspend fun getPreviousTemplate(
memberId: Int,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.puzzling.puzzlingaos.data.source.remote.impl

import com.puzzling.puzzlingaos.data.model.request.RequestReview5FDto
import com.puzzling.puzzlingaos.data.model.request.RequestReviewAARDto
import com.puzzling.puzzlingaos.data.model.request.RequestReviewTILDto
import com.puzzling.puzzlingaos.data.model.response.ResponsePreviousTemplateDto
import com.puzzling.puzzlingaos.data.model.response.ResponseReviewTypeDto
import com.puzzling.puzzlingaos.data.model.response.ResponseSaveReviewDto
import com.puzzling.puzzlingaos.data.service.WriteReviewService
import com.puzzling.puzzlingaos.data.source.remote.WriteReviewDataSource
import javax.inject.Inject

class WriteReviewDataSourceImpl @Inject constructor(
private val apiService: WriteReviewService,
) : WriteReviewDataSource {
override suspend fun getReviewTemplate(): ResponseReviewTypeDto =
apiService.getReviewTemplate()

override suspend fun uploadReviewTIL(
memberId: Int,
projectId: Int,
requestReviewTIL: RequestReviewTILDto,
): ResponseSaveReviewDto =
apiService.postSaveReviewTIL(memberId, projectId, requestReviewTIL)

override suspend fun uploadReview5F(
memberId: Int,
projectId: Int,
requestReview5F: RequestReview5FDto,
): ResponseSaveReviewDto =
apiService.postSaveReview5F(memberId, projectId, requestReview5F)

override suspend fun uploadReviewAAR(
memberId: Int,
projectId: Int,
requestReviewAAR: RequestReviewAARDto,
): ResponseSaveReviewDto =
apiService.postSaveReviewAAR(memberId, projectId, requestReviewAAR)

override suspend fun getPreviousTemplate(
memberId: Int,
projectId: Int,
): ResponsePreviousTemplateDto = apiService.getPreviousTemplate(
memberId,
projectId,
)
}
6 changes: 6 additions & 0 deletions app/src/main/java/com/puzzling/puzzlingaos/di/ApiModule.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.puzzling.puzzlingaos.di

import com.puzzling.puzzlingaos.data.service.PersonalReviewService
import com.puzzling.puzzlingaos.data.service.WriteReviewService
import com.puzzling.puzzlingaos.data.service.ProjectService
import dagger.Module
import dagger.Provides
Expand All @@ -17,6 +18,11 @@ object ApiModule {
fun provideMyDashBoardService(@PuzzlingRetrofit retrofit: Retrofit): PersonalReviewService =
retrofit.create(PersonalReviewService::class.java)

@Provides
@Singleton
fun provideWriteReviewService(@PuzzlingRetrofit retrofit: Retrofit): WriteReviewService =
retrofit.create(WriteReviewService::class.java)

@Provides
@Singleton
fun sendProjectRegister(@PuzzlingRetrofit retrofit: Retrofit): ProjectService =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package com.puzzling.puzzlingaos.di

import com.puzzling.puzzlingaos.data.source.remote.MyDashBoardDataSource
import com.puzzling.puzzlingaos.data.source.remote.ProjectDataSource
import com.puzzling.puzzlingaos.data.source.remote.WriteReviewDataSource
import com.puzzling.puzzlingaos.data.source.remote.impl.MyDashBoardDataSourceImpl
import com.puzzling.puzzlingaos.data.source.remote.impl.ProjectDataSourceImpl
import com.puzzling.puzzlingaos.data.source.remote.impl.WriteReviewDataSourceImpl
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
Expand All @@ -17,6 +19,10 @@ abstract class DataSourceModule {
@Binds
abstract fun providesPersonalReviewDataSource(DataSourceImpl: MyDashBoardDataSourceImpl): MyDashBoardDataSource

@Singleton
@Binds
abstract fun providesWriteReviewDataSource(DataSourceImpl: WriteReviewDataSourceImpl): WriteReviewDataSource

@Singleton
@Binds
abstract fun sendProjectRegisterDataSource(DataSourceImpl: ProjectDataSourceImpl): ProjectDataSource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package com.puzzling.puzzlingaos.di

import com.puzzling.puzzlingaos.data.repository.MyBoardRepositoryImpl
import com.puzzling.puzzlingaos.data.repository.ProjectRepositoryImpl
import com.puzzling.puzzlingaos.data.repository.WriteReviewRepositoryImpl
import com.puzzling.puzzlingaos.domain.repository.MyBoardRepository
import com.puzzling.puzzlingaos.domain.repository.ProjectRepository
import com.puzzling.puzzlingaos.domain.repository.WriteReviewRepository
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
Expand All @@ -17,6 +19,10 @@ abstract class RepositoryModule {
@Binds
abstract fun providesMyBoardRepository(repoImpl: MyBoardRepositoryImpl): MyBoardRepository

@Singleton
@Binds
abstract fun providesWriteReviewRepository(repoImpl: WriteReviewRepositoryImpl): WriteReviewRepository

@Singleton
@Binds
abstract fun sendProjectRepository(repoImpl: ProjectRepositoryImpl): ProjectRepository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ object RetrofitModule {
val builder = original.newBuilder()
builder.addHeader(
"Authorization",
"Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2ODk2MTcyMTEsImV4cCI6MTY4OTk3NzIxMSwibWVtYmVySWQiOjJ9.w7II75HjzpXLVlBSRmcH5g5Q85oQ3KYq59KSlRvTV3w",
// "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2ODk2MzAyMjIsImV4cCI6MTY4OTk5MDIyMiwibWVtYmVySWQiOjF9.tR938XSLko7fuv8RduU6AL7dFs8JnzDNRS1OIfpFSC0",
"Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2ODk3NTAxMTIsImV4cCI6MTY5MDExMDExMiwibWVtYmVySWQiOjJ9.cObREoCFGC8jgcBJjz0z7Bnb03KfP_Fzzup9Oge1tYA",
)
chain.proceed(builder.build())
}
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/com/puzzling/puzzlingaos/domain/entity/AAR.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.puzzling.puzzlingaos.domain.entity

data class AAR(
val reviewTemplateId: Int,
val initialGoal: String,
val result: String,
val difference: String,
val persistence: String,
val actionPlan: String,
)
11 changes: 11 additions & 0 deletions app/src/main/java/com/puzzling/puzzlingaos/domain/entity/F5.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.puzzling.puzzlingaos.domain.entity

data class F5(
val reviewTemplateId: Int,
val fact: String,
val feeling: String,
val finding: String,
val feedback: String,
val actionPlan: String,

)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.puzzling.puzzlingaos.domain.entity

data class TIL(
val reviewTemplateId: Int,
val liked: String,
val lacked: String,
val actionPlan: String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.puzzling.puzzlingaos.domain.repository

import com.puzzling.puzzlingaos.data.model.request.RequestReview5FDto
import com.puzzling.puzzlingaos.data.model.request.RequestReviewAARDto
import com.puzzling.puzzlingaos.data.model.request.RequestReviewTILDto
import com.puzzling.puzzlingaos.data.model.response.ResponsePreviousTemplateDto
import com.puzzling.puzzlingaos.data.model.response.ResponseSaveReviewDto
import com.puzzling.puzzlingaos.domain.entity.ReviewType

interface WriteReviewRepository {
suspend fun getReviewType(): Result<List<ReviewType>>

suspend fun uploadTIL(
memberId: Int,
projectId: Int,
requestReviewTIL: RequestReviewTILDto,
): Result<ResponseSaveReviewDto>

suspend fun upload5F(
memberId: Int,
projectId: Int,
requestReview5F: RequestReview5FDto,
): Result<ResponseSaveReviewDto>

suspend fun uploadAAR(
memberId: Int,
projectId: Int,
requestReviewAAR: RequestReviewAARDto,
): Result<ResponseSaveReviewDto>

suspend fun getPreviousTemplate(
memberId: Int,
projectId: Int,
): Result<ResponsePreviousTemplateDto>
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import androidx.lifecycle.viewModelScope
import com.puzzling.puzzlingaos.data.model.response.ResponseMyPageProjectDto
import com.puzzling.puzzlingaos.domain.entity.Project
import com.puzzling.puzzlingaos.domain.repository.MyBoardRepository
import com.puzzling.puzzlingaos.util.UserInfo
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
import javax.inject.Inject
Expand Down Expand Up @@ -54,7 +55,7 @@ class HomeViewModel @Inject constructor(
}

private fun getProjectList() = viewModelScope.launch {
repository.getProceedingProject(1).onSuccess { response ->
repository.getProceedingProject(UserInfo.MEMBER_ID).onSuccess { response ->
Log.d("home", "getProjectList() success:: $response")
_projectList.value = response
}.onFailure {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,20 @@ class PersonalDashboardFragment :

private fun clickBottomBtn() {
binding.clPersonalBottomBtn.setOnClickListener {
activity?.let {
val intent = Intent(context, WriteRetrospectiveActivity::class.java)
startActivity(intent)
when (viewModel.previousReviewType.value) {
1 -> activity?.let { // TIL
val intent = Intent(context, WriteRetrospectiveActivity::class.java)
startActivity(intent)
}
2 -> activity?.let { // 5F
val intent = Intent(context, WriteRetrospectiveActivity::class.java)
startActivity(intent)
}
3 -> activity?.let {
// AAR
val intent = Intent(context, WriteRetrospectiveActivity::class.java)
startActivity(intent)
}
}
}
}
Expand Down
Loading

0 comments on commit 74dd8f1

Please sign in to comment.