-
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.
Merge pull request #217 from School-of-Company/feature/216-network-se…
…tting-training-part 🔀 :: (#216) - Training 파트 부분의 네트워크 세팅을 합니다.
- Loading branch information
Showing
35 changed files
with
548 additions
and
18 deletions.
There are no files selected for viewing
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
15 changes: 15 additions & 0 deletions
15
core/data/src/main/java/com/school_of_company/data/repository/training/TrainingRepository.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.school_of_company.data.repository.training | ||
|
||
import com.school_of_company.model.entity.training.TeacherTrainingProgramResponseEntity | ||
import com.school_of_company.model.entity.training.TrainingProgramListResponseEntity | ||
import com.school_of_company.model.model.training.TrainingDtoModel | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
interface TrainingRepository { | ||
fun registerTrainingProgram(expoId: String, body: TrainingDtoModel) : Flow<Unit> | ||
fun registerTrainingProgramList(expoId: String, body: List<TrainingDtoModel>) : Flow<Unit> | ||
fun modifyTrainingProgram(trainingProId: Long, body: TrainingDtoModel) : Flow<Unit> | ||
fun deleteTrainingProgram(trainingProId: Long) : Flow<Unit> | ||
fun trainingProgramList(expoId: String) : Flow<List<TrainingProgramListResponseEntity>> | ||
fun teacherTrainingProgramList(trainingProId: Long) : Flow<List<TeacherTrainingProgramResponseEntity>> | ||
} |
59 changes: 59 additions & 0 deletions
59
...ta/src/main/java/com/school_of_company/data/repository/training/TrainingRepositoryImpl.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,59 @@ | ||
package com.school_of_company.data.repository.training | ||
|
||
import com.school_of_company.model.entity.training.TeacherTrainingProgramResponseEntity | ||
import com.school_of_company.model.entity.training.TrainingProgramListResponseEntity | ||
import com.school_of_company.model.model.training.TrainingDtoModel | ||
import com.school_of_company.network.datasource.training.TrainingDataSource | ||
import com.school_of_company.network.mapper.expo.response.toEntity | ||
import com.school_of_company.network.mapper.training.request.toDto | ||
import com.school_of_company.network.mapper.training.response.toEntity | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.transform | ||
import javax.inject.Inject | ||
|
||
class TrainingRepositoryImpl @Inject constructor( | ||
private val dataSource: TrainingDataSource | ||
) : TrainingRepository { | ||
override fun registerTrainingProgram(expoId: String, body: TrainingDtoModel): Flow<Unit> { | ||
return dataSource.registerTrainingProgram( | ||
expoId = expoId, | ||
body = body.toDto() | ||
) | ||
} | ||
|
||
override fun registerTrainingProgramList( | ||
expoId: String, | ||
body: List<TrainingDtoModel> | ||
): Flow<Unit> { | ||
return dataSource.registerTrainingProgramList( | ||
expoId = expoId, | ||
body = body.map { it.toDto() } | ||
) | ||
} | ||
|
||
override fun modifyTrainingProgram( | ||
trainingProId: Long, | ||
body: TrainingDtoModel | ||
): Flow<Unit> { | ||
return dataSource.modifyTrainingProgram( | ||
trainingProId = trainingProId, | ||
body = body.toDto() | ||
) | ||
} | ||
|
||
override fun deleteTrainingProgram(trainingProId: Long): Flow<Unit> { | ||
return dataSource.deleteTrainingProgram(trainingProId = trainingProId) | ||
} | ||
|
||
override fun trainingProgramList(expoId: String): Flow<List<TrainingProgramListResponseEntity>> { | ||
return dataSource.trainingProgramList(expoId = expoId).transform { list -> | ||
emit(list.map { it.toEntity() }) | ||
} | ||
} | ||
|
||
override fun teacherTrainingProgramList(trainingProId: Long): Flow<List<TeacherTrainingProgramResponseEntity>> { | ||
return dataSource.teacherTrainingProgramList(trainingProId = trainingProId).transform { list -> | ||
emit(list.map { it.toEntity() }) | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...c/main/java/com/school_of_company/domain/usecase/training/DeleteTrainingProgramUseCase.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,12 @@ | ||
package com.school_of_company.domain.usecase.training | ||
|
||
import com.school_of_company.data.repository.training.TrainingRepository | ||
import javax.inject.Inject | ||
|
||
class DeleteTrainingProgramUseCase @Inject constructor( | ||
private val repository: TrainingRepository | ||
) { | ||
operator fun invoke(trainingProId: Long) = runCatching { | ||
repository.deleteTrainingProgram(trainingProId = trainingProId) | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...c/main/java/com/school_of_company/domain/usecase/training/ModifyTrainingProgramUseCase.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,19 @@ | ||
package com.school_of_company.domain.usecase.training | ||
|
||
import com.school_of_company.data.repository.training.TrainingRepository | ||
import com.school_of_company.model.model.training.TrainingDtoModel | ||
import javax.inject.Inject | ||
|
||
class ModifyTrainingProgramUseCase @Inject constructor( | ||
private val repository: TrainingRepository | ||
) { | ||
operator fun invoke( | ||
trainingProId: Long, | ||
body: TrainingDtoModel | ||
) = runCatching { | ||
repository.modifyTrainingProgram( | ||
trainingProId = trainingProId, | ||
body = body | ||
) | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
.../java/com/school_of_company/domain/usecase/training/RegisterTrainingProgramListUseCase.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,19 @@ | ||
package com.school_of_company.domain.usecase.training | ||
|
||
import com.school_of_company.data.repository.training.TrainingRepository | ||
import com.school_of_company.model.model.training.TrainingDtoModel | ||
import javax.inject.Inject | ||
|
||
class RegisterTrainingProgramListUseCase @Inject constructor( | ||
private val repository: TrainingRepository | ||
) { | ||
operator fun invoke( | ||
expoId: String, | ||
body: List<TrainingDtoModel> | ||
) = runCatching { | ||
repository.registerTrainingProgramList( | ||
expoId = expoId, | ||
body = body | ||
) | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...main/java/com/school_of_company/domain/usecase/training/RegisterTrainingProgramUseCase.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,19 @@ | ||
package com.school_of_company.domain.usecase.training | ||
|
||
import com.school_of_company.data.repository.training.TrainingRepository | ||
import com.school_of_company.model.model.training.TrainingDtoModel | ||
import javax.inject.Inject | ||
|
||
class RegisterTrainingProgramUseCase @Inject constructor( | ||
private val repository: TrainingRepository | ||
) { | ||
operator fun invoke( | ||
expoId: String, | ||
body: TrainingDtoModel | ||
) = runCatching { | ||
repository.registerTrainingProgram( | ||
expoId = expoId, | ||
body = body | ||
) | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...n/java/com/school_of_company/domain/usecase/training/TeacherTrainingProgramListUseCase.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,13 @@ | ||
package com.school_of_company.domain.usecase.training | ||
|
||
import com.school_of_company.data.repository.training.TrainingRepository | ||
import com.school_of_company.model.entity.training.TeacherTrainingProgramResponseEntity | ||
import kotlinx.coroutines.flow.Flow | ||
import javax.inject.Inject | ||
|
||
class TeacherTrainingProgramListUseCase @Inject constructor( | ||
private val repository: TrainingRepository | ||
) { | ||
operator fun invoke(trainingProId: Long): Flow<List<TeacherTrainingProgramResponseEntity>> = | ||
repository.teacherTrainingProgramList(trainingProId = trainingProId) | ||
} |
13 changes: 13 additions & 0 deletions
13
...src/main/java/com/school_of_company/domain/usecase/training/TrainingProgramListUseCase.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,13 @@ | ||
package com.school_of_company.domain.usecase.training | ||
|
||
import com.school_of_company.data.repository.training.TrainingRepository | ||
import com.school_of_company.model.entity.training.TrainingProgramListResponseEntity | ||
import kotlinx.coroutines.flow.Flow | ||
import javax.inject.Inject | ||
|
||
class TrainingProgramListUseCase @Inject constructor( | ||
private val repository: TrainingRepository | ||
) { | ||
operator fun invoke(expoId: String): Flow<List<TrainingProgramListResponseEntity>> = | ||
repository.trainingProgramList(expoId = expoId) | ||
} |
11 changes: 11 additions & 0 deletions
11
.../java/com/school_of_company/model/entity/training/TeacherTrainingProgramResponseEntity.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.school_of_company.model.entity.training | ||
|
||
data class TeacherTrainingProgramResponseEntity( | ||
val name: String, | ||
val organization: String, | ||
val position: String, | ||
val programName: String, | ||
val status: Boolean, | ||
val entryTime: String, | ||
val leaveTime: String | ||
) |
12 changes: 12 additions & 0 deletions
12
...ain/java/com/school_of_company/model/entity/training/TrainingProgramListResponseEntity.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,12 @@ | ||
package com.school_of_company.model.entity.training | ||
|
||
data class TrainingProgramListResponseEntity( | ||
val essential: List<Training>, | ||
val choice: List<Training> | ||
) { | ||
data class Training( | ||
val title: String, | ||
val startedAt: String, | ||
val endedAt: String, | ||
) | ||
} |
Empty file.
8 changes: 8 additions & 0 deletions
8
core/model/src/main/java/com/school_of_company/model/model/training/TrainingDtoModel.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.school_of_company.model.model.training | ||
|
||
data class TrainingDtoModel( | ||
val title: String, | ||
val startedAt: String, | ||
val finishedAt: String, | ||
val category: String, | ||
) |
2 changes: 1 addition & 1 deletion
2
core/network/src/main/java/com/school_of_company/network/api/ExpoAPI.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
47 changes: 47 additions & 0 deletions
47
core/network/src/main/java/com/school_of_company/network/api/TrainingAPI.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,47 @@ | ||
package com.school_of_company.network.api | ||
|
||
import com.school_of_company.network.dto.training.response.TeacherTrainingProgramResponse | ||
import com.school_of_company.network.dto.training.all.TrainingDto | ||
import com.school_of_company.network.dto.training.response.TrainingProgramListResponse | ||
import retrofit2.http.Body | ||
import retrofit2.http.DELETE | ||
import retrofit2.http.GET | ||
import retrofit2.http.PATCH | ||
import retrofit2.http.POST | ||
import retrofit2.http.Path | ||
|
||
interface TrainingAPI { | ||
|
||
@POST("/training/{expo_id}") | ||
suspend fun registerTrainingProgram( | ||
@Path("expo_id") expoId: String, | ||
@Body body: TrainingDto | ||
) | ||
|
||
@POST("/training/list/{expo_id}") | ||
suspend fun registerTrainingProgramList( | ||
@Path("expo_id") expoId: String, | ||
@Body body: List<TrainingDto> | ||
) | ||
|
||
@PATCH("/training/{trainingPro_id}") | ||
suspend fun modifyTrainingProgram( | ||
@Path("trainingPro_id") trainingProId: Long, | ||
@Body body: TrainingDto | ||
) | ||
|
||
@DELETE("/training/{trainingPro_id}") | ||
suspend fun deleteTrainingProgram( | ||
@Path("trainingPro_id") trainingProId: Long | ||
) | ||
|
||
@GET("/training/program/{expo_id}") | ||
suspend fun trainingProgramList( | ||
@Path("expo_id") expoId: String | ||
) : List<TrainingProgramListResponse> | ||
|
||
@GET("/training/{trainingPro_id}") | ||
suspend fun teacherTrainingProgramList( | ||
@Path("trainingPro_id") trainingProId: Long | ||
) : List<TeacherTrainingProgramResponse> | ||
} |
2 changes: 1 addition & 1 deletion
2
core/network/src/main/java/com/school_of_company/network/datasource/expo/ExpoDataSource.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
2 changes: 1 addition & 1 deletion
2
...network/src/main/java/com/school_of_company/network/datasource/expo/ExpoDataSourceImpl.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
15 changes: 15 additions & 0 deletions
15
...ork/src/main/java/com/school_of_company/network/datasource/training/TrainingDataSource.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.school_of_company.network.datasource.training | ||
|
||
import com.school_of_company.network.dto.training.response.TeacherTrainingProgramResponse | ||
import com.school_of_company.network.dto.training.all.TrainingDto | ||
import com.school_of_company.network.dto.training.response.TrainingProgramListResponse | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
interface TrainingDataSource { | ||
fun registerTrainingProgram(expoId: String, body: TrainingDto) : Flow<Unit> | ||
fun registerTrainingProgramList(expoId: String, body: List<TrainingDto>) : Flow<Unit> | ||
fun modifyTrainingProgram(trainingProId: Long, body: TrainingDto) : Flow<Unit> | ||
fun deleteTrainingProgram(trainingProId: Long) : Flow<Unit> | ||
fun trainingProgramList(expoId: String) : Flow<List<TrainingProgramListResponse>> | ||
fun teacherTrainingProgramList(trainingProId: Long) : Flow<List<TeacherTrainingProgramResponse>> | ||
} |
46 changes: 46 additions & 0 deletions
46
...src/main/java/com/school_of_company/network/datasource/training/TrainingDataSourceImpl.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,46 @@ | ||
package com.school_of_company.network.datasource.training | ||
|
||
import com.school_of_company.network.api.TrainingAPI | ||
import com.school_of_company.network.dto.training.response.TeacherTrainingProgramResponse | ||
import com.school_of_company.network.dto.training.all.TrainingDto | ||
import com.school_of_company.network.dto.training.response.TrainingProgramListResponse | ||
import com.school_of_company.network.util.performApiRequest | ||
import kotlinx.coroutines.flow.Flow | ||
import javax.inject.Inject | ||
|
||
class TrainingDataSourceImpl @Inject constructor( | ||
private val service: TrainingAPI | ||
) : TrainingDataSource { | ||
override fun registerTrainingProgram( | ||
expoId: String, | ||
body: TrainingDto | ||
): Flow<Unit> = | ||
performApiRequest { service.registerTrainingProgram( | ||
expoId = expoId, | ||
body = body | ||
) } | ||
|
||
override fun registerTrainingProgramList( | ||
expoId: String, | ||
body: List<TrainingDto> | ||
): Flow<Unit> = | ||
performApiRequest { service.registerTrainingProgramList( | ||
expoId = expoId, | ||
body = body | ||
) } | ||
|
||
override fun modifyTrainingProgram(trainingProId: Long, body: TrainingDto): Flow<Unit> = | ||
performApiRequest { service.modifyTrainingProgram( | ||
trainingProId = trainingProId, | ||
body = body | ||
) } | ||
|
||
override fun deleteTrainingProgram(trainingProId: Long): Flow<Unit> = | ||
performApiRequest { service.deleteTrainingProgram(trainingProId = trainingProId) } | ||
|
||
override fun trainingProgramList(expoId: String): Flow<List<TrainingProgramListResponse>> = | ||
performApiRequest { service.trainingProgramList(expoId = expoId) } | ||
|
||
override fun teacherTrainingProgramList(trainingProId: Long): Flow<List<TeacherTrainingProgramResponse>> = | ||
performApiRequest { service.teacherTrainingProgramList(trainingProId = trainingProId) } | ||
} |
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
Oops, something went wrong.