|
@@ -26,6 +26,7 @@ import org.elasticsearch.index.query.BoolQueryBuilder;
|
|
|
import org.elasticsearch.index.query.MatchAllQueryBuilder;
|
|
|
import org.elasticsearch.index.query.QueryBuilders;
|
|
|
import org.elasticsearch.index.reindex.DeleteByQueryRequest;
|
|
|
+import org.elasticsearch.rest.BaseRestHandler;
|
|
|
import org.elasticsearch.search.SearchHit;
|
|
|
import org.elasticsearch.search.builder.SearchSourceBuilder;
|
|
|
import org.elasticsearch.xcontent.XContentBuilder;
|
|
@@ -38,6 +39,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author "杨旭朋"
|
|
@@ -378,4 +380,19 @@ public class ESCourseService {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ public List<MongoDBCourse> searchLogs(){
|
|
|
+ List<MongoDBCourse> all = esService.findAll();
|
|
|
+ List<MongoDBCourse> mongoDBCourses = new ArrayList<>();
|
|
|
+ for (MongoDBCourse mongoDBCourse : all) {
|
|
|
+ if (mongoDBCourse.getUid().equals(1L)){
|
|
|
+ mongoDBCourses.add(mongoDBCourse);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 按 createTime 降序排序并取最多 10 条数据
|
|
|
+ List<MongoDBCourse> sortedCourses = mongoDBCourses.stream()
|
|
|
+ .sorted(Comparator.comparing(MongoDBCourse::getCreateTime).reversed())
|
|
|
+ .limit(10)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ return sortedCourses;
|
|
|
+ }
|
|
|
}
|