Skip to content

Commit

Permalink
refactor: comment API의 URI 수정 #560 (#561)
Browse files Browse the repository at this point in the history
* refactor: comment API의 URI 수정

URI 상수 이름 변경
 - COMMENTS_PATH -> COMMENTS_URI

Path Variable 상수화
 - momentId 상수화 : MOMENT_ID
 - commentId 상수화 : COMMENT_ID

댓글 수정, 삭제 API의 URI 수정
 - Query String에서 Path Variable로 변경
 - Path Variable로 commentId가 담긴 URI 상수 생성 : COMMENTS_URI_WITH_COMMENT_ID
 - URI의 v2는 추후 제거 예정

* refactor: CommentApiService 내 moment를 staccato로 변경

누락된 도메인명 수정 사항 반영
 - MOMENT_ID -> STACCATO_ID
 - momentId -> staccatoId
 - 서버 측은 도메인명이 수정되지 않았으므로, 실제 URI 값은 변경하지 않음

* refactor: CommentRequest 내 moment를 staccato로 변경

누락된 도메인명 수정 사항 반영
 - momentId -> staccatoId
 - 서버 측은 도메인명이 수정되지 않았으므로, SerialName 값은 변경하지 않음
  • Loading branch information
Junyoung-WON authored Nov 27, 2024
1 parent 7730421 commit bc0a7ad
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,35 @@ import retrofit2.http.DELETE
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.PUT
import retrofit2.http.Path
import retrofit2.http.Query

interface CommentApiService {
@GET(COMMENTS_PATH)
@GET(COMMENTS_URI)
suspend fun getComments(
@Query("momentId") momentId: Long,
@Query(STACCATO_ID) staccatoId: Long,
): Response<CommentsResponse>

@POST(COMMENTS_PATH)
@POST(COMMENTS_URI)
suspend fun postComment(
@Body commentRequest: CommentRequest,
): Response<Unit>

@PUT(COMMENTS_PATH)
@PUT(COMMENTS_URI_WITH_COMMENT_ID)
suspend fun putComment(
@Query("commentId") commentId: Long,
@Path(COMMENT_ID) commentId: Long,
@Body commentUpdateRequest: CommentUpdateRequest,
): Response<Unit>

@DELETE(COMMENTS_PATH)
@DELETE(COMMENTS_URI_WITH_COMMENT_ID)
suspend fun deleteComment(
@Query("commentId") commentId: Long,
@Path(COMMENT_ID) commentId: Long,
): Response<Unit>

companion object {
private const val COMMENTS_PATH = "/comments"
private const val COMMENT_ID = "/{commentId}"
private const val COMMENTS_PATH_WITH_ID = "$COMMENTS_PATH$COMMENT_ID"
private const val COMMENTS_URI = "/comments"
private const val STACCATO_ID = "momentId"
private const val COMMENT_ID = "commentId"
private const val COMMENTS_URI_WITH_COMMENT_ID = "$COMMENTS_URI/v2/{$COMMENT_ID}"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ import kotlinx.serialization.Serializable

@Serializable
data class CommentRequest(
@SerialName("momentId") val momentId: Long,
@SerialName("momentId") val staccatoId: Long,
@SerialName("content") val content: String,
)
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ fun CommentDto.toDomain(): Comment =

fun NewComment.toDto(): CommentRequest =
CommentRequest(
momentId = staccatoId,
staccatoId = staccatoId,
content = content,
)

0 comments on commit bc0a7ad

Please sign in to comment.