From 8a7e33332203a2e1334ba55a4838b6b1060d406c Mon Sep 17 00:00:00 2001
From: feige <791364011@qq.com>
Date: 星期二, 11 六月 2024 22:14:05 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 /dev/null                                                                             |   56 ------
 zhang-content/src/main/java/com/ruoyi/domain/ShareMore.java                           |   27 +++
 zhang-content/src/main/java/com/ruoyi/service/ZfDoctorShareService.java               |   25 ++
 zhang-content/src/main/java/com/ruoyi/mapper/ZfDoctorShareMapper.java                 |    9 +
 zhang-content/src/main/java/com/ruoyi/domain/ZfDoctorShare.java                       |   35 +++
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfDoctorShareController.java |   50 +++++
 zhang-content/src/main/java/com/ruoyi/service/impl/ZfDoctorShareServiceImpl.java      |  176 +++++++++++++++++++
 zhang-content/src/main/java/com/ruoyi/domain/ZfDoctor.java                            |    1 
 zhang-content/src/main/java/com/ruoyi/service/impl/ZfDoctorServiceImpl.java           |  140 +++++++++-----
 9 files changed, 411 insertions(+), 108 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZDictController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZDictController.java
deleted file mode 100644
index f448c7e..0000000
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZDictController.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package com.ruoyi.web.controller.zhang;
-
-
-import com.ruoyi.common.core.domain.AjaxResult;
-import com.ruoyi.domain.ZDict;
-import com.ruoyi.service.ZDictService;
-import io.swagger.v3.oas.models.security.SecurityScheme;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-import javax.naming.ldap.PagedResultsControl;
-import javax.websocket.server.PathParam;
-import java.util.List;
-
-/**
- * <p>
- * 瀛楀吀琛� 鍓嶇鎺у埗鍣�
- * </p>
- *
- * @author ojq
- * @since 2023-03-14
- */
-@RestController
-@RequestMapping("/zDict")
-public class ZDictController {
-
-    @Resource
-    private ZDictService zDictService;
-
-    @GetMapping("/all")
-    public AjaxResult getAllDict(){
-        return zDictService.listAllDict();
-    }
-
-    @GetMapping("/byId")
-    public AjaxResult getDictById(@PathParam("id")Integer id){
-        ZDict result = zDictService.getById(id);
-        return AjaxResult.success(result);
-    }
-
-}
-
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfDoctorShareController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfDoctorShareController.java
new file mode 100644
index 0000000..1cb8036
--- /dev/null
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfDoctorShareController.java
@@ -0,0 +1,50 @@
+package com.ruoyi.web.controller.zhang;
+
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.domain.ShareMore;
+import com.ruoyi.service.ZfDoctorShareService;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+
+@RestController
+@RequestMapping("/ZfDoctorShare")
+public class ZfDoctorShareController extends BaseController {
+    @Resource
+    ZfDoctorShareService zfDoctorShareService;
+
+    /**
+     * 鍒嗕韩鏁版嵁
+     */
+    @PostMapping("/share")
+    public AjaxResult share(@RequestBody ShareMore zfDoctor){
+        return zfDoctorShareService.saveZa(zfDoctor);
+    }
+
+    /**
+     * 鏍规嵁UserId鍜屽垎浜汉shareId鏌ョ湅宸茬粡鎺堟潈缁欓偅浜涗汉閭d簺鏁版嵁
+     */
+    @PostMapping("/getInfoByUserId")
+    public AjaxResult empowerGetInfo(@RequestBody ShareMore zfDoctor){
+
+        return zfDoctorShareService.listByFidAid(zfDoctor);
+    }
+
+    /**
+     * 鐢ㄦ埛鑷繁鏌ョ湅鍒汉鍒嗕韩鐨勬暟鎹拰鍒嗕韩浜�
+     */
+    @GetMapping("/getInfoByShareId")
+    public AjaxResult empowerGetInfo2(){
+        return zfDoctorShareService.listByUserId();
+    }
+    /**
+     * 鏍规嵁userId鍜宻hareId鏀跺洖宸茬粡鎺堟潈缁欓偅浜涗汉
+     */
+    @PostMapping("/deleteInfoByUserId")
+    public AjaxResult deleteEmpower(@RequestBody ShareMore zfDoctor){
+        return zfDoctorShareService.deleteZa(zfDoctor);
+    }
+
+
+}
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/MapUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/MapUtils.java
deleted file mode 100644
index 9003b2d..0000000
--- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/MapUtils.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.ruoyi.common.utils;
-
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-
-import java.util.HashMap;
-
-/**
- * @Version 1.0
- * @Author Jin_quan Ou
- * @Date 2023-03-22 17:08
- */
-public class MapUtils {
-
-    public static HashMap<String,Object> getResult(Page pageResult){
-        HashMap<String, Object> data = new HashMap<>();
-        data.put("data",pageResult.getRecords());
-        data.put("total",pageResult.getTotal());
-        data.put("pageNum",pageResult.getCurrent());
-        data.put("pageSize",pageResult.getSize());
-        return data;
-    }
-
-    public static HashMap<String,Object> getResult(Page pageResult,Object record){
-        HashMap<String, Object> data = new HashMap<>();
-        data.put("data",record);
-        data.put("total",pageResult.getTotal());
-        data.put("pageNum",pageResult.getCurrent());
-        data.put("pageSize",pageResult.getSize());
-        return data;
-    }
-}
diff --git a/zhang-content/src/main/java/com/ruoyi/domain/ShareMore.java b/zhang-content/src/main/java/com/ruoyi/domain/ShareMore.java
new file mode 100644
index 0000000..6869fef
--- /dev/null
+++ b/zhang-content/src/main/java/com/ruoyi/domain/ShareMore.java
@@ -0,0 +1,27 @@
+package com.ruoyi.domain;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class ShareMore implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 鐢ㄦ埛id
+     */
+    private Long userId;
+
+    /**
+     * 鍒嗕韩鐨勭敤鎴穒d
+     */
+    private Long[] shareIds;
+
+    /**
+     * 鍒嗕韩鐨勫唴瀹�
+     */
+    private Long[] shareContents;
+}
diff --git a/zhang-content/src/main/java/com/ruoyi/domain/ZfDoctor.java b/zhang-content/src/main/java/com/ruoyi/domain/ZfDoctor.java
index 5abaf28..91b6fab 100644
--- a/zhang-content/src/main/java/com/ruoyi/domain/ZfDoctor.java
+++ b/zhang-content/src/main/java/com/ruoyi/domain/ZfDoctor.java
@@ -94,4 +94,5 @@
     @TableField(exist = false)
     private Integer ownData;
 
+    private Long shareId;
 }
diff --git a/zhang-content/src/main/java/com/ruoyi/domain/ZfDoctorShare.java b/zhang-content/src/main/java/com/ruoyi/domain/ZfDoctorShare.java
new file mode 100644
index 0000000..5c492b5
--- /dev/null
+++ b/zhang-content/src/main/java/com/ruoyi/domain/ZfDoctorShare.java
@@ -0,0 +1,35 @@
+package com.ruoyi.domain;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+@TableName("zf_doctor_share")
+public class ZfDoctorShare implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 鐢ㄦ埛id
+     */
+    private Long userId;
+
+    /**
+     * 鍒嗕韩鐨勭敤鎴穒d
+     */
+    private Long shareId;
+
+    /**
+     * 鍒嗕韩鐨勫唴瀹�
+     */
+    private Long shareContent;
+
+
+
+}
diff --git a/zhang-content/src/main/java/com/ruoyi/mapper/ZfDoctorShareMapper.java b/zhang-content/src/main/java/com/ruoyi/mapper/ZfDoctorShareMapper.java
new file mode 100644
index 0000000..57f5a07
--- /dev/null
+++ b/zhang-content/src/main/java/com/ruoyi/mapper/ZfDoctorShareMapper.java
@@ -0,0 +1,9 @@
+package com.ruoyi.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ruoyi.domain.ZfDoctorShare;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface ZfDoctorShareMapper extends BaseMapper<ZfDoctorShare> {
+}
diff --git a/zhang-content/src/main/java/com/ruoyi/service/ZfDoctorShareService.java b/zhang-content/src/main/java/com/ruoyi/service/ZfDoctorShareService.java
new file mode 100644
index 0000000..5b125ae
--- /dev/null
+++ b/zhang-content/src/main/java/com/ruoyi/service/ZfDoctorShareService.java
@@ -0,0 +1,25 @@
+package com.ruoyi.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.domain.ShareMore;
+import com.ruoyi.domain.ZfDoctor;
+import com.ruoyi.domain.ZfDoctorShare;
+
+import java.util.List;
+
+public interface ZfDoctorShareService extends IService<ZfDoctorShare> {
+
+    List<ZfDoctorShare> getAuthority();
+
+    AjaxResult saveZa(ShareMore zfDoctor);
+
+    AjaxResult listByFidAid(ShareMore zfDoctor);
+
+    AjaxResult deleteZa(ShareMore zfDoctor);
+
+    AjaxResult listByUserId();
+
+    List<ZfDoctor> listUserId(Long shareId);
+
+}
diff --git a/zhang-content/src/main/java/com/ruoyi/service/impl/ZExperienceServiceImpl.java b/zhang-content/src/main/java/com/ruoyi/service/impl/ZExperienceServiceImpl.java
deleted file mode 100644
index bac2b39..0000000
--- a/zhang-content/src/main/java/com/ruoyi/service/impl/ZExperienceServiceImpl.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package com.ruoyi.service.impl;
-
-
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.ruoyi.common.core.domain.AjaxResult;
-import com.ruoyi.common.utils.poi.ExcelUtil;
-import com.ruoyi.domain.ZExperience;
-import com.ruoyi.mapper.ZExperienceMapper;
-import com.ruoyi.service.ZExperienceService;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Service;
-import org.springframework.web.multipart.MultipartFile;
-
-import java.util.List;
-import java.util.stream.Collectors;
-
-/**
- * <p>
- *  鏈嶅姟瀹炵幇绫�
- * </p>
- *
- * @author ojq
- * @since 2023-03-14
- */
-@Slf4j
-@Service
-public class ZExperienceServiceImpl extends ServiceImpl<ZExperienceMapper, ZExperience> implements ZExperienceService {
-
-    @Override
-    public List<ZExperience> selectExperienceList(Long userId) {
-
-        LambdaQueryWrapper<ZExperience> lqw = new LambdaQueryWrapper<>();
-        lqw.eq(ZExperience::getUserId,userId);
-        return list(lqw);
-
-
-    }
-
-    @Override
-    public boolean importExcel(MultipartFile file, Long userId) {
-        ExcelUtil<ZExperience> util = new ExcelUtil<>(ZExperience.class);
-        List<ZExperience> propertyList = null;
-        try {
-            propertyList = util.importExcel(file.getInputStream());
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        assert propertyList != null;
-        List<ZExperience> list = propertyList.stream().peek(
-                (property) -> property.setUserId(userId)
-        ).collect(Collectors.toList());
-        log.info("璧勪骇鍒楄〃涓猴細{}",list);
-        return saveBatch(list);
-    }
-}
diff --git a/zhang-content/src/main/java/com/ruoyi/service/impl/ZfDoctorServiceImpl.java b/zhang-content/src/main/java/com/ruoyi/service/impl/ZfDoctorServiceImpl.java
index bdafaa5..6512ca9 100644
--- a/zhang-content/src/main/java/com/ruoyi/service/impl/ZfDoctorServiceImpl.java
+++ b/zhang-content/src/main/java/com/ruoyi/service/impl/ZfDoctorServiceImpl.java
@@ -6,7 +6,9 @@
 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.common.utils.poi.ExcelUtil;
 import com.ruoyi.domain.*;
@@ -60,6 +62,10 @@
     @Resource
     private RestHighLevelClient restHighLevelClient;
 
+    @Resource
+    ZfDoctorShareService zfDoctorShareService;
+
+
     @Override
     public AjaxResult selectDoctorList(ZfDoctor zfDoctor, Integer pageNum, Integer pageSize) {
 //        LambdaQueryWrapper<ZfDoctor> lqw = buildCondition(zfDoctor);
@@ -72,8 +78,7 @@
 //        return AjaxResult.success(data);
         //瑕佹煡鑷繁瀹跺涵鐨�
         ZInfoUser myself = zInfoUserService.getMyself();
-        if(myself==null)
-        {
+        if (myself == null) {
             //   System.out.println("ssssss");
             return AjaxResult.success("鎮ㄦ病鍔犲叆鍒板搴旂殑瀹跺涵锛岃鑱旂郴绠$悊鍛�");
         }
@@ -85,8 +90,11 @@
         idList.add(familyId);
 //        String familyIds = listFamilyIds();
 //        String secondFamilyAuthority = listSecondFamilyIds();
-        LambdaQueryWrapper<ZfDoctor> lqw = buildCondition(zfDoctor, idList);
 
+        //鏌ョ湅鍒汉鍒嗕韩
+        List<ZfDoctor> bs = zfDoctorShareService.listUserId(myself.getUserId());
+
+        LambdaQueryWrapper<ZfDoctor> lqw = buildCondition(zfDoctor, idList);
 
         Page<ZfDoctor> zfDoctorPage = new Page<>(pageNum, pageSize);
         Page<ZfDoctor> pageResult = page(zfDoctorPage, lqw);
@@ -94,7 +102,7 @@
         List<ZfDoctor> beanRecords = pageResult.getRecords();//寰楀埌鏌ヨ鍑烘潵鐨勬暟鎹�
 
         List<ZfDoctor> dtoResult = markOwnData(familyId, beanRecords);
-
+        dtoResult.addAll(bs);
         HashMap<String, Object> data = MapUtils.getResult(pageResult, dtoResult);
         return AjaxResult.success(data);
     }
@@ -116,13 +124,17 @@
         //鍔犱笂鑷繁瀹跺涵鐨刬d
         idList.add(familyId);
 
+        //鏌ョ湅鍒汉鍒嗕韩
+        List<ZfDoctor> bs = zfDoctorShareService.listUserId(myself.getUserId());
+
         LambdaQueryWrapper<ZfDoctor> lambdaQueryWrapper = buildCondition(zfDoctor, idList);
         List<ZfDoctor> beanRecords = list(lambdaQueryWrapper);
+        beanRecords.addAll(bs);
         log.info("浠庢暟鎹簱涓煡鍒扮殑涓�:{}", beanRecords);
         return markOwnData(familyId, beanRecords);
     }
 
-    public List<ZfDoctor> markOwnData(Long familyId,List<ZfDoctor> beanRecords){
+    public List<ZfDoctor> markOwnData(Long familyId, List<ZfDoctor> beanRecords) {
         return beanRecords.stream().peek(
                 bean -> {
                     if (bean.getFamilyId() == familyId) {
@@ -131,7 +143,7 @@
                         bean.setOwnData(0);
                     }
                 }
-        ).sorted((a,b)-> b.getOwnData()-a.getOwnData()).collect(Collectors.toList());
+        ).sorted((a, b) -> b.getOwnData() - a.getOwnData()).collect(Collectors.toList());
     }
 
     @Override
@@ -159,8 +171,7 @@
         for (ZfDoctor zfDoctor : dataList) {
             if (zfDoctor.getSymptom().length() == 0 || zfDoctor.getSymptom() == null) {
                 throw new RuntimeException("鐥囩姸涓虹┖锛屽鍏ユ暟鎹け璐�");
-            }
-            else {
+            } else {
                 zfDoctorService.addData(zfDoctor);
             }
         }
@@ -173,7 +184,7 @@
         ZInfoUser myself = zInfoUserService.getMyself();
         Long familyId = myself.getFamilyId();
 
-        if(familyId == null){
+        if (familyId == null) {
             throw new RuntimeException("鎮ㄨ繕鏈姞鍏ヤ换浣曞搴�");
         }
 
@@ -181,12 +192,16 @@
         List<Long> familyIdList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(DOCTOR_LIST_ADD)).map(ZAuthority::getFid).collect(Collectors.toList());
         familyIdList.add(familyId);
 
-        if (zfDoctor.getFamilyId()!=null && !familyIdList.contains(zfDoctor.getFamilyId())) {
+//        List<ZfDoctorShare> authority1 = zfDoctorShareService.getAuthority();
+//        List<Long> idList1 = authority1.stream().filter(auth -> auth.getShareContent().toString().equals(DOCTOR_LIST)).map(ZfDoctorShare::getShareId).collect(Collectors.toList());
+        zfDoctorService.addData(zfDoctor);
+
+        if (zfDoctor.getFamilyId() != null && !familyIdList.contains(zfDoctor.getFamilyId())) {
             throw new RuntimeException("浣犳病鏈夋潈闄愭搷浣滄瀹跺涵鐨勬暟鎹�");
         }
 
 
-        if(zfDoctor.getFamilyId() == null){
+        if (zfDoctor.getFamilyId() == null) {
             //榛樿娣诲姞鑷繁瀹跺涵鐨勬暟鎹�
             zfDoctor.setFamilyId(familyId);
         }
@@ -195,14 +210,14 @@
         LambdaQueryWrapper<ZfDoctor> lqw = uniqueCondition(zfDoctor);
         List<ZfDoctor> list = list(lqw);
 
-        if(list.size()>0){
+        if (list.size() > 0) {
             throw new RuntimeException("璇峰嬁鏂板閲嶅鏁版嵁");
         }
 
         if (save(zfDoctor)) {
             EsModel esModel = new EsModel();
             Integer inte = zfDoctor.getId().intValue();
-            String uuid = UUID.randomUUID().toString().replace("-","");
+            String uuid = UUID.randomUUID().toString().replace("-", "");
             esModel.setId(uuid);
             esModel.setCtId(Long.valueOf(inte));
             esModel.setCtTableName("瀹跺涵灏忓尰鐢�");
@@ -213,8 +228,11 @@
             esModel.setBy5("/family/zfDoctor");
             esModel.setBy6(zfDoctor.getCmedical());
             esModel.setBy7(zfDoctor.getWmedical());
+//            esModel.setBy7();
             esModel.setRemark(zfDoctor.getRemark());
             esModel.setFid(familyId);
+
+
             //杩欓噷瀛樺偍鏌ヨ璇︽儏鐨勮矾寰�
             esService.insertTable(esModel);
             return AjaxResult.success();
@@ -222,6 +240,7 @@
             return AjaxResult.error();
         }
     }
+
 
     @Resource
     ZfLogService zfLogService;
@@ -238,7 +257,7 @@
         List<Long> familyIdList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(DOCTOR_LIST_UPDATE)).map(ZAuthority::getFid).collect(Collectors.toList());
         familyIdList.add(familyId);
 
-        if (dataFamilyId!=null && !familyIdList.contains(dataFamilyId)) {
+        if (dataFamilyId != null && !familyIdList.contains(dataFamilyId)) {
             throw new RuntimeException("浣犳病鏈夋潈闄愭搷浣滄瀹跺涵鐨勬暟鎹�");
         }
 
@@ -249,71 +268,71 @@
         zfLog.setUpdater(zInfoUserService.getMyself().getNickName());
         zfLogService.save(zfLog);
 
-        if(updateById(zfDoctor)){
+        if (updateById(zfDoctor)) {
             //鍒版暟鎹簱涓煡璇㈠搴旂殑鏁版嵁
             ZfDoctor dataById = getById(zfDoctor.getId());
 
             //鍏堝埌es涓煡璇㈠埌瀵瑰簲閭f潯鏁版嵁鍦╡s鐨刬d
             EsModel esResult = esService.findByCtId(dataById.getId().intValue(), "瀹跺涵灏忓尰鐢�");
 
-            if (esResult == null){
+            if (esResult == null) {
                 return AjaxResult.success();
             }
 
             //鎿嶄綔es淇敼鏁版嵁
             EsModel newModel = new EsModel();
-            if(zfDoctor.getType()!=null){
+            if (zfDoctor.getType() != null) {
                 newModel.setBy1(zfDoctor.getType());
-            }else {
+            } else {
                 newModel.setBy1(dataById.getType());
             }
 
-            if(zfDoctor.getSymptom()!=null){
+            if (zfDoctor.getSymptom() != null) {
                 newModel.setBy2(zfDoctor.getSymptom());
-            }else {
+            } else {
                 newModel.setBy2(dataById.getSymptom());
             }
 
-            if(zfDoctor.getEffect()!=null){
+            if (zfDoctor.getEffect() != null) {
                 newModel.setBy3(zfDoctor.getEffect());
-            }else {
+            } else {
                 newModel.setBy3(dataById.getEffect());
             }
 
-            if(zfDoctor.getSuitable()!=null){
+            if (zfDoctor.getSuitable() != null) {
                 newModel.setBy4(zfDoctor.getSuitable());
-            }else {
+            } else {
                 newModel.setBy4(dataById.getSuitable());
             }
 
-            if(zfDoctor.getCmedical()!=null){
+            if (zfDoctor.getCmedical() != null) {
                 newModel.setBy6(zfDoctor.getCmedical());
-            }else {
+            } else {
                 newModel.setBy6(dataById.getCmedical());
             }
 
-            if(zfDoctor.getWmedical()!=null){
+            if (zfDoctor.getWmedical() != null) {
                 newModel.setBy7(zfDoctor.getWmedical());
-            }else {
+            } else {
                 newModel.setBy7(dataById.getWmedical());
             }
 
-            if(zfDoctor.getRemark()!=null){
+            if (zfDoctor.getRemark() != null) {
                 newModel.setRemark(zfDoctor.getRemark());
-            }else {
+            } else {
                 newModel.setRemark(dataById.getRemark());
             }
 
 
             UpdateRequest updateRequest = new UpdateRequest("allsearchdata", esResult.getId());
             updateRequest.doc(
-                    "by1",newModel.getBy1(),
-                    "by2",newModel.getBy2(),
-                    "by3",newModel.getBy3(),
-                    "by4",newModel.getBy4(),
-                    "by6",newModel.getBy6(),
-                    "by7",newModel.getBy7(),
-                    "remark",newModel.getRemark()
+                    "by1", newModel.getBy1(),
+                    "by2", newModel.getBy2(),
+                    "by3", newModel.getBy3(),
+                    "by4", newModel.getBy4(),
+                    "by6", newModel.getBy6(),
+                    "by7", newModel.getBy7(),
+                    "remark", newModel.getRemark()
             );
 
             try {
@@ -321,9 +340,9 @@
             } catch (IOException e) {
                 throw new RuntimeException(e);
             }
-            
+
             return AjaxResult.success();
-        }else {
+        } else {
             return AjaxResult.error();
         }
     }
@@ -340,7 +359,7 @@
         familyIdList.add(familyId);
 
         for (ZfDoctor data : dataList) {
-            if (!familyIdList.contains(data.getFamilyId())){
+            if (!familyIdList.contains(data.getFamilyId())) {
                 throw new RuntimeException("浣犳病鏈夋潈闄愭搷浣滄瀹跺涵鐨勬暟鎹�");
             }
         }
@@ -352,10 +371,10 @@
             zfDoctors.stream().forEach(zfDoctor -> {
                 EsModel esModel = esService.findByCtId(zfDoctor.getId().intValue(), "瀹跺涵灏忓尰鐢�");
 
-                if (esModel != null){
+                if (esModel != null) {
                     DeleteRequest deleteRequest = new DeleteRequest("allsearchdata", esModel.getId());
                     try {
-                        restHighLevelClient.delete(deleteRequest,RequestOptions.DEFAULT);
+                        restHighLevelClient.delete(deleteRequest, RequestOptions.DEFAULT);
                     } catch (IOException e) {
                         throw new RuntimeException(e);
                     }
@@ -363,7 +382,7 @@
                 }
             });
             return AjaxResult.success();
-        }else {
+        } else {
             return AjaxResult.error();
         }
     }
@@ -402,29 +421,46 @@
         lqw.eq(StringUtils.isNotEmpty(zfDoctor.getEffect()), ZfDoctor::getEffect, zfDoctor.getEffect());
         lqw.eq(StringUtils.isNotEmpty(zfDoctor.getSuitable()), ZfDoctor::getSuitable, zfDoctor.getSuitable());
         lqw.eq(StringUtils.isNotEmpty(zfDoctor.getRemark()), ZfDoctor::getRemark, zfDoctor.getRemark());
-        lqw.eq(zfDoctor.getFamilyId()!=null,ZfDoctor::getFamilyId,zfDoctor.getFamilyId());
+        lqw.eq(zfDoctor.getFamilyId() != null, ZfDoctor::getFamilyId, zfDoctor.getFamilyId());
         return lqw;
     }
 
-    private LambdaQueryWrapper<ZfDoctor> buildCondition(ZfDoctor zfDoctor,List<Long> familyIdList) {
+    private LambdaQueryWrapper<ZfDoctor> buildCondition(ZfDoctor zfDoctor, List<Long> familyIdList) {
         LambdaQueryWrapper<ZfDoctor> lqw = new LambdaQueryWrapper<>();
-        lqw.in(ZfDoctor::getFamilyId,familyIdList);
+        lqw.in(ZfDoctor::getFamilyId, familyIdList);
         lqw.orderByDesc(ZfDoctor::getCreateTime);
         lqw.like(StringUtils.isNotEmpty(zfDoctor.getType()), ZfDoctor::getType, zfDoctor.getType())
                 .like(StringUtils.isNotEmpty(zfDoctor.getSymptom()), ZfDoctor::getSymptom, zfDoctor.getSymptom())
                 .like(StringUtils.isNotEmpty(zfDoctor.getDuration()), ZfDoctor::getDuration, zfDoctor.getDuration())
                 .like(StringUtils.isNotEmpty(zfDoctor.getEffect()), ZfDoctor::getEffect, zfDoctor.getEffect())
                 .like(StringUtils.isNotEmpty(zfDoctor.getSuitable()), ZfDoctor::getSuitable, zfDoctor.getSuitable())
-                .like(StringUtils.isNotEmpty(zfDoctor.getWmedical()),ZfDoctor::getWmedical,zfDoctor.getWmedical())
-                .like(StringUtils.isNotEmpty(zfDoctor.getCmedical()),ZfDoctor::getCmedical,zfDoctor.getCmedical())
+                .like(StringUtils.isNotEmpty(zfDoctor.getWmedical()), ZfDoctor::getWmedical, zfDoctor.getWmedical())
+                .like(StringUtils.isNotEmpty(zfDoctor.getCmedical()), ZfDoctor::getCmedical, zfDoctor.getCmedical())
                 .like(StringUtils.isNotEmpty(zfDoctor.getRemark()), ZfDoctor::getRemark, zfDoctor.getRemark());
-        if (StringUtils.isNotEmpty(zfDoctor.getPrescription())){
+        if (StringUtils.isNotEmpty(zfDoctor.getPrescription())) {
             lqw.and(wrapper -> {
-                wrapper.like(StringUtils.isNotEmpty(zfDoctor.getPrescription()),ZfDoctor::getWmedical,zfDoctor.getPrescription())
+                wrapper.like(StringUtils.isNotEmpty(zfDoctor.getPrescription()), ZfDoctor::getWmedical, zfDoctor.getPrescription())
                         .or()
-                        .like(StringUtils.isNotEmpty(zfDoctor.getPrescription()),ZfDoctor::getCmedical,zfDoctor.getPrescription());
+                        .like(StringUtils.isNotEmpty(zfDoctor.getPrescription()), ZfDoctor::getCmedical, zfDoctor.getPrescription());
             });
         }
         return lqw;
     }
-}
+
+//        private List<Long> buildCondition1(){
+//        List<ZfDoctorShare> authority1 = zfDoctorShareService.getAuthority();
+//        List<Long> idList1 = authority1.stream().filter(auth -> auth.getShareContent().toString().equals(DOCTOR_LIST)).map(ZfDoctorShare::getShareId).collect(Collectors.toList());
+//        return idList1;
+//    }
+//    private LambdaQueryWrapper<ZfDoctor> buildCondition2(ZfDoctor zfDoctor, List<Long> IdList) {
+//        LambdaQueryWrapper<ZfDoctorShare> lqw = new LambdaQueryWrapper<>();
+//        lqw.in(ZfDoctorShare::getShareId, IdList);
+//        List<ZfDoctorShare> beanRecords = list(lqw);
+//        for (ZfDoctorShare shareContent : beanRecords){
+//            zfDoctorService.getById(shareContent);
+//        }
+//
+//    }
+
+
+}
\ No newline at end of file
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
new file mode 100644
index 0000000..cef2d83
--- /dev/null
+++ b/zhang-content/src/main/java/com/ruoyi/service/impl/ZfDoctorShareServiceImpl.java
@@ -0,0 +1,176 @@
+package com.ruoyi.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.domain.entity.SysUser;
+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 lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+@Slf4j
+@Service
+public class ZfDoctorShareServiceImpl extends ServiceImpl<ZfDoctorShareMapper, ZfDoctorShare> 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());
+        return lqw;
+    }
+    @Override
+    public List<ZfDoctorShare> getAuthority() {
+        SysUser user = SecurityUtils.getLoginUser().getUser();
+        Long userId = user.getUserId();
+
+        LambdaQueryWrapper<ZfDoctorShare> lqw = new LambdaQueryWrapper<>();
+        lqw.eq(ZfDoctorShare::getShareId,userId);
+
+        return list(lqw);
+    }
+
+    @Resource
+    ZfDoctorShareService zfDoctorShareService;
+
+    public void addData(ZfDoctorShare za)
+    {
+        LambdaQueryWrapper<ZfDoctorShare> lqw = uniqueCondition(za);
+        List<ZfDoctorShare> list = list(lqw);
+
+        if(list.size()>0){
+            throw new RuntimeException("璇峰嬁鍒嗕韩閲嶅鏁版嵁");
+        }
+        else {
+            zfDoctorShareService.save(za);
+        }
+
+    }
+
+
+    @Override
+    public AjaxResult saveZa(ShareMore zfDoctor) {
+        //  boolean bl = zAuthorityService.saveOrUpdate(zAuthority);
+        Long [] shareIds = zfDoctor.getShareIds();
+        Long [] shareContents =  zfDoctor.getShareContents();
+        for (Long shareId : shareIds) {
+            for (Long shareContent : shareContents) {
+                ZfDoctorShare za = new ZfDoctorShare();
+                za.setUserId(getUserId());
+                za.setShareContent(shareContent);
+                za.setShareId(shareId);
+                addData(za);
+            }
+        }
+        //  Long []
+        //  if(bl)
+        return AjaxResult.success("鍒嗕韩鎴愬姛!");
+        // else
+        //    return  AjaxResult.error("鏉冮檺鏂板澶辫触锛�");
+
+
+    }
+    /**
+     * 鏍规嵁UserId鍜屽垎浜汉shareId鏌ョ湅宸茬粡鎺堟潈缁欓偅浜涗汉閭d簺鏁版嵁
+     */
+    @Override
+    public AjaxResult listByFidAid(ShareMore zfDoctor) {
+        //鎵惧埌瀵瑰簲鐨勮祴浜堟暟鎹殑鐢ㄦ埛浠ュ強鏁版嵁鍐呭
+        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 ) {
+                    beanRecord3.add(zfDoctorService.getById(beanRecord.getShareContent()));
+                }
+            }
+        }
+        log.info("浠庢暟鎹簱涓煡鍒扮殑涓�:{}", beanRecord3);
+
+        return AjaxResult.success(beanRecord3);
+    }
+
+    @Override
+    public AjaxResult deleteZa(ShareMore zfDoctor) {
+        Long [] shareIds = zfDoctor.getShareIds();
+        Long [] shareContents =  zfDoctor.getShareContents();
+        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());
+
+                zfDoctorShareService.remove(lqw);
+                //   addData(za);
+            }
+        return AjaxResult.success("鏁版嵁鏀跺洖鎴愬姛!");
+
+    }
+
+    /**
+     * 鐢ㄦ埛鑷繁鏌ョ湅鍒汉鍒嗕韩鐨勬暟鎹拰鍒嗕韩浜�
+     */
+    @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()));
+        }
+        log.info("浠庢暟鎹簱涓煡鍒扮殑涓�:{}", bs);
+        return AjaxResult.success(bs);
+
+    }
+    /**
+     * 鐢ㄦ埛鑷繁鏌ョ湅鍒汉鍒嗕韩鐨勬暟鎹�
+     */
+    @Override
+    public List<ZfDoctor> listUserId(Long shareId) {
+        //鎵惧埌瀵瑰簲鐨勮祴浜堟暟鎹殑鐢ㄦ埛浠ュ強鏁版嵁鍐呭
+        List<ZfDoctor>  bs = new ArrayList<>();
+        LambdaQueryWrapper<ZfDoctorShare> lqw = new LambdaQueryWrapper<>();
+        lqw.eq(ZfDoctorShare::getShareId,shareId);
+        List<ZfDoctorShare> beanRecords = list(lqw);
+        for (ZfDoctorShare beanRecord : beanRecords ) {
+            ZfDoctor bs2 = zfDoctorService.getById(beanRecord.getShareContent());
+            bs2.setShareId(beanRecord.getUserId());
+            bs.add(bs2);
+        }
+        log.info("浠庢暟鎹簱涓煡鍒扮殑涓�:{}", bs);
+        return bs;
+
+    }
+    public Long getUserId(){
+        ZInfoUser myself = zInfoUserService.getMyself();
+        return myself.getUserId();
+
+    }
+
+}

--
Gitblit v1.9.1