Skip to content

Commit 3e28846

Browse files
authored
Merge pull request #159 from captures-2024/feature/SG-211-comment-curd-api
[SG-211] comment curd api 연동
2 parents 5c616cf + 0a427b0 commit 3e28846

File tree

17 files changed

+567
-0
lines changed

17 files changed

+567
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package com.captures2024.soongan.core.model.network
2+
3+
enum class ContestType {
4+
WEEKLY,
5+
DAILY,
6+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.captures2024.soongan.core.model.network.request.comments
2+
3+
import kotlinx.serialization.SerialName
4+
import kotlinx.serialization.Serializable
5+
6+
@Serializable
7+
data class ModifyCommentRequest(
8+
@SerialName("contestType")
9+
val contestType: String,
10+
@SerialName("postId")
11+
val postId: Int,
12+
@SerialName("commentId")
13+
val commentId: Int,
14+
@SerialName("commentText")
15+
val commentText: String,
16+
)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.captures2024.soongan.core.model.network.request.comments
2+
3+
import kotlinx.serialization.SerialName
4+
import kotlinx.serialization.Serializable
5+
6+
@Serializable
7+
data class PostCommentRequest(
8+
@SerialName("contestType")
9+
val contestType: String,
10+
@SerialName("postId")
11+
val postId: Int,
12+
@SerialName("commentText")
13+
val commentText: String,
14+
@SerialName("parentCommentId")
15+
val parentCommentId: Int,
16+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.captures2024.soongan.core.model.network.response.comments
2+
3+
import kotlinx.serialization.SerialName
4+
import kotlinx.serialization.Serializable
5+
6+
@Serializable
7+
data class GetCommentRepliesCommentInfoResponse(
8+
@SerialName("commentId")
9+
val commentId: Int,
10+
@SerialName("memberId")
11+
val memberId: Int,
12+
@SerialName("memberNickname")
13+
val memberNickname: String,
14+
@SerialName("commentText")
15+
val commentText: String,
16+
@SerialName("parentCommentID")
17+
val parentCommentID: Int,
18+
@SerialName("commentStatus")
19+
val commentStatus: String,
20+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.captures2024.soongan.core.model.network.response.comments
2+
3+
import kotlinx.serialization.SerialName
4+
import kotlinx.serialization.Serializable
5+
6+
@Serializable
7+
data class GetCommentRepliesPageInfoResponse(
8+
@SerialName("page")
9+
val page: Int,
10+
@SerialName("size")
11+
val size: Int,
12+
@SerialName("hasNext")
13+
val hasNext: Boolean,
14+
)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.captures2024.soongan.core.model.network.response.comments
2+
3+
import kotlinx.serialization.SerialName
4+
import kotlinx.serialization.Serializable
5+
6+
@Serializable
7+
data class GetCommentRepliesResponse(
8+
@SerialName("comments")
9+
val comments: List<GetCommentRepliesCommentInfoResponse>,
10+
@SerialName("pageInfo")
11+
val pageInfo: GetCommentRepliesPageInfoResponse,
12+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.captures2024.soongan.core.model.network.response.comments
2+
3+
import kotlinx.serialization.SerialName
4+
import kotlinx.serialization.Serializable
5+
6+
@Serializable
7+
data class GetCommentsCommentInfoResponse(
8+
@SerialName("commentId")
9+
val commentId: Int,
10+
@SerialName("memberId")
11+
val memberId: Int,
12+
@SerialName("memberNickname")
13+
val memberNickname: String,
14+
@SerialName("commentText")
15+
val commentText: String,
16+
@SerialName("parentCommentID")
17+
val parentCommentID: Int,
18+
@SerialName("commentStatus")
19+
val commentStatus: String,
20+
)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.captures2024.soongan.core.model.network.response.comments
2+
3+
import kotlinx.serialization.SerialName
4+
import kotlinx.serialization.Serializable
5+
6+
@Serializable
7+
data class GetCommentsPageInfoResponse(
8+
@SerialName("page")
9+
val page: Int,
10+
@SerialName("size")
11+
val size: Int,
12+
@SerialName("hasNext")
13+
val hasNext: Boolean,
14+
)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.captures2024.soongan.core.model.network.response.comments
2+
3+
import kotlinx.serialization.SerialName
4+
import kotlinx.serialization.Serializable
5+
6+
@Serializable
7+
data class GetCommentsResponse(
8+
@SerialName("postId")
9+
val postId: Int,
10+
@SerialName("comments")
11+
val comments: List<GetCommentsCommentInfoResponse>,
12+
@SerialName("pageInfo")
13+
val pageInfo: GetCommentsPageInfoResponse,
14+
)
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
package com.captures2024.soongan.data.service.api
2+
3+
import com.captures2024.soongan.core.model.network.request.comments.ModifyCommentRequest
4+
import com.captures2024.soongan.core.model.network.request.comments.PostCommentRequest
5+
import com.captures2024.soongan.core.model.network.response.BaseResponse
6+
import com.captures2024.soongan.core.model.network.response.comments.GetCommentRepliesResponse
7+
import com.captures2024.soongan.core.model.network.response.comments.GetCommentsResponse
8+
import retrofit2.Response
9+
import retrofit2.http.Body
10+
import retrofit2.http.DELETE
11+
import retrofit2.http.GET
12+
import retrofit2.http.POST
13+
import retrofit2.http.PUT
14+
import retrofit2.http.Query
15+
16+
interface CommentsAPI {
17+
18+
@GET("comments")
19+
suspend fun getComments(
20+
@Query("contestType") contestType: String,
21+
@Query("postId") postId: Int,
22+
): Response<BaseResponse<GetCommentsResponse>>
23+
24+
@GET("comments")
25+
suspend fun getComments(
26+
@Query("contestType") contestType: String,
27+
@Query("postId") postId: Int,
28+
@Query("page") page: Int,
29+
): Response<BaseResponse<GetCommentsResponse>>
30+
31+
@GET("comments")
32+
suspend fun getComments(
33+
@Query("contestType") contestType: String,
34+
@Query("postId") postId: Int,
35+
@Query("page") page: Int,
36+
@Query("size") size: Int,
37+
): Response<BaseResponse<GetCommentsResponse>>
38+
39+
@PUT("comments")
40+
suspend fun modifyComment(
41+
@Body request: ModifyCommentRequest,
42+
): Response<BaseResponse<Unit>>
43+
44+
@POST("comments")
45+
suspend fun postComment(
46+
@Body request: PostCommentRequest,
47+
): Response<BaseResponse<Unit>>
48+
49+
// TODO 수정 필요
50+
@DELETE("comments")
51+
suspend fun deleteComment(): Response<BaseResponse<Unit>>
52+
53+
@GET("comments/replies")
54+
suspend fun getCommentReplies(
55+
@Query("contestType") contestType: String,
56+
@Query("parentCommentId") parentCommentId: Int,
57+
): Response<BaseResponse<GetCommentRepliesResponse>>
58+
59+
@GET("comments/replies")
60+
suspend fun getCommentReplies(
61+
@Query("contestType") contestType: String,
62+
@Query("parentCommentId") parentCommentId: Int,
63+
@Query("page") page: Int,
64+
): Response<BaseResponse<GetCommentRepliesResponse>>
65+
66+
@GET("comments/replies")
67+
suspend fun getCommentReplies(
68+
@Query("contestType") contestType: String,
69+
@Query("parentCommentId") parentCommentId: Int,
70+
@Query("page") page: Int,
71+
@Query("size") size: Int,
72+
): Response<BaseResponse<GetCommentRepliesResponse>>
73+
}

0 commit comments

Comments
 (0)