|
@@ -329,7 +329,7 @@ public class SearchQueryServiceImpl implements SearchQueryService {
|
|
|
* @return JsonStr(list)
|
|
|
*/
|
|
|
@Override
|
|
|
- public ResponseJson<String> queryArticleByKeyword(String keyword, int pageNum, int pageSize) {
|
|
|
+ public ResponseJson<String> queryArticleByKeyword(String keyword, int pageNum, int pageSize,Integer status,String startDate,String endDate) {
|
|
|
String queryStr = "article:'" + keyword + "'";
|
|
|
if (StringUtils.isEmpty(keyword)) {
|
|
|
queryStr = "a_all:'1'";
|
|
@@ -350,7 +350,15 @@ public class SearchQueryServiceImpl implements SearchQueryService {
|
|
|
return result;
|
|
|
} else {
|
|
|
// 阿里云搜索失败,再次从数据库搜索
|
|
|
- return queryArticleFromDatabase(pageNum, pageSize, keyword, null, null, null);
|
|
|
+ //1.2.8版本新加根据时间排序
|
|
|
+ if(status==1){
|
|
|
+ //综合排序
|
|
|
+ return queryArticleFromDatabase(pageNum, pageSize, keyword, null, null, null);
|
|
|
+ }else {
|
|
|
+ //根据时间排序
|
|
|
+ return queryArticleFromDatabaseByProDate(pageNum, pageSize, keyword, null, null, null,startDate,endDate);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -464,6 +472,54 @@ public class SearchQueryServiceImpl implements SearchQueryService {
|
|
|
return ResponseJson.error("未查询到文档记录(数据库)", null);
|
|
|
}
|
|
|
}
|
|
|
+ /**1.2.8新加发布时间排序
|
|
|
+ * 文章查询(数据库)
|
|
|
+ *
|
|
|
+ * @param keyword 关键词
|
|
|
+ * @param articleId 文章Id
|
|
|
+ * @param typeId 分类Id
|
|
|
+ * @param labelId 标签Id
|
|
|
+ * @param num 页码
|
|
|
+ * @param size 每页数量
|
|
|
+ * @param startDate 开始时间
|
|
|
+ * @param endDate 结束时间
|
|
|
+ */
|
|
|
+ private ResponseJson<String> queryArticleFromDatabaseByProDate(int num, int size, String keyword, Integer articleId, Integer typeId, Integer labelId,String startDate,String endDate) {
|
|
|
+ String labelText = null;
|
|
|
+ if (null != labelId){
|
|
|
+ labelText = searchMapper.findLabelNameById(labelId);
|
|
|
+ }
|
|
|
+ PageHelper.startPage(num, size);
|
|
|
+ List<ArticleListVo> articleList = searchMapper.queryArticleByProDate(keyword, articleId, typeId, labelText,startDate,endDate);
|
|
|
+ articleList.forEach(article -> {
|
|
|
+ String imagePath = ImageUtils.getImageURL("", article.getImage(), 0, domain);
|
|
|
+ article.setImage(imagePath);
|
|
|
+ // 搜索供应商文档数据
|
|
|
+ String[] labelTexts = article.getLabelText().split(",");
|
|
|
+ if(labelTexts.length > 0){
|
|
|
+ boolean notEmpty = StringUtil.isNotEmpty(labelTexts[0]);
|
|
|
+ if(notEmpty){
|
|
|
+ List<Integer> labelIdList = searchMapper.findLabelIdsByName(labelTexts);
|
|
|
+ StringBuilder labelIds = new StringBuilder();
|
|
|
+ labelIdList.forEach(id -> {
|
|
|
+ labelIds.append(",").append(id);
|
|
|
+ });
|
|
|
+ article.setLabelIds(labelIds.toString().replaceFirst(",",""));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ PaginationVo<ArticleListVo> pageData = new PaginationVo<>(articleList);
|
|
|
+ int total = pageData.getTotalRecord();
|
|
|
+ JSONObject pageObj = new JSONObject();
|
|
|
+ pageObj.put("total", total);
|
|
|
+ pageObj.put("items", articleList);
|
|
|
+ log.info(">>>>>>数据库容错查询: pageSize(" + size +"),pageNum("+size+"),total("+total+")");
|
|
|
+ if (articleList.size()>0) {
|
|
|
+ return ResponseJson.success(pageObj.toString());
|
|
|
+ } else {
|
|
|
+ return ResponseJson.error("未查询到文档记录(数据库)", null);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 文章查询
|