提交 0b8673b5 authored 作者: renjiancai's avatar renjiancai

--no commit message

上级 73cfb8d3
......@@ -127,7 +127,7 @@ public class AuthorLibraryController {
if (result == null || !result.isStatus() || result.getData() == null) {
logger.info("专家会员服务调用失败");
}else{
List<Integer> authorIds = result.getData().stream().map(li -> {
List<String> authorIds = result.getData().stream().map(li -> {
return li.getAuthorId();
}).collect(Collectors.toList());
cr.andNotIn("id", authorIds);
......
package com.zrqx.resource.bg.controller.resourcelibrary;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import scala.util.Success;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.jboss.logging.Logger;
import org.springframework.beans.BeanUtils;
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;
......@@ -62,6 +62,11 @@ import com.zrqx.resource.bg.service.pdffilelibrary.PdfLibraryService;
import com.zrqx.resource.bg.service.recommend.RecommendResourceService;
import com.zrqx.resource.bg.service.recommend.RecommendService;
import com.zrqx.resource.bg.service.videolibrary.VideoLibraryService;
import com.zrqx.resource.commons.solr.SolrAdapter;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
/**
* 资源Controller
......@@ -70,7 +75,7 @@ import com.zrqx.resource.bg.service.videolibrary.VideoLibraryService;
@RequestMapping(ResourceRequestPath.BG + ResourceRequestPath.RESOURCE)
@Api(description = "资源的公共接口")
public class ResourceLibraryController {
private static final Logger log = Logger.getLogger(ResourceLibraryController.class);
@Autowired
private CoursewareLibraryService coursewareLibraryService;
@Autowired
......@@ -99,6 +104,11 @@ public class ResourceLibraryController {
private PromotionService promotionService;
@Autowired
private PromotionContentService promotionContentService;
@Value("${spring.data.solr.host}")
private String BASE_URL ;
@Autowired
private SolrAdapter solrAdapter;
@ApiOperation(value = "新增资源" , notes ="视频、音频、图片、课件、pdf的新增")
@PostMapping(value = ResourceRequestPath.SAVE)
......@@ -316,5 +326,51 @@ public class ResourceLibraryController {
(oldValue, newValue) -> oldValue, LinkedHashMap::new));*/
return map;
}
@ApiOperation(value = "索引数据同步(全部索引)" , notes ="索引数据同步(全部索引)")
@GetMapping(value = ResourceRequestPath.CREATE + ResourceRequestPath.INDEX)
public CallBack<Boolean> createIndex(){
SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
log.info("全文检索资源库全量索引开始...时间:"+f.format(new Date()));
String result = solrAdapter.createIndex();
if(result.equals("1")){
log.info("全文检索创建成功...时间:"+f.format(new Date()));
return CallBack.success();
}else{
log.info("全文检索创建失败...时间:"+f.format(new Date()));
return CallBack.fail();
}
}
@ApiOperation(value = "索引数据同步(更新索引)" , notes ="索引数据同步(更新索引)")
@GetMapping(value = ResourceRequestPath.UPDATE + ResourceRequestPath.INDEX)
public CallBack<Boolean> updateDeltaIndex(){
SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
log.info("全文检索更新资源库索引开始...时间:"+f.format(new Date()));
String result = solrAdapter.deltaImportIndex();
if(result.equals("1")){
log.info("全文检索更新成功...时间:"+f.format(new Date()));
return CallBack.success();
}else{
log.info("全文检索更新失败...时间:"+f.format(new Date()));
return CallBack.fail();
}
}
/**
* 创建SolrServer对象
* @return
* @author ycw
* @date: 2019年3月1日 下午4:38:00
*/
private HttpSolrClient getSolrClient(){
/*
* 设置超时时间
* .withConnectionTimeout(10000)
* .withSocketTimeout(60000)
*/
return new HttpSolrClient.Builder(BASE_URL)
.withConnectionTimeout(10000)
.withSocketTimeout(60000)
.build();
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论