|
|
@@ -2,45 +2,55 @@ package cn.reghao.tnb.search.app.controller;
|
|
|
|
|
|
import cn.reghao.jutil.jdk.web.db.PageList;
|
|
|
import cn.reghao.tnb.common.web.WebResult;
|
|
|
+import cn.reghao.tnb.search.app.es.QueryService;
|
|
|
import cn.reghao.tnb.search.app.model.po.Wenshu;
|
|
|
+import cn.reghao.tnb.search.app.model.vo.ElasticQuery;
|
|
|
import cn.reghao.tnb.search.app.model.vo.WenshuResult;
|
|
|
import cn.reghao.tnb.search.app.service.WenshuSearchService;
|
|
|
+import org.springframework.data.domain.Page;
|
|
|
import org.springframework.http.MediaType;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
/**
|
|
|
* 裁判文书搜索接口
|
|
|
*
|
|
|
* @author reghao
|
|
|
* @date 2025-05-02 16:44:46
|
|
|
*/
|
|
|
-//@RestController
|
|
|
-//@RequestMapping("/api/search1/wenshu")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/api/search1/wenshu")
|
|
|
public class WenshuSearchController {
|
|
|
private final WenshuSearchService wenshuSearchService;
|
|
|
+ private final QueryService<Wenshu> queryService;
|
|
|
|
|
|
- public WenshuSearchController(WenshuSearchService wenshuSearchService) {
|
|
|
+ public WenshuSearchController(WenshuSearchService wenshuSearchService, QueryService<Wenshu> queryService) {
|
|
|
this.wenshuSearchService = wenshuSearchService;
|
|
|
+ this.queryService = queryService;
|
|
|
}
|
|
|
|
|
|
@GetMapping(value = "/query", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
- public String searchWenshu(@RequestParam(value = "pn") int pn,
|
|
|
- @RequestParam(value = "keyword") String keyword) {
|
|
|
+ public String searchWenshu(@RequestParam(value = "pn") int pn, @RequestParam(value = "keyword") String keyword) {
|
|
|
+ int pageSize = 10;
|
|
|
+ String indexName = "";
|
|
|
PageList<WenshuResult> pageList1 = wenshuSearchService.search(pn, keyword);
|
|
|
- /*ElasticQuery elasticQuery = new ElasticQuery.Builder()
|
|
|
+ ElasticQuery elasticQuery = new ElasticQuery.Builder()
|
|
|
.pageSize(pageSize)
|
|
|
.pageNumber(pn)
|
|
|
.indexName(indexName)
|
|
|
- .highlightFieldName("caseName")
|
|
|
- .otherFiledNames(List.of("caseName", "cause", "parties"))
|
|
|
+ .highlightFiledNames(List.of("caseName"))
|
|
|
+ //.otherFiledNames(List.of("caseName", "cause", "parties"))
|
|
|
.queryString(keyword)
|
|
|
.build();
|
|
|
+
|
|
|
Page<Wenshu> page = queryService.queryWithHighlight(elasticQuery, Wenshu.class);
|
|
|
int pageNumber = page.getNumber();
|
|
|
- int pageSize = page.getSize();
|
|
|
+ //int pageSize = page.getSize();
|
|
|
int total = (int) page.getTotalElements();
|
|
|
List<WenshuResult> list = page.getContent().stream().map(WenshuResult::new).collect(Collectors.toList());
|
|
|
- PageList<WenshuResult> pageList = PageList.pageList(pageNumber, pageSize, total, list);*/
|
|
|
+ PageList<WenshuResult> pageList = PageList.pageList(pageNumber, pageSize, total, list);
|
|
|
return WebResult.success(pageList1);
|
|
|
}
|
|
|
|