Skip to content
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

๐Ÿ”€ :: (#156) write the logic sign up #157

Merged
merged 22 commits into from
Feb 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
60eaa09
:fire: :: Remove modifier clickable
diejdkll Feb 3, 2024
c50dd48
:sparkles: :: Add dotoriClickable
diejdkll Feb 3, 2024
c8809b7
:lipstick: :: Modify gender text
diejdkll Feb 3, 2024
c406129
:sparkles: :: Add send email dto and model
diejdkll Feb 3, 2024
287c6b1
:sparkles: :: Add email verify dto and model
diejdkll Feb 3, 2024
64a7bf6
:sparkles: :: Add sign up dto and model
diejdkll Feb 3, 2024
e5f52fe
:sparkles: :: Add send email and email verify to EmailDataSource
diejdkll Feb 3, 2024
70afc57
:sparkles: :: Add send email and email verify to EmailRepository
diejdkll Feb 3, 2024
62a9a21
:sparkles: :: Add sign up to AuthDataSource
diejdkll Feb 3, 2024
b5c2337
:sparkles: :: Add sign up to AuthRepository
diejdkll Feb 3, 2024
964ae13
:sparkles: :: Add SendEmailUseCase
diejdkll Feb 3, 2024
c3c490e
:sparkles: :: Add EmailVerifyUseCase
diejdkll Feb 3, 2024
6eb139a
:sparkles: :: Add gender dto and model
diejdkll Feb 3, 2024
2a397a1
:sparkles: :: Add send email and verify email to EmailApi
diejdkll Feb 3, 2024
851154f
:sparkles: :: Add sign up to AuthApi
diejdkll Feb 3, 2024
a6d333b
:sparkles: :: Add SignUpUseCase
diejdkll Feb 3, 2024
ab36997
:sparkles: :: Add email to module
diejdkll Feb 3, 2024
5e95080
:sparkles: :: Add email to AuthInterceptor
diejdkll Feb 3, 2024
9a66dd8
:sparkles: :: Add SignUpViewModel
diejdkll Feb 3, 2024
0e78772
:sparkles: :: Add toGenderText function
diejdkll Feb 3, 2024
32f1e43
:sparkles: :: Add SignUpViewModelProvider
diejdkll Feb 3, 2024
870136e
:sparkles: :: Write the logic sign up
diejdkll Feb 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/src/main/java/com/msg/dotori/DotoriNavHost.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.msg.dotori

import androidx.compose.runtime.Composable
import androidx.lifecycle.viewmodel.compose.LocalViewModelStoreOwner
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import com.msg.presentation.view.find_password.navigation.findPasswordScreen
Expand Down Expand Up @@ -30,6 +31,8 @@ fun DotoriNavHost(
navController: NavHostController,
startDestination: String
) {
val viewModelStoreOwner = checkNotNull(LocalViewModelStoreOwner.current)

NavHost(
navController = navController,
startDestination = startDestination
Expand All @@ -39,16 +42,19 @@ fun DotoriNavHost(
navigateToSignUp = { navController.navigateToSignUp() }
)
signUpScreen(
viewModelStoreOwner = viewModelStoreOwner,
navigateToBack = { navController.popBackStack() },
navigateToLogin = { navController.navigateToLogin() },
navigateToAuthentication = { navController.navigateToAuthentication() }
)
authenticationScreen(
viewModelStoreOwner = viewModelStoreOwner,
navigateToBack = { navController.popBackStack() },
navigateToLogin = { navController.navigateToLogin() },
navigateToPassword = { navController.navigateToPassword() }
)
passwordScreen(
viewModelStoreOwner = viewModelStoreOwner,
navigateToBack = { navController.popBackStack() },
navigateToLogin = { navController.navigateToLogin() }
)
Expand Down
8 changes: 7 additions & 1 deletion app/src/main/java/com/msg/dotori/module/NetworkModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.msg.dotori.module
import android.util.Log
import com.msg.dotori.BuildConfig
import com.msg.data.remote.network.AuthApi
import com.msg.data.remote.network.EmailApi
import com.msg.data.remote.network.MassageApi
import com.msg.data.remote.network.MusicApi
import com.msg.data.remote.network.NoticeApi
Expand All @@ -18,6 +19,7 @@ import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import retrofit2.create
import java.util.concurrent.TimeUnit
import javax.inject.Singleton

Expand Down Expand Up @@ -53,7 +55,7 @@ object NetworkModule {
gsonConverterFactory: GsonConverterFactory
): Retrofit {
return Retrofit.Builder()
.baseUrl(BuildConfig.RELEASE_URL)
.baseUrl(BuildConfig.DEVELOP_URL)
.client(okHttpClient)
.addConverterFactory(gsonConverterFactory)
.build()
Expand Down Expand Up @@ -92,4 +94,8 @@ object NetworkModule {
@Provides
@Singleton
fun provideRuleViolationApi(retrofit: Retrofit): RuleViolationApi = retrofit.create(RuleViolationApi::class.java)

@Provides
@Singleton
fun provideEmailApi(retrofit: Retrofit): EmailApi = retrofit.create(EmailApi::class.java)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package com.msg.dotori.module

import com.msg.data.remote.datasource.auth.AuthDataSourceImpl
import com.msg.data.remote.datasource.auth.AuthDataSource
import com.msg.data.remote.datasource.email.EmailDataSource
import com.msg.data.remote.datasource.email.EmailDataSourceImpl
import com.msg.data.remote.datasource.massage.MassageDataSource
import com.msg.data.remote.datasource.massage.MassageDataSourceImpl
import com.msg.data.remote.datasource.music.MusicDataSource
Expand Down Expand Up @@ -42,4 +44,7 @@ interface RemoteDataSourceModule {

@Binds
fun bindsRuleViolationDataSource(ruleViolationDataSourceImpl: RuleViolationDataSourceImpl): RuleViolationDataSource

@Binds
fun bindsEmailDataSource(emailDataSourceImpl: EmailDataSourceImpl): EmailDataSource
}
5 changes: 5 additions & 0 deletions app/src/main/java/com/msg/dotori/module/RepositoryModule.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package com.msg.dotori.module

import com.msg.data.repository.AuthRepositoryImpl
import com.msg.data.repository.EmailRepositoryImpl
import com.msg.data.repository.MassageRepositoryImpl
import com.msg.data.repository.MusicRepositoryImpl
import com.msg.data.repository.NoticeRepositoryImpl
import com.msg.data.repository.RuleViolationRepositoryImpl
import com.msg.data.repository.SelfStudyRepositoryImpl
import com.msg.data.repository.StudentInfoRepositoryImpl
import com.msg.domain.repository.AuthRepository
import com.msg.domain.repository.EmailRepository
import com.msg.domain.repository.MassageRepository
import com.msg.domain.repository.MusicRepository
import com.msg.domain.repository.NoticeRepository
Expand Down Expand Up @@ -42,4 +44,7 @@ interface RepositoryModule {

@Binds
fun bindsRuleViolationRepository(ruleViolationRepositoryImpl: RuleViolationRepositoryImpl): RuleViolationRepository

@Binds
fun bindsEmailRepository(emailRepositoryImpl: EmailRepositoryImpl): EmailRepository
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ package com.msg.data.remote.datasource.auth

import com.msg.data.remote.dto.auth.LoginRequest
import com.msg.data.remote.dto.auth.LoginResponse
import com.msg.data.remote.dto.auth.SignUpRequest

interface AuthDataSource {
suspend fun login(loginRequest: LoginRequest): LoginResponse

suspend fun tokenReissue(): LoginResponse

suspend fun signUp(body: SignUpRequest)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,23 @@ package com.msg.data.remote.datasource.auth

import com.msg.data.remote.dto.auth.LoginRequest
import com.msg.data.remote.dto.auth.LoginResponse
import com.msg.data.remote.dto.auth.SignUpRequest
import com.msg.data.remote.network.AuthApi
import com.msg.data.remote.util.safeApiCall
import javax.inject.Inject

class AuthDataSourceImpl @Inject constructor(
private val authApi: AuthApi
): AuthDataSource {
override suspend fun login(loginRequest: LoginRequest): LoginResponse = safeApiCall { authApi.login(loginRequest) }
override suspend fun login(loginRequest: LoginRequest): LoginResponse = safeApiCall {
authApi.login(loginRequest)
}

override suspend fun tokenReissue(): LoginResponse = safeApiCall { authApi.tokenReissue() }
override suspend fun tokenReissue(): LoginResponse = safeApiCall {
authApi.tokenReissue()
}

override suspend fun signUp(body: SignUpRequest) = safeApiCall {
authApi.signUp(body)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.msg.data.remote.datasource.email

import com.msg.data.remote.dto.email.EmailVerifyRequest
import com.msg.data.remote.dto.email.SendEmailRequest

interface EmailDataSource {
suspend fun sendEmail(body: SendEmailRequest)

suspend fun emailVerify(body: EmailVerifyRequest)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.msg.data.remote.datasource.email

import com.msg.data.remote.dto.email.EmailVerifyRequest
import com.msg.data.remote.dto.email.SendEmailRequest
import com.msg.data.remote.network.EmailApi
import com.msg.data.remote.util.safeApiCall
import javax.inject.Inject

class EmailDataSourceImpl @Inject constructor(
private val emailApi: EmailApi
): EmailDataSource {
override suspend fun sendEmail(body: SendEmailRequest) = safeApiCall {
emailApi.sendEmail(body)
}

override suspend fun emailVerify(body: EmailVerifyRequest) = safeApiCall {
emailApi.emailVerify(body)
}
}
13 changes: 13 additions & 0 deletions data/src/main/java/com/msg/data/remote/dto/auth/Gender.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.msg.data.remote.dto.auth

import com.msg.domain.model.auth.GenderModel

enum class Gender {
MAN,
WOMAN
}

fun GenderModel.asRole() = when (this) {
GenderModel.MAN -> Gender.MAN
GenderModel.WOMAN -> Gender.WOMAN
}
19 changes: 19 additions & 0 deletions data/src/main/java/com/msg/data/remote/dto/auth/SignUpRequest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.msg.data.remote.dto.auth

import com.msg.domain.model.auth.SignUpRequestModel

data class SignUpRequest(
val memberName: String,
val stuNum: String,
val password: String,
val email: String,
val gender: Gender
)

fun SignUpRequestModel.asSignUpRequest() = SignUpRequest(
memberName = memberName,
stuNum = stuNum,
password = password,
email = email,
gender = gender.asRole()
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.msg.data.remote.dto.email

import com.msg.domain.model.email.EmailVerifyRequestModel

data class EmailVerifyRequest(
val key: String
)

fun EmailVerifyRequestModel.asEmailVerifyRequest() = EmailVerifyRequest(
key = key
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.msg.data.remote.dto.email

import com.msg.domain.model.email.SendEmailRequestModel

data class SendEmailRequest(
val email: String
)

fun SendEmailRequestModel.asSendEmailRequest() = SendEmailRequest(
email = email
)
6 changes: 6 additions & 0 deletions data/src/main/java/com/msg/data/remote/network/AuthApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.msg.data.remote.network

import com.msg.data.remote.dto.auth.LoginRequest
import com.msg.data.remote.dto.auth.LoginResponse
import com.msg.data.remote.dto.auth.SignUpRequest
import retrofit2.http.Body
import retrofit2.http.PATCH
import retrofit2.http.POST
Expand All @@ -14,4 +15,9 @@ interface AuthApi {

@PATCH("auth")
suspend fun tokenReissue(): LoginResponse

@POST("auth/signup")
suspend fun signUp(
@Body body: SignUpRequest
)
}
18 changes: 18 additions & 0 deletions data/src/main/java/com/msg/data/remote/network/EmailApi.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.msg.data.remote.network

import com.msg.data.remote.dto.email.EmailVerifyRequest
import com.msg.data.remote.dto.email.SendEmailRequest
import retrofit2.http.Body
import retrofit2.http.POST

interface EmailApi {
@POST("email/signup")
suspend fun sendEmail(
@Body body: SendEmailRequest
)

@POST("email/verify-email")
suspend fun emailVerify(
@Body body: EmailVerifyRequest
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class AuthInterceptor @Inject constructor(
val builder = request.newBuilder()
val path = request.url.encodedPath
val ignorePath = listOf("/auth")
val ignorePath2 = listOf("/email")
val currentTime = LocalDateTime.now()

ignorePath.forEach {
Expand All @@ -34,6 +35,12 @@ class AuthInterceptor @Inject constructor(
}
}

ignorePath2.forEach {
if (path.contains(it)) {
return chain.proceed(request)
}
}

val refreshToken = runBlocking { localDataSource.getRefreshToken().first() }
val accessTokenExp = runBlocking { LocalDateTime.parse(localDataSource.getExpiresAt().first()) }
val refreshTokenExp = accessTokenExp.plusMonths(6)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import com.msg.data.local.datasource.LocalDataSource
import com.msg.data.remote.datasource.auth.AuthDataSource
import com.msg.data.remote.dto.auth.asLoginRequest
import com.msg.data.remote.dto.auth.asLoginResponseModel
import com.msg.data.remote.dto.auth.asSignUpRequest
import com.msg.domain.model.auth.LoginRequestModel
import com.msg.domain.model.auth.LoginResponseModel
import com.msg.domain.model.auth.SignUpRequestModel
import com.msg.domain.repository.AuthRepository
import kotlinx.coroutines.flow.first
import javax.inject.Inject
Expand All @@ -17,6 +19,7 @@ class AuthRepositoryImpl @Inject constructor(
override suspend fun login(loginRequest: LoginRequestModel): LoginResponseModel = authDataSource.login(loginRequest.asLoginRequest()).asLoginResponseModel()

override suspend fun tokenReissue(): LoginResponseModel = authDataSource.tokenReissue().asLoginResponseModel()

override suspend fun saveToken(
accessToken: String,
refreshToken: String,
Expand All @@ -30,4 +33,6 @@ class AuthRepositoryImpl @Inject constructor(
override suspend fun saveRole(roles: String) = localDataSource.saveRole(roles)

override suspend fun getRole(): String = localDataSource.getRole().first()

override suspend fun signUp(body: SignUpRequestModel) = authDataSource.signUp(body.asSignUpRequest())
}
17 changes: 17 additions & 0 deletions data/src/main/java/com/msg/data/repository/EmailRepositoryImpl.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.msg.data.repository

import com.msg.data.remote.datasource.email.EmailDataSource
import com.msg.data.remote.dto.email.asEmailVerifyRequest
import com.msg.data.remote.dto.email.asSendEmailRequest
import com.msg.domain.model.email.EmailVerifyRequestModel
import com.msg.domain.model.email.SendEmailRequestModel
import com.msg.domain.repository.EmailRepository
import javax.inject.Inject

class EmailRepositoryImpl @Inject constructor(
private val emailDataSource: EmailDataSource
): EmailRepository {
override suspend fun sendEmail(body: SendEmailRequestModel) = emailDataSource.sendEmail(body.asSendEmailRequest())

override suspend fun emailVerify(body: EmailVerifyRequestModel) = emailDataSource.emailVerify(body.asEmailVerifyRequest())
}
6 changes: 6 additions & 0 deletions domain/src/main/java/com/msg/domain/model/auth/GenderModel.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.msg.domain.model.auth

enum class GenderModel {
MAN,
WOMAN
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.msg.domain.model.auth

data class SignUpRequestModel(
val memberName: String,
val stuNum: String,
val password: String,
val email: String,
val gender: GenderModel
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.msg.domain.model.email

data class EmailVerifyRequestModel(
val key: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.msg.domain.model.email

data class SendEmailRequestModel(
val email: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.msg.domain.repository

import com.msg.domain.model.auth.LoginRequestModel
import com.msg.domain.model.auth.LoginResponseModel
import com.msg.domain.model.auth.SignUpRequestModel

interface AuthRepository {
suspend fun login(loginRequest: LoginRequestModel): LoginResponseModel
Expand All @@ -17,4 +18,6 @@ interface AuthRepository {
suspend fun saveRole(roles: String)

suspend fun getRole(): String

suspend fun signUp(body: SignUpRequestModel)
}
Loading
Loading