-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
505 additions
and
99 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
app/src/main/java/com/sopetit/softie/data/entity/request/AddDailyRoutineRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) |
21 changes: 21 additions & 0 deletions
21
app/src/main/java/com/sopetit/softie/data/entity/response/AchieveDailyResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) | ||
} |
15 changes: 15 additions & 0 deletions
15
app/src/main/java/com/sopetit/softie/data/entity/response/AddDailyRoutineResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) | ||
} |
25 changes: 25 additions & 0 deletions
25
app/src/main/java/com/sopetit/softie/data/entity/response/DailyCardResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
app/src/main/java/com/sopetit/softie/data/entity/response/DailyRoutineResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 24 additions & 1 deletion
25
app/src/main/java/com/sopetit/softie/data/service/DailyRoutineService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
} |
15 changes: 15 additions & 0 deletions
15
app/src/main/java/com/sopetit/softie/data/source/DailyRoutineDataSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |
5 changes: 5 additions & 0 deletions
5
app/src/main/java/com/sopetit/softie/domain/entity/AddRoutine.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) |
7 changes: 7 additions & 0 deletions
7
app/src/main/java/com/sopetit/softie/domain/entity/DailyAchieve.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) |
8 changes: 8 additions & 0 deletions
8
app/src/main/java/com/sopetit/softie/domain/entity/UserDailyRoutine.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) |
9 changes: 8 additions & 1 deletion
9
app/src/main/java/com/sopetit/softie/domain/repository/DailyRoutineRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
} |
11 changes: 11 additions & 0 deletions
11
app/src/main/java/com/sopetit/softie/domain/usecase/DeleteDailyRoutineUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) { | ||
suspend operator fun invoke(routineIdList: List<Int>) = | ||
deleteDailyRoutine.deleteDailyRoutine(routineIdList) | ||
} |
10 changes: 10 additions & 0 deletions
10
app/src/main/java/com/sopetit/softie/domain/usecase/GetDailyRoutineUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} |
11 changes: 11 additions & 0 deletions
11
app/src/main/java/com/sopetit/softie/domain/usecase/PatchAchieveDailyUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |
11 changes: 11 additions & 0 deletions
11
app/src/main/java/com/sopetit/softie/domain/usecase/PostAddDailyRoutineUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |
Oops, something went wrong.