feat: 自定义es及接口完成
This commit is contained in:
@@ -10,6 +10,7 @@ import com.landaiqing.subject.common.entity.Result;
|
||||
import com.landaiqing.subject.domain.entity.SubjectAnswerBO;
|
||||
import com.landaiqing.subject.domain.entity.SubjectInfoBO;
|
||||
import com.landaiqing.subject.domain.service.SubjectInfoDomainService;
|
||||
import com.landaiqing.subject.infra.basic.entity.SubjectInfoEs;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
@@ -116,4 +117,32 @@ public class SubjectController {
|
||||
return Result.fail("查询题目详情失败!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 全文检索
|
||||
* @param: [subjectInfoDTO]
|
||||
* @return: com.landaiqing.subject.common.entity.Result<com.landaiqing.subject.common.entity.PageResult < com.landaiqing.subject.infra.basic.entity.SubjectInfoEs>>
|
||||
* @author landaiqing
|
||||
* @date: 2024/3/6 17:05
|
||||
*/
|
||||
@PostMapping("/getSubjectPageBySearch")
|
||||
public Result<PageResult<SubjectInfoEs>> getSubjectPageBySearch(@RequestBody SubjectInfoDTO subjectInfoDTO) {
|
||||
|
||||
try {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("SubjectController.getSubjectPageBySearch.dto:{}", JSON.toJSONString(subjectInfoDTO));
|
||||
}
|
||||
|
||||
Preconditions.checkArgument(StringUtils.isNotBlank(subjectInfoDTO.getKeyWord()), "关键词不能为空!");
|
||||
|
||||
SubjectInfoBO subjectInfoBO = SubjectInfoDTOConverter.INSTANCE.convertDtoToBO(subjectInfoDTO);
|
||||
subjectInfoBO.setPageNo(subjectInfoDTO.getPageNo());
|
||||
subjectInfoBO.setPageSize(subjectInfoDTO.getPageSize());
|
||||
PageResult<SubjectInfoEs> boPageResult = subjectInfoDomainService.getSubjectPageBySearch(subjectInfoBO);
|
||||
return Result.ok(boPageResult);
|
||||
} catch (Exception e) {
|
||||
log.error("SubjectController.getSubjectPageBySearch.error:{}", e.getMessage(), e);
|
||||
return Result.fail("全文检索失败!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,10 +1,14 @@
|
||||
package com.landaiqing.subject.application.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.landaiqing.subject.common.entity.PageResult;
|
||||
import com.landaiqing.subject.infra.basic.entity.SubjectInfoEs;
|
||||
import com.landaiqing.subject.infra.basic.service.SubjectEsService;
|
||||
import com.landaiqing.subject.infra.entity.UserInfo;
|
||||
import com.landaiqing.subject.infra.rpc.UserRpc;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@@ -24,31 +28,12 @@ public class TestFeignController {
|
||||
@Resource
|
||||
private UserRpc userRpc;
|
||||
|
||||
@Resource
|
||||
private SubjectEsService subjectEsService;
|
||||
@GetMapping("testFeign")
|
||||
public void testFeign() {
|
||||
UserInfo userInfo = userRpc.getUserInfo("jichi");
|
||||
log.info("testFeign.userInfo:{}", userInfo);
|
||||
}
|
||||
@GetMapping("testCreateIndex")
|
||||
public void testCreateIndex() {
|
||||
subjectEsService.createIndex();
|
||||
}
|
||||
|
||||
@GetMapping("addDoc")
|
||||
public void addDoc() {
|
||||
subjectEsService.addDocs();
|
||||
}
|
||||
|
||||
@GetMapping("find")
|
||||
public void find() {
|
||||
subjectEsService.find();
|
||||
}
|
||||
|
||||
@GetMapping("search")
|
||||
public void search() {
|
||||
subjectEsService.search();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -73,6 +73,8 @@ public class SubjectInfoDTO extends PageInfo implements Serializable {
|
||||
*/
|
||||
private List<String> labelName;
|
||||
|
||||
private String keyWord;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user