-
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.
Merge pull request #94 from Team-HMH/feat/social_login_api
[feat/social login api]: ์์ ๋ก๊ทธ์ธ ์์
- Loading branch information
Showing
54 changed files
with
220 additions
and
363 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
Empty file.
Empty file.
This file was deleted.
Oops, something went wrong.
Empty file.
This file was deleted.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
core/network/src/main/java/com/hmh/hamyeonham/core/network/di/LoginModule.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.hmh.hamyeonham.core.network.di | ||
|
||
import com.hmh.hamyeonham.common.qualifier.Unsecured | ||
import com.hmh.hamyeonham.core.network.login.LoginService | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import retrofit2.Retrofit | ||
import retrofit2.create | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
object LoginModule { | ||
@Provides | ||
@Singleton | ||
fun provideLoginApi(@Unsecured retrofit: Retrofit): LoginService = retrofit.create() | ||
} |
16 changes: 16 additions & 0 deletions
16
core/network/src/main/java/com/hmh/hamyeonham/core/network/login/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,16 @@ | ||
package com.hmh.hamyeonham.core.network.login | ||
|
||
import com.hmh.hamyeonham.core.network.login.model.LoginRequest | ||
import com.hmh.hamyeonham.core.network.login.model.LoginResponse | ||
import com.hmh.hamyeonham.core.network.model.BaseResponse | ||
import retrofit2.http.Body | ||
import retrofit2.http.Header | ||
import retrofit2.http.POST | ||
|
||
interface LoginService { | ||
@POST("api/v1/user/login") | ||
suspend fun login( | ||
@Header("Authorization") accessToken: String, | ||
@Body request: LoginRequest | ||
): BaseResponse<LoginResponse> | ||
} |
10 changes: 10 additions & 0 deletions
10
core/network/src/main/java/com/hmh/hamyeonham/core/network/login/model/LoginRequest.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,10 @@ | ||
package com.hmh.hamyeonham.core.network.login.model | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class LoginRequest( | ||
@SerialName("socialPlatform") | ||
val socialPlatform: String, | ||
) |
21 changes: 21 additions & 0 deletions
21
core/network/src/main/java/com/hmh/hamyeonham/core/network/login/model/LoginResponse.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,21 @@ | ||
package com.hmh.hamyeonham.core.network.login.model | ||
|
||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class LoginResponse( | ||
@SerialName("token") | ||
val token: Token? = null, | ||
@SerialName("userId") | ||
val userId: Int? = null | ||
) { | ||
@Serializable | ||
data class Token( | ||
@SerialName("accessToken") | ||
val accessToken: String? = null, | ||
@SerialName("refreshToken") | ||
val refreshToken: String? = null | ||
) | ||
} |
7 changes: 7 additions & 0 deletions
7
core/network/src/main/java/com/hmh/hamyeonham/core/network/model/BaseResponse.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 |
---|---|---|
@@ -1,7 +1,14 @@ | ||
package com.hmh.hamyeonham.core.network.model | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class BaseResponse<T>( | ||
@SerialName("status") | ||
val status: Int, | ||
@SerialName("message") | ||
val message: String, | ||
@SerialName("data") | ||
val data: T | ||
) |
Empty file.
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 @@ | ||
/build |
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 @@ | ||
@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed | ||
plugins { | ||
hmh("feature") | ||
} | ||
|
||
android { | ||
namespace = "com.hmh.hamyeonham.data.login" | ||
} | ||
|
||
dependencies { | ||
implementation(projects.core.network) | ||
implementation(projects.core.common) | ||
|
||
implementation(projects.domain.login) | ||
} |
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,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
</manifest> |
21 changes: 21 additions & 0 deletions
21
data/login/src/main/java/com/hmh/hamyeonham/login/DefaultLoginRepository.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,21 @@ | ||
package com.hmh.hamyeonham.login | ||
|
||
import com.hmh.hamyeonham.core.network.login.LoginService | ||
import com.hmh.hamyeonham.core.network.login.model.LoginRequest | ||
import com.hmh.hamyeonham.login.mapper.toLogin | ||
import com.hmh.hamyeonham.login.model.Login | ||
import com.hmh.hamyeonham.login.repository.LoginRepository | ||
import javax.inject.Inject | ||
|
||
class DefaultLoginRepository @Inject constructor( | ||
private val loginService: LoginService | ||
) : LoginRepository { | ||
|
||
override suspend fun login(accessToken: String): Result<Login> { | ||
val request = LoginRequest("KAKAO") | ||
val bearerToken = "Bearer $accessToken" | ||
return runCatching { | ||
loginService.login(bearerToken, request).data.toLogin() | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
data/login/src/main/java/com/hmh/hamyeonham/login/di/LoginModule.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,21 @@ | ||
package com.hmh.hamyeonham.login.di | ||
|
||
import com.hmh.hamyeonham.login.DefaultLoginRepository | ||
import com.hmh.hamyeonham.login.repository.LoginRepository | ||
import dagger.Binds | ||
import dagger.Module | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
object LoginModule { | ||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
interface Binder { | ||
@Binds | ||
@Singleton | ||
fun provideUsageGoalsRepository(loginRepository: DefaultLoginRepository): LoginRepository | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
data/login/src/main/java/com/hmh/hamyeonham/login/mapper/LoginMapper.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,14 @@ | ||
package com.hmh.hamyeonham.login.mapper | ||
|
||
import com.hmh.hamyeonham.core.network.login.model.LoginResponse | ||
import com.hmh.hamyeonham.login.model.Login | ||
|
||
internal fun LoginResponse.toLogin(): Login { | ||
return Login( | ||
userId = userId ?: -1, | ||
accessToken = token?.accessToken.orEmpty(), | ||
refreshToken = token?.refreshToken.orEmpty(), | ||
) | ||
} | ||
|
||
|
Empty file.
This file was deleted.
Oops, something went wrong.
Empty file.
This file was deleted.
Oops, something went wrong.
Empty file.
This file was deleted.
Oops, something went wrong.
Empty file.
This file was deleted.
Oops, something went wrong.
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 @@ | ||
/build |
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,9 @@ | ||
@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed | ||
plugins { | ||
`java-library` | ||
kotlin("jvm") | ||
} | ||
|
||
dependencies { | ||
implementation(libs.javax.inject) | ||
} |
File renamed without changes.
File renamed without changes.
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,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
</manifest> |
7 changes: 7 additions & 0 deletions
7
domain/login/src/main/java/com/hmh/hamyeonham/login/model/Login.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,7 @@ | ||
package com.hmh.hamyeonham.login.model | ||
|
||
data class Login( | ||
val userId: Int, | ||
val accessToken: String, | ||
val refreshToken: String, | ||
) |
7 changes: 7 additions & 0 deletions
7
domain/login/src/main/java/com/hmh/hamyeonham/login/repository/LoginRepository.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,7 @@ | ||
package com.hmh.hamyeonham.login.repository | ||
|
||
import com.hmh.hamyeonham.login.model.Login | ||
|
||
interface LoginRepository { | ||
suspend fun login(accessToken: String): Result<Login> | ||
} |
Empty file.
Oops, something went wrong.