Skip to content

Commit

Permalink
Merge pull request #25 from EarthGardener/feature/24_login_mypage_ref…
Browse files Browse the repository at this point in the history
…actor

Feature/24 login mypage refactor
  • Loading branch information
OliviaYJH authored Feb 12, 2022
2 parents c258f11 + 5d1d0be commit 1ad4800
Show file tree
Hide file tree
Showing 51 changed files with 380 additions and 163 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@ package team.gdsc.earthgardener.data.api
import okhttp3.MultipartBody
import okhttp3.RequestBody
import retrofit2.http.*
import team.gdsc.earthgardener.data.model.response.ResCheckEmailSuccessData
import team.gdsc.earthgardener.data.model.response.ResCheckNicknameSuccessData
import team.gdsc.earthgardener.data.model.response.ResSignUpSuccessData
import team.gdsc.earthgardener.data.model.request.signin.ReqSignInSuccessData
import team.gdsc.earthgardener.data.model.response.signup.ResCheckEmailSuccessData
import team.gdsc.earthgardener.data.model.response.signup.ResCheckNicknameSuccessData
import team.gdsc.earthgardener.data.model.response.signin.ResSignInSuccessData
import team.gdsc.earthgardener.data.model.response.signup.ResSignUpSuccessData

interface LoginService {
// Get Email Code
@GET("user/signup/email")
suspend fun getEmail(
@Query("email") email: String
):ResCheckEmailSuccessData
): ResCheckEmailSuccessData

// Get NickName
@GET("user/signup/nickname")
Expand All @@ -29,4 +31,8 @@ interface LoginService {
): ResSignUpSuccessData

// Post SignIn
@POST("user/signin")
suspend fun postSignIn(
@Body data: ReqSignInSuccessData
): ResSignInSuccessData
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package team.gdsc.earthgardener.data.api

import retrofit2.http.GET
import team.gdsc.earthgardener.data.model.response.profile.ResProfileSuccessData

interface ProfileService {
@GET("user/profile")
suspend fun getProfile() : ResProfileSuccessData
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package team.gdsc.earthgardener.data.datasource.profile

import team.gdsc.earthgardener.data.model.response.profile.ResProfileSuccessData

interface ProfileDataSource {
suspend fun getProfile(): ResProfileSuccessData
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package team.gdsc.earthgardener.data.datasource.profile

import team.gdsc.earthgardener.data.api.ProfileService
import team.gdsc.earthgardener.data.model.response.profile.ResProfileSuccessData

class ProfileRemoteDataSource(private val profileService: ProfileService)
:ProfileDataSource{
override suspend fun getProfile(): ResProfileSuccessData {
return profileService.getProfile()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package team.gdsc.earthgardener.data.datasource.signin

import team.gdsc.earthgardener.data.model.request.signin.ReqSignInSuccessData
import team.gdsc.earthgardener.data.model.response.signin.ResSignInSuccessData

interface SignInDataSource {
suspend fun postSignIn(data: ReqSignInSuccessData): ResSignInSuccessData
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package team.gdsc.earthgardener.data.datasource.signin

import team.gdsc.earthgardener.data.api.LoginService
import team.gdsc.earthgardener.data.model.request.signin.ReqSignInSuccessData
import team.gdsc.earthgardener.data.model.response.signin.ResSignInSuccessData

class SignInRemoteDataSource(private val loginService: LoginService)
: SignInDataSource{
override suspend fun postSignIn(data: ReqSignInSuccessData): ResSignInSuccessData {
return loginService.postSignIn(data)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package team.gdsc.earthgardener.data.datasource.signup

import okhttp3.MultipartBody
import okhttp3.RequestBody
import team.gdsc.earthgardener.data.model.response.ResSignUpSuccessData
import team.gdsc.earthgardener.data.model.response.signup.ResSignUpSuccessData

interface SignUpDataSource {
suspend fun postSignUp(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package team.gdsc.earthgardener.data.datasource.signup
import okhttp3.MultipartBody
import okhttp3.RequestBody
import team.gdsc.earthgardener.data.api.LoginService
import team.gdsc.earthgardener.data.model.response.ResSignUpSuccessData
import team.gdsc.earthgardener.data.model.response.signup.ResSignUpSuccessData

class SignUpRemoteDataSource(private val loginService: LoginService)
:SignUpDataSource{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package team.gdsc.earthgardener.data.datasource.signup.email

import team.gdsc.earthgardener.data.model.response.signup.ResCheckEmailSuccessData

interface CheckEmailDataSource {
suspend fun getCheckEmail(email: String): ResCheckEmailSuccessData
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package team.gdsc.earthgardener.data.datasource.email
package team.gdsc.earthgardener.data.datasource.signup.email

import team.gdsc.earthgardener.data.api.LoginService
import team.gdsc.earthgardener.data.model.response.ResCheckEmailSuccessData
import team.gdsc.earthgardener.data.model.response.signup.ResCheckEmailSuccessData

class CheckEmailRemoteDataSource (private val loginService: LoginService) : CheckEmailDataSource {
class CheckEmailRemoteDataSource (private val loginService: LoginService)
: CheckEmailDataSource {
override suspend fun getCheckEmail(email: String): ResCheckEmailSuccessData {
return loginService.getEmail(email)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package team.gdsc.earthgardener.data.datasource.signup.nickname

import team.gdsc.earthgardener.data.model.response.signup.ResCheckNicknameSuccessData

interface CheckNicknameDataSource {
suspend fun getCheckNickname(nickname: String): ResCheckNicknameSuccessData
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package team.gdsc.earthgardener.data.datasource.nickname
package team.gdsc.earthgardener.data.datasource.signup.nickname

import team.gdsc.earthgardener.data.api.LoginService
import team.gdsc.earthgardener.data.model.response.ResCheckNicknameSuccessData
import team.gdsc.earthgardener.data.model.response.signup.ResCheckNicknameSuccessData

class CheckNicknameRemoteDataSource(private val loginService: LoginService): CheckNicknameDataSource {
override suspend fun getCheckNickname(nickname: String): ResCheckNicknameSuccessData {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package team.gdsc.earthgardener.data.mapper.profile

import team.gdsc.earthgardener.data.model.response.profile.ResProfileSuccessData
import team.gdsc.earthgardener.domain.profile.ProfileData

object ProfileMapper {
fun mapperProfileSuccessData(resProfileSuccessData: ResProfileSuccessData)
: ProfileData {
return ProfileData(
message = resProfileSuccessData.message,
status = resProfileSuccessData.status,
data = ProfileData.ProfileInfo(
resProfileSuccessData.data.email,
resProfileSuccessData.data.nickname,
resProfileSuccessData.data.image_url
)
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package team.gdsc.earthgardener.data.mapper.signin

import team.gdsc.earthgardener.data.model.response.signin.ResSignInSuccessData
import team.gdsc.earthgardener.domain.signin.SigninSuccessData

object SignInMapper {

fun mapperSignInSuccessData(resSignInSuccessData: ResSignInSuccessData)
: SigninSuccessData {
return SigninSuccessData(
message = resSignInSuccessData.message,
status = resSignInSuccessData.status,
token = resSignInSuccessData.token
)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package team.gdsc.earthgardener.data.mapper
package team.gdsc.earthgardener.data.mapper.signup

import team.gdsc.earthgardener.data.model.response.ResCheckEmailSuccessData
import team.gdsc.earthgardener.data.model.response.signup.ResCheckEmailSuccessData
import team.gdsc.earthgardener.domain.email.CheckEmailData

object CheckEmailMapper {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package team.gdsc.earthgardener.data.mapper
package team.gdsc.earthgardener.data.mapper.signup

import team.gdsc.earthgardener.data.model.response.ResCheckNicknameSuccessData
import team.gdsc.earthgardener.data.model.response.signup.ResCheckNicknameSuccessData
import team.gdsc.earthgardener.domain.nickname.CheckNicknameData

object CheckNicknameMapper {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package team.gdsc.earthgardener.data.mapper
package team.gdsc.earthgardener.data.mapper.signup

import team.gdsc.earthgardener.data.model.response.ResSignUpSuccessData
import team.gdsc.earthgardener.data.model.response.signup.ResSignUpSuccessData
import team.gdsc.earthgardener.domain.signup.SignUpData

object SignUpMapper {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package team.gdsc.earthgardener.data.model.request.signin

import com.google.gson.annotations.SerializedName

data class ReqSignInSuccessData(
@SerializedName("email")
val email: String,

@SerializedName("pw")
val pw: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package team.gdsc.earthgardener.data.model.response.profile

import com.google.gson.annotations.SerializedName

data class ResProfileSuccessData(
@SerializedName("message")
val message: String,

@SerializedName("data")
val data: Profile,

@SerializedName("status")
val status: Int
){
data class Profile(
@SerializedName("email")
val email: String,

@SerializedName("nickname")
val nickname: String,

@SerializedName("image_url")
val image_url: String
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package team.gdsc.earthgardener.data.model.response.signin

data class ResSignInSuccessData(
val message: String,
val status: Int,
val token: String
)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package team.gdsc.earthgardener.data.model.response
package team.gdsc.earthgardener.data.model.response.signup

import com.google.gson.annotations.SerializedName

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package team.gdsc.earthgardener.data.model.response
package team.gdsc.earthgardener.data.model.response.signup

import com.google.gson.annotations.SerializedName

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package team.gdsc.earthgardener.data.model.response
package team.gdsc.earthgardener.data.model.response.signup

import com.google.gson.annotations.SerializedName

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package team.gdsc.earthgardener.data.repository.profile

import team.gdsc.earthgardener.data.datasource.profile.ProfileDataSource
import team.gdsc.earthgardener.data.mapper.profile.ProfileMapper
import team.gdsc.earthgardener.domain.profile.ProfileData
import team.gdsc.earthgardener.domain.profile.ProfileRepository

class ProfileRepositoryImpl(private val profileDataSource: ProfileDataSource)
: ProfileRepository {
override suspend fun getProfileResult(): ProfileData {
return ProfileMapper.mapperProfileSuccessData(profileDataSource.getProfile())
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package team.gdsc.earthgardener.data.repository.signin

import team.gdsc.earthgardener.data.datasource.signin.SignInDataSource
import team.gdsc.earthgardener.data.mapper.signin.SignInMapper
import team.gdsc.earthgardener.data.model.request.signin.ReqSignInSuccessData
import team.gdsc.earthgardener.domain.signin.SignInRepository
import team.gdsc.earthgardener.domain.signin.SigninSuccessData

class SignInRepositoryImpl(private val signInDataSource: SignInDataSource)
:SignInRepository{
override suspend fun postSignInResult(data: ReqSignInSuccessData): SigninSuccessData {
return SignInMapper.mapperSignInSuccessData(signInDataSource.postSignIn(data))
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package team.gdsc.earthgardener.data.repository
package team.gdsc.earthgardener.data.repository.signup

import team.gdsc.earthgardener.data.datasource.email.CheckEmailDataSource
import team.gdsc.earthgardener.data.mapper.CheckEmailMapper
import team.gdsc.earthgardener.data.datasource.signup.email.CheckEmailDataSource
import team.gdsc.earthgardener.data.mapper.signup.CheckEmailMapper
import team.gdsc.earthgardener.domain.email.CheckEmailData
import team.gdsc.earthgardener.domain.email.CheckEmailRepository

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package team.gdsc.earthgardener.data.repository
package team.gdsc.earthgardener.data.repository.signup

import team.gdsc.earthgardener.data.datasource.nickname.CheckNicknameDataSource
import team.gdsc.earthgardener.data.mapper.CheckNicknameMapper
import team.gdsc.earthgardener.data.datasource.signup.nickname.CheckNicknameDataSource
import team.gdsc.earthgardener.data.mapper.signup.CheckNicknameMapper
import team.gdsc.earthgardener.domain.nickname.CheckNicknameData
import team.gdsc.earthgardener.domain.nickname.CheckNicknameRepository

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package team.gdsc.earthgardener.data.repository
package team.gdsc.earthgardener.data.repository.signup

import okhttp3.MultipartBody
import okhttp3.RequestBody
import team.gdsc.earthgardener.data.datasource.signup.SignUpDataSource
import team.gdsc.earthgardener.data.mapper.SignUpMapper
import team.gdsc.earthgardener.data.mapper.signup.SignUpMapper
import team.gdsc.earthgardener.domain.signup.SignUpData
import team.gdsc.earthgardener.domain.signup.SignUpRepository

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
package team.gdsc.earthgardener.di

import org.koin.dsl.module
import team.gdsc.earthgardener.data.datasource.email.CheckEmailDataSource
import team.gdsc.earthgardener.data.datasource.email.CheckEmailRemoteDataSource
import team.gdsc.earthgardener.data.datasource.nickname.CheckNicknameDataSource
import team.gdsc.earthgardener.data.datasource.nickname.CheckNicknameRemoteDataSource
import team.gdsc.earthgardener.data.datasource.signup.email.CheckEmailDataSource
import team.gdsc.earthgardener.data.datasource.signup.email.CheckEmailRemoteDataSource
import team.gdsc.earthgardener.data.datasource.signup.nickname.CheckNicknameDataSource
import team.gdsc.earthgardener.data.datasource.signup.nickname.CheckNicknameRemoteDataSource
import team.gdsc.earthgardener.data.datasource.tree.TreeInfoDataSource
import team.gdsc.earthgardener.data.datasource.tree.TreeInfoRemoteDataSource
import team.gdsc.earthgardener.data.datasource.tree.TreeNameDataSource
import team.gdsc.earthgardener.data.datasource.tree.TreeNameRemoteDataSource
import team.gdsc.earthgardener.data.datasource.post.PostLocalDataSource
import team.gdsc.earthgardener.data.datasource.post.PostRemoteDataSource
import team.gdsc.earthgardener.data.datasource.post.PostDataSource
import team.gdsc.earthgardener.data.datasource.profile.ProfileDataSource
import team.gdsc.earthgardener.data.datasource.profile.ProfileRemoteDataSource
import team.gdsc.earthgardener.data.datasource.signin.SignInDataSource
import team.gdsc.earthgardener.data.datasource.signin.SignInRemoteDataSource

val dataSourceModule = module {
single<CheckEmailDataSource> { CheckEmailRemoteDataSource(get()) }
single<CheckNicknameDataSource> { CheckNicknameRemoteDataSource(get()) }
single<TreeInfoDataSource> { TreeInfoRemoteDataSource(get()) }
single<TreeNameDataSource> { TreeNameRemoteDataSource(get()) }
single<PostDataSource>{ PostRemoteDataSource(get()) }
single<SignInDataSource>{ SignInRemoteDataSource(get()) }
single<ProfileDataSource>{ ProfileRemoteDataSource(get())}
}
Loading

0 comments on commit 1ad4800

Please sign in to comment.