Skip to content

Commit 55db036

Browse files
committed
Feat: 반복루틴 단일 삭제 API 연동
1 parent e8f6d41 commit 55db036

File tree

6 files changed

+34
-0
lines changed

6 files changed

+34
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package com.threegap.bitnagil.data.routine.datasource
22

3+
import com.threegap.bitnagil.data.routine.model.request.RoutineByDayDeletionRequestDto
34
import com.threegap.bitnagil.data.routine.model.request.RoutineCompletionRequestDto
45
import com.threegap.bitnagil.data.routine.model.response.RoutinesResponseDto
56

67
interface RoutineRemoteDataSource {
78
suspend fun fetchWeeklyRoutines(startDate: String, endDate: String): Result<RoutinesResponseDto>
89
suspend fun syncRoutineCompletion(routineCompletionRequestDto: RoutineCompletionRequestDto): Result<Unit>
910
suspend fun deleteRoutine(routineId: String): Result<Unit>
11+
suspend fun deleteRoutineByDay(routineByDayDeletionRequestDto: RoutineByDayDeletionRequestDto): Result<Unit>
1012
}

data/src/main/java/com/threegap/bitnagil/data/routine/datasourceImpl/RoutineRemoteDataSourceImpl.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.threegap.bitnagil.data.routine.datasourceImpl
33
import com.threegap.bitnagil.data.common.safeApiCall
44
import com.threegap.bitnagil.data.common.safeUnitApiCall
55
import com.threegap.bitnagil.data.routine.datasource.RoutineRemoteDataSource
6+
import com.threegap.bitnagil.data.routine.model.request.RoutineByDayDeletionRequestDto
67
import com.threegap.bitnagil.data.routine.model.request.RoutineCompletionRequestDto
78
import com.threegap.bitnagil.data.routine.model.response.RoutinesResponseDto
89
import com.threegap.bitnagil.data.routine.service.RoutineService
@@ -25,4 +26,9 @@ class RoutineRemoteDataSourceImpl @Inject constructor(
2526
safeUnitApiCall {
2627
routineService.deleteRoutine(routineId)
2728
}
29+
30+
override suspend fun deleteRoutineByDay(routineByDayDeletionRequestDto: RoutineByDayDeletionRequestDto): Result<Unit> =
31+
safeUnitApiCall {
32+
routineService.deleteRoutineByDay(routineByDayDeletionRequestDto)
33+
}
2834
}

data/src/main/java/com/threegap/bitnagil/data/routine/repositoryImpl/RoutineRepositoryImpl.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package com.threegap.bitnagil.data.routine.repositoryImpl
33
import com.threegap.bitnagil.data.routine.datasource.RoutineRemoteDataSource
44
import com.threegap.bitnagil.data.routine.mapper.toDomain
55
import com.threegap.bitnagil.data.routine.mapper.toDto
6+
import com.threegap.bitnagil.data.routine.model.request.toDto
7+
import com.threegap.bitnagil.domain.routine.model.RoutineByDayDeletion
68
import com.threegap.bitnagil.domain.routine.model.RoutineCompletion
79
import com.threegap.bitnagil.domain.routine.model.Routines
810
import com.threegap.bitnagil.domain.routine.repository.RoutineRepository
@@ -20,4 +22,7 @@ class RoutineRepositoryImpl @Inject constructor(
2022

2123
override suspend fun deleteRoutine(routineId: String): Result<Unit> =
2224
routineRemoteDataSource.deleteRoutine(routineId)
25+
26+
override suspend fun deleteRoutineByDay(routineByDayDeletion: RoutineByDayDeletion): Result<Unit> =
27+
routineRemoteDataSource.deleteRoutineByDay(routineByDayDeletion.toDto())
2328
}

data/src/main/java/com/threegap/bitnagil/data/routine/service/RoutineService.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package com.threegap.bitnagil.data.routine.service
22

3+
import com.threegap.bitnagil.data.routine.model.request.RoutineByDayDeletionRequestDto
34
import com.threegap.bitnagil.data.routine.model.request.RoutineCompletionRequestDto
45
import com.threegap.bitnagil.data.routine.model.response.RoutinesResponseDto
56
import com.threegap.bitnagil.network.model.BaseResponse
67
import retrofit2.http.Body
78
import retrofit2.http.DELETE
89
import retrofit2.http.GET
10+
import retrofit2.http.HTTP
911
import retrofit2.http.POST
1012
import retrofit2.http.Path
1113
import retrofit2.http.Query
@@ -26,4 +28,9 @@ interface RoutineService {
2628
suspend fun deleteRoutine(
2729
@Path("routineId") routineId: String,
2830
): BaseResponse<Unit>
31+
32+
@HTTP(method = "DELETE", path = "/api/v1/routines/day", hasBody = true)
33+
suspend fun deleteRoutineByDay(
34+
@Body request: RoutineByDayDeletionRequestDto,
35+
): BaseResponse<Unit>
2936
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package com.threegap.bitnagil.domain.routine.repository
22

3+
import com.threegap.bitnagil.domain.routine.model.RoutineByDayDeletion
34
import com.threegap.bitnagil.domain.routine.model.RoutineCompletion
45
import com.threegap.bitnagil.domain.routine.model.Routines
56

67
interface RoutineRepository {
78
suspend fun fetchWeeklyRoutines(startDate: String, endDate: String): Result<Routines>
89
suspend fun syncRoutineCompletion(routineCompletion: RoutineCompletion): Result<Unit>
910
suspend fun deleteRoutine(routineId: String): Result<Unit>
11+
suspend fun deleteRoutineByDay(routineByDayDeletion: RoutineByDayDeletion): Result<Unit>
1012
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.threegap.bitnagil.domain.routine.usecase
2+
3+
import com.threegap.bitnagil.domain.routine.model.RoutineByDayDeletion
4+
import com.threegap.bitnagil.domain.routine.repository.RoutineRepository
5+
import javax.inject.Inject
6+
7+
class DeleteRoutineByDayUseCase @Inject constructor(
8+
private val routineRepository: RoutineRepository,
9+
) {
10+
suspend operator fun invoke(routineByDayDeletion: RoutineByDayDeletion) =
11+
routineRepository.deleteRoutineByDay(routineByDayDeletion)
12+
}

0 commit comments

Comments
 (0)