generated from NOW-SOPT-ANDROID/now-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
1 parent
2dafe7e
commit 706e700
Showing
16 changed files
with
146 additions
and
68 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
8 changes: 8 additions & 0 deletions
8
app/src/main/java/com/sopt/now/data/datasource/FriendRemoteDataSource.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 com.sopt.now.data.datasource | ||
|
||
import com.sopt.now.data.model.response.ResponseFriendsDto | ||
import com.sopt.now.util.BaseResponse | ||
|
||
interface FriendRemoteDataSource { | ||
suspend fun getFriendsList(page: Int): BaseResponse<ResponseFriendsDto> | ||
} |
13 changes: 13 additions & 0 deletions
13
app/src/main/java/com/sopt/now/data/datasourceimpl/FriendRemoteDataSourceImpl.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 com.sopt.now.data.datasourceimpl | ||
|
||
import com.sopt.now.data.ServicePool | ||
import com.sopt.now.data.datasource.FriendRemoteDataSource | ||
import com.sopt.now.data.model.response.ResponseFriendsDto | ||
import com.sopt.now.util.BaseResponse | ||
|
||
class FriendRemoteDataSourceImpl : FriendRemoteDataSource { | ||
private val friendService = ServicePool.friendService | ||
|
||
override suspend fun getFriendsList(page: Int): BaseResponse<ResponseFriendsDto> = | ||
friendService.getFriendsList(page = page) | ||
} |
13 changes: 13 additions & 0 deletions
13
app/src/main/java/com/sopt/now/data/mapper/FriendResponseDtoMapper.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 com.sopt.now.data.mapper | ||
|
||
import com.sopt.now.data.model.response.ResponseFriendsDto.ResponseFriend | ||
import com.sopt.now.domain.model.Friend | ||
|
||
fun ResponseFriend.toFriendModel() = | ||
Friend( | ||
id = this.id, | ||
email = this.email, | ||
firstName = this.firstName, | ||
lastName = this.lastName, | ||
avatar = this.avatar | ||
) |
9 changes: 9 additions & 0 deletions
9
app/src/main/java/com/sopt/now/data/mapper/FriendsListResponseDtoMapper.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 com.sopt.now.data.mapper | ||
|
||
import com.sopt.now.data.model.response.ResponseFriendsDto | ||
import com.sopt.now.domain.model.FriendsList | ||
|
||
fun ResponseFriendsDto.toFriendsListModel() = | ||
FriendsList( | ||
friendsList = this.data.map { it.toFriendModel() } | ||
) |
43 changes: 43 additions & 0 deletions
43
app/src/main/java/com/sopt/now/data/model/response/ResponseFriendsDto.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,43 @@ | ||
package com.sopt.now.data.model.response | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ResponseFriendsDto( | ||
@SerialName("page") | ||
val page: Int, | ||
@SerialName("per_page") | ||
val perPage: Int, | ||
@SerialName("total") | ||
val total: Int, | ||
@SerialName("total_pages") | ||
val totalPages: Int, | ||
@SerialName("data") | ||
val data: List<ResponseFriend>, | ||
@SerialName("support") | ||
val support: ResponseFriendsListSupportDto, | ||
) { | ||
@Serializable | ||
data class ResponseFriend( | ||
@SerialName("id") | ||
val id: Int, | ||
@SerialName("email") | ||
val email: String, | ||
@SerialName("firstName") | ||
val firstName: String, | ||
@SerialName("lastName") | ||
val lastName: String, | ||
@SerialName("avatar") | ||
val avatar: String, | ||
) | ||
|
||
@Serializable | ||
data class ResponseFriendsListSupportDto( | ||
@SerialName("url") | ||
val url: String, | ||
@SerialName("text") | ||
val text: String, | ||
) | ||
} | ||
|
29 changes: 0 additions & 29 deletions
29
app/src/main/java/com/sopt/now/data/model/response/ResponseUserListDto.kt
This file was deleted.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
app/src/main/java/com/sopt/now/data/repository/FriendRepositoryImpl.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,17 @@ | ||
package com.sopt.now.data.repository | ||
|
||
import com.sopt.now.data.datasource.FriendRemoteDataSource | ||
import com.sopt.now.data.mapper.toFriendsListModel | ||
import com.sopt.now.data.model.response.ResponseFriendsDto | ||
import com.sopt.now.data.service.FriendService | ||
import com.sopt.now.domain.model.FriendsList | ||
import com.sopt.now.domain.repository.FriendRepository | ||
|
||
class FriendRepositoryImpl( | ||
private val friendRemoteDataSource: FriendRemoteDataSource | ||
): FriendRepository { | ||
override suspend fun getFriendsList(page: Int): Result<FriendsList> = | ||
runCatching { | ||
friendRemoteDataSource.getFriendsList(page = page).data.toFriendsListModel() | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
app/src/main/java/com/sopt/now/data/service/FriendService.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 com.sopt.now.data.service | ||
|
||
import com.sopt.now.data.model.response.ResponseFriendsDto | ||
import com.sopt.now.util.BaseResponse | ||
import retrofit2.http.GET | ||
import retrofit2.http.Query | ||
|
||
interface FriendService { | ||
@GET("api/users") | ||
fun getFriendsList( | ||
@Query("page") page: Int, | ||
): BaseResponse<ResponseFriendsDto> | ||
} |
13 changes: 0 additions & 13 deletions
13
app/src/main/java/com/sopt/now/data/service/UserService.kt
This file was deleted.
Oops, something went wrong.
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 com.sopt.now.domain.model | ||
|
||
data class Friend( | ||
val id: Int, | ||
val email: String, | ||
val firstName: String, | ||
val lastName: String, | ||
val avatar: String, | ||
) |
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,5 @@ | ||
package com.sopt.now.domain.model | ||
|
||
data class FriendsList( | ||
val friendsList: List<Friend> | ||
) |
7 changes: 7 additions & 0 deletions
7
app/src/main/java/com/sopt/now/domain/repository/FriendRepository.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,7 @@ | ||
package com.sopt.now.domain.repository | ||
|
||
import com.sopt.now.domain.model.FriendsList | ||
|
||
interface FriendRepository { | ||
suspend fun getFriendsList(page: Int): Result<FriendsList> | ||
} |
18 changes: 0 additions & 18 deletions
18
app/src/main/java/com/sopt/now/presentation/Home/Friend/Friend.kt
This file was deleted.
Oops, something went wrong.
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