From b02beccf4567068cb47a3f1181a00039456c872d Mon Sep 17 00:00:00 2001
From: zqy <2522236926@qq.com>
Date: 星期三, 06 八月 2025 15:37:20 +0800
Subject: [PATCH] 用户修改姓名和电话同步修改uaid

---
 zhang-content/src/main/java/com/ruoyi/service/impl/ZfDoctorShareServiceImpl.java |  186 ++++++++++++++++++++++++++++++++++------------
 1 files changed, 138 insertions(+), 48 deletions(-)

diff --git a/zhang-content/src/main/java/com/ruoyi/service/impl/ZfDoctorShareServiceImpl.java b/zhang-content/src/main/java/com/ruoyi/service/impl/ZfDoctorShareServiceImpl.java
index cef2d83..6c1927b 100644
--- a/zhang-content/src/main/java/com/ruoyi/service/impl/ZfDoctorShareServiceImpl.java
+++ b/zhang-content/src/main/java/com/ruoyi/service/impl/ZfDoctorShareServiceImpl.java
@@ -1,60 +1,80 @@
 package com.ruoyi.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+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;
 import com.ruoyi.common.utils.StringUtils;
-import com.ruoyi.domain.ShareMore;
-import com.ruoyi.domain.ZInfoUser;
-import com.ruoyi.domain.ZfDoctor;
-import com.ruoyi.domain.ZfDoctorShare;
-import com.ruoyi.mapper.ZfDoctorShareMapper;
-import com.ruoyi.service.ZInfoUserService;
-import com.ruoyi.service.ZfDoctorService;
-import com.ruoyi.service.ZfDoctorShareService;
+import com.ruoyi.domain.*;
+import com.ruoyi.mapper.ZfShareMapper;
+import com.ruoyi.service.*;
 import lombok.extern.slf4j.Slf4j;
+import org.elasticsearch.action.delete.DeleteRequest;
+import org.elasticsearch.client.RequestOptions;
+import org.elasticsearch.client.RestHighLevelClient;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
+import java.io.IOException;
+import java.util.*;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static com.alibaba.druid.sql.PagerUtils.limit;
+import static com.ruoyi.constant.MenuAuthority.DOCTOR_LIST_UPDATE;
 
 @Slf4j
 @Service
-public class ZfDoctorShareServiceImpl extends ServiceImpl<ZfDoctorShareMapper, ZfDoctorShare> implements ZfDoctorShareService {
+public class ZfDoctorShareServiceImpl extends ServiceImpl<ZfShareMapper, ZfShare> implements ZfDoctorShareService {
     @Resource
     private ZfDoctorService zfDoctorService;
 
     @Resource
     private ZInfoUserService zInfoUserService;
 
-    private LambdaQueryWrapper<ZfDoctorShare> uniqueCondition(ZfDoctorShare zfDoctorShare) {
-        LambdaQueryWrapper<ZfDoctorShare> lqw = new LambdaQueryWrapper<>();
-        lqw.eq(StringUtils.isNotEmpty(String.valueOf(zfDoctorShare.getShareId())), ZfDoctorShare::getShareId, zfDoctorShare.getShareId());
-        lqw.eq(StringUtils.isNotEmpty(String.valueOf(zfDoctorShare.getShareContent())), ZfDoctorShare::getShareContent, zfDoctorShare.getShareContent());
+    @Resource
+    private RestHighLevelClient restHighLevelClient;
+
+    @Resource
+    EsService esService;
+
+    @Resource
+    private ZfEventService zfEventService;
+
+
+    private LambdaQueryWrapper<ZfShare> uniqueCondition(ZfShare zfShare) {
+        LambdaQueryWrapper<ZfShare> lqw = new LambdaQueryWrapper<>();
+        lqw.eq(StringUtils.isNotEmpty(String.valueOf(zfShare.getShareId())), ZfShare::getShareId, zfShare.getShareId());
+        lqw.eq(StringUtils.isNotEmpty(String.valueOf(zfShare.getShareContent())), ZfShare::getShareContent, zfShare.getShareContent());
+        lqw.eq(StringUtils.isNotEmpty(String.valueOf(zfShare.getSysMenuId())), ZfShare::getSysMenuId, zfShare.getSysMenuId());
         return lqw;
     }
+
+
+
     @Override
-    public List<ZfDoctorShare> getAuthority() {
+    public List<ZfShare> getByUserId() {
         SysUser user = SecurityUtils.getLoginUser().getUser();
         Long userId = user.getUserId();
 
-        LambdaQueryWrapper<ZfDoctorShare> lqw = new LambdaQueryWrapper<>();
-        lqw.eq(ZfDoctorShare::getShareId,userId);
+        LambdaQueryWrapper<ZfShare> lqw = new LambdaQueryWrapper<>();
+        lqw.eq(ZfShare::getUserId,userId);
 
         return list(lqw);
     }
 
+
     @Resource
     ZfDoctorShareService zfDoctorShareService;
 
-    public void addData(ZfDoctorShare za)
+    public void addData(ZfShare za)
     {
-        LambdaQueryWrapper<ZfDoctorShare> lqw = uniqueCondition(za);
-        List<ZfDoctorShare> list = list(lqw);
+        LambdaQueryWrapper<ZfShare> lqw = uniqueCondition(za);
+        List<ZfShare> list = list(lqw);
 
         if(list.size()>0){
             throw new RuntimeException("璇峰嬁鍒嗕韩閲嶅鏁版嵁");
@@ -73,10 +93,11 @@
         Long [] shareContents =  zfDoctor.getShareContents();
         for (Long shareId : shareIds) {
             for (Long shareContent : shareContents) {
-                ZfDoctorShare za = new ZfDoctorShare();
+                ZfShare za = new ZfShare();
                 za.setUserId(getUserId());
                 za.setShareContent(shareContent);
                 za.setShareId(shareId);
+                za.setSysMenuId(2019L);
                 addData(za);
             }
         }
@@ -92,24 +113,30 @@
      * 鏍规嵁UserId鍜屽垎浜汉shareId鏌ョ湅宸茬粡鎺堟潈缁欓偅浜涗汉閭d簺鏁版嵁
      */
     @Override
-    public AjaxResult listByFidAid(ShareMore zfDoctor) {
+    public AjaxResult listByFidAid(ShareMore zfDoctor,Integer pageNo ,Integer pageSize) {
         //鎵惧埌瀵瑰簲鐨勮祴浜堟暟鎹殑鐢ㄦ埛浠ュ強鏁版嵁鍐呭
         Long [] shareIds = zfDoctor.getShareIds();
         List<ZfDoctor> beanRecord3 = new ArrayList<>();
         for (Long shareId : shareIds) {
             {
-                LambdaQueryWrapper<ZfDoctorShare> lqw = new LambdaQueryWrapper<>();
-                lqw.eq(ZfDoctorShare::getShareId,shareId)
-                        .eq(ZfDoctorShare::getUserId, getUserId());
-                List<ZfDoctorShare> beanRecords = list(lqw);
-                for (ZfDoctorShare beanRecord : beanRecords ) {
+                LambdaQueryWrapper<ZfShare> lqw = new LambdaQueryWrapper<>();
+                lqw.eq(ZfShare::getShareId,shareId)
+                    .eq(ZfShare::getSysMenuId,zfDoctor.getSysMenuId())
+                        .eq(ZfShare::getUserId, getUserId());
+                List<ZfShare> beanRecords = list(lqw);
+                for (ZfShare beanRecord : beanRecords ) {
                     beanRecord3.add(zfDoctorService.getById(beanRecord.getShareContent()));
                 }
             }
         }
-        log.info("浠庢暟鎹簱涓煡鍒扮殑涓�:{}", beanRecord3);
+        List<ZfDoctor>  record =  beanRecord3.stream().skip((pageNo-1)*pageSize).limit(pageSize).collect(Collectors.toList());
 
-        return AjaxResult.success(beanRecord3);
+        int totalPage = (beanRecord3.size() -1) / pageSize +1;
+
+        Page<ZfDoctor> zfDoctorPage = new Page<>(pageNo, pageSize,totalPage);
+        HashMap<String, Object> data = MapUtils.getShareResult(zfDoctorPage, record,beanRecord3.size());
+
+        return AjaxResult.success(data);
     }
 
     @Override
@@ -119,10 +146,11 @@
         for(Long shareId : shareIds)
             for(Long shareContent: shareContents)
             {
-                LambdaQueryWrapper<ZfDoctorShare> lqw = new LambdaQueryWrapper<>();
-                lqw.eq(ZfDoctorShare::getShareId,shareId)
-                        .eq(ZfDoctorShare::getShareContent, shareContent)
-                        .eq(ZfDoctorShare::getUserId, getUserId());
+                LambdaQueryWrapper<ZfShare> lqw = new LambdaQueryWrapper<>();
+                lqw.eq(ZfShare::getShareId,shareId)
+                        .eq(ZfShare::getShareContent, shareContent)
+                        .eq(ZfShare::getSysMenuId, zfDoctor.getSysMenuId())
+                        .eq(ZfShare::getUserId, getUserId());
 
                 zfDoctorShareService.remove(lqw);
                 //   addData(za);
@@ -137,34 +165,44 @@
     @Override
     public AjaxResult listByUserId() {
         //鎵惧埌瀵瑰簲鐨勮祴浜堟暟鎹殑鐢ㄦ埛浠ュ強鏁版嵁鍐呭
-        HashMap<Long,ZfDoctor>  bs = new HashMap<>();
-        LambdaQueryWrapper<ZfDoctorShare> lqw = new LambdaQueryWrapper<>();
-        lqw.eq(ZfDoctorShare::getShareId,getUserId());
-        List<ZfDoctorShare> beanRecords = list(lqw);
-        for (ZfDoctorShare beanRecord : beanRecords ) {
-            bs.put(beanRecord.getUserId(),zfDoctorService.getById(beanRecord.getShareContent()));
+        HashMap<Long,List<ZfDoctor>>  bs = new HashMap<>();
+        LambdaQueryWrapper<ZfShare> lqw = new LambdaQueryWrapper<>();
+        lqw.eq(ZfShare::getShareId,getUserId());
+        lqw.eq(ZfShare::getSysMenuId,2019L);
+        List<ZfShare> beanRecords = list(lqw);
+        List<ZfDoctor> b1 = new ArrayList<>();
+        for (ZfShare beanRecord : beanRecords ) {
+                b1.add(zfDoctorService.getById(beanRecord.getShareContent()));
+                bs.put(beanRecord.getUserId(),b1);
         }
         log.info("浠庢暟鎹簱涓煡鍒扮殑涓�:{}", bs);
         return AjaxResult.success(bs);
 
     }
     /**
-     * 鐢ㄦ埛鑷繁鏌ョ湅鍒汉鍒嗕韩鐨勬暟鎹�
+     * 鐢ㄦ埛鑷繁鏌ョ湅鍒汉鍒嗕韩鐨勬暟鎹�==鐢ㄦ埛鑷繁鏌ョ湅鍒汉鍒嗕韩鐨勬暟鎹拰鍒嗕韩浜�
      */
     @Override
-    public List<ZfDoctor> listUserId(Long shareId) {
+    public AjaxResult listUserId(Integer pageNo ,Integer pageSize) {
         //鎵惧埌瀵瑰簲鐨勮祴浜堟暟鎹殑鐢ㄦ埛浠ュ強鏁版嵁鍐呭
         List<ZfDoctor>  bs = new ArrayList<>();
-        LambdaQueryWrapper<ZfDoctorShare> lqw = new LambdaQueryWrapper<>();
-        lqw.eq(ZfDoctorShare::getShareId,shareId);
-        List<ZfDoctorShare> beanRecords = list(lqw);
-        for (ZfDoctorShare beanRecord : beanRecords ) {
+        LambdaQueryWrapper<ZfShare> lqw = new LambdaQueryWrapper<>();
+        lqw.eq(ZfShare::getShareId,getUserId());
+        lqw.eq(ZfShare::getSysMenuId,2019L);
+        List<ZfShare> beanRecords = list(lqw);
+        for (ZfShare beanRecord : beanRecords ) {
             ZfDoctor bs2 = zfDoctorService.getById(beanRecord.getShareContent());
             bs2.setShareId(beanRecord.getUserId());
             bs.add(bs2);
         }
         log.info("浠庢暟鎹簱涓煡鍒扮殑涓�:{}", bs);
-        return bs;
+        List<ZfDoctor>  record = bs.stream().skip((pageNo-1)*pageSize).limit(pageSize).collect(Collectors.toList());
+
+        int totalPage = (bs.size() -1) / pageSize +1;
+
+        Page<ZfDoctor> zfDoctorPage = new Page<>(pageNo, pageSize,totalPage);
+        HashMap<String, Object> data = MapUtils.getShareResult(zfDoctorPage, record,bs.size());
+        return AjaxResult.success(data);
 
     }
     public Long getUserId(){
@@ -172,5 +210,57 @@
         return myself.getUserId();
 
     }
+    @Override
+    public Long getShareId(ZfDownload zfDownload){
+        LambdaQueryWrapper<ZfShare> lqw = new LambdaQueryWrapper<>();
+        lqw.eq(ZfShare::getShareId, zfDownload.getDownloadId())
+                .eq(ZfShare::getShareContent, zfDownload.getDownloadContent())
+                .eq(ZfShare::getSysMenuId, zfDownload.getSysMenuId());
+        List<ZfShare> beanRecords = list(lqw);
+        if (beanRecords.size() != 0){
+            return beanRecords.get(0).getUserId();
+        }
+        else {
+            return null;
+        }
+    }
+
+    @Override
+    public Boolean deleteByContentId(Long[] ids) {
+         List<Long> id = new ArrayList<>();
+
+        LambdaQueryWrapper<ZfShare> lqw = new LambdaQueryWrapper<>();
+        lqw.in(ids != null, ZfShare::getShareContent,  ids)
+                .eq(ZfShare::getSysMenuId, 2019L);
+
+        List<ZfShare> zfShares = list(lqw);
+        if (zfShares.size() == 0){
+            return true;
+        }
+        for (ZfShare zfShare: zfShares) {
+            id.add(zfShare.getId());
+        }
+
+        System.out.println(id);
+        if (removeByIds(id)) {
+            //鍒犻櫎es涓殑鏁版嵁
+            zfShares.forEach(zfDoctorDownload -> {
+                EsModel esModel = esService.findByCtId(zfDoctorDownload.getId().intValue(), "灏忓尰鐢熷垎浜垹闄�");
+                if (esModel != null) {
+                    DeleteRequest deleteRequest = new DeleteRequest("allsearchdata", esModel.getId());
+                    System.out.println(deleteRequest);
+                    try {
+                        restHighLevelClient.delete(deleteRequest, RequestOptions.DEFAULT);
+                    } catch (IOException e) {
+                        throw new RuntimeException(e);
+                    }
+                }
+            });
+            return true;
+        } else {
+            return false;
+        }
+
+    }
 
 }

--
Gitblit v1.9.1