Skip to content
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

Merged
merged 21 commits into from
Jun 2, 2024

Conversation

minisundev
Copy link
Member

#️⃣연관된 이슈

#122

📝작업 내용

서버 전체 채팅 조회 기능을 개발했습니다

@minisundev minisundev added enhancement 추가 기능 API 상세 api 문서 Chat 채팅 관련 기능 labels Jun 2, 2024
@minisundev minisundev added this to the MSA 채팅 서비스 개발 milestone Jun 2, 2024
@minisundev minisundev requested a review from a team June 2, 2024 08:58
@minisundev minisundev self-assigned this Jun 2, 2024
Comment on lines 41 to 46
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)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기는 chattype이 없네요?

Copy link
Member Author

@minisundev minisundev Jun 2, 2024

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되지 않아서 쓸 수 없었어요..!

Comment on lines 39 to 46
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)
}
Copy link
Contributor

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을 안써도 괜찮을 것 같아요.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

좋네요~!

Comment on lines 87 to 100
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

확장된 기능이 아니라면 private하는 것은 어떨까요?

Copy link
Member Author

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ServiceException을 사용하지 않고 GlobalException을 사용하신 이유가 있을까요?

Copy link
Member Author

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)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

가독성을 위해서 라인을 구분해주시면 더 좋을 것 같아요.

Copy link
Member Author

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(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

가독성을 위해서 라인을 구분해주시면 더 좋을 것 같아요.

@yudonggeun
Copy link
Contributor

main말고 dev로 pr 생성해서 머지해주세요

@minisundev
Copy link
Member Author

main말고 dev로 pr 생성해서 머지해주세요

@minisundev minisundev changed the base branch from main to dev June 2, 2024 11:33
@minisundev minisundev merged commit a7a2807 into kSideProject:dev Jun 2, 2024
1 check passed
@yudonggeun
Copy link
Contributor

pr에서 동적으로 브랜치 바꾸는거 처음 알았어요

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API 상세 api 문서 Chat 채팅 관련 기능 enhancement 추가 기능
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants