-
Notifications
You must be signed in to change notification settings - Fork 0
๐ :: (#46) Mission Domain Network Setting #56
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
Merged
yeongun130
merged 26 commits into
develop
from
feature/#46_mission_domain_network_setting
Jun 26, 2024
Merged
Changes from 24 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
e279711
:sparkles: :: checkout์ ์์
๋ฌผ ์ปค๋ฐ
Chaejongin12 0255f53
:sparkles: :: add mission Repository
yeongun130 3169b3a
:sparkles: :: add mission UseCase
yeongun130 4f49e55
:sparkles: :: Mission Request ์์ฑ
yeongun130 b634995
:sparkles: :: Mission Response ์์ฑ
yeongun130 0b29e24
:sparkles: :: add enum class MissionStatus
yeongun130 a463492
:sparkles: :: Mission API ์์ฑ
yeongun130 cba0c97
:sparkles: :: Mission DataSource ์์ฑ
yeongun130 36c80a9
:sparkles: :: Mission NetworkModule์ ์ถ๊ฐ
yeongun130 190c8a6
:sparkles: :: Mission ViewModel ์์ฑ
yeongun130 e0a9e2c
:sparkles: :: Event ์์ฑ
yeongun130 e964979
:fire: :: delete .gitkeep
yeongun130 21b50d0
Merge branch 'develop' of https://github.com/Stack-Knowledge/Stack-Knโฆ
yeongun130 6af450e
Merge branch 'develop' of https://github.com/Stack-Knowledge/Stack-Knโฆ
yeongun130 ed06f71
Merge remote-tracking branch 'origin/feature/#46_mission_domain_netwoโฆ
yeongun130 58804bd
Merge branch 'develop' of https://github.com/Stack-Knowledge/Stack-Knโฆ
yeongun130 3a9619d
Merge branch 'develop' of https://github.com/Stack-Knowledge/Stack-Knโฆ
yeongun130 7c47875
:memo: :: @Singleton ์ถ๊ฐ
yeongun130 5e33307
:sparkles: :: modify NetWorkModule
yeongun130 b2c11f9
:memo: :: modify import
yeongun130 967cd0c
:sparkles: :: Event, errorHandling ๊ฒฝ๋ก ์ด๋
yeongun130 bf30343
:fire: :: delete suspend
yeongun130 edb68e4
:sparkles: :: Success response data type
yeongun130 6e69f83
:fire: :: delete suspend
yeongun130 014e5e0
:fire: :: ๊ณต๋ฐฑ ์ ๊ฑฐ
yeongun130 c911549
:memo: :: ์ปจ๋ฒค์
์์
yeongun130 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
core/common/src/main/java/com/example/common/util/Event.kt
This file contains hidden or 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.example.common.util | ||
|
||
sealed class Event<out T>( | ||
val data: T? = null | ||
) { | ||
|
||
object Loading : Event<Nothing>() | ||
|
||
/** | ||
* ์ฑ๊ณต | ||
*/ | ||
class Success<T>(data: T? = null) : Event<T>(data = data) | ||
|
||
/** | ||
* 400๋ฒ ์์ฒญ์ด ์ฌ๋ฐ๋ฅด์ง ์์ ๊ฒฝ์ฐ | ||
*/ | ||
object BadRequest : Event<Nothing>() | ||
|
||
/** | ||
* 401๋ฒ ๋น์ธ์ฆ ์์ฒญ | ||
*/ | ||
object Unauthorized : Event<Nothing>() | ||
|
||
/** | ||
* 403๋ฒ ๊ถํ์ด ์์ | ||
*/ | ||
object ForBidden : Event<Nothing>() | ||
|
||
/** | ||
* 404 ์ฐพ์ ์ ์๋ ๊ฒฝ์ฐ | ||
*/ | ||
object NotFound : Event<Nothing>() | ||
|
||
/** | ||
* 406 ๋ง๋ ๊ท๊ฒฉ์ด ์๋ ๊ฒฝ์ฐ | ||
*/ | ||
object NotAcceptable : Event<Nothing>() | ||
|
||
/** | ||
* 408 ์์ฒญ์ด ๋๋ฌด ์ค๋ ๊ฑธ๋ฆฌ๋ ๊ฒฝ์ฐ | ||
*/ | ||
object TimeOut : Event<Nothing>() | ||
|
||
/** | ||
* 409 ๊ถํ์ด ์์ ๋ | ||
*/ | ||
object Conflict : Event<Nothing>() | ||
|
||
/** | ||
* 50X ์๋ฒ์๋ฌ | ||
*/ | ||
object Server : Event<Nothing>() | ||
|
||
/** | ||
* ์์์น ๋ชปํ ์๋ฌ | ||
*/ | ||
object UnKnown : Event<Nothing>() | ||
|
||
} |
67 changes: 67 additions & 0 deletions
67
core/common/src/main/java/com/example/common/util/errorHandling.kt
This file contains hidden or 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,67 @@ | ||
package com.example.common.util | ||
|
||
import android.util.Log | ||
import com.example.common.exception.* | ||
|
||
suspend fun <T> Throwable.errorHandling( | ||
badRequestAction: suspend () -> Unit = {}, | ||
unauthorizedAction: suspend () -> Unit = {}, | ||
forBiddenAction: suspend () -> Unit = {}, | ||
notFoundAction: suspend () -> Unit = {}, | ||
notAcceptableAction: suspend () -> Unit = {}, | ||
timeOutAction: suspend () -> Unit = {}, | ||
conflictAction: suspend () -> Unit = {}, | ||
serverAction: suspend () -> Unit = {}, | ||
unknownAction: suspend () -> Unit = {}, | ||
): Event<T> = | ||
when (this) { | ||
is BadRequestException -> { | ||
errorLog("BadRequestException", message) | ||
badRequestAction() | ||
Event.BadRequest | ||
} | ||
is UnauthorizedException, is NeedLoginException -> { | ||
errorLog("UnauthorizedException", message) | ||
unauthorizedAction() | ||
Event.Unauthorized | ||
} | ||
is ForBiddenException -> { | ||
errorLog("ForBiddenException", message) | ||
forBiddenAction() | ||
Event.ForBidden | ||
} | ||
is NotFoundException -> { | ||
errorLog("NotFoundException", message) | ||
notFoundAction() | ||
Event.NotFound | ||
} | ||
is NotAcceptableException -> { | ||
errorLog("NotAcceptableException", message) | ||
notAcceptableAction() | ||
Event.NotAcceptable | ||
} | ||
is TimeOutException -> { | ||
errorLog("TimeOutException", message) | ||
timeOutAction() | ||
Event.TimeOut | ||
} | ||
is ConflictException -> { | ||
errorLog("ConflictException", message) | ||
conflictAction() | ||
Event.Conflict | ||
} | ||
is ServerException -> { | ||
errorLog("ServerException", message) | ||
serverAction() | ||
Event.Server | ||
} | ||
else -> { | ||
errorLog("UnKnownException", message) | ||
unknownAction() | ||
Event.UnKnown | ||
} | ||
} | ||
|
||
private fun errorLog(tag: String, msg: String?) { | ||
Log.d("ErrorHandling-$tag", msg ?: "์ ์ ์๋ ์ค๋ฅ") | ||
} |
This file contains hidden or 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/kotlin/com/stackknowledge/repository/mission/MissionRepository.kt
This file contains hidden or 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.stackknowledge.repository.mission | ||
|
||
import kotlinx.coroutines.flow.Flow | ||
import remote.request.mission.CreateMissionRequestModel | ||
import remote.request.mission.DetailMissionRequestModel | ||
import remote.response.mission.DetailMissionResponseModel | ||
import remote.response.mission.MissionResponseModel | ||
|
||
interface MissionRepository { | ||
fun getMission(): Flow<MissionResponseModel> | ||
|
||
fun detailMission(missionId: DetailMissionRequestModel): Flow<DetailMissionResponseModel> | ||
|
||
fun createMission(body: CreateMissionRequestModel): Flow<Unit> | ||
} |
25 changes: 25 additions & 0 deletions
25
core/data/src/main/kotlin/com/stackknowledge/repository/mission/MissionRepositoryImpl.kt
This file contains hidden or 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.stackknowledge.repository.mission | ||
|
||
import com.stackknowledge.datasource.mission.MissionDataSource | ||
import kotlinx.coroutines.flow.Flow | ||
import remote.request.mission.CreateMissionRequestModel | ||
import remote.request.mission.DetailMissionRequestModel | ||
import remote.response.mission.DetailMissionResponseModel | ||
import remote.response.mission.MissionResponseModel | ||
import javax.inject.Inject | ||
|
||
class MissionRepositoryImpl @Inject constructor( | ||
private val missionDataSource: MissionDataSource | ||
): MissionRepository { | ||
override fun getMission(): Flow<MissionResponseModel> { | ||
return missionDataSource.getMission() | ||
} | ||
|
||
override fun detailMission(missionId: DetailMissionRequestModel): Flow<DetailMissionResponseModel> { | ||
return missionDataSource.detailMission(missionId = missionId) | ||
} | ||
|
||
override fun createMission(body: CreateMissionRequestModel): Flow<Unit> { | ||
return missionDataSource.createMission(body = body) | ||
} | ||
} |
7 changes: 1 addition & 6 deletions
7
core/data/src/main/kotlin/com/stackknowledge/repository/user/UserRepositoryImpl.kt
This file contains hidden or 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
13 changes: 13 additions & 0 deletions
13
core/domain/src/main/kotlin/com/stackknowledge/usecase/misson/CreateMissionUseCase.kt
This file contains hidden or 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.stackknowledge.usecase.misson | ||
|
||
import com.stackknowledge.repository.mission.MissionRepository | ||
import remote.request.mission.CreateMissionRequestModel | ||
import javax.inject.Inject | ||
|
||
class CreateMissionUseCase @Inject constructor( | ||
private val missionRepository: MissionRepository | ||
) { | ||
suspend operator fun invoke(body: CreateMissionRequestModel) = runCatching { | ||
missionRepository.createMission(body = body) | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
core/domain/src/main/kotlin/com/stackknowledge/usecase/misson/DetailMissionUseCase.kt
This file contains hidden or 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.stackknowledge.usecase.misson | ||
|
||
import com.stackknowledge.repository.mission.MissionRepository | ||
import remote.request.mission.DetailMissionRequestModel | ||
import javax.inject.Inject | ||
|
||
class DetailMissionUseCase @Inject constructor( | ||
private val missionRepository: MissionRepository | ||
) { | ||
suspend operator fun invoke(missionId: DetailMissionRequestModel) = runCatching { | ||
missionRepository.detailMission(missionId = missionId) | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
core/domain/src/main/kotlin/com/stackknowledge/usecase/misson/GetMissionUseCase.kt
This file contains hidden or 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.stackknowledge.usecase.misson | ||
|
||
import com.stackknowledge.repository.mission.MissionRepository | ||
import javax.inject.Inject | ||
|
||
class GetMissionUseCase @Inject constructor( | ||
private val missionRepository: MissionRepository | ||
) { | ||
suspend operator fun invoke() = runCatching { | ||
missionRepository.getMission() | ||
} | ||
} |
This file contains hidden or 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
This file contains hidden or 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 enumdata | ||
|
||
enum class MissionStatus { | ||
CLOSED, // Mission์ ํ ์ ์๋ ์ํ | ||
OPENED, // Mission์ ํ ์ ์๋ ์ํ | ||
AVAILABLE_OPEN, // Mission์ ๋ด์ผ ํ ์ ์๋ ์ํ | ||
} |
This file contains hidden or 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 enumdatatype | ||
|
||
enum class MissionStatus { | ||
CLOSED, | ||
OPENED, | ||
AVAILABLE_OPEN, | ||
} |
11 changes: 11 additions & 0 deletions
11
core/model/src/main/kotlin/remote/request/mission/CreateMissionRequestModel.kt
This file contains hidden or 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 remote.request.mission | ||
|
||
import com.squareup.moshi.Json | ||
import com.squareup.moshi.JsonClass | ||
|
||
@JsonClass(generateAdapter = true) | ||
data class CreateMissionRequestModel( | ||
@Json(name = "title") val title: String, | ||
@Json(name = "content") val content: String, | ||
@Json(name = "timeLimit") val timeLimit: Int, | ||
) |
10 changes: 10 additions & 0 deletions
10
core/model/src/main/kotlin/remote/request/mission/DetailMissionRequestModel.kt
This file contains hidden or 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 remote.request.mission | ||
|
||
import com.squareup.moshi.Json | ||
import com.squareup.moshi.JsonClass | ||
import java.util.UUID | ||
|
||
@JsonClass(generateAdapter = true) | ||
data class DetailMissionRequestModel( | ||
@Json(name = "mission_id") val missionId: UUID, | ||
) |
This file contains hidden or 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 |
---|---|---|
|
@@ -4,4 +4,4 @@ import okhttp3.MultipartBody | |
|
||
data class UploadProfileImageRequest( | ||
val image: MultipartBody.Part | ||
) | ||
) |
11 changes: 11 additions & 0 deletions
11
core/model/src/main/kotlin/remote/response/mission/DetailMissionResponseModel.kt
Chaejongin12 marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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 remote.response.mission | ||
|
||
import com.squareup.moshi.Json | ||
import com.squareup.moshi.JsonClass | ||
|
||
@JsonClass(generateAdapter = true) | ||
data class DetailMissionResponseModel( | ||
@Json(name = "title") val title : String, | ||
@Json(name = "content") val content : String, | ||
@Json(name = "timeLimit") val timeLimit: Int, | ||
) |
12 changes: 12 additions & 0 deletions
12
core/model/src/main/kotlin/remote/response/mission/MissionResponseModel.kt
Chaejongin12 marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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 remote.response.mission | ||
|
||
import com.squareup.moshi.Json | ||
import com.squareup.moshi.JsonClass | ||
import enumdatatype.MissionStatus | ||
import remote.user.UserModel | ||
import java.util.UUID | ||
|
||
@JsonClass(generateAdapter = true) | ||
data class MissionResponseModel( | ||
@Json(name = "body") val missions : MissionsModel, | ||
) |
16 changes: 16 additions & 0 deletions
16
core/model/src/main/kotlin/remote/response/mission/MissionsModel.kt
This file contains hidden or 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,16 @@ | ||
package remote.response.mission | ||
|
||
import com.squareup.moshi.Json | ||
import com.squareup.moshi.JsonClass | ||
import enumdatatype.MissionStatus | ||
import remote.user.UserModel | ||
import java.util.UUID | ||
|
||
@JsonClass(generateAdapter = true) | ||
data class MissionsModel( | ||
@Json(name = "id") val id : UUID, | ||
@Json(name = "title") val title : String, | ||
@Json(name = "point") val point : Int, | ||
@Json(name = "missionStatus") val missionStatus : MissionStatus, | ||
@Json(name = "user") val user : UserModel, | ||
minStone-dev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) |
This file contains hidden or 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 |
---|---|---|
|
@@ -2,4 +2,4 @@ package remote.response.student | |
|
||
data class UploadProfileImageResponse( | ||
val fileName: String, | ||
) | ||
) |
This file contains hidden or 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 |
---|---|---|
|
@@ -5,4 +5,4 @@ data class DetailSolveMissionResponseModel( | |
val solveId: UUID, | ||
val title: String, | ||
val solution: String, | ||
) | ||
) |
This file contains hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.