-
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 #18 from wsi1212/feature/detail
상세 페이지 만들기
- Loading branch information
Showing
105 changed files
with
1,755 additions
and
384 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
5 changes: 4 additions & 1 deletion
5
.../mentomenv2/data/remote/AuthDataSource.kt → ...tomenv2/data/datasource/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 |
---|---|---|
@@ -1,8 +1,11 @@ | ||
package kr.hs.dgsw.mentomenv2.data.remote | ||
package kr.hs.dgsw.mentomenv2.data.datasource | ||
|
||
import kotlinx.coroutines.flow.Flow | ||
import kr.hs.dgsw.mentomenv2.data.response.TokenResponse | ||
import kr.hs.dgsw.mentomenv2.domain.model.Token | ||
|
||
interface AuthDataSource { | ||
fun signIn(code: String): Flow<Token> | ||
|
||
fun getAccessToken(): Flow<TokenResponse> | ||
} |
16 changes: 16 additions & 0 deletions
16
data/src/main/java/kr/hs/dgsw/mentomenv2/data/datasource/CommentDataSource.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,16 @@ | ||
package kr.hs.dgsw.mentomenv2.data.datasource | ||
|
||
import kotlinx.coroutines.flow.Flow | ||
import kr.hs.dgsw.mentomenv2.data.request.CommentSubmitRequest | ||
import kr.hs.dgsw.mentomenv2.data.request.CommentUpdateRequest | ||
import kr.hs.dgsw.mentomenv2.domain.model.Comment | ||
|
||
interface CommentDataSource { | ||
fun getCommentList(postId: Int): Flow<List<Comment>> | ||
|
||
fun submitComment(commentSubmitRequest: CommentSubmitRequest): Flow<Unit> | ||
|
||
fun updateComment(commentUpdateRequest: CommentUpdateRequest): Flow<Unit> | ||
|
||
fun deleteComment(commentId: Int): Flow<Unit> | ||
} |
2 changes: 1 addition & 1 deletion
2
...omenv2/data/remote/DataStoreDataSource.kt → ...v2/data/datasource/DataStoreDataSource.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
6 changes: 3 additions & 3 deletions
6
.../mentomenv2/data/remote/FileDataSource.kt → ...tomenv2/data/datasource/FileDataSource.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,9 +1,9 @@ | ||
package kr.hs.dgsw.mentomenv2.data.remote | ||
package kr.hs.dgsw.mentomenv2.data.datasource | ||
|
||
import kotlinx.coroutines.flow.Flow | ||
import kr.hs.dgsw.mentomenv2.data.response.ImgUrlResponseDto | ||
import kr.hs.dgsw.mentomenv2.data.response.ImgUrlResponse | ||
import okhttp3.MultipartBody | ||
|
||
interface FileDataSource { | ||
fun postFile(files: List<MultipartBody.Part>): Flow<List<ImgUrlResponseDto>> | ||
fun postFile(files: List<MultipartBody.Part>): Flow<List<ImgUrlResponse>> | ||
} |
11 changes: 11 additions & 0 deletions
11
data/src/main/java/kr/hs/dgsw/mentomenv2/data/datasource/MyDataSource.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 kr.hs.dgsw.mentomenv2.data.datasource | ||
|
||
import kotlinx.coroutines.flow.Flow | ||
import kr.hs.dgsw.mentomenv2.domain.model.Post | ||
import kr.hs.dgsw.mentomenv2.domain.model.User | ||
|
||
interface MyDataSource { | ||
fun getMyInfo(): Flow<User> | ||
|
||
fun getMyPost(): Flow<List<Post>> | ||
} |
2 changes: 1 addition & 1 deletion
2
.../mentomenv2/data/remote/PostDataSource.kt → ...tomenv2/data/datasource/PostDataSource.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
23 changes: 0 additions & 23 deletions
23
data/src/main/java/kr/hs/dgsw/mentomenv2/data/datasource/remote/AuthDataSourceImpl.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
44 changes: 44 additions & 0 deletions
44
data/src/main/java/kr/hs/dgsw/mentomenv2/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,44 @@ | ||
package kr.hs.dgsw.mentomenv2.data.datasourceimpl.remote | ||
|
||
import android.util.Log | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.flow | ||
import kotlinx.coroutines.flow.flowOn | ||
import kr.hs.dgsw.mentomenv2.data.datasource.AuthDataSource | ||
import kr.hs.dgsw.mentomenv2.data.datasourceimpl.remote.base.RetrofitDataSourceImpl | ||
import kr.hs.dgsw.mentomenv2.data.request.DAuthClientRequest | ||
import kr.hs.dgsw.mentomenv2.data.response.TokenResponse | ||
import kr.hs.dgsw.mentomenv2.data.service.AuthService | ||
import kr.hs.dgsw.mentomenv2.domain.exception.MenToMenException | ||
import kr.hs.dgsw.mentomenv2.domain.model.Token | ||
import kr.hs.dgsw.mentomenv2.domain.usecase.token.GetTokenUseCase | ||
import javax.inject.Inject | ||
|
||
class AuthDataSourceImpl | ||
@Inject | ||
constructor( | ||
getTokenUseCase: GetTokenUseCase, | ||
) : RetrofitDataSourceImpl<AuthService>(getTokenUseCase), AuthDataSource { | ||
override val api: AuthService | ||
get() = createApi(AuthService::class.java) | ||
|
||
override fun signIn(code: String): Flow<Token> { | ||
Log.d("AuthDataSourceImpl", "signIn out return flow: $code") | ||
return flow { | ||
emit(api.signIn(DAuthClientRequest(code)).data) | ||
} | ||
} | ||
|
||
override fun getAccessToken(): Flow<TokenResponse> { | ||
return flow { | ||
val response = api.refreshToken().execute() | ||
|
||
if (response.isSuccessful) { | ||
emit(response.body()?.data ?: TokenResponse()) | ||
} else { | ||
throw MenToMenException("토큰을 갱신하는데 실패했습니다.") | ||
} | ||
}.flowOn(Dispatchers.IO) | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
data/src/main/java/kr/hs/dgsw/mentomenv2/data/datasourceimpl/remote/CommentDataSourceImpl.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,67 @@ | ||
package kr.hs.dgsw.mentomenv2.data.datasourceimpl.remote | ||
|
||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.flow | ||
import kotlinx.coroutines.flow.flowOn | ||
import kr.hs.dgsw.mentomenv2.data.datasource.CommentDataSource | ||
import kr.hs.dgsw.mentomenv2.data.request.CommentSubmitRequest | ||
import kr.hs.dgsw.mentomenv2.data.request.CommentUpdateRequest | ||
import kr.hs.dgsw.mentomenv2.data.service.CommentService | ||
import kr.hs.dgsw.mentomenv2.domain.exception.MenToMenException | ||
import kr.hs.dgsw.mentomenv2.domain.model.Comment | ||
import javax.inject.Inject | ||
|
||
class CommentDataSourceImpl | ||
@Inject | ||
constructor( | ||
private val api: CommentService, | ||
) : CommentDataSource { | ||
override fun getCommentList(postId: Int): Flow<List<Comment>> { | ||
return flow { | ||
val response = api.getCommentList(postId).execute() | ||
|
||
if (response.isSuccessful) { | ||
emit(response.body()?.data ?: emptyList()) | ||
} else { | ||
throw MenToMenException("댓글 목록을 불러오는데 실패했습니다.") | ||
} | ||
}.flowOn(Dispatchers.IO) | ||
} | ||
|
||
override fun submitComment(commentSubmitRequest: CommentSubmitRequest): Flow<Unit> { | ||
return flow { | ||
val response = api.submitComment(commentSubmitRequest).execute() | ||
|
||
if (response.isSuccessful) { | ||
emit(response.body()?.data ?: Unit) | ||
} else { | ||
throw MenToMenException("댓글을 작성하는데 실패했습니다.") | ||
} | ||
}.flowOn(Dispatchers.IO) | ||
} | ||
|
||
override fun updateComment(commentUpdateRequest: CommentUpdateRequest): Flow<Unit> { | ||
return flow { | ||
val response = api.updateComment(commentUpdateRequest).execute() | ||
|
||
if (response.isSuccessful) { | ||
emit(response.body()?.data ?: Unit) | ||
} else { | ||
throw MenToMenException("댓글을 수정하는데 실패했습니다.") | ||
} | ||
}.flowOn(Dispatchers.IO) | ||
} | ||
|
||
override fun deleteComment(commentId: Int): Flow<Unit> { | ||
return flow { | ||
val response = api.deleteComment(commentId).execute() | ||
|
||
if (response.isSuccessful) { | ||
emit(response.body()?.data ?: Unit) | ||
} else { | ||
throw MenToMenException("댓글을 삭제하는데 실패했습니다.") | ||
} | ||
}.flowOn(Dispatchers.IO) | ||
} | ||
} |
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
53 changes: 53 additions & 0 deletions
53
data/src/main/java/kr/hs/dgsw/mentomenv2/data/datasourceimpl/remote/MyDataSourceImpl.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,53 @@ | ||
package kr.hs.dgsw.mentomenv2.data.datasourceimpl.remote | ||
|
||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.flow | ||
import kotlinx.coroutines.flow.flowOn | ||
import kr.hs.dgsw.mentomenv2.data.datasource.MyDataSource | ||
import kr.hs.dgsw.mentomenv2.data.service.MyService | ||
import kr.hs.dgsw.mentomenv2.domain.model.Post | ||
import kr.hs.dgsw.mentomenv2.domain.model.StdInfo | ||
import kr.hs.dgsw.mentomenv2.domain.model.User | ||
import retrofit2.HttpException | ||
import javax.inject.Inject | ||
|
||
class MyDataSourceImpl | ||
@Inject | ||
constructor( | ||
private val myApi: MyService, | ||
) : MyDataSource { | ||
override fun getMyInfo(): Flow<User> = | ||
flow { | ||
val response = myApi.getUserInfo().execute() | ||
if (response.isSuccessful) { | ||
if (response.body()?.data?.profileImage == null) { | ||
emit( | ||
User( | ||
email = response.body()?.data?.email ?: "", | ||
name = response.body()?.data?.name ?: "", | ||
profileImage = "", | ||
roles = response.body()?.data?.roles ?: "", | ||
stdInfo = response.body()?.data?.stdInfo ?: StdInfo(0, 0, 0), | ||
userId = response.body()?.data?.userId ?: 0, | ||
), | ||
) | ||
} else { | ||
emit(response.body()?.data ?: User()) | ||
} | ||
} else { | ||
throw HttpException(response) | ||
} | ||
}.flowOn(Dispatchers.IO) | ||
|
||
override fun getMyPost(): Flow<List<Post>> = | ||
flow { | ||
val response = myApi.getMyPost().execute() | ||
|
||
if (response.isSuccessful) { | ||
emit(response.body()?.data ?: emptyList()) | ||
} else { | ||
throw HttpException(response) | ||
} | ||
}.flowOn(Dispatchers.IO) | ||
} |
4 changes: 2 additions & 2 deletions
4
...a/datasource/remote/PostDataSourceImpl.kt → ...tasourceimpl/remote/PostDataSourceImpl.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
5 changes: 5 additions & 0 deletions
5
...src/main/java/kr/hs/dgsw/mentomenv2/data/datasourceimpl/remote/base/BaseDataSourceImpl.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,5 @@ | ||
package kr.hs.dgsw.mentomenv2.data.datasourceimpl.remote.base | ||
|
||
abstract class BaseDataSourceImpl<API> { | ||
abstract val api: API | ||
} |
Oops, something went wrong.