Added custom message repository
This commit is contained in:
parent
3b7f380b57
commit
4109acfab7
@ -6,7 +6,7 @@ import org.springframework.data.mongodb.repository.Query;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface MessageRepository extends MongoRepository<MessageDocument, String> {
|
public interface MessageRepository extends MongoRepository<MessageDocument, String>, MessageRepositoryCustom {
|
||||||
|
|
||||||
@Query("{ $and: [{'conversationId': ?1} , {$or: [{ 'authorId': ?0 },{ 'recipientId': ?0 }]}] }")
|
@Query("{ $and: [{'conversationId': ?1} , {$or: [{ 'authorId': ?0 },{ 'recipientId': ?0 }]}] }")
|
||||||
List<MessageDocument> findMessagesForUserAndConversation(String userId, String conversationId); // TODO: Test query or create a repository implementation
|
List<MessageDocument> findMessagesForUserAndConversation(String userId, String conversationId); // TODO: Test query or create a repository implementation
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
package com.fnecan.study.bookapi.repository;
|
||||||
|
|
||||||
|
import com.fnecan.study.bookapi.model.MessageDocument;
|
||||||
|
|
||||||
|
public interface MessageRepositoryCustom {
|
||||||
|
MessageDocument createMessage(
|
||||||
|
String message,
|
||||||
|
String authorId,
|
||||||
|
String recipientId
|
||||||
|
);
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
package com.fnecan.study.bookapi.repository;
|
||||||
|
|
||||||
|
import com.fnecan.study.bookapi.model.MessageDocument;
|
||||||
|
|
||||||
|
public class MessageRepositoryCustomImpl implements MessageRepositoryCustom {
|
||||||
|
@Override
|
||||||
|
public MessageDocument createMessage(String message, String authorId, String recipientId) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -21,4 +21,8 @@ public class MessageService {
|
|||||||
return messageRepository.findMessagesForUserAndConversation(userId, conversationId);
|
return messageRepository.findMessagesForUserAndConversation(userId, conversationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MessageDocument createMessage(String message, String authorId, String recipientId) {
|
||||||
|
return messageRepository.createMessage(message, authorId, recipientId);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user