-
Notifications
You must be signed in to change notification settings - Fork 3
[API] 기록장 api 연결 #80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[API] 기록장 api 연결 #80
Changes from all commits
c10eb10
5b3b041
895f3e6
0c0e960
c78770e
f8c2504
0e48948
bd1975d
be8b564
7bdd7da
7bfed3b
2a72200
5ac5643
e2c03e6
8f21cfd
9882cbd
7e20b53
5225503
c5ca340
6366fa1
5f4d446
464bfed
80832dc
de6f588
868c89d
71fe1bb
e78faaf
1088396
72a299f
a3587dd
b18b536
762dd72
32ffc32
8e9002e
1d64855
d8df01e
4380431
9fad483
9fad327
593845c
524708a
6b56cb9
c192fef
26dc7e5
fc710d1
b28de01
8524d55
60d45c4
1866fcc
612da00
a34a03c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package com.texthip.thip.data.model.rooms.request | ||
|
|
||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class RoomsCreateVoteRequest( | ||
| val page: Int, | ||
| val isOverview: Boolean, | ||
| val content: String, | ||
| val voteItemList: List<VoteItem> | ||
| ) | ||
|
|
||
| @Serializable | ||
| data class VoteItem( | ||
| val itemName: String | ||
| ) |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,9 @@ | ||||||||||||||||||||||||||||||||||
| package com.texthip.thip.data.model.rooms.request | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| import kotlinx.serialization.Serializable | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| @Serializable | ||||||||||||||||||||||||||||||||||
| data class RoomsPostsLikesRequest( | ||||||||||||||||||||||||||||||||||
| val type: Boolean, | ||||||||||||||||||||||||||||||||||
| val roomPostType: String, | ||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+5
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion 불리언 좋아요/해제 의미가 분명하도록 다음 변경을 제안합니다: package com.texthip.thip.data.model.rooms.request
import kotlinx.serialization.Serializable
+import kotlinx.serialization.SerialName
@Serializable
data class RoomsPostsLikesRequest(
- val type: Boolean,
+ @SerialName("type")
+ val isLike: Boolean,
val roomPostType: String,
)📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package com.texthip.thip.data.model.rooms.request | ||
|
|
||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class RoomsPostsRequestParams( | ||
| val type: String, | ||
| val sort: String? = null, | ||
| val pageStart: Int? = null, | ||
| val pageEnd: Int? = null, | ||
| val isOverview: Boolean? = null, | ||
| val isPageFilter: Boolean? = null, | ||
| val cursor: String? = null | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package com.texthip.thip.data.model.rooms.request | ||
|
|
||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class RoomsRecordRequest( | ||
| val page: Int, | ||
| val isOverview: Boolean = false, | ||
| val content: String, | ||
| ) | ||
|
Comment on lines
+5
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chain직렬화 키 네이밍과 선택적 필드 포함 여부 검증 필요.
다음 스크립트로 기존 코드베이스의 직렬화 관례와 Json 설정을 확인해 주세요: 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "1) @SerialName 사용 현황:"
rg -n '@SerialName\(' -A2 app/src/main/java
echo
echo "2) Request 모델들 직렬화 어노테이션 요약:"
fd -t f -e kt 'Request.kt' app/src/main/java | while read -r f; do
echo "=== $f ==="
rg -n '@Serializable|@SerialName|data class' "$f"
done
echo
echo "3) kotlinx.serialization Json 설정(explicitNulls 등) 확인:"
rg -n 'Json\s*\{' -A5 -U
rg -n 'explicitNulls\s*=\s*(true|false)' -ULength of output: 17285 직렬화 키 네이밍 일관성 및 선택적 필드 포함 처리
🤖 Prompt for AI Agents |
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,9 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| package com.texthip.thip.data.model.rooms.request | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import kotlinx.serialization.Serializable | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @Serializable | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| data class RoomsVoteRequest( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| val voteItemId: Int, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| val type: Boolean | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+5
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chain호출부 빌드 안정성 확인 (명명 인자 사용 여부) 프로퍼티명을 변경하면 호출부를 점검해 주세요: 🏁 Script executed: #!/bin/bash
set -euxo pipefail
# RoomsVoteRequest 생성 시 명명 인자 사용 여부 확인
rg -n --glob '!**/build/**' 'RoomsVoteRequest\(' -A2 app | sed -n '1,200p'Length of output: 751 명명 인자 사용으로 인한 빌드 불안정 확인 필요
· app/src/main/java/com/texthip/thip/data/repository/RoomsRepository.kt request = RoomsVoteRequest(
voteItemId = voteItemId,
type = type
)🤖 Prompt for AI Agents🛠️ Refactor suggestion 의미 모호한 불리언 필드명 불리언 다음 변경을 제안합니다: package com.texthip.thip.data.model.rooms.request
import kotlinx.serialization.Serializable
+import kotlinx.serialization.SerialName
@Serializable
data class RoomsVoteRequest(
val voteItemId: Int,
- val type: Boolean
+ @SerialName("type")
+ val isSelected: Boolean,
)호출부에서 명명 인자를 사용하고 있다면 함께 수정이 필요합니다. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
Comment on lines
+6
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chain불명확한 필드명(type) 개선 + API 키 고정(@SerialName) 제안 Boolean에 “type”은 의미가 모호합니다. 도메인 의미(선택/해제 등)가 드러나도록 프로퍼티명을 개선하고, 서버 키는 @SerialName으로 고정해 API 스키마와 도메인 모델을 분리하는 것을 권장합니다.
적용 예시: package com.texthip.thip.data.model.rooms.request
-import kotlinx.serialization.Serializable
+import kotlinx.serialization.SerialName
+import kotlinx.serialization.Serializable
@Serializable
data class RoomsVoteRequest(
- val voteItemId: Int,
- val type: Boolean
+ @SerialName("voteItemId") val voteItemId: Int,
+ @SerialName("type") val isSelected: Boolean
)🏁 Script executed: #!/bin/bash
set -e
# 1. Locate usages of RoomsVoteRequest in Retrofit or service interfaces
rg "RoomsVoteRequest" -n
# 2. Search for vote-related endpoints to see how 'type' is used
rg "@POST" -n app/src
rg "vote" -n app/src
# 3. Check for existing @SerialName annotations in model packages for consistency
rg "@SerialName" -n app/srcLength of output: 22360 불명확한 필드명(type) 개선 및 @SerialName 적용 제안 Boolean 타입의 적용 예시 (app/src/main/java/com/texthip/thip/data/model/rooms/request/RoomsVoteRequest.kt): -import kotlinx.serialization.Serializable
+import kotlinx.serialization.SerialName
+import kotlinx.serialization.Serializable
@Serializable
data class RoomsVoteRequest(
- val voteItemId: Int,
- val type: Boolean
+ @SerialName("voteItemId") val voteItemId: Int,
+ @SerialName("type") val isSelected: Boolean
)검증 요청:
📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package com.texthip.thip.data.model.rooms.response | ||
|
|
||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class RoomsBookPageResponse( | ||
| val totalBookPage: Int, | ||
| val recentBookPage: Int, | ||
| val isOverviewPossible: Boolean, | ||
| val roomId: Int, | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package com.texthip.thip.data.model.rooms.response | ||
|
|
||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class RoomsCreateVoteResponse( | ||
| val voteId: Int, | ||
| val roomId: Int | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package com.texthip.thip.data.model.rooms.response | ||
|
|
||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class RoomsDeleteRecordResponse( | ||
| val roomId: Int, | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package com.texthip.thip.data.model.rooms.response | ||
|
|
||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class RoomsPostsLikesResponse( | ||
| val postId: Int, | ||
| val isLiked: Boolean, | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| package com.texthip.thip.data.model.rooms.response | ||
|
|
||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class RoomsPostsResponse( | ||
| val postList: List<PostList>, | ||
| val roomId: Int, | ||
| val isbn: String, | ||
| val isOverviewEnabled: Boolean, | ||
| val nextCursor: String?, | ||
| val isLast: Boolean, | ||
| ) | ||
|
Comment on lines
+7
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion 직렬화 안정성 강화: 기본값 부여로 MissingFieldException 예방 백엔드가 특정 필드를 조건부로 생략하는 경우를 대비해 컬렉션/옵셔널 필드에 기본값을 부여해 두는 것이 안전합니다. 다음과 같이 기본값을 제안합니다. data class RoomsPostsResponse(
- val postList: List<PostList>,
+ val postList: List<PostList> = emptyList(),
@@
- val nextCursor: String?,
+ val nextCursor: String? = null,
- val isLast: Boolean,
+ val isLast: Boolean = false,
)
@@
- val profileImageUrl: String?,
+ val profileImageUrl: String? = null,
@@
- val voteItems: List<VoteItems>,
+ val voteItems: List<VoteItems> = emptyList(),비투표형 포스트에서 voteItems가 누락되더라도 디코딩이 안전해집니다. Also applies to: 23-24, 30-31 🤖 Prompt for AI Agents |
||
|
|
||
| @Serializable | ||
| data class PostList( | ||
| val postId: Int, | ||
| val postDate: String, | ||
| val postType: String, | ||
| val page: Int, | ||
| val userId: Int, | ||
| val nickName: String, | ||
| val profileImageUrl: String?, | ||
| val content: String, | ||
| val likeCount: Int, | ||
| val commentCount: Int, | ||
| val isLiked: Boolean, | ||
| val isWriter: Boolean, | ||
| val isLocked: Boolean, | ||
| val voteItems: List<VoteItems>, | ||
| ) | ||
|
|
||
| @Serializable | ||
| data class VoteItems( | ||
| val voteItemId: Int, | ||
| val itemName: String, | ||
| val percentage: Int, | ||
| val isVoted: Boolean, | ||
| ) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package com.texthip.thip.data.model.rooms.response | ||
|
|
||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class RoomsRecordResponse( | ||
| val recordId: Int, | ||
| val roomId: Int, | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package com.texthip.thip.data.model.rooms.response | ||
|
|
||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class RoomsVoteResponse( | ||
| val voteItemId: Int, | ||
| val roomId: Int, | ||
| val type: Boolean, | ||
| ) | ||
|
Comment on lines
+5
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion 응답 불리언 필드 요청/응답 모델 모두 동일한 도메인 용어를 사용하면 이해가 쉬워집니다. 요청과 동일하게 다음 변경을 제안합니다: package com.texthip.thip.data.model.rooms.response
import kotlinx.serialization.Serializable
+import kotlinx.serialization.SerialName
@Serializable
data class RoomsVoteResponse(
val voteItemId: Int,
val roomId: Int,
- val type: Boolean,
+ @SerialName("type")
+ val isSelected: Boolean,
)🤖 Prompt for AI Agents |
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,6 +1,11 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| package com.texthip.thip.data.repository | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.texthip.thip.data.model.base.handleBaseResponse | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.texthip.thip.data.model.rooms.request.RoomsCreateVoteRequest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.texthip.thip.data.model.rooms.request.RoomsPostsLikesRequest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.texthip.thip.data.model.rooms.request.RoomsRecordRequest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.texthip.thip.data.model.rooms.request.RoomsVoteRequest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.texthip.thip.data.model.rooms.request.VoteItem | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.texthip.thip.data.service.RoomsService | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import javax.inject.Inject | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import javax.inject.Singleton | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -24,4 +29,108 @@ class RoomsRepository @Inject constructor( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| roomId = roomId | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ).handleBaseResponse().getOrThrow() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| suspend fun getRoomsPosts( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| roomId: Int, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: String = "group", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sort: String? = "latest", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+35
to
+36
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chain기본 파라미터 값 검증 필요
🏁 Script executed: #!/bin/bash
# Description: API가 지원하는 정렬 옵션 확인
# swagger 문서나 API 명세 파일 검색
fd -e json -e yaml -e md | xargs rg -A 5 "sort.*latest|sorting.*options"
# 정렬 관련 상수나 enum 확인
ast-grep --pattern 'enum $_SortType {
$$$
}'
# 정렬 관련 타입 정의 확인
rg -A 3 "enum.*Sort|object.*Sort|companion.*Sort"Length of output: 496 🏁 Script executed: #!/bin/bash
# Display full enum entries for supported sort options
sed -n '1,200p' app/src/main/java/com/texthip/thip/utils/type/SortType.ktLength of output: 546 🏁 Script executed: #!/bin/bash
# Show context around the sort parameter in RoomsRepository
sed -n '1,100p' app/src/main/java/com/texthip/thip/data/repository/RoomsRepository.ktLength of output: 3014 🏁 Script executed: #!/bin/bash
# Locate and display the service interface for getRoomsPosts
file="$(rg -l 'interface RoomsService' -g '*.kt')"
echo "RoomsService file: $file"
sed -n '1,200p' "$file" | sed -n '/getRoomsPosts/,/)/p'Length of output: 469 Sort 파라미터에 enum 기반 검증 추가 필요 현재 수정 포인트:
예시 diff: @@ RoomsRepository.kt
- suspend fun getRoomsPosts(
- roomId: Int,
- type: String = "group",
- sort: String? = "latest",
+ suspend fun getRoomsPosts(
+ roomId: Int,
+ type: String = "group",
+ sort: SortType = SortType.LATEST,
pageStart: Int? = null,
pageEnd: Int? = null,
isOverview: Boolean? = false,
isPageFilter: Boolean? = false,
cursor: String? = null,
) = runCatching {
roomsService.getRoomsPosts(
roomId = roomId,
type = type,
- sort = sort,
+ sort = sort.apiKey,
pageStart = pageStart,
pageEnd = pageEnd,
isOverview = isOverview,
isPageFilter = isPageFilter,
cursor = cursor
).handleBaseResponse().getOrThrow()
}이렇게 변경하면
📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pageStart: Int? = null, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pageEnd: Int? = null, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isOverview: Boolean? = false, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isPageFilter: Boolean? = false, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cursor: String? = null, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) = runCatching { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| roomsService.getRoomsPosts( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| roomId = roomId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type = type, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sort = sort, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pageStart = pageStart, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pageEnd = pageEnd, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isOverview = isOverview, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isPageFilter = isPageFilter, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cursor = cursor | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ).handleBaseResponse().getOrThrow() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| suspend fun postRoomsRecord( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| roomId: Int, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| content: String, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isOverview: Boolean = false, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| page: Int = 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) = runCatching { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| roomsService.postRoomsRecord( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| roomId = roomId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| request = RoomsRecordRequest( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| page = page, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isOverview = isOverview, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| content = content | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ).handleBaseResponse().getOrThrow() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| suspend fun postRoomsCreateVote( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| roomId: Int, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| page: Int, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isOverview: Boolean, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| content: String, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| voteItemList: List<VoteItem> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) = runCatching { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| roomsService.postRoomsCreateVote( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| roomId = roomId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| request = RoomsCreateVoteRequest( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| page = page, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isOverview = isOverview, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| content = content, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| voteItemList = voteItemList | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ).handleBaseResponse().getOrThrow() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| suspend fun getRoomsBookPage( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| roomId: Int, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) = runCatching { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| roomsService.getRoomsBookPage( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| roomId = roomId | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ).handleBaseResponse().getOrThrow() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| suspend fun postRoomsVote( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| roomId: Int, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| voteId: Int, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| voteItemId: Int, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: Boolean | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) = runCatching { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+101
to
+102
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Boolean 타입 파라미터명 일관성 부족
파라미터명을 더 명확하게 변경하는 것을 권장합니다: suspend fun postRoomsVote(
roomId: Int,
voteId: Int,
voteItemId: Int,
- type: Boolean
+ isVoteFor: Boolean // 또는 isPositiveVote, isAgree 등
) = runCatching {
roomsService.postRoomsVote(
roomId = roomId,
voteId = voteId,
request = RoomsVoteRequest(
voteItemId = voteItemId,
- type = type
+ type = isVoteFor
)
).handleBaseResponse().getOrThrow()
}📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| roomsService.postRoomsVote( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| roomId = roomId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| voteId = voteId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| request = RoomsVoteRequest( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| voteItemId = voteItemId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type = type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ).handleBaseResponse().getOrThrow() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| suspend fun deleteRoomsRecord( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| roomId: Int, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| recordId: Int | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) = runCatching { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| roomsService.deleteRoomsRecord( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| roomId = roomId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| recordId = recordId | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ).handleBaseResponse().getOrThrow() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| suspend fun postRoomsPostsLikes( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| postId: Int, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: Boolean, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| roomPostType: String | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) = runCatching { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| roomsService.postRoomsPostsLikes( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| postId = postId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| request = RoomsPostsLikesRequest( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type = type, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| roomPostType = roomPostType | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ).handleBaseResponse().getOrThrow() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,10 +1,25 @@ | ||||||||||||
| package com.texthip.thip.data.service | ||||||||||||
|
|
||||||||||||
| import com.texthip.thip.data.model.base.BaseResponse | ||||||||||||
| import com.texthip.thip.data.model.rooms.request.RoomsCreateVoteRequest | ||||||||||||
| import com.texthip.thip.data.model.rooms.request.RoomsPostsLikesRequest | ||||||||||||
| import com.texthip.thip.data.model.rooms.request.RoomsRecordRequest | ||||||||||||
| import com.texthip.thip.data.model.rooms.request.RoomsVoteRequest | ||||||||||||
| import com.texthip.thip.data.model.rooms.response.RoomsBookPageResponse | ||||||||||||
| import com.texthip.thip.data.model.rooms.response.RoomsCreateVoteResponse | ||||||||||||
| import com.texthip.thip.data.model.rooms.response.RoomsDeleteRecordResponse | ||||||||||||
| import com.texthip.thip.data.model.rooms.response.RoomsPlayingResponse | ||||||||||||
| import com.texthip.thip.data.model.rooms.response.RoomsPostsLikesResponse | ||||||||||||
| import com.texthip.thip.data.model.rooms.response.RoomsPostsResponse | ||||||||||||
| import com.texthip.thip.data.model.rooms.response.RoomsRecordResponse | ||||||||||||
| import com.texthip.thip.data.model.rooms.response.RoomsUsersResponse | ||||||||||||
| import com.texthip.thip.data.model.rooms.response.RoomsVoteResponse | ||||||||||||
| import retrofit2.http.Body | ||||||||||||
| import retrofit2.http.DELETE | ||||||||||||
| import retrofit2.http.GET | ||||||||||||
| import retrofit2.http.POST | ||||||||||||
| import retrofit2.http.Path | ||||||||||||
| import retrofit2.http.Query | ||||||||||||
|
|
||||||||||||
| interface RoomsService { | ||||||||||||
| @GET("rooms/{roomId}/playing") | ||||||||||||
|
|
@@ -16,4 +31,52 @@ interface RoomsService { | |||||||||||
| suspend fun getRoomsUsers( | ||||||||||||
| @Path("roomId") roomId: Int | ||||||||||||
| ): BaseResponse<RoomsUsersResponse> | ||||||||||||
|
|
||||||||||||
| @GET("rooms/{roomId}/posts") | ||||||||||||
| suspend fun getRoomsPosts( | ||||||||||||
| @Path("roomId") roomId: Int, | ||||||||||||
| @Query("type") type: String = "group", | ||||||||||||
| @Query("sort") sort: String? = "latest", | ||||||||||||
| @Query("pageStart") pageStart: Int? = null, | ||||||||||||
| @Query("pageEnd") pageEnd: Int? = null, | ||||||||||||
| @Query("isOverview") isOverview: Boolean? = false, | ||||||||||||
| @Query("isPageFilter") isPageFilter: Boolean? = false, | ||||||||||||
| @Query("cursor") cursor: String? = null, | ||||||||||||
| ): BaseResponse<RoomsPostsResponse> | ||||||||||||
|
|
||||||||||||
| @POST("rooms/{roomId}/record") | ||||||||||||
| suspend fun postRoomsRecord( | ||||||||||||
| @Path("roomId") roomId: Int, | ||||||||||||
| @Body request: RoomsRecordRequest | ||||||||||||
| ): BaseResponse<RoomsRecordResponse> | ||||||||||||
|
|
||||||||||||
| @POST("rooms/{roomId}/vote") | ||||||||||||
| suspend fun postRoomsCreateVote( | ||||||||||||
| @Path("roomId") roomId: Int, | ||||||||||||
| @Body request: RoomsCreateVoteRequest | ||||||||||||
| ): BaseResponse<RoomsCreateVoteResponse> | ||||||||||||
|
|
||||||||||||
| @GET("rooms/{roomId}/book-page") | ||||||||||||
| suspend fun getRoomsBookPage( | ||||||||||||
| @Path("roomId") roomId: Int, | ||||||||||||
| ): BaseResponse<RoomsBookPageResponse> | ||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 불필요한 trailing comma 제거 Line 62의 - @Path("roomId") roomId: Int,
+ @Path("roomId") roomId: Int📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||
|
|
||||||||||||
| @POST("rooms/{roomId}/vote/{voteId}") | ||||||||||||
| suspend fun postRoomsVote( | ||||||||||||
| @Path("roomId") roomId: Int, | ||||||||||||
| @Path("voteId") voteId: Int, | ||||||||||||
| @Body request: RoomsVoteRequest | ||||||||||||
| ): BaseResponse<RoomsVoteResponse> | ||||||||||||
|
|
||||||||||||
| @DELETE("rooms/{roomId}/record/{recordId}") | ||||||||||||
| suspend fun deleteRoomsRecord( | ||||||||||||
| @Path("roomId") roomId: Int, | ||||||||||||
| @Path("recordId") recordId: Int | ||||||||||||
| ): BaseResponse<RoomsDeleteRecordResponse> | ||||||||||||
|
|
||||||||||||
| @POST("room-posts/{postId}/likes") | ||||||||||||
| suspend fun postRoomsPostsLikes( | ||||||||||||
| @Path("postId") postId: Int, | ||||||||||||
| @Body request: RoomsPostsLikesRequest | ||||||||||||
| ): BaseResponse<RoomsPostsLikesResponse> | ||||||||||||
| } | ||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
roomPostType 유효값 검증 위치 확인
문자열을 유지한다면 어디선가 유효값 검증이 필요합니다(예: 레포지토리에서 화이트리스트). 누락 시 서버 4xx/5xx 유발 가능.
레포지토리에서 검증/정규화가 있는지 점검해 주세요:
🏁 Script executed:
Length of output: 1210
roomPostType 값 검증 추가 필요
현재
RoomsPostsLikesRequest에 전달되는roomPostType은 String 형태로만 정의되어 있으며, 호출 지점이나 repository/service 계층 어디에서도 허용 가능한 값(화이트리스트 등)을 검증하는 로직이 없습니다. 검증이 빠질 경우 잘못된 값 전송 시 서버에서 4xx/5xx 에러가 발생할 수 있습니다.검토가 필요한 주요 위치:
RoomsPostsLikesRequest생성부)postType전달부)repository 또는 service 계층에서 enum 클래스, 화이트리스트 체크 등으로 유효값 검증/정규화를 추가해 주세요.
🤖 Prompt for AI Agents