-
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
Week4 #8
base: develop
Are you sure you want to change the base?
Week4 #8
Changes from 3 commits
cda17c8
113b9fa
71d677f
ee9d131
841d04e
72b791b
5cbd2ee
18cd80e
26c22c1
0512b01
f6f4b09
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,11 @@ | ||
package org.sopt.and.model.dto.login | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
//์์ฒญํ ๋๋ username๋ง ๊ฐ์ง๊ณ ์์ฒญ (uniqueํด์ผ ํจ) | ||
@Serializable | ||
data class RequestGetUserDto( | ||
@SerialName("username") | ||
val userName: String, | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.sopt.and.model.dto.login | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ResponseGetUserFailDto( | ||
@SerialName("code") | ||
val no: Int | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.sopt.and.model.dto.login | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ResponseGetUserSuccessDto( | ||
@SerialName("result") | ||
val result: UserResult | ||
) | ||
|
||
@Serializable | ||
data class UserResult( | ||
@SerialName("token") | ||
val token: String | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.sopt.and.model.dto.login | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ResponseGetUserWrapperDto( | ||
@SerialName("success") | ||
val success: ResponseGetUserSuccessDto, | ||
@SerialName("failed") | ||
val failed: ResponseGetUserFailDto | ||
) | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.sopt.and.model.dto.mypage | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
//์์ฒญํ ๋๋ token๋ง ๊ฐ์ง๊ณ ์์ฒญ | ||
@Serializable | ||
data class RequestGetUserHobbyDto( | ||
@SerialName("token") | ||
val token: String, | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.sopt.and.model.dto.mypage | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ResponseGetUserHobbyFailDto( | ||
@SerialName("code") | ||
val no: Int | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.sopt.and.model.dto.mypage | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ResponseGetUserHobbySuccessDto( | ||
@SerialName("result") | ||
val result: HobbyResult? = null, | ||
) | ||
|
||
@Serializable | ||
data class HobbyResult( | ||
@SerialName("hobby") | ||
val userHobby: String? = null, | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.sopt.and.model.dto.mypage | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
import org.sopt.and.model.dto.login.ResponseGetUserFailDto | ||
import org.sopt.and.model.dto.login.ResponseGetUserSuccessDto | ||
|
||
@Serializable | ||
data class ResponseGetUserHobbyWrapperDto( | ||
@SerialName("success") | ||
val success: ResponseGetUserHobbySuccessDto, | ||
@SerialName("failed") | ||
val failed: ResponseGetUserHobbyFailDto | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.sopt.and.model.dto.signup | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class RequestCreateUserDto( | ||
@SerialName("username") | ||
val userName: String, | ||
@SerialName("password") | ||
val password: String, | ||
@SerialName("hobby") | ||
val hobby: String | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.sopt.and.model.dto.signup | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ResponseCreateUserFailDto( | ||
@SerialName("failed") | ||
val code: FailureResult | ||
) | ||
|
||
@Serializable | ||
data class FailureResult( | ||
@SerialName("code") | ||
val no: Int | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.sopt.and.model.dto.signup | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ResponseCreateUserSuccessDto( | ||
@SerialName("success") | ||
val result: UserResult | ||
) | ||
|
||
@Serializable | ||
data class UserResult( | ||
@SerialName("no") | ||
val no: Int | ||
) |
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. DTO์์ฑ์ด ๋งค์ฐ ์์ธํ๋ค์๐ ๋ํผํด๋์ค๋ฅผ ๋ฃ์ ์ด์ ๊ฐ ์๋์? ๊ถ๊ธํด์!!! 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. ์๋ฒ ์์ฒญ์ด ์ฑ๊ณตํ ๊ฒฝ์ฐ์ ์คํจํ ๊ฒฝ์ฐ์ ์ฌ์ฉํ๋ DTO๊ฐ ๋ถ๋ฆฌ๋์ด ์๋๋ฐ, ์๋ต ํ์ ์ ๋ ํ๋์ฌ์ผ ํ๋.. ๋ถ๊ธฐ ์ฒ๋ฆฌ๋ฅผ ํ๋ ๊ฒ๋ณด๋จ WrapperDTO ์์ failedDTO๋ successDTO๋ฅผ ํจ๊ป ๋ฃ์ด๋๊ณ ๋ WrapperDTO๋ฅผ ๋ฐํํ๋ ๋ฐฉ์์ด ๋ง๋ค๊ณ ์๊ฐํ์ด์! ๊ทธ๋ฐ๋ฐ ํฉ์ธ ๋ ์ฌ๋ฏผ๋๊ป ๊ผญ ๊ทธ๋ ๊ฒ ํ์ง ์์๋ ๋๋ค๋ ๋ง์์ ๋ค์ด์ (๊ทธ๋ฆฌ๊ณ ์ด๊ฒ ์ง๊ธ ์๋ฌ์ ์์ธ ๊ฐ์์ ๐ ๋ฐฉ์์ ์์ ํด๋ณผ ์์ ์ ๋๋น) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.sopt.and.model.dto.signup | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ResponseCreateUserWrapperDto( //ํน์ ์ ์ ํ ๋ช ์ ์๋ต DTO | ||
@SerialName("success") | ||
val success: ResponseCreateUserSuccessDto, | ||
@SerialName("failed") | ||
val failed: ResponseCreateUserFailDto | ||
) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.sopt.and.model.network | ||
|
||
import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory | ||
import kotlinx.serialization.json.Json | ||
import okhttp3.MediaType.Companion.toMediaType | ||
import okhttp3.OkHttpClient | ||
import okhttp3.logging.HttpLoggingInterceptor | ||
import org.sopt.and.BuildConfig | ||
import retrofit2.Retrofit | ||
|
||
object ApiFactory { | ||
private const val BASE_URL: String = BuildConfig.BASE_URL | ||
|
||
private val loggingInterceptor = HttpLoggingInterceptor().apply { | ||
level = HttpLoggingInterceptor.Level.BODY | ||
} | ||
|
||
private val client = OkHttpClient.Builder() | ||
.addInterceptor(loggingInterceptor) | ||
.build() | ||
|
||
val retrofit: Retrofit by lazy { | ||
Retrofit.Builder() | ||
.baseUrl(BASE_URL) | ||
.client(client) | ||
.addConverterFactory(Json.asConverterFactory("application/json".toMediaType())) | ||
.build() | ||
} | ||
|
||
inline fun <reified T> create(): T = retrofit.create(T::class.java) | ||
} | ||
|
||
//์ด userService๋ฅผ, ์๋ฒ๋ฅผ ๋ถ์ด๋ ๋ถ๋ถ์์ ์ฌ์ฉํด์ผ ํจ. | ||
//Viewmodel์์ ์ด userService์ ์ ๊ทผํ๋ฉด ๋จ. | ||
object ServicePool { | ||
val userService = ApiFactory.create<UserService>() | ||
} |
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.
์ด๊ฑฐ ์ด๋ฐ ์์ผ๋ก ๋ง๋ค์ด๋ ํต์ ์ ์ด๋ฃจ์ด ์ง๋์?
์ฑ๊ณต์ ๊ฒฝ์ฐ์๋ success์ ๋ํ ๊ฒ๋ง ์คํจ์ ๊ฒฝ์ฐ์๋ failed ๋ง ๋ด๋ ค๋ณด๋ด์ฃผ์ด ์ง๋ ฌํ๊ฐ ์ ์ ๋ ๊ฒ ๊ฐ์๋ฐ ์ ๋์ํ๋์?