提交 e202d6cd authored 作者: lizhuo's avatar lizhuo

--no commit message

上级 1e017660
package com.zrqx.resource.fg.controller.resourcelibrary;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
......@@ -18,12 +17,11 @@ import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
......@@ -31,16 +29,12 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import tk.mybatis.mapper.entity.Example;
import com.github.pagehelper.PageHelper;
import com.zrqx.core.constant.BaseRequestPath;
import com.zrqx.core.constant.resource.ResourceRequestPath;
import com.zrqx.core.enums.AllResourceTypeEnum;
import com.zrqx.core.enums.ArticleTypeEnum;
import com.zrqx.core.enums.GoodsTypeEnum;
import com.zrqx.core.enums.ResourceTypeEnum;
import com.zrqx.core.enums.resource.LibraryStatusEnum;
import com.zrqx.core.exception.ParameterValidateException;
import com.zrqx.core.form.resource.fg.articlelibrary.FgQueryArticleLibraryForm;
import com.zrqx.core.form.resource.fg.authorLibrary.FgQueryAuthorLibraryForm;
......@@ -50,8 +44,6 @@ import com.zrqx.core.form.resource.fg.resource.FgSearchForm;
import com.zrqx.core.model.order.OrderInfo;
import com.zrqx.core.model.resource.articlelibrary.ArticleLibrary;
import com.zrqx.core.model.resource.articlelibrary.ArticleLibraryDiyType;
import com.zrqx.core.model.resource.articlelibrary.ChapterLibrary;
import com.zrqx.core.model.resource.authorLibrary.AuthorLibrary;
import com.zrqx.core.model.resource.ebook.Book;
import com.zrqx.core.model.resource.ebook.Ebook;
import com.zrqx.core.model.resource.ebook.EbookDiyType;
......@@ -63,10 +55,8 @@ import com.zrqx.core.util.response.CallBack;
import com.zrqx.core.vo.order.fg.GoodsBuyVo;
import com.zrqx.core.vo.resource.fg.ResultPage;
import com.zrqx.core.vo.resource.fg.articlelibrary.FgArticleLibraryListVO;
import com.zrqx.core.vo.resource.fg.articlelibrary.FgArticleLibraryOneVO;
import com.zrqx.core.vo.resource.fg.diytype.FgDiyTypeVo;
import com.zrqx.core.vo.resource.fg.ebook.FgEbookListVO;
import com.zrqx.core.vo.resource.fg.ebook.FgEbookVO;
import com.zrqx.core.vo.resource.fg.label.FgLabelInfoVO;
import com.zrqx.core.vo.resource.fg.marketing.FgPromotionInfoOneVO;
import com.zrqx.resource.bg.service.articlelibrary.ChapterLibraryService;
......@@ -92,6 +82,10 @@ import com.zrqx.resource.fg.service.resource.FgResourceLibraryService;
import com.zrqx.resource.fg.service.videolibrary.FgVideoLibraryDiyTypeService;
import com.zrqx.resource.fg.service.videolibrary.FgVideoLibraryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
/**
* 资源Controller
*/
......@@ -166,34 +160,30 @@ public class FgResourceLibraryController {
@ApiOperation(value = "搜索栏", notes = "搜索栏")
@GetMapping(ResourceRequestPath.SEARCH + ResourceRequestPath.LIST)
public CallBack<List<String>> queryList(@ApiParam(value = "输入内容", required = true) @RequestParam String name,
@ApiParam(value = "资源类型", required = true) @RequestParam Integer resourceType) {
if (StringUtils.isBlank(name) || resourceType == null) {
throw new ParameterValidateException(1, "参数不能为空");
}
List<String> list = new ArrayList<String>();
PageHelper.startPage(1, 20);
// 医家
if (resourceType == AllResourceTypeEnum.YIJIA.getCode()) {
Example example = authorLibraryService.createExample();
example.createCriteria().andLike("name", name + "%").andEqualTo("status",
LibraryStatusEnum.STATUS_1.getCode());
List<AuthorLibrary> authorList = authorLibraryService.selectByExample(example);
list = authorList.stream().map(AuthorLibrary::getName).collect(Collectors.toList());
}
// 医著
if (resourceType == AllResourceTypeEnum.YIZHU.getCode()) {
list = ebookService.searchList(name);
}
// 文章类型
if (ArticleTypeEnum.getName(resourceType.toString()) != null) {
Example example = articleLibraryService.createExample();
example.createCriteria().andLike("title", name + "%").andEqualTo("status",
LibraryStatusEnum.STATUS_1.getCode());
List<ArticleLibrary> articleList = articleLibraryService.selectByExample(example);
list = articleList.stream().map(ArticleLibrary::getTitle).collect(Collectors.toList());
public CallBack<Set> queryList(@ApiParam(value = "输入内容", required = true) @RequestParam String name) {
Set set = new HashSet();
SolrQuery sq = new SolrQuery();
StringBuffer sb = new StringBuffer();
sb.append("keywords_li:" + name);
sq.set("q", sb.toString());
QueryResponse sr;
try {
sr = client.query(sq);
SolrDocumentList doclist = sr.getResults();
for (SolrDocument solrDocument : doclist) {
set.add(solrDocument.get("name"));
set.add(solrDocument.get("bookName"));
}
} catch (SolrServerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return CallBack.success(list);
return CallBack.success(set);
};
@ApiOperation(value = "分页条件查询资源列表", notes = "分页条件查询资源列表")
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论