generated from AND-SOPT-ANDROID/and-sopt-android-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
178 additions
and
61 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...opt/and/data/remote/model/TodayTopData.kt → ...a/org/sopt/and/data/local/TodayTopData.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
4 changes: 3 additions & 1 deletion
4
app/src/main/java/org/sopt/and/data/mapper/todata/UserLoginModelMapper.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,9 @@ | ||
package org.sopt.and.data.mapper.todata | ||
|
||
import org.sopt.and.data.remote.model.request.UserLoginRequestDto | ||
import org.sopt.and.domain.model.request.UserLoginModel | ||
|
||
fun UserLoginModel.toData() : UserLoginRequestDto = UserLoginRequestDto( | ||
|
||
username = this.username, | ||
password = this.password | ||
) |
5 changes: 4 additions & 1 deletion
5
app/src/main/java/org/sopt/and/data/mapper/todata/UserSignUpModelMapper.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,10 @@ | ||
package org.sopt.and.data.mapper.todata | ||
|
||
import org.sopt.and.data.remote.model.request.UserSignUpRequestDto | ||
import org.sopt.and.domain.model.request.UserSignUpModel | ||
|
||
fun UserSignUpModel.toData() : UserSignUpRequestDto = UserSignUpRequestDto( | ||
|
||
username = this.username, | ||
password = this.password, | ||
hobby = this.hobby | ||
) |
1 change: 1 addition & 0 deletions
1
app/src/main/java/org/sopt/and/data/mapper/todomain/UserHobbyResponseDtoMapper.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
8 changes: 8 additions & 0 deletions
8
app/src/main/java/org/sopt/and/data/mapper/todomain/UserSignUpResponseDtoMapper.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 org.sopt.and.data.mapper.todomain | ||
|
||
import org.sopt.and.data.remote.model.response.UserSignUpResponseDto | ||
import org.sopt.and.domain.model.response.UserNumber | ||
|
||
fun UserSignUpResponseDto.toDomain(): UserNumber = UserNumber( | ||
no = this.no | ||
) |
8 changes: 8 additions & 0 deletions
8
app/src/main/java/org/sopt/and/data/mapper/todomain/UserTokenResponseDtoMapper.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 org.sopt.and.data.mapper.todomain | ||
|
||
import org.sopt.and.data.remote.model.response.UserTokenResponseDto | ||
import org.sopt.and.domain.model.response.Token | ||
|
||
fun UserTokenResponseDto.toDomain(): Token = Token( | ||
token = this.token | ||
) |
14 changes: 14 additions & 0 deletions
14
app/src/main/java/org/sopt/and/data/remote/datasource/UserDataRemoteSource.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 org.sopt.and.data.remote.datasource | ||
|
||
import org.sopt.and.data.remote.model.base.ApiResponse | ||
import org.sopt.and.data.remote.model.request.UserLoginRequestDto | ||
import org.sopt.and.data.remote.model.request.UserSignUpRequestDto | ||
import org.sopt.and.data.remote.model.response.UserHobbyResponseDto | ||
import org.sopt.and.data.remote.model.response.UserSignUpResponseDto | ||
import org.sopt.and.data.remote.model.response.UserTokenResponseDto | ||
|
||
interface UserDataRemoteSource { | ||
suspend fun postUserSignUp(userSignUpRequestDto: UserSignUpRequestDto): ApiResponse<UserSignUpResponseDto> | ||
suspend fun postUserLogin(userLoginRequestDto: UserLoginRequestDto): ApiResponse<UserTokenResponseDto> | ||
suspend fun getUserHobby(token: String): ApiResponse<UserHobbyResponseDto> | ||
} |
7 changes: 0 additions & 7 deletions
7
app/src/main/java/org/sopt/and/data/remote/datasource/UserDataSource.kt
This file was deleted.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
app/src/main/java/org/sopt/and/data/remote/datasourceimpl/UserDataRemoteSourceImpl.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,26 @@ | ||
package org.sopt.and.data.remote.datasourceimpl | ||
|
||
import org.sopt.and.data.remote.datasource.UserDataRemoteSource | ||
import org.sopt.and.data.remote.model.base.ApiResponse | ||
import org.sopt.and.data.remote.model.request.UserLoginRequestDto | ||
import org.sopt.and.data.remote.model.request.UserSignUpRequestDto | ||
import org.sopt.and.data.remote.model.response.UserHobbyResponseDto | ||
import org.sopt.and.data.remote.model.response.UserSignUpResponseDto | ||
import org.sopt.and.data.remote.model.response.UserTokenResponseDto | ||
import org.sopt.and.data.remote.service.UserService | ||
import org.sopt.and.di.ServicePool | ||
|
||
class UserDataRemoteSourceImpl( | ||
private val userService: UserService | ||
) : UserDataRemoteSource { | ||
|
||
override suspend fun postUserSignUp(userSignUpRequestDto: UserSignUpRequestDto): ApiResponse<UserSignUpResponseDto> = | ||
userService.postUserSignUp(body = userSignUpRequestDto) | ||
|
||
override suspend fun postUserLogin(userLoginRequestDto: UserLoginRequestDto): ApiResponse<UserTokenResponseDto> = | ||
userService.postUserLogin(body = userLoginRequestDto) | ||
|
||
|
||
override suspend fun getUserHobby(token: String): ApiResponse<UserHobbyResponseDto> = | ||
userService.getUserHobby(token = token) | ||
} |
11 changes: 0 additions & 11 deletions
11
app/src/main/java/org/sopt/and/data/remote/datasourceimpl/UserDataSourceImpl.kt
This file was deleted.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
app/src/main/java/org/sopt/and/data/remote/utils/ApiResponseHandler.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,11 @@ | ||
package org.sopt.and.data.remote.utils | ||
|
||
import org.sopt.and.data.remote.model.base.ApiResponse | ||
|
||
fun <T> ApiResponse<T>.handleApiResponse(): Result<T> { | ||
return try { | ||
Result.success(this.result) | ||
} catch (e: Exception) { | ||
Result.failure(e) | ||
} | ||
} |
10 changes: 0 additions & 10 deletions
10
app/src/main/java/org/sopt/and/data/repositoryimpl/UserHobbyRepositoryImpl.kt
This file was deleted.
Oops, something went wrong.
35 changes: 35 additions & 0 deletions
35
app/src/main/java/org/sopt/and/data/repositoryimpl/UserRepositoryImpl.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,35 @@ | ||
package org.sopt.and.data.repositoryimpl | ||
|
||
import org.sopt.and.data.mapper.todata.toData | ||
import org.sopt.and.data.mapper.todomain.toDomain | ||
import org.sopt.and.data.remote.datasource.UserDataRemoteSource | ||
import org.sopt.and.data.remote.utils.handleApiResponse | ||
import org.sopt.and.domain.model.request.UserLoginModel | ||
import org.sopt.and.domain.model.request.UserSignUpModel | ||
import org.sopt.and.domain.model.response.Hobby | ||
import org.sopt.and.domain.model.response.Token | ||
import org.sopt.and.domain.model.response.UserNumber | ||
import org.sopt.and.domain.repository.UserRepository | ||
|
||
class UserRepositoryImpl ( | ||
private val userDataRemoteSource: UserDataRemoteSource | ||
) : UserRepository { | ||
|
||
override suspend fun postUserSignUp(userSignUpModel: UserSignUpModel): Result<UserNumber> { | ||
return runCatching { | ||
userDataRemoteSource.postUserSignUp(userSignUpModel.toData()).handleApiResponse().getOrThrow().toDomain() | ||
} | ||
} | ||
|
||
override suspend fun postUserLogin(userLoginModel: UserLoginModel): Result<Token> { | ||
return runCatching { | ||
userDataRemoteSource.postUserLogin(userLoginModel.toData()).handleApiResponse().getOrThrow().toDomain() | ||
} | ||
} | ||
|
||
override suspend fun getUserHobby(token: String): Result<Hobby> { | ||
return runCatching { | ||
userDataRemoteSource.getUserHobby(token = token).handleApiResponse().getOrThrow().toDomain() | ||
} | ||
} | ||
} |
4 changes: 0 additions & 4 deletions
4
app/src/main/java/org/sopt/and/domain/repository/UserHobbyRepository.kt
This file was deleted.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
app/src/main/java/org/sopt/and/domain/repository/UserRepository.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 org.sopt.and.domain.repository | ||
|
||
import org.sopt.and.domain.model.request.UserLoginModel | ||
import org.sopt.and.domain.model.request.UserSignUpModel | ||
import org.sopt.and.domain.model.response.Hobby | ||
import org.sopt.and.domain.model.response.Token | ||
import org.sopt.and.domain.model.response.UserNumber | ||
|
||
interface UserRepository { | ||
suspend fun postUserSignUp(userSignUpModel: UserSignUpModel): Result<UserNumber> | ||
suspend fun postUserLogin(userLoginModel: UserLoginModel): Result<Token> | ||
suspend fun getUserHobby(token: String): Result<Hobby> | ||
} |
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
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
10 changes: 10 additions & 0 deletions
10
app/src/main/java/org/sopt/and/presentation/login/LoginState.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 org.sopt.and.presentation.login | ||
|
||
import org.sopt.and.domain.model.response.Token | ||
|
||
sealed class LoginState { | ||
data object Idle: LoginState() | ||
data object Loading: LoginState() | ||
data class Success(val result: Token): LoginState() | ||
data class Failure(val message: String): LoginState() | ||
} |
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