opencv/src/main/java/pl/edu/amu/wmi/bookapi/repositories/ThreadRepositoryCustomImpl....

32 lines
1.0 KiB
Java

package pl.edu.amu.wmi.bookapi.repositories;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Component;
import pl.edu.amu.wmi.bookapi.models.ThreadDocument;
import java.util.List;
@Component
public class ThreadRepositoryCustomImpl implements ThreadRepositoryCustom {
MongoTemplate mongoTemplate;
@Autowired
public ThreadRepositoryCustomImpl(MongoTemplate mongoTemplate) {
this.mongoTemplate = mongoTemplate;
}
@Override
public List<ThreadDocument> findByParticipants(String participantId1, String participantId2) {
Query query = new Query();
query.addCriteria(
Criteria.where("participantsIds").all(List.of(participantId1, participantId2))
);
return mongoTemplate.find(query, ThreadDocument.class);
}
}