-
Notifications
You must be signed in to change notification settings - Fork 3
채널 UnSubscribe 및 DisConnect 시 Last Read Message ID 저장 #231
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
Show all changes
16 commits
Select commit
Hold shift + click to select a range
b9d4122
#221 refactor(be): Mongo Index background 옵션 deprecated
ki-met-hoon 9c4d25b
#221 build(be): JDBC, mongo 의존성 추가
ki-met-hoon 00cdf97
#221 remove(be): 사용하지 않는 import 삭제
ki-met-hoon 4c3b9b6
#221 style(be): repository 패키지 이동
ki-met-hoon f3ae5c8
#221 feat(be): ChatMessage 복합 인덱스 생성
ki-met-hoon 15012a2
#221 build(be): yml 의존성 추가
ki-met-hoon 94a3188
#221 style(be): jpa 패키지 이동
ki-met-hoon 4ed0df3
#221 feat(be): ChatMessageRepository 구현
ki-met-hoon 74d41b5
#221 feat(be): UserChannelRepository 구현
ki-met-hoon 97609d5
#221 feat(be): ChatMessage Document 구현
ki-met-hoon 08d0db4
#221 feat(be): Message DTO 구현
ki-met-hoon bcea09e
#221 feat(be): handleChatUnsubscription 내 updateLastReadId 추가
ki-met-hoon a8cb173
feat(be): handleUserDisconnection 내 handleChatUnsubscriptionmethod 추가
ki-met-hoon 3d5432e
Merge branch 'dev' into be-feat/unread-message
ki-met-hoon 703762c
#221 refactor(be): null 시 Default_id 값 등록 로직 구현
ki-met-hoon d3fd75b
Merge branch 'be-feat/unread-message' of https://github.com/sgdevcamp…
ki-met-hoon 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
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
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
41 changes: 41 additions & 0 deletions
41
src/backend/chat_server/src/main/java/com/jootalkpia/chat_server/domain/ChatMessage.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,41 @@ | ||
| package com.jootalkpia.chat_server.domain; | ||
|
|
||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import org.springframework.data.annotation.Id; | ||
| import org.springframework.data.mongodb.core.index.CompoundIndex; | ||
| import org.springframework.data.mongodb.core.mapping.Document; | ||
| import org.springframework.data.mongodb.core.mapping.Field; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @Getter | ||
| @Builder | ||
| @Document(collection = "chat_messages") | ||
| @CompoundIndex(name = "channel_thread_idx", def = "{'channel_id': 1, 'thread_id': -1}") | ||
| public class ChatMessage extends BaseTimeEntity { | ||
|
|
||
| @Id | ||
| private String id; // MongoDB의 ObjectId 자동 생성 | ||
|
|
||
| @Field("channel_id") | ||
| private Long channelId; | ||
|
|
||
| @Field("thread_id") | ||
| private Long threadId; | ||
|
|
||
| @Field("thread_date_time") | ||
| private String threadDateTime; | ||
|
|
||
| @Field("user_id") | ||
| private Long userId; | ||
|
|
||
| @Field("user_nickname") | ||
| private String userNickname; | ||
|
|
||
| @Field("user_profile_image") | ||
| private String userProfileImage; | ||
|
|
||
| @Field("messages") | ||
| private List<Message> messages; | ||
| } |
32 changes: 32 additions & 0 deletions
32
src/backend/chat_server/src/main/java/com/jootalkpia/chat_server/domain/Message.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,32 @@ | ||
| package com.jootalkpia.chat_server.domain; | ||
|
|
||
| import lombok.*; | ||
| import org.springframework.data.mongodb.core.mapping.Field; | ||
|
|
||
| @Getter | ||
| @Builder | ||
| public class Message { | ||
| @Field("type") | ||
| private String type; | ||
|
|
||
| @Field("text") | ||
| private String text; | ||
|
|
||
| @Field("image_id") | ||
| private Long imageId; | ||
|
|
||
| @Field("image_url") | ||
| private String imageUrl; | ||
|
|
||
| @Field("video_id") | ||
| private Long videoId; | ||
|
|
||
| @Field("video_thumbnail_id") | ||
| private Long videoThumbnailId; | ||
|
|
||
| @Field("thumbnail_url") | ||
| private String thumbnailUrl; | ||
|
|
||
| @Field("video_url") | ||
| private String videoUrl; | ||
| } |
13 changes: 2 additions & 11 deletions
13
src/backend/chat_server/src/main/java/com/jootalkpia/chat_server/domain/User.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
18 changes: 18 additions & 0 deletions
18
...hat_server/src/main/java/com/jootalkpia/chat_server/repository/UserChannelRepository.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,18 @@ | ||
| package com.jootalkpia.chat_server.repository; | ||
|
|
||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.jdbc.core.JdbcTemplate; | ||
| import org.springframework.stereotype.Repository; | ||
|
|
||
| @Repository | ||
| @RequiredArgsConstructor | ||
| public class UserChannelRepository { | ||
| private final JdbcTemplate jdbcTemplate; | ||
|
|
||
| public void updateLastReadId(String userId, String channelId, Long lastReadId) { | ||
| String sql = "UPDATE user_channel SET last_read_id = ? " + | ||
| "WHERE user_id = ? AND channel_id = ?"; | ||
|
|
||
| jdbcTemplate.update(sql, lastReadId, Long.valueOf(userId), Long.valueOf(channelId)); | ||
|
Member
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. updateLastReadId가 실행될 때 해당 row가 DB에 존재하는지 보장되지 않아서 존재하지 않으면 아무 일도 안 일어날텐데 예외처리까지는 너무 과할까요?
Collaborator
Author
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. Optional 추가했고 없을 시 Default 값으로 0L 등록 로직 구현 완료했습니다! |
||
| } | ||
| } | ||
2 changes: 1 addition & 1 deletion
2
...hat_server/repository/FileRepository.java → ...server/repository/jpa/FileRepository.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
2 changes: 1 addition & 1 deletion
2
...t_server/repository/ThreadRepository.java → ...rver/repository/jpa/ThreadRepository.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
2 changes: 1 addition & 1 deletion
2
...hat_server/repository/UserRepository.java → ...server/repository/jpa/UserRepository.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
10 changes: 10 additions & 0 deletions
10
...rver/src/main/java/com/jootalkpia/chat_server/repository/mongo/ChatMessageRepository.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,10 @@ | ||
| package com.jootalkpia.chat_server.repository.mongo; | ||
|
|
||
| import com.jootalkpia.chat_server.domain.ChatMessage; | ||
| import org.springframework.data.mongodb.repository.MongoRepository; | ||
|
|
||
| import java.util.Optional; | ||
|
|
||
| public interface ChatMessageRepository extends MongoRepository<ChatMessage,String> { | ||
| Optional<ChatMessage> findFirstByChannelIdOrderByThreadIdDesc(Long channelId); | ||
| } |
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
8 changes: 6 additions & 2 deletions
8
...ackend/history_server/src/main/java/com/jootalkpia/history_server/domain/ChatMessage.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
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
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.
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.
해당 메서드 @transactional처리 안해줘도 될까요?
updateChannelFromSession, removeTabFromChannel, updateLastReadId 3개의 변경이 발생되고 있어서요!
하나라도 실패해도 될까요?
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.
현재 Redis 트랜잭션, 보상 트랜잭션 등 다양한 방안을 검토 중입니다!
추후에 리팩토링하겠습니다!