-
Notifications
You must be signed in to change notification settings - Fork 0
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
[TNT-176] 트레이너, 트레이니 메인 네비게이션 기초 세팅 #64
Changes from all commits
fd10026
7dd11b1
ffb5898
d133796
ce19dc9
d065755
18e2b5e
a015414
75c5a86
8804a14
85cf8a2
b4168e0
f9fb1ef
e00f461
96a6d92
55b2e66
153b238
6abbc60
2714349
fc1e747
6d47a33
c0fc779
5389e6f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package co.kr.data.network.model | ||
|
||
import co.kr.data.network.model.enum.MemberType | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class CheckSessionResponse( | ||
val memberType: MemberType, | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
package co.kr.data.network.model | ||
|
||
import co.kr.data.network.model.enum.MemberType | ||
import co.kr.data.network.model.enum.toDomain | ||
import co.kr.tnt.domain.model.AuthType | ||
import co.kr.tnt.domain.model.LoginResult | ||
import kotlinx.serialization.Serializable | ||
|
@@ -14,6 +16,7 @@ data class LoginResponse( | |
val socialEmail: String, | ||
val socialType: AuthType, | ||
val isSignUp: Boolean, | ||
val memberType: MemberType, | ||
) | ||
|
||
fun LoginResponse.toDomain(): LoginResult = | ||
|
@@ -22,4 +25,5 @@ fun LoginResponse.toDomain(): LoginResult = | |
email = socialEmail, | ||
authType = socialType, | ||
isSignUp = isSignUp, | ||
userType = runCatching(memberType::toDomain).getOrNull(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 😯👍 |
||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package co.kr.data.network.model.enum | ||
|
||
import co.kr.tnt.domain.model.UserType | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
enum class MemberType { | ||
TRAINER, | ||
TRAINEE, | ||
UNREGISTERED, | ||
} | ||
|
||
fun MemberType.toDomain(): UserType = | ||
when (this) { | ||
MemberType.TRAINER -> UserType.TRAINER | ||
MemberType.TRAINEE -> UserType.TRAINEE | ||
MemberType.UNREGISTERED -> error("등록되지 않은 유저입니다.") | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ import co.kr.data.network.model.toSignUpRequest | |
import co.kr.data.network.source.SignUpRemoteDataSource | ||
import co.kr.data.storage.source.SessionLocalDataSource | ||
import co.kr.tnt.domain.model.SignUpResult | ||
import co.kr.tnt.domain.model.UserType | ||
import co.kr.tnt.domain.model.User | ||
import co.kr.tnt.domain.repository.SignUpRepository | ||
import kotlinx.serialization.encodeToString | ||
import kotlinx.serialization.json.Json | ||
|
@@ -25,7 +25,7 @@ class SignUpRepositoryImpl @Inject constructor( | |
) : SignUpRepository { | ||
override suspend fun signUp( | ||
profileImage: File?, | ||
userType: UserType, | ||
user: User, | ||
socialId: String, | ||
socialType: String, | ||
email: String, | ||
|
@@ -36,13 +36,13 @@ class SignUpRepositoryImpl @Inject constructor( | |
} | ||
|
||
// TODO FCM token | ||
val signUpRequest = userType.toSignUpRequest( | ||
val signUpRequest = user.toSignUpRequest( | ||
socialId = socialId, | ||
socialType = socialType, | ||
email = email, | ||
fcmToken = "EMPTY", | ||
) | ||
val requestBody = signUpRequest.toRequestBody(Json) | ||
val requestBody = signUpRequest.toRequestBody() | ||
|
||
val response = signupRemoteDataSource.postSignUp( | ||
profileImage = profileImagePart, | ||
|
@@ -54,7 +54,7 @@ class SignUpRepositoryImpl @Inject constructor( | |
return response.toDomain() | ||
} | ||
|
||
private fun SignUpRequest.toRequestBody(json: Json): RequestBody { | ||
private fun SignUpRequest.toRequestBody(): RequestBody { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 앗,, 감사합니다 |
||
val jsonString = json.encodeToString(this) | ||
return jsonString.toRequestBody("application/json".toMediaTypeOrNull()) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package co.kr.tnt.domain.model | ||
|
||
import java.time.LocalDate | ||
|
||
sealed class User { | ||
abstract val id: String | ||
abstract val name: String | ||
abstract val image: String? | ||
|
||
data class Trainer( | ||
override val id: String, | ||
override val name: String, | ||
override val image: String?, | ||
) : User() { | ||
companion object { | ||
val EMPTY = Trainer( | ||
id = "", | ||
name = "", | ||
image = null, | ||
) | ||
} | ||
} | ||
Comment on lines
+15
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아 이런 방법이 있었군요..! |
||
|
||
data class Trainee( | ||
override val id: String, | ||
override val name: String, | ||
override val image: String?, | ||
val birthday: LocalDate?, | ||
val age: Int?, | ||
val weight: Double, | ||
val height: Int, | ||
val ptPurpose: List<String>, | ||
val caution: String?, | ||
) : User() { | ||
companion object { | ||
val EMPTY = Trainee( | ||
id = "", | ||
name = "", | ||
image = null, | ||
birthday = null, | ||
age = 0, | ||
weight = 0.0, | ||
height = 0, | ||
ptPurpose = emptyList(), | ||
caution = null, | ||
) | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,6 @@ | ||
package co.kr.tnt.domain.model | ||
|
||
import java.time.LocalDate | ||
|
||
sealed class UserType { | ||
abstract val id: String | ||
abstract val name: String | ||
abstract val image: String? | ||
|
||
data class Trainer( | ||
override val id: String, | ||
override val name: String, | ||
override val image: String?, | ||
) : UserType() | ||
|
||
data class Trainee( | ||
override val id: String, | ||
override val name: String, | ||
override val image: String?, | ||
val birthday: LocalDate?, | ||
val age: Int?, | ||
val weight: Double, | ||
val height: Int, | ||
val ptPurpose: List<String>, | ||
val caution: String?, | ||
) : UserType() | ||
enum class UserType { | ||
TRAINER, | ||
TRAINEE, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
굿굿굿 감사합니다👍