-
Notifications
You must be signed in to change notification settings - Fork 6
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
[Chat] 서버 전체 채팅 조회 API 구현 GET api/v1/chat #145
[Chat] 서버 전체 채팅 조회 API 구현 GET api/v1/chat #145
Conversation
chore : dev 브랜치 추가로 인한 pr test 수정
if (type.equals("Room")) { | ||
result = chatService.getRoomChats(id, userId, page) | ||
} else if (type.equals("Server")) { | ||
val serverList = serverClient.getServerList(token, GetServerCondition()).body!!.data!! | ||
result = chatService.getServerChats(id, userId, page, serverList) | ||
} |
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.
여기는 chattype이 없네요?
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.
여기도 ChatType을 받을까 하다가 requestParam 방식으로 받게 되어서 저렇게 했는데 ChatType.ROOM.toString()이라도 쓰는게 나아보이긴 하네요~! 다시 보니 createServerChat할때 만든 ChatType이 merge되지 않아서 쓸 수 없었어요..!
var result: List<ChatResponse>? = null | ||
|
||
if (type.equals("Room")) { | ||
result = chatService.getRoomChats(id, userId, page) | ||
} else if (type.equals("Server")) { | ||
val serverList = serverClient.getServerList(token, GetServerCondition()).body!!.data!! | ||
result = chatService.getServerChats(id, userId, page, serverList) | ||
} |
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.
val result = when(type) {
"Server" -> return chatService.getRoomChats(id, userId, page)
"Room" -> return chatService.getServerList(token, ..)
}
when
을 이용하면 var
을 안써도 괜찮을 것 같아요.
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.
좋네요~!
fun convertRoomChatsToResponses(roomChats: List<RoomChat>): List<ChatResponse> { | ||
val chatResponse = | ||
roomChats.map { chat -> | ||
ChatResponse(chat.id!!, chat.isEdited(), chat.createdAt.toString(), chat.content) | ||
} | ||
return chatResponse | ||
} | ||
|
||
fun convertServerChatsToResponses(chats: List<ServerChat>): List<ChatResponse> { | ||
val chatResponse = | ||
chats.map { chat -> | ||
ChatResponse(chat.roomId, chat.isEdited(), chat.createdAt, chat.content) | ||
ChatResponse(chat.id!!, chat.isEdited(), chat.createdAt.toString(), chat.content) | ||
} | ||
return chatResponses | ||
return chatResponse |
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.
확장된 기능이 아니라면 private
하는 것은 어떨까요?
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.
좋은 지적이네요~!
return | ||
} | ||
} | ||
throw GlobalException(ErrorCode.FORBIDDEN_SERVER) |
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.
ServiceException
을 사용하지 않고 GlobalException
을 사용하신 이유가 있을까요?
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.
에러 핸들러를 추가할 필요가 없다고 생각해서 공용으로 쓰고 있었습니다~
.header("Authorization", "Bearer mock_token") | ||
.exchange() | ||
|
||
val docs = result.expectStatus().isOk.expectBody().json(om.writeValueAsString(ApiResponse(data = data))) |
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.
가독성을 위해서 라인을 구분해주시면 더 좋을 것 같아요.
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.
그러네요
// When | ||
val result = | ||
webTestClient.get().uri( | ||
URLBuilder(url).query("id", roomId).query("type", "Room").query("page", 1).build(), |
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.
가독성을 위해서 라인을 구분해주시면 더 좋을 것 같아요.
main말고 dev로 pr 생성해서 머지해주세요 |
네 |
pr에서 동적으로 브랜치 바꾸는거 처음 알았어요 |
#️⃣연관된 이슈
#122
📝작업 내용
서버 전체 채팅 조회 기능을 개발했습니다