|
@@ -357,7 +357,7 @@ public class SearchQueryServiceImpl implements SearchQueryService {
|
|
|
return queryArticleFromDatabase(pageNum, pageSize, keyword, null, null, null);
|
|
|
} else {
|
|
|
//根据时间排序
|
|
|
- return queryArticleFromDatabaseByProDate(pageNum, pageSize, keyword, null, null, null);
|
|
|
+ return queryArticleFromDatabaseByProDate(pageNum, pageSize, keyword, null, null, null,1);
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -392,16 +392,23 @@ public class SearchQueryServiceImpl implements SearchQueryService {
|
|
|
* @return JsonStr(list)
|
|
|
*/
|
|
|
@Override
|
|
|
- public ResponseJson<String> queryArticleByType(Integer id, int pageNum, int pageSize) {
|
|
|
+ public ResponseJson<String> queryArticleByType(Integer id, int pageNum, int pageSize,Integer sortType) {
|
|
|
String queryStr = "a_type:'" + id + "'";
|
|
|
ArrayList<String> fetchFields = Lists.newArrayList("id", "a_id", "a_title", "a_image", "a_publisher", "a_publish_date", "a_intro", "a_pv", "a_type_id", "a_type_text", "a_label_ids", "a_label_text");
|
|
|
// 阿里云搜索
|
|
|
- ResponseJson<String> result = scrollArticleForParams(queryStr, fetchFields, pageNum, pageSize, "a_id", 1);
|
|
|
+ String sort = null == sortType ?"a_id": "a_publish_date" ;
|
|
|
+ ResponseJson<String> result = scrollArticleForParams(queryStr, fetchFields, pageNum, pageSize, sort, sortType);
|
|
|
if (0 == result.getCode()) {
|
|
|
return result;
|
|
|
} else {
|
|
|
- // 阿里云搜索失败,再次从数据库搜索
|
|
|
- return queryArticleFromDatabase(pageNum, pageSize, null, null, id, null);
|
|
|
+ if (sortType == null) {
|
|
|
+ //综合排序
|
|
|
+ // 阿里云搜索失败,再次从数据库搜索
|
|
|
+ return queryArticleFromDatabase(pageNum, pageSize, null, null, id, null);
|
|
|
+ } else {
|
|
|
+ //根据时间排序
|
|
|
+ return queryArticleFromDatabaseByProDate(pageNum, pageSize, null, null, null, null,sortType);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -485,13 +492,13 @@ public class SearchQueryServiceImpl implements SearchQueryService {
|
|
|
* @param num 页码
|
|
|
* @param size 每页数量
|
|
|
*/
|
|
|
- private ResponseJson<String> queryArticleFromDatabaseByProDate(int num, int size, String keyword, Integer articleId, Integer typeId, Integer labelId) {
|
|
|
+ private ResponseJson<String> queryArticleFromDatabaseByProDate(int num, int size, String keyword, Integer articleId, Integer typeId, Integer labelId,Integer sortType) {
|
|
|
String labelText = null;
|
|
|
if (null != labelId) {
|
|
|
labelText = searchMapper.findLabelNameById(labelId);
|
|
|
}
|
|
|
PageHelper.startPage(num, size);
|
|
|
- List<ArticleListVo> articleList = searchMapper.queryArticleByProDate(keyword, articleId, typeId, labelText);
|
|
|
+ List<ArticleListVo> articleList = searchMapper.queryArticleByProDate(keyword, articleId, typeId, labelText,sortType);
|
|
|
articleList.forEach(article -> {
|
|
|
String imagePath = ImageUtils.getImageURL("", article.getImage(), 0, domain);
|
|
|
article.setImage(imagePath);
|