generated from DO-SOPT-ANDROID/do-sopt-android-repo-template
-
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 #12 from DO-SOPT-ANDROID/feat/week8_clean_architec…
…ture [Feat/week8] clean architecture
- Loading branch information
Showing
48 changed files
with
438 additions
and
228 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
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/dosopttemplate/data/datasource/remote/AuthDataSource.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.dosopttemplate.data.datasource.remote | ||
|
||
import org.sopt.dosopttemplate.data.dto.remote.request.RequestLoginDto | ||
import org.sopt.dosopttemplate.data.dto.remote.request.RequestSignUpDto | ||
import org.sopt.dosopttemplate.data.dto.remote.respose.ResponseLoginDto | ||
|
||
interface AuthDataSource { | ||
suspend fun login(request: RequestLoginDto): ResponseLoginDto | ||
suspend fun signUp(request: RequestSignUpDto): Unit | ||
} |
8 changes: 8 additions & 0 deletions
8
app/src/main/java/org/sopt/dosopttemplate/data/datasource/remote/ReqresDataSource.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.dosopttemplate.data.datasource.remote | ||
|
||
import org.sopt.dosopttemplate.data.dto.remote.respose.ResponseReqresDto | ||
|
||
// 레포지터리 인터페이스, 데이터 접근을 추상화, 데이터를 요청하는 코드를 부름 | ||
interface ReqresDataSource { | ||
suspend fun getReqresList(page: Int): ResponseReqresDto | ||
} |
15 changes: 15 additions & 0 deletions
15
app/src/main/java/org/sopt/dosopttemplate/data/datasourceimpl/remote/AuthDataSourceImpl.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,15 @@ | ||
package org.sopt.dosopttemplate.data.datasourceimpl.remote | ||
|
||
import org.sopt.dosopttemplate.data.datasource.remote.AuthDataSource | ||
import org.sopt.dosopttemplate.data.dto.remote.request.RequestLoginDto | ||
import org.sopt.dosopttemplate.data.dto.remote.request.RequestSignUpDto | ||
import org.sopt.dosopttemplate.data.dto.remote.respose.ResponseLoginDto | ||
import org.sopt.dosopttemplate.data.service.AuthService | ||
|
||
class AuthDataSourceImpl(private val authService: AuthService) : AuthDataSource { | ||
override suspend fun login(request: RequestLoginDto): ResponseLoginDto = | ||
authService.postLogin(request) | ||
|
||
override suspend fun signUp(request: RequestSignUpDto): Unit = | ||
authService.postSignUp(request) | ||
} |
14 changes: 14 additions & 0 deletions
14
app/src/main/java/org/sopt/dosopttemplate/data/datasourceimpl/remote/ReqresDataSourceImpl.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.dosopttemplate.data.datasourceimpl.remote | ||
|
||
import org.sopt.dosopttemplate.data.datasource.remote.ReqresDataSource | ||
import org.sopt.dosopttemplate.data.dto.remote.respose.ResponseReqresDto | ||
import org.sopt.dosopttemplate.data.service.ReqresService | ||
|
||
// 실제 데이터 소스를 구현하는 클래스, 네트워크 호출을 통해 데이터를 가져오는 역할 | ||
class ReqresDataSourceImpl( | ||
private val reqresService: ReqresService, | ||
) : ReqresDataSource { | ||
override suspend fun getReqresList(page: Int): ResponseReqresDto { | ||
return reqresService.getUserList(page) | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...template/network/login/RequestLoginDto.kt → ...ata/dto/remote/request/RequestLoginDto.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
2 changes: 1 addition & 1 deletion
2
...emplate/network/login/RequestSignUpDto.kt → ...ta/dto/remote/request/RequestSignUpDto.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
22 changes: 22 additions & 0 deletions
22
app/src/main/java/org/sopt/dosopttemplate/data/dto/remote/respose/ResponseLoginDto.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,22 @@ | ||
package org.sopt.dosopttemplate.data.dto.remote.respose | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
import org.sopt.dosopttemplate.domain.entity.UserEntity | ||
|
||
@Serializable | ||
data class ResponseLoginDto( | ||
@SerialName("id") | ||
val id: Int, | ||
@SerialName("username") | ||
val username: String, | ||
@SerialName("nickname") | ||
val nickname: String, | ||
) { | ||
fun toUserEntity() = UserEntity( | ||
id = username, | ||
pwd = "", | ||
nickName = nickname, | ||
mbti = "", | ||
) | ||
} |
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
12 changes: 0 additions & 12 deletions
12
app/src/main/java/org/sopt/dosopttemplate/data/login/User.kt
This file was deleted.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
app/src/main/java/org/sopt/dosopttemplate/data/repositoryimpl/AuthRepositoryImpl.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,31 @@ | ||
package org.sopt.dosopttemplate.data.repositoryimpl | ||
|
||
import org.sopt.dosopttemplate.data.datasource.remote.AuthDataSource | ||
import org.sopt.dosopttemplate.data.dto.remote.request.RequestLoginDto | ||
import org.sopt.dosopttemplate.data.dto.remote.request.RequestSignUpDto | ||
import org.sopt.dosopttemplate.domain.entity.UserEntity | ||
import org.sopt.dosopttemplate.domain.entity.UserRequestEntity | ||
import org.sopt.dosopttemplate.domain.repository.AuthDomainRepository | ||
|
||
class AuthRepositoryImpl(private val authDataSource: AuthDataSource) : AuthDomainRepository { | ||
override suspend fun login(userRequestEntity: UserRequestEntity): Result<UserEntity> = | ||
kotlin.runCatching { | ||
authDataSource.login( | ||
RequestLoginDto( | ||
userRequestEntity.userName, | ||
userRequestEntity.passWord, | ||
), | ||
).toUserEntity() | ||
} | ||
|
||
override suspend fun signUp(userEntity: UserEntity): Result<Unit> = | ||
kotlin.runCatching { | ||
authDataSource.signUp( | ||
RequestSignUpDto( | ||
userEntity.id, | ||
userEntity.pwd, | ||
userEntity.nickName, | ||
), | ||
) | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
app/src/main/java/org/sopt/dosopttemplate/data/repositoryimpl/ReqresRepositoryImpl.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,15 @@ | ||
package org.sopt.dosopttemplate.data.repositoryimpl | ||
|
||
import org.sopt.dosopttemplate.data.datasource.remote.ReqresDataSource | ||
import org.sopt.dosopttemplate.domain.entity.ReqresEntity | ||
import org.sopt.dosopttemplate.domain.repository.ReqresDomainRepository | ||
|
||
// 외부 데이터 소스(ReqresDataSource)로부터 데이터를 가져오고, 필요한 형태로 변환하여 비즈니스 로직 계층에게 제공 | ||
class ReqresRepositoryImpl(private val reqresDataSource: ReqresDataSource) : | ||
ReqresDomainRepository { | ||
override suspend fun getReqresList(page: Int): Result<List<ReqresEntity>> { | ||
return runCatching { | ||
reqresDataSource.getReqresList(page).toReqresList() | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
app/src/main/java/org/sopt/dosopttemplate/data/service/AuthService.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 org.sopt.dosopttemplate.data.service | ||
|
||
import org.sopt.dosopttemplate.data.dto.remote.request.RequestLoginDto | ||
import org.sopt.dosopttemplate.data.dto.remote.request.RequestSignUpDto | ||
import org.sopt.dosopttemplate.data.dto.remote.respose.ResponseLoginDto | ||
import retrofit2.http.Body | ||
import retrofit2.http.POST | ||
|
||
interface AuthService { | ||
@POST("api/v1/members/sign-in") | ||
suspend fun postLogin( | ||
@Body request: RequestLoginDto, | ||
): ResponseLoginDto | ||
|
||
@POST("api/v1/members") | ||
suspend fun postSignUp( | ||
@Body request: RequestSignUpDto, | ||
): Unit | ||
} |
12 changes: 12 additions & 0 deletions
12
app/src/main/java/org/sopt/dosopttemplate/data/service/ReqresService.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,12 @@ | ||
package org.sopt.dosopttemplate.data.service | ||
|
||
import org.sopt.dosopttemplate.data.dto.remote.respose.ResponseReqresDto | ||
import retrofit2.http.GET | ||
import retrofit2.http.Query | ||
|
||
interface ReqresService { | ||
@GET("api/users") | ||
suspend fun getUserList( | ||
@Query("page") page: Int, | ||
): ResponseReqresDto | ||
} |
9 changes: 9 additions & 0 deletions
9
app/src/main/java/org/sopt/dosopttemplate/domain/entity/ReqresEntity.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,9 @@ | ||
package org.sopt.dosopttemplate.domain.entity | ||
|
||
data class ReqresEntity( | ||
val id: Int, | ||
val avatar: String, | ||
val email: String, | ||
val first_name: String, | ||
val last_name: String, | ||
) |
12 changes: 12 additions & 0 deletions
12
app/src/main/java/org/sopt/dosopttemplate/domain/entity/UserEntity.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,12 @@ | ||
package org.sopt.dosopttemplate.domain.entity | ||
|
||
import android.os.Parcelable | ||
import kotlinx.parcelize.Parcelize | ||
|
||
@Parcelize | ||
data class UserEntity( | ||
val id: String, | ||
val pwd: String, | ||
val nickName: String, | ||
val mbti: String, | ||
) : Parcelable |
6 changes: 6 additions & 0 deletions
6
app/src/main/java/org/sopt/dosopttemplate/domain/entity/UserRequestEntity.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,6 @@ | ||
package org.sopt.dosopttemplate.domain.entity | ||
|
||
data class UserRequestEntity( | ||
val userName: String, | ||
val passWord: String, | ||
) |
9 changes: 9 additions & 0 deletions
9
app/src/main/java/org/sopt/dosopttemplate/domain/repository/AuthDomainRepository.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,9 @@ | ||
package org.sopt.dosopttemplate.domain.repository | ||
|
||
import org.sopt.dosopttemplate.domain.entity.UserEntity | ||
import org.sopt.dosopttemplate.domain.entity.UserRequestEntity | ||
|
||
interface AuthDomainRepository { | ||
suspend fun login(userRequestEntity: UserRequestEntity): Result<UserEntity> | ||
suspend fun signUp(userEntity: UserEntity): Result<Unit> | ||
} |
9 changes: 9 additions & 0 deletions
9
app/src/main/java/org/sopt/dosopttemplate/domain/repository/ReqresDomainRepository.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,9 @@ | ||
package org.sopt.dosopttemplate.domain.repository | ||
|
||
import org.sopt.dosopttemplate.domain.entity.ReqresEntity | ||
|
||
/*ReqresRepository 인터페이스는 도메인(Domain) 레이어에서 사용되며, | ||
원격 데이터 소스(ReqresDataSource)로부터 Reqres 사용자 리스트를 가져오는 기능을 정의*/ | ||
interface ReqresDomainRepository { | ||
suspend fun getReqresList(page: Int): Result<List<ReqresEntity>> | ||
} |
12 changes: 0 additions & 12 deletions
12
app/src/main/java/org/sopt/dosopttemplate/network/doandroid/ReqresService.kt
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
app/src/main/java/org/sopt/dosopttemplate/network/login/AuthService.kt
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
app/src/main/java/org/sopt/dosopttemplate/network/login/ResponseLoginDto.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.