From d29cce61fb3a38f9f57a64a2a20d276b0d1254bc Mon Sep 17 00:00:00 2001
From: feige <feige@qq.com>
Date: 星期六, 16 九月 2023 11:54:24 +0800
Subject: [PATCH] es的增加索引和查询已经写好了,可以直接调用了

---
 zhang-content/src/main/java/com/ruoyi/service/impl/ZfEventServiceImpl.java |   76 ++++++++++++++++++++++++++------------
 1 files changed, 52 insertions(+), 24 deletions(-)

diff --git a/zhang-content/src/main/java/com/ruoyi/service/impl/ZfEventServiceImpl.java b/zhang-content/src/main/java/com/ruoyi/service/impl/ZfEventServiceImpl.java
index 88b3cf2..e3688dd 100644
--- a/zhang-content/src/main/java/com/ruoyi/service/impl/ZfEventServiceImpl.java
+++ b/zhang-content/src/main/java/com/ruoyi/service/impl/ZfEventServiceImpl.java
@@ -5,6 +5,7 @@
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.domain.entity.EsModel;
 import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.utils.MapUtils;
 import com.ruoyi.common.utils.SecurityUtils;
@@ -14,9 +15,7 @@
 import com.ruoyi.domain.ZfEvent;
 import com.ruoyi.domain.ZfEvent;
 import com.ruoyi.mapper.ZfEventMapper;
-import com.ruoyi.service.ZAuthorityService;
-import com.ruoyi.service.ZInfoUserService;
-import com.ruoyi.service.ZfEventService;
+import com.ruoyi.service.*;
 import com.ruoyi.util.ArraysUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
@@ -24,6 +23,7 @@
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
+import java.time.LocalDateTime;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -49,7 +49,9 @@
 
     @Resource
     ZAuthorityService zAuthorityService;
-
+    //鍔犲叆鍒癳s涓�
+    @Resource
+    private esService esSer;
     private LambdaQueryWrapper<ZfEvent> buildCondition(ZfEvent zfEvent,List<Long> familyIdList) {
         LambdaQueryWrapper<ZfEvent> lqw = new LambdaQueryWrapper<>();
         lqw.orderByDesc(ZfEvent::getCreateTime);
@@ -311,26 +313,26 @@
 
     @Override
     public AjaxResult addData(ZfEvent zfEvent) {
-        ZInfoUser myself = zInfoUserService.getMyself();
-        Long familyId = myself.getFamilyId();
-
-        if(familyId == null){
-            throw new RuntimeException("鎮ㄨ繕鏈姞鍏ヤ换浣曞搴�");
-        }
-
-        List<ZAuthority> authority = zAuthorityService.getAuthority();
-        List<Long> familyIdList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(EVENT_LIST_ADD)).map(ZAuthority::getFid).collect(Collectors.toList());
-        familyIdList.add(familyId);
-
-        if (zfEvent.getFamilyId()!=null && !familyIdList.contains(zfEvent.getFamilyId())) {
-            throw new RuntimeException("浣犳病鏈夋潈闄愭搷浣滄瀹跺涵鐨勬暟鎹�");
-        }
-
-
-        if(zfEvent.getFamilyId() == null){
-            //榛樿娣诲姞鑷繁瀹跺涵鐨勬暟鎹�
-            zfEvent.setFamilyId(familyId);
-        }
+//        ZInfoUser myself = zInfoUserService.getMyself();
+//        Long familyId = myself.getFamilyId();
+//
+//        if(familyId == null){
+//            throw new RuntimeException("鎮ㄨ繕鏈姞鍏ヤ换浣曞搴�");
+//        }
+//
+//        List<ZAuthority> authority = zAuthorityService.getAuthority();
+//        List<Long> familyIdList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(EVENT_LIST_ADD)).map(ZAuthority::getFid).collect(Collectors.toList());
+//        familyIdList.add(familyId);
+//
+//        if (zfEvent.getFamilyId()!=null && !familyIdList.contains(zfEvent.getFamilyId())) {
+//            throw new RuntimeException("浣犳病鏈夋潈闄愭搷浣滄瀹跺涵鐨勬暟鎹�");
+//        }
+//
+//
+//        if(zfEvent.getFamilyId() == null){
+//            //榛樿娣诲姞鑷繁瀹跺涵鐨勬暟鎹�
+//            zfEvent.setFamilyId(familyId);
+//        }
 
         //鍒ゆ柇鏄惁鏈夐噸澶嶆暟鎹�
         LambdaQueryWrapper<ZfEvent> lqw = uniqueCondition(zfEvent);
@@ -341,6 +343,22 @@
         }
 
         if (save(zfEvent)) {
+            //  椋�  鍔犲叆
+            EsModel esModel = new EsModel();
+            Integer inte = zfEvent.getId();
+            String uuid = UUID.randomUUID().toString().replace("-","");
+            esModel.setId(uuid);
+            esModel.setCtId(Long.valueOf(inte));
+            esModel.setCtName(zfEvent.getTitle());
+            esModel.setCtContent(zfEvent.getAddress());
+            esModel.setBy1(zfEvent.getRemark());
+            //杩欓噷瀛樺偍鏌ヨ璇︽儏鐨勮矾寰�
+            esModel.setBy5("/family/zfEvent");
+            // esModel.setCtTableName("tb_ajk");
+            //   esModel.setCtName("澶у");
+            //  esModel.setCtContent("澶у濂斤紝鎵嶆槸鐪熺殑濂�");//澶勪簨鐢�
+            esSer.insertTable(esModel);
+
             return AjaxResult.success();
         } else {
             return AjaxResult.error();
@@ -403,6 +421,9 @@
 
     }
 
+    @Resource
+    ZfLogService zfLogService;
+
     @Override
     public AjaxResult updateData(ZfEvent zfEvent) {
         ZInfoUser myself = zInfoUserService.getMyself();
@@ -419,6 +440,13 @@
             throw new RuntimeException("浣犳病鏈夋潈闄愭搷浣滄瀹跺涵鐨勬暟鎹�");
         }
 
+        //鎿嶄綔鍚庡姞鍏ユ棩蹇�
+        ZfLog zfLog = new ZfLog();
+        zfLog.setUpdateTime(LocalDateTime.now());
+        zfLog.setModule("瀹跺ぇ浜嬭");
+        zfLog.setUpdater(zInfoUserService.getMyself().getNickName());
+        zfLogService.save(zfLog);
+
         if(updateById(zfEvent)){
             return AjaxResult.success();
         }else {

--
Gitblit v1.9.1