Эх сурвалжийг харах

故障字典ES增删改查,mapper自动扫描

Gaokun Wang 6 сар өмнө
parent
commit
d51cbd64eb

+ 0 - 2
als-modules/agile-assurance/src/main/java/org/eco/als/es/mapper/EsFaultCaseMapper.java

@@ -1,13 +1,11 @@
 package org.eco.als.es.mapper;
 
 
-import org.apache.ibatis.annotations.Mapper;
 import org.dromara.easyes.core.core.BaseEsMapper;
 import org.eco.als.domain.FaultCase;
 
 /**
  * es 故障案例
  */
-@Mapper
 public interface EsFaultCaseMapper extends BaseEsMapper<FaultCase> {
 }

+ 9 - 6
als-modules/agile-assurance/src/main/java/org/eco/als/service/impl/FaultCaseServiceImpl.java

@@ -126,6 +126,7 @@ public class FaultCaseServiceImpl extends BaseServiceImpl<FaultCaseMapper, Fault
      */
     @Override
     public PageResult<FaultCaseVo> selectPage(FaultCaseBo faultCaseBo) {
+
         QueryWrapper queryWrapper = buildQueryWrapper(faultCaseBo);
         Page<FaultCaseVo> page = this.pageAs(PageQuery.build(), queryWrapper, FaultCaseVo.class);
         return PageResult.build(page);
@@ -133,17 +134,19 @@ public class FaultCaseServiceImpl extends BaseServiceImpl<FaultCaseMapper, Fault
 
     @Override
     public EsPageInfo<FaultCase> selectEsPage(FaultCaseBo faultCaseBo) {
+        FaultCase faultCase = MapstructUtils.convert(faultCaseBo, FaultCase.class);
         LambdaEsQueryWrapper<FaultCase> wrapper = new LambdaEsQueryWrapper<>();
-        wrapper.match(StrUtil.isNotBlank(faultCaseBo.getFaultPhenomenon()), "pContent", faultCaseBo.getFaultPhenomenon(), 5.0f)
+        assert faultCase != null;
+        wrapper.match(StrUtil.isNotBlank(faultCase.getFaultPhenomenon()), "pContent", faultCaseBo.getFaultPhenomenon(), 5.0f)
             .or()
-            .match(StrUtil.isNotBlank(faultCaseBo.getFaultPhenomenon()), "fContent", faultCaseBo.getFaultPhenomenon(), 5.0f);
-        if (StrUtil.equals(faultCaseBo.getOrderBy(), "createTimeAsc")) {
+            .match(StrUtil.isNotBlank(faultCase.getFaultPhenomenon()), "fContent", faultCaseBo.getFaultPhenomenon(), 5.0f);
+        if (StrUtil.equals(faultCase.getOrderBy(), "createTimeAsc")) {
             wrapper.orderByAsc("createTime");
-        } else if (StrUtil.equals(faultCaseBo.getOrderBy(), "createTimeDesc")) {
+        } else if (StrUtil.equals(faultCase.getOrderBy(), "createTimeDesc")) {
             wrapper.orderByDesc("createTime");
-        } else if (StrUtil.equals(faultCaseBo.getOrderBy(), "countAsc")) {
+        } else if (StrUtil.equals(faultCase.getOrderBy(), "countAsc")) {
             wrapper.orderByAsc("viewCount");
-        } else if (StrUtil.equals(faultCaseBo.getOrderBy(), "countDesc")) {
+        } else if (StrUtil.equals(faultCase.getOrderBy(), "countDesc")) {
             wrapper.orderByDesc("viewCount");
         }
         if (!esFaultCaseMapper.existsIndex("fault_case_index")) {

+ 2 - 0
als-start/src/main/java/org/eco/StartApplication.java

@@ -1,5 +1,6 @@
 package org.eco;
 
+import org.dromara.easyes.starter.register.EsMapperScan;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
@@ -11,6 +12,7 @@ import org.springframework.boot.context.metrics.buffering.BufferingApplicationSt
  * @author wgk
  */
 @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}, scanBasePackages = {"org.eco"})
+@EsMapperScan("org.eco.als.es.mapper")
 public class StartApplication {
     public static void main(String[] args) {
         SpringApplication application = new SpringApplication(StartApplication.class);