-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[#45] 닉네임 중복체크 API
- Loading branch information
Showing
17 changed files
with
307 additions
and
26 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
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
13 changes: 13 additions & 0 deletions
13
app/src/main/java/com/android/example/travalue/GlobalApplication.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.android.example.travalue | ||
|
||
import android.app.Application | ||
import com.kakao.sdk.common.KakaoSdk | ||
|
||
class GlobalApplication : Application() { | ||
override fun onCreate() { | ||
super.onCreate() | ||
// 다른 초기화 코드들 | ||
|
||
KakaoSdk.init(this, getString(R.string.native_key)) | ||
} | ||
} |
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
app/src/main/java/com/android/example/travalue/api/LoginService.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.android.example.travalue.api | ||
|
||
import com.android.example.travalue.model.LoginRequestModel | ||
import com.android.example.travalue.model.LoginResponseModel | ||
import retrofit2.Call | ||
import retrofit2.http.Body | ||
import retrofit2.http.GET | ||
import retrofit2.http.POST | ||
|
||
interface LoginService { | ||
|
||
@POST("/v1/auth/login") | ||
fun loginRequest(@Body loginRequestData: LoginRequestModel): Call<LoginResponseModel> | ||
|
||
} |
63 changes: 63 additions & 0 deletions
63
app/src/main/java/com/android/example/travalue/apiManager/LoginApiManager.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,63 @@ | ||
package com.android.example.travalue.apiManager | ||
|
||
import android.content.Context | ||
import android.util.Log | ||
import com.android.example.travalue.api.LoginService | ||
import com.android.example.travalue.model.LoginRequestModel | ||
import com.android.example.travalue.model.LoginResponseModel | ||
import retrofit2.Call | ||
import retrofit2.Callback | ||
import retrofit2.Response | ||
import retrofit2.Retrofit | ||
import retrofit2.converter.gson.GsonConverterFactory | ||
import retrofit2.http.Body | ||
|
||
class LoginApiManager { | ||
private var retrofit: Retrofit? = null | ||
private var retrofitService: LoginService? = null | ||
|
||
companion object { // DCL 적용한 싱글톤 구현 | ||
var instance: LoginApiManager? = null | ||
fun getInstance(context: Context?): LoginApiManager? { | ||
if (instance == null) { | ||
@Synchronized | ||
if (instance == null) | ||
instance = LoginApiManager() | ||
} | ||
return instance | ||
} | ||
} | ||
|
||
init { | ||
retrofit = Retrofit.Builder() | ||
.baseUrl("http://13.125.137.16:8080") | ||
.addConverterFactory(GsonConverterFactory.create()) | ||
.build() | ||
|
||
retrofitService = retrofit?.create(LoginService::class.java) | ||
} | ||
|
||
fun loginRequest(@Body loginRequestData: LoginRequestModel){ | ||
val resultData: Call<LoginResponseModel>? = retrofitService?.loginRequest(loginRequestData) | ||
resultData?.enqueue(object : Callback<LoginResponseModel> { | ||
override fun onResponse( | ||
call: Call<LoginResponseModel>, | ||
response: Response<LoginResponseModel> | ||
) { | ||
if (response.isSuccessful) { | ||
val result: LoginResponseModel = response.body()!! | ||
Log.d("[loignRequest]", "서버응답 : $result") | ||
} else { | ||
Log.d("[loignRequest]", "실패코드_${response.code()}") | ||
} | ||
} | ||
|
||
override fun onFailure(call: Call<LoginResponseModel>, t: Throwable) { | ||
t.printStackTrace() | ||
Log.d("[loignRequest]","통신 실패") | ||
} | ||
}) | ||
} | ||
|
||
|
||
} |
8 changes: 8 additions & 0 deletions
8
app/src/main/java/com/android/example/travalue/model/LoginRequestModel.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.android.example.travalue.model | ||
|
||
data class LoginRequestModel( | ||
val uniqueId: Long?, | ||
val email:String?, | ||
val profileImage:String?, | ||
val socialType:String | ||
) |
6 changes: 6 additions & 0 deletions
6
app/src/main/java/com/android/example/travalue/model/LoginResponseModel.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,6 @@ | ||
package com.android.example.travalue.model | ||
|
||
data class LoginResponseModel( | ||
val token:String, | ||
val userId:Long | ||
) |
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
File renamed without changes.
Binary file not shown.
Binary file not shown.
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,10 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="13dp" | ||
android:height="12dp" | ||
android:viewportWidth="13" | ||
android:viewportHeight="12"> | ||
<path | ||
android:pathData="M6.5,0C3.098,0 0,2.223 0,4.966C0,6.671 1.125,8.175 2.839,9.069L2.118,11.674C2.054,11.905 2.321,12.088 2.525,11.955L5.686,9.892C5.953,9.917 6.224,9.932 6.5,9.932C10.09,9.932 13,7.708 13,4.966C13,2.223 10.09,0 6.5,0Z" | ||
android:fillColor="#000000" | ||
android:fillType="evenOdd"/> | ||
</vector> |
Oops, something went wrong.