Parcourir la source

处理文档删除之后,需要删除ES数据库对应数据的内容。避免查询报错

wukai il y a 2 ans
Parent
commit
8c2acade90

+ 2 - 2
lzga-modules/lzga-doc/src/main/java/com/jjt/doc/controller/ElasticSearchController.java

@@ -134,7 +134,7 @@ public class ElasticSearchController {
     @GetMapping("/getAll")
     public String getAll(@RequestParam(value = "page") int page, @RequestParam(value = "size") int size) {
         PageRequest pageable = PageRequest.of(page, size);
-        Page<HelloEntity> all = helloDao.findAll(pageable);
+        Page<EsDocInfo> all = esDocInfoService.findAll(pageable);
         return JSON.toJSONString(all);
     }
 
@@ -146,7 +146,7 @@ public class ElasticSearchController {
      */
     @DeleteMapping("/{id}")
     public String delete(@PathVariable(value = "id") Long id) {
-        helloDao.deleteById(id);
+        esDocInfoService.deleteById(id);
         return "success";
     }
 

+ 4 - 0
lzga-modules/lzga-doc/src/main/java/com/jjt/doc/service/impl/DocInfoServiceImpl.java

@@ -192,6 +192,9 @@ public class DocInfoServiceImpl implements IDocInfoService {
      */
     @Override
     public int deleteDocInfoByDocIds(Long[] docIds) {
+        for (Long docId : docIds) {
+            esDocInfoService.deleteById(docId);
+        }
         return docInfoMapper.deleteDocInfoByDocIds(docIds);
     }
 
@@ -203,6 +206,7 @@ public class DocInfoServiceImpl implements IDocInfoService {
      */
     @Override
     public int deleteDocInfoByDocId(Long docId) {
+        esDocInfoService.deleteById(docId);
         return docInfoMapper.deleteDocInfoByDocId(docId);
     }