-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from L1nkWave/feature/LWB-45_messages-pagination
feature/LWB-45_messages-pagination
- Loading branch information
Showing
14 changed files
with
433 additions
and
80 deletions.
There are no files selected for viewing
This file contains 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
6 changes: 3 additions & 3 deletions
6
backend/chat-service/src/main/java/org/linkwave/chatservice/chat/ChatMemberDto.java
This file contains 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 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 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
13 changes: 13 additions & 0 deletions
13
backend/chat-service/src/main/java/org/linkwave/chatservice/message/FetchMessageMapping.java
This file contains 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,13 @@ | ||
package org.linkwave.chatservice.message; | ||
|
||
import org.linkwave.chatservice.api.users.UserDto; | ||
import org.modelmapper.ModelMapper; | ||
import org.springframework.lang.NonNull; | ||
|
||
import java.util.Map; | ||
|
||
public interface FetchMessageMapping { | ||
|
||
MessageDto mapForFetch(@NonNull ModelMapper modelMapper, Long fetcherUserId, Map<Long, UserDto> users); | ||
|
||
} |
This file contains 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 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 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
21 changes: 21 additions & 0 deletions
21
backend/chat-service/src/main/java/org/linkwave/chatservice/message/MessageRepository.java
This file contains 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 |
---|---|---|
@@ -1,14 +1,35 @@ | ||
package org.linkwave.chatservice.message; | ||
|
||
import org.springframework.data.mongodb.repository.Aggregation; | ||
import org.springframework.data.mongodb.repository.MongoRepository; | ||
import org.springframework.data.mongodb.repository.Query; | ||
import org.springframework.data.querydsl.QuerydslPredicateExecutor; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.List; | ||
|
||
@Repository | ||
public interface MessageRepository extends MongoRepository<Message, String>, QuerydslPredicateExecutor<Message> { | ||
|
||
@Query(value = "{ 'chat.$id': { $eq: ObjectId(?0) } }", delete = true) | ||
void deleteAllChatMessages(String chatId); | ||
|
||
@Aggregation( | ||
pipeline = {""" | ||
{ | ||
$match: { | ||
'chat.$id': { $eq: ObjectId(?0) } | ||
} | ||
} | ||
""", | ||
"{ $sort: { createdAt: -1 } }", | ||
"{ $skip : ?1 }", | ||
"{ $limit : ?2 }" | ||
} | ||
) | ||
List<Message> getMessages(String chatId, int offset, int limit); | ||
|
||
@Query(value = "{ 'chat.$id': { $eq: ObjectId(?0) } }", count = true) | ||
long getChatMessagesCount(String chatId); | ||
|
||
} |
This file contains 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.