-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#91 댓글 전송 시 로직을 BindingAdapter로 통합해 제작, 댓글 등록/수정/좋아요/삭제 비즈니스 로직 교체,
- Loading branch information
Showing
44 changed files
with
870 additions
and
513 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
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
core/common/src/main/java/com/android/mediproject/core/common/bindingadapter/ISendText.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 com.android.mediproject.core.common.bindingadapter | ||
|
||
interface ISendText { | ||
fun onClickedSendButton(text: CharSequence) | ||
} |
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
31 changes: 30 additions & 1 deletion
31
...ata/src/main/java/com/android/mediproject/core/data/remote/comments/CommentsRepository.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,11 +1,40 @@ | ||
package com.android.mediproject.core.data.remote.comments | ||
|
||
import androidx.paging.PagingData | ||
import com.android.mediproject.core.model.comments.EditedCommentDto | ||
import com.android.mediproject.core.model.comments.MyCommentDto | ||
import com.android.mediproject.core.model.comments.NewCommentDto | ||
import com.android.mediproject.core.model.remote.comments.MedicineCommentsResponse | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
interface CommentsRepository { | ||
suspend fun getCommentsForAMedicine( | ||
fun getCommentsForAMedicine( | ||
itemSeq: String, | ||
): Flow<PagingData<MedicineCommentsResponse>> | ||
|
||
/** | ||
* 내가 작성한 댓글을 가져오는 메서드입니다. | ||
*/ | ||
fun getMyComments(userId: Int): Flow<PagingData<MyCommentDto>> | ||
|
||
/** | ||
* 댓글을 수정합니다. | ||
*/ | ||
fun applyEditedComment(editedCommentDto: EditedCommentDto): Flow<Result<Unit>> | ||
|
||
|
||
/** | ||
* 댓글을 등록합니다. | ||
*/ | ||
fun applyNewComment(newCommentDto: NewCommentDto): Flow<Result<Unit>> | ||
|
||
/** | ||
* 댓글 삭제 클릭 | ||
*/ | ||
fun deleteComment(commentId: Int): Flow<Result<Unit>> | ||
|
||
/** | ||
* 댓글 좋아요 클릭 | ||
*/ | ||
fun likeComment(commentId: Int): Flow<Result<Unit>> | ||
} |
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
56 changes: 56 additions & 0 deletions
56
core/domain/src/main/java/com/android/mediproject/core/domain/CommentsUseCase.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,56 @@ | ||
package com.android.mediproject.core.domain | ||
|
||
import androidx.paging.PagingData | ||
import androidx.paging.map | ||
import com.android.mediproject.core.data.remote.comments.CommentsRepository | ||
import com.android.mediproject.core.model.comments.CommentDto | ||
import com.android.mediproject.core.model.comments.EditedCommentDto | ||
import com.android.mediproject.core.model.comments.MyCommentDto | ||
import com.android.mediproject.core.model.comments.NewCommentDto | ||
import com.android.mediproject.core.model.comments.toDto | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.map | ||
import javax.inject.Inject | ||
|
||
class CommentsUseCase @Inject constructor( | ||
private val commentsRepository: CommentsRepository | ||
) { | ||
|
||
/** | ||
* 약에 대한 댓글을 가져오는 메서드입니다. | ||
*/ | ||
fun getCommentsForAMedicine(itemSeq: String): Flow<PagingData<CommentDto>> = commentsRepository.getCommentsForAMedicine(itemSeq).map { | ||
it.map { response -> | ||
response.toDto() | ||
} | ||
} | ||
|
||
/** | ||
* 내가 작성한 댓글을 가져오는 메서드입니다. | ||
*/ | ||
fun getMyComments(userId: Int): Flow<PagingData<MyCommentDto>> { | ||
TODO() | ||
} | ||
|
||
|
||
/** | ||
* 댓글을 수정합니다. | ||
*/ | ||
fun applyEditedComment(editedCommentDto: EditedCommentDto): Flow<Result<Unit>> = commentsRepository.applyEditedComment(editedCommentDto) | ||
|
||
|
||
/** | ||
* 댓글을 등록합니다. | ||
*/ | ||
fun applyNewComment(newCommentDto: NewCommentDto): Flow<Result<Unit>> = commentsRepository.applyNewComment(newCommentDto) | ||
|
||
/** | ||
* 댓글 삭제 클릭 | ||
*/ | ||
fun deleteComment(commentId: Int): Flow<Result<Unit>> = commentsRepository.deleteComment(commentId) | ||
|
||
/** | ||
* 댓글 좋아요 클릭 | ||
*/ | ||
fun likeComment(commentId: Int): Flow<Result<Unit>> = commentsRepository.likeComment(commentId) | ||
} |
Oops, something went wrong.