-
Notifications
You must be signed in to change notification settings - Fork 0
feat(#20): 채팅 서비스 레이어 기본 뼈대 구현 #21
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
src/main/java/com/example/RealMatch/chat/application/service/ChatService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| package com.example.RealMatch.chat.application.service; | ||
|
|
||
| import org.springframework.web.multipart.MultipartFile; | ||
|
|
||
| import com.example.RealMatch.chat.presentation.conversion.MessageCursor; | ||
| import com.example.RealMatch.chat.presentation.conversion.RoomCursor; | ||
| import com.example.RealMatch.chat.presentation.dto.enums.ChatRoomFilterStatus; | ||
| import com.example.RealMatch.chat.presentation.dto.enums.ChatRoomSort; | ||
| import com.example.RealMatch.chat.presentation.dto.enums.ChatRoomTab; | ||
| import com.example.RealMatch.chat.presentation.dto.enums.ChatSystemMessageKind; | ||
| import com.example.RealMatch.chat.presentation.dto.request.ChatAttachmentUploadRequest; | ||
| import com.example.RealMatch.chat.presentation.dto.request.ChatRoomCreateRequest; | ||
| import com.example.RealMatch.chat.presentation.dto.response.ChatAttachmentUploadResponse; | ||
| import com.example.RealMatch.chat.presentation.dto.response.ChatMessageListResponse; | ||
| import com.example.RealMatch.chat.presentation.dto.response.ChatMessageResponse; | ||
| import com.example.RealMatch.chat.presentation.dto.response.ChatRoomCreateResponse; | ||
| import com.example.RealMatch.chat.presentation.dto.response.ChatRoomDetailResponse; | ||
| import com.example.RealMatch.chat.presentation.dto.response.ChatRoomListResponse; | ||
| import com.example.RealMatch.chat.presentation.dto.response.ChatSystemMessagePayload; | ||
| import com.example.RealMatch.global.config.jwt.CustomUserDetails; | ||
|
|
||
| public interface ChatService { | ||
| ChatRoomCreateResponse createOrGetRoom(CustomUserDetails user, ChatRoomCreateRequest request); | ||
|
|
||
| ChatRoomListResponse getRoomList( | ||
| CustomUserDetails user, | ||
| ChatRoomTab tab, | ||
| ChatRoomFilterStatus filterStatus, | ||
| ChatRoomSort sort, | ||
| RoomCursor roomCursor, | ||
| int size | ||
| ); | ||
|
|
||
| ChatRoomDetailResponse getRoomDetail(CustomUserDetails user, Long roomId); | ||
|
|
||
| ChatMessageListResponse getMessages( | ||
| CustomUserDetails user, | ||
| Long roomId, | ||
| MessageCursor messageCursor, | ||
| int size | ||
| ); | ||
|
|
||
| ChatAttachmentUploadResponse uploadAttachment( | ||
| CustomUserDetails user, | ||
| ChatAttachmentUploadRequest request, | ||
| MultipartFile file | ||
| ); | ||
|
|
||
| ChatMessageResponse createSystemMessage( | ||
| Long roomId, | ||
| ChatSystemMessageKind kind, | ||
| ChatSystemMessagePayload payload | ||
| ); | ||
| } |
76 changes: 76 additions & 0 deletions
76
src/main/java/com/example/RealMatch/chat/application/service/ChatServiceImpl.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| package com.example.RealMatch.chat.application.service; | ||
|
|
||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.web.multipart.MultipartFile; | ||
|
|
||
| import com.example.RealMatch.chat.presentation.controller.fixture.ChatFixtureFactory; | ||
| import com.example.RealMatch.chat.presentation.conversion.MessageCursor; | ||
| import com.example.RealMatch.chat.presentation.conversion.RoomCursor; | ||
| import com.example.RealMatch.chat.presentation.dto.enums.ChatRoomFilterStatus; | ||
| import com.example.RealMatch.chat.presentation.dto.enums.ChatRoomSort; | ||
| import com.example.RealMatch.chat.presentation.dto.enums.ChatRoomTab; | ||
| import com.example.RealMatch.chat.presentation.dto.enums.ChatSystemMessageKind; | ||
| import com.example.RealMatch.chat.presentation.dto.request.ChatAttachmentUploadRequest; | ||
| import com.example.RealMatch.chat.presentation.dto.request.ChatRoomCreateRequest; | ||
| import com.example.RealMatch.chat.presentation.dto.response.ChatAttachmentUploadResponse; | ||
| import com.example.RealMatch.chat.presentation.dto.response.ChatMessageListResponse; | ||
| import com.example.RealMatch.chat.presentation.dto.response.ChatMessageResponse; | ||
| import com.example.RealMatch.chat.presentation.dto.response.ChatRoomCreateResponse; | ||
| import com.example.RealMatch.chat.presentation.dto.response.ChatRoomDetailResponse; | ||
| import com.example.RealMatch.chat.presentation.dto.response.ChatRoomListResponse; | ||
| import com.example.RealMatch.chat.presentation.dto.response.ChatSystemMessagePayload; | ||
| import com.example.RealMatch.global.config.jwt.CustomUserDetails; | ||
|
|
||
| @Service | ||
| public class ChatServiceImpl implements ChatService { | ||
|
|
||
| @Override | ||
| public ChatRoomCreateResponse createOrGetRoom(CustomUserDetails user, ChatRoomCreateRequest request) { | ||
| return ChatFixtureFactory.sampleRoomCreateResponse(); | ||
| } | ||
|
|
||
| @Override | ||
| public ChatRoomListResponse getRoomList( | ||
| CustomUserDetails user, | ||
| ChatRoomTab tab, | ||
| ChatRoomFilterStatus filterStatus, | ||
| ChatRoomSort sort, | ||
| RoomCursor roomCursor, | ||
| int size | ||
| ) { | ||
| return ChatFixtureFactory.sampleRoomListResponse(); | ||
| } | ||
|
|
||
| @Override | ||
| public ChatRoomDetailResponse getRoomDetail(CustomUserDetails user, Long roomId) { | ||
| return ChatFixtureFactory.sampleRoomDetailResponse(roomId); | ||
| } | ||
|
|
||
| @Override | ||
| public ChatMessageListResponse getMessages( | ||
| CustomUserDetails user, | ||
| Long roomId, | ||
| MessageCursor messageCursor, | ||
| int size | ||
| ) { | ||
| return ChatFixtureFactory.sampleMessageListResponse(roomId); | ||
| } | ||
|
|
||
| @Override | ||
| public ChatAttachmentUploadResponse uploadAttachment( | ||
| CustomUserDetails user, | ||
| ChatAttachmentUploadRequest request, | ||
| MultipartFile file | ||
| ) { | ||
| return ChatFixtureFactory.sampleAttachmentUploadResponse(request, file); | ||
| } | ||
|
|
||
| @Override | ||
| public ChatMessageResponse createSystemMessage( | ||
| Long roomId, | ||
| ChatSystemMessageKind kind, | ||
| ChatSystemMessagePayload payload | ||
| ) { | ||
| return ChatFixtureFactory.sampleSystemMessageResponse(roomId, kind, payload); | ||
| } | ||
| } | ||
22 changes: 22 additions & 0 deletions
22
src/main/java/com/example/RealMatch/chat/application/service/ChatSocketService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package com.example.RealMatch.chat.application.service; | ||
|
|
||
| import org.springframework.lang.NonNull; | ||
|
|
||
| import com.example.RealMatch.chat.presentation.dto.enums.ChatSystemMessageKind; | ||
| import com.example.RealMatch.chat.presentation.dto.response.ChatSystemMessagePayload; | ||
| import com.example.RealMatch.chat.presentation.dto.websocket.ChatMessageCreatedEvent; | ||
| import com.example.RealMatch.chat.presentation.dto.websocket.ChatSendMessageAck; | ||
| import com.example.RealMatch.chat.presentation.dto.websocket.ChatSendMessageCommand; | ||
|
|
||
| public interface ChatSocketService { | ||
| @NonNull | ||
| ChatMessageCreatedEvent createMessageEvent(ChatSendMessageCommand command); | ||
|
|
||
| ChatSendMessageAck createAck(ChatSendMessageCommand command, Long messageId); | ||
|
|
||
| ChatMessageCreatedEvent createSystemMessageEvent( | ||
| Long roomId, | ||
| ChatSystemMessageKind kind, | ||
| ChatSystemMessagePayload payload | ||
| ); | ||
| } |
40 changes: 40 additions & 0 deletions
40
src/main/java/com/example/RealMatch/chat/application/service/ChatSocketServiceImpl.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| package com.example.RealMatch.chat.application.service; | ||
|
|
||
| import java.util.Objects; | ||
|
|
||
| import org.springframework.lang.NonNull; | ||
| import org.springframework.stereotype.Service; | ||
|
|
||
| import com.example.RealMatch.chat.presentation.controller.fixture.ChatSocketFixtureFactory; | ||
| import com.example.RealMatch.chat.presentation.dto.enums.ChatSystemMessageKind; | ||
| import com.example.RealMatch.chat.presentation.dto.response.ChatSystemMessagePayload; | ||
| import com.example.RealMatch.chat.presentation.dto.websocket.ChatMessageCreatedEvent; | ||
| import com.example.RealMatch.chat.presentation.dto.websocket.ChatSendMessageAck; | ||
| import com.example.RealMatch.chat.presentation.dto.websocket.ChatSendMessageCommand; | ||
|
|
||
| @Service | ||
| public class ChatSocketServiceImpl implements ChatSocketService { | ||
|
|
||
| @Override | ||
| @NonNull | ||
| public ChatMessageCreatedEvent createMessageEvent(ChatSendMessageCommand command) { | ||
| return Objects.requireNonNull( | ||
| ChatSocketFixtureFactory.sampleMessageCreatedEvent(command), | ||
| "ChatMessageCreatedEvent must not be null." | ||
| ); | ||
| } | ||
|
|
||
| @Override | ||
| public ChatSendMessageAck createAck(ChatSendMessageCommand command, Long messageId) { | ||
| return ChatSocketFixtureFactory.sampleAck(command, messageId); | ||
| } | ||
|
|
||
| @Override | ||
| public ChatMessageCreatedEvent createSystemMessageEvent( | ||
| Long roomId, | ||
| ChatSystemMessageKind kind, | ||
| ChatSystemMessagePayload payload | ||
| ) { | ||
| throw new UnsupportedOperationException("Not implemented yet."); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.