Skip to content

Commit

Permalink
Merge pull request #94 from Team-HMH/feat/social_login_api
Browse files Browse the repository at this point in the history
[feat/social login api]: ์†Œ์…œ ๋กœ๊ทธ์ธ ์ž‘์—…
  • Loading branch information
kangyuri1114 authored Jan 12, 2024
2 parents ac37bb9 + edf72f0 commit 80bf2b4
Show file tree
Hide file tree
Showing 54 changed files with 220 additions and 363 deletions.
2 changes: 2 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,12 @@ dependencies {
// Domain
implementation(projects.domain.usagestats)
implementation(projects.domain.userinfo)
implementation(projects.domain.login)

// Data
implementation(projects.data.usagestats)
implementation(projects.data.userinfo)
implementation(projects.data.login)

// Core
implementation(projects.core.common)
Expand Down
Empty file removed core/database/consumer-rules.pro
Empty file.
Empty file.
21 changes: 0 additions & 21 deletions core/designsystem/proguard-rules.pro

This file was deleted.

Empty file removed core/network/consumer-rules.pro
Empty file.
21 changes: 0 additions & 21 deletions core/network/proguard-rules.pro

This file was deleted.

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()
}
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>
}
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,
)
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
)
}
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 removed core/viewmodel/consumer-rules.pro
Empty file.
Empty file.
21 changes: 0 additions & 21 deletions core/viewmodel/main/proguard-rules.pro

This file was deleted.

21 changes: 0 additions & 21 deletions core/viewmodel/proguard-rules.pro

This file was deleted.

1 change: 1 addition & 0 deletions data/login/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
15 changes: 15 additions & 0 deletions data/login/build.gradle.kts
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)
}
4 changes: 4 additions & 0 deletions data/login/src/main/AndroidManifest.xml
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>
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()
}
}
}
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
}
}
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 removed data/onboarding/consumer-rules.pro
Empty file.
21 changes: 0 additions & 21 deletions data/onboarding/proguard-rules.pro

This file was deleted.

Empty file removed data/usagestats/consumer-rules.pro
Empty file.
21 changes: 0 additions & 21 deletions data/usagestats/proguard-rules.pro

This file was deleted.

Empty file removed data/userinfo/consumer-rules.pro
Empty file.
21 changes: 0 additions & 21 deletions data/userinfo/proguard-rules.pro

This file was deleted.

Empty file.
21 changes: 0 additions & 21 deletions domain/challenge/proguard-rules.pro

This file was deleted.

1 change: 1 addition & 0 deletions domain/login/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
9 changes: 9 additions & 0 deletions domain/login/build.gradle.kts
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.
4 changes: 4 additions & 0 deletions domain/login/src/main/AndroidManifest.xml
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>
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,
)
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.
Loading

0 comments on commit 80bf2b4

Please sign in to comment.