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

#66 [feat] 유저별 데일리루틴 리스트 조회 api 연결 #69

Merged
merged 44 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
2b1f79e
#66 [add] 유저별 데일리 루틴 리스폰스 추가
minemi00 Jan 16, 2024
56f1c2c
#66 [add] 유저별 데일리 루틴 리포지토리 추가
minemi00 Jan 16, 2024
a6f652c
#66 [add] 유저별 데일리 루틴 서비스 추가
minemi00 Jan 16, 2024
c1d208f
#66 [add] 유저별 데일리 루틴 데이터소스 추가
minemi00 Jan 16, 2024
6b060d5
#66 [add] 유저별 데일리 루틴 유스케이스 추가
minemi00 Jan 16, 2024
f344130
#66 [add] 유저별 데일리 루틴 의존성 주입
minemi00 Jan 16, 2024
c37c173
#66 [feat] 유저별 데일리 루틴 뷰모델 서버통신
minemi00 Jan 16, 2024
c72aff4
#66 [feat] 유저별 데일리 루틴 ui에 뷰모델 연결
minemi00 Jan 16, 2024
8010d8c
#66 [feat] 유저별 데일리 루틴 서버통신 성공
minemi00 Jan 16, 2024
c8b91da
#66 [chore] ci 오류 수정
minemi00 Jan 16, 2024
3f82e09
#66 [chore] 세번째 루틴 정렬 완
minemi00 Jan 16, 2024
2905657
Merge branch 'develop' of https://github.com/Team-Sopetit/Sopetit-And…
minemi00 Jan 16, 2024
f268ea2
Merge branch 'develop' of https://github.com/Team-Sopetit/Sopetit-And…
minemi00 Jan 16, 2024
78d256c
#66 [chore] 이미지 로드 수정
minemi00 Jan 16, 2024
e6a5ec6
Merge branch 'develop' of https://github.com/Team-Sopetit/Sopetit-And…
minemi00 Jan 16, 2024
21e37cd
#66 [add] 데일리루틴 달성 데이터클래스 생성
minemi00 Jan 16, 2024
eb9a3f3
#66 [add] 데일리루틴 달성 리스폰스 생성
minemi00 Jan 16, 2024
361998b
#66 [add] 데일리루틴 달성 리포지토리 생성
minemi00 Jan 16, 2024
83b836c
#66 [add] 데일리루틴 달성 데이터소스,서비스 생성
minemi00 Jan 16, 2024
efb7939
#66 [add] 데일리루틴 달성 유스케이스 생성
minemi00 Jan 16, 2024
a366dfa
#66 [add] 데일리루틴 달성 버튼 비활성화
minemi00 Jan 16, 2024
f2885c4
#66 [add] 데일리루틴 삭제 리포지토리 추가
minemi00 Jan 16, 2024
1758ffa
#66 [add] 데일리루틴 삭제 데이터소스 추가
minemi00 Jan 16, 2024
d7840a5
#66 [add] 데일리루틴 삭제 서비스 추가
minemi00 Jan 16, 2024
a721cd7
#66 [add] 데일리루틴 주석 제거 및 timber 제거
minemi00 Jan 16, 2024
675821c
#66 [add] 데일리루틴 삭제 유스케이스 추가
minemi00 Jan 16, 2024
ecf9ce2
#66 [add] 데일리루틴 글자 행간 수정
minemi00 Jan 16, 2024
366b151
Merge branch 'develop' of https://github.com/Team-Sopetit/Sopetit-And…
minemi00 Jan 16, 2024
f2e2849
#66 [chore] 충돌 해결
minemi00 Jan 16, 2024
7121ee6
#66 [chore] 삭제 서버 로직 변경
minemi00 Jan 16, 2024
1f29c4b
#66 [add] 데일리루틴 달성 데이터 클래스 추가
minemi00 Jan 16, 2024
6cccba1
#66 [add] 데일리루틴 달성 리스폰스,리퀘스트 추가
minemi00 Jan 16, 2024
18fa251
#66 [add] 데일리루틴 달성 리포지토리 추가
minemi00 Jan 17, 2024
2e8cbe9
#66 [add] 데일리루틴 달성 데이터소스, 서비스 추가
minemi00 Jan 17, 2024
c4e2e4b
#66 [add] 데일리루틴 달성 유스케이스 추가
minemi00 Jan 17, 2024
0849b79
#66 [add] 데일리 루틴 문장수에 따른 반응형으로 만들기
minemi00 Jan 17, 2024
55fac11
#66 [add] 유저 데일리 루틴 데이터 클래스 생성
minemi00 Jan 17, 2024
409ada6
#66 [chore] 네이밍 수정
minemi00 Jan 17, 2024
e3bbb06
Merge branch 'develop' of https://github.com/Team-Sopetit/Sopetit-And…
minemi00 Jan 17, 2024
d3e3370
Merge branch 'develop' of https://github.com/Team-Sopetit/Sopetit-And…
minemi00 Jan 17, 2024
0df6381
#66 [chore] 데일리 루틴 삭제 로직 수정, 루틴id에서 루틴 list로 수정 및 삭제시 리스트 get해서 업데이트 추가
minemi00 Jan 17, 2024
9154bdd
Merge branch 'develop' of https://github.com/Team-Sopetit/Sopetit-And…
minemi00 Jan 17, 2024
ccc3858
#66 [chore] 데일리 루틴 삭제 서버 연결 성공
minemi00 Jan 17, 2024
77a8fe5
#66 [chore] ci 해결
minemi00 Jan 17, 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.sopetit.softie.data.entity.request

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class AddDailyRoutineRequest(
@SerialName("routineId")
val routineId: Int
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.sopetit.softie.data.entity.response

import com.sopetit.softie.domain.entity.DailyAchieve
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class AchieveDailyResponse(
@SerialName("routineId")
val routineId: Int,
@SerialName("isAchieve")
val isAchieve: Boolean,
@SerialName("achieveCount")
val achieveCount: Int
) {
fun toAchieveDaily(): DailyAchieve = DailyAchieve(
routineId = this.routineId,
isAchieve = this.isAchieve,
achieveCount = this.achieveCount
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.sopetit.softie.data.entity.response

import com.sopetit.softie.domain.entity.AddRoutine
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class AddDailyRoutineResponse(
@SerialName("routineId")
val routineId: Int
) {
fun toAddDailyRoutine(): AddRoutine = AddRoutine(
routineId = this.routineId
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.sopetit.softie.data.entity.response

import com.sopetit.softie.domain.entity.Routine
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

data class DailyCardResponse(
@SerialName("routines")
val routines: List<RoutineItem>
) {
@Serializable
data class RoutineItem(
@SerialName("routineId")
val routineId: Int,
@SerialName("content")
val content: String
)

fun toRoutine() = routines.map {
Routine(
routineId = it.routineId,
content = it.content
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.sopetit.softie.data.entity.response

import com.sopetit.softie.domain.entity.DailyRoutine
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class DailyRoutineResponse(
@SerialName("routines")
val routines: List<DailyRoutineItem>
) {
@Serializable
data class DailyRoutineItem(
@SerialName("routineId")
val routineId: Int,
@SerialName("content")
val content: String,
@SerialName("iconImageUrl")
val iconImageUrl: String,
@SerialName("achieveCount")
val achieveCount: Int,
@SerialName("isAchieve")
val isAchieve: Boolean
)

fun toUserDailyRoutine() = routines.map {
DailyRoutine(
routineId = it.routineId,
content = it.content,
iconImageUrl = it.iconImageUrl,
achieveCount = it.achieveCount,
isAchieve = it.isAchieve
)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.sopetit.softie.data.repositoryImpl

import com.sopetit.softie.data.source.DailyRoutineDataSource
import com.sopetit.softie.domain.entity.AddRoutine
import com.sopetit.softie.domain.entity.DailyAchieve
import com.sopetit.softie.domain.entity.DailyRoutine
import com.sopetit.softie.domain.entity.Routine
import com.sopetit.softie.domain.entity.Theme
import com.sopetit.softie.domain.repository.DailyRoutineRepository
Expand All @@ -9,6 +12,18 @@ import javax.inject.Inject
class DailyRoutineRepositoryImpl @Inject constructor(
private val dailyRoutineDataSource: DailyRoutineDataSource
) : DailyRoutineRepository {
override suspend fun getDailyRoutine(): Result<List<DailyRoutine>> =
runCatching { dailyRoutineDataSource.getDailyRoutine() }.mapCatching { response ->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mapCatching을 쓰셨군요! 👍
https://medium.com/harrythegreat/kotlin-runcatching%EA%B3%BC-result-%ED%83%80%EC%9E%85-ab261f47efa8
map과 mapCatching의 차이입니다~ 혹시나 하여 남기고 가요

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아하 정독해보겠습니다!

requireNotNull(response.data).toUserDailyRoutine()
}

override suspend fun patchAchieveDaily(routineId: Int): Result<DailyAchieve> =
runCatching { dailyRoutineDataSource.patchAchieveDaily(routineId) }.map { response ->
requireNotNull(response.data).toAchieveDaily()
}

override suspend fun deleteDailyRoutine(routineIdList: List<Int>): Result<Unit> =
runCatching { dailyRoutineDataSource.deleteDailyRoutine(routineIdList) }

override suspend fun getTheme(): Result<List<Theme>> = runCatching {
dailyRoutineDataSource.getTheme()
Expand All @@ -21,4 +36,11 @@ class DailyRoutineRepositoryImpl @Inject constructor(
}.mapCatching { dailyRoutineList ->
requireNotNull(dailyRoutineList.data).toRoutine()
}

override suspend fun postAddDailyRoutine(routineId: Int): Result<AddRoutine> =
runCatching {
dailyRoutineDataSource.postAddDailyRoutine(routineId)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it대신 response로 그 위치를 명시해주라는 리드님의 말씀을 잘 지켰네요!

}.map { response ->
requireNotNull(response.data).toAddDailyRoutine()
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,41 @@
package com.sopetit.softie.data.service

import com.sopetit.softie.data.entity.BaseResponse
import com.sopetit.softie.data.entity.response.AchieveDailyResponse
import com.sopetit.softie.data.entity.response.AddDailyRoutineResponse
import com.sopetit.softie.data.entity.response.DailyCardResponse
import com.sopetit.softie.data.entity.response.DailyRoutineListResponse
import com.sopetit.softie.data.entity.response.DailyRoutineResponse
import com.sopetit.softie.data.entity.response.ThemeListResponse
import retrofit2.http.Body
import retrofit2.http.DELETE
import retrofit2.http.GET
import retrofit2.http.PATCH
import retrofit2.http.POST
import retrofit2.http.Path
import retrofit2.http.Query

interface DailyRoutineService {

@GET("api/v1/routines/daily/themes")
suspend fun getTheme(): BaseResponse<ThemeListResponse>

@GET("api/v1/routines/daily")
suspend fun getRoutineList(
@Query("themes") themes: List<Int>
): BaseResponse<DailyRoutineListResponse>

@GET("api/v1/routines/daily/member")
suspend fun getDailyRoutine(): BaseResponse<DailyRoutineResponse>

@PATCH("api/v1/routines/daily/member/routine/{routineId}")
suspend fun patchAchieveDaily(@Path("routineId") routineId: Int): BaseResponse<AchieveDailyResponse>

@DELETE("api/v1/routines/daily/member")
suspend fun deleteDailyRoutine(@Query("routines") routineIdList: List<Int>): BaseResponse<Unit>

@POST("api/v1/routines/daily/member")
suspend fun postAddDailyRoutine(@Body routineId: Int): BaseResponse<AddDailyRoutineResponse>

@GET("api/v1/routines/daily/theme/{themeId}")
suspend fun getDailyCardList(@Path("themeId") themeId: Int): BaseResponse<DailyCardResponse>
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
package com.sopetit.softie.data.source

import com.sopetit.softie.data.entity.BaseResponse
import com.sopetit.softie.data.entity.response.AchieveDailyResponse
import com.sopetit.softie.data.entity.response.AddDailyRoutineResponse
import com.sopetit.softie.data.entity.response.DailyRoutineListResponse
import com.sopetit.softie.data.entity.response.DailyRoutineResponse
import com.sopetit.softie.data.entity.response.ThemeListResponse
import com.sopetit.softie.data.service.DailyRoutineService
import javax.inject.Inject

class DailyRoutineDataSource @Inject constructor(
private val dailyRoutineService: DailyRoutineService
) {
suspend fun getDailyRoutine(): BaseResponse<DailyRoutineResponse> =
dailyRoutineService.getDailyRoutine()

suspend fun patchAchieveDaily(routineId: Int): BaseResponse<AchieveDailyResponse> =
dailyRoutineService.patchAchieveDaily(routineId)

suspend fun deleteDailyRoutine(routineIdList: List<Int>): BaseResponse<Unit> =
dailyRoutineService.deleteDailyRoutine(routineIdList)

suspend fun getTheme(): BaseResponse<ThemeListResponse> = dailyRoutineService.getTheme()

suspend fun getRoutineList(themeId: List<Int>): BaseResponse<DailyRoutineListResponse> =
dailyRoutineService.getRoutineList(themeId)

suspend fun postAddDailyRoutine(routineId: Int): BaseResponse<AddDailyRoutineResponse> =
dailyRoutineService.postAddDailyRoutine(routineId)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.sopetit.softie.domain.entity

data class AddRoutine(
val routineId: Int
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.sopetit.softie.domain.entity

data class DailyAchieve(
val routineId: Int,
val isAchieve: Boolean,
val achieveCount: Int
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.sopetit.softie.domain.entity

data class UserDailyRoutine(
val routineId: Int,
val iconImageUrl: String,
val content: String,
val backgroundImageUrl: String
)
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
package com.sopetit.softie.domain.repository

import com.sopetit.softie.domain.entity.AddRoutine
import com.sopetit.softie.domain.entity.DailyAchieve
import com.sopetit.softie.domain.entity.DailyRoutine
import com.sopetit.softie.domain.entity.Routine
import com.sopetit.softie.domain.entity.Theme

interface DailyRoutineRepository {

suspend fun getDailyRoutine(): Result<List<DailyRoutine>>
suspend fun patchAchieveDaily(routineId: Int): Result<DailyAchieve>
suspend fun deleteDailyRoutine(routineIdList: List<Int>): Result<Unit>
suspend fun getTheme(): Result<List<Theme>>

suspend fun getRoutineList(themeId: List<Int>): Result<List<Routine>>

suspend fun postAddDailyRoutine(routineId: Int): Result<AddRoutine>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.sopetit.softie.domain.usecase

import com.sopetit.softie.domain.repository.DailyRoutineRepository
import javax.inject.Inject

class DeleteDailyRoutineUseCase @Inject constructor(
private val deleteDailyRoutine: DailyRoutineRepository
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 부분 변수 크게 상관은 없지만 dailyRoutineRespository 이런 식으로 repository를 받아온다는 걸 명확하게 하면 좀 더 좋을 것 같습니당

) {
suspend operator fun invoke(routineIdList: List<Int>) =
deleteDailyRoutine.deleteDailyRoutine(routineIdList)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.sopetit.softie.domain.usecase

import com.sopetit.softie.domain.repository.DailyRoutineRepository
import javax.inject.Inject

class GetDailyRoutineUseCase @Inject constructor(
private val dailyRoutineRepository: DailyRoutineRepository
) {
suspend operator fun invoke() = dailyRoutineRepository.getDailyRoutine()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.sopetit.softie.domain.usecase

import com.sopetit.softie.domain.repository.DailyRoutineRepository
import javax.inject.Inject

class PatchAchieveDailyUseCase @Inject constructor(
private val achieveDailyRepository: DailyRoutineRepository
) {
suspend operator fun invoke(routineId: Int) =
achieveDailyRepository.patchAchieveDaily(routineId)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.sopetit.softie.domain.usecase

import com.sopetit.softie.domain.repository.DailyRoutineRepository
import javax.inject.Inject

class PostAddDailyRoutineUseCase @Inject constructor(
private val dailyRoutineRepository: DailyRoutineRepository
) {
suspend operator fun invoke(routineId: Int) =
dailyRoutineRepository.postAddDailyRoutine(routineId)
}
Loading