From 392cbd30e4d512ddb42aed63e23bad1537e8fe81 Mon Sep 17 00:00:00 2001
From: zqy <2522236926@qq.com>
Date: 星期日, 21 七月 2024 18:01:07 +0800
Subject: [PATCH] 分享bug

---
 zhang-content/src/main/java/com/ruoyi/domain/ZfClan.java                              |   33 +++++
 zhang-content/src/main/java/com/ruoyi/service/ZfDoctorShareService.java               |    2 
 zhang-content/src/main/java/com/ruoyi/service/ZfClanService.java                      |   17 ++
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfDoctorShareController.java |    4 
 zhang-content/src/main/java/com/ruoyi/service/impl/ZfDoctorShareServiceImpl.java      |    2 
 zhang-content/src/main/java/com/ruoyi/service/impl/ZfClanManageServiceImpl.java       |   26 ++++
 zhang-content/src/main/java/com/ruoyi/domain/ZfClanManage.java                        |   18 +++
 zhang-content/src/main/java/com/ruoyi/mapper/ZfClanMapper.java                        |   11 +
 zhang-content/src/main/java/com/ruoyi/service/ZfClanManageService.java                |   14 ++
 zhang-content/src/main/java/com/ruoyi/service/impl/ZfClanServiceImpl.java             |  203 +++++++++++++++++++++++++++++++++
 zhang-content/src/main/java/com/ruoyi/mapper/ZfClanManageMapper.java                  |    9 +
 11 files changed, 335 insertions(+), 4 deletions(-)

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
index ea95f3a..37f4325 100644
--- 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
@@ -59,10 +59,10 @@
      * 鐢ㄦ埛鑷繁鏌ョ湅鍒汉鍒嗕韩鐨勬暟鎹拰鍒嗕韩浜�
      */
     @GetMapping("/getInfoByShareId")
-    public AjaxResult empowerGetInfo2(@RequestBody ShareMore zfDoctor){
+    public AjaxResult empowerGetInfo2(){
         Integer pageNo = Convert.toInt(ServletUtils.getParameter(PAGE_NO), 1);
         Integer pageSize = Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10);
-        return zfDoctorShareService.listUserId(zfDoctor,pageNo ,pageSize);
+        return zfDoctorShareService.listUserId(pageNo ,pageSize);
     }
     /**
      * 鏍规嵁userId鍜宻hareId鏀跺洖宸茬粡鎺堟潈缁欓偅浜涗汉
diff --git a/zhang-content/src/main/java/com/ruoyi/domain/ZfClan.java b/zhang-content/src/main/java/com/ruoyi/domain/ZfClan.java
new file mode 100644
index 0000000..2b6f34c
--- /dev/null
+++ b/zhang-content/src/main/java/com/ruoyi/domain/ZfClan.java
@@ -0,0 +1,33 @@
+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;
+
+@Data
+@TableName("zf_clan")
+public class ZfClan {
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer clanId;
+
+    /**
+     * 瀹舵棌鍚嶇О
+     */
+    private String clanName;
+
+    /**
+     * 鐖朵翰id
+     */
+    private Integer dadId;
+
+    /**
+     * 姣嶄翰id
+     */
+    private Integer momId;
+
+    /**
+     * 绠$悊鍛榠d
+     */
+    private Integer adminId;
+}
diff --git a/zhang-content/src/main/java/com/ruoyi/domain/ZfClanManage.java b/zhang-content/src/main/java/com/ruoyi/domain/ZfClanManage.java
new file mode 100644
index 0000000..57e550b
--- /dev/null
+++ b/zhang-content/src/main/java/com/ruoyi/domain/ZfClanManage.java
@@ -0,0 +1,18 @@
+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;
+
+@Data
+@TableName("zf_clan_manage")
+public class ZfClanManage {
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer clanId;
+
+    /**
+     * 鎴愬憳sysUser_id
+     */
+    private Integer memberId;
+}
diff --git a/zhang-content/src/main/java/com/ruoyi/mapper/ZfClanManageMapper.java b/zhang-content/src/main/java/com/ruoyi/mapper/ZfClanManageMapper.java
new file mode 100644
index 0000000..38439ec
--- /dev/null
+++ b/zhang-content/src/main/java/com/ruoyi/mapper/ZfClanManageMapper.java
@@ -0,0 +1,9 @@
+package com.ruoyi.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ruoyi.domain.ZfClanManage;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface ZfClanManageMapper extends BaseMapper<ZfClanManage> {
+}
diff --git a/zhang-content/src/main/java/com/ruoyi/mapper/ZfClanMapper.java b/zhang-content/src/main/java/com/ruoyi/mapper/ZfClanMapper.java
new file mode 100644
index 0000000..10c4810
--- /dev/null
+++ b/zhang-content/src/main/java/com/ruoyi/mapper/ZfClanMapper.java
@@ -0,0 +1,11 @@
+package com.ruoyi.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ruoyi.domain.ZfClan;
+import org.apache.ibatis.annotations.Mapper;
+
+import javax.annotation.ManagedBean;
+
+@Mapper
+public interface ZfClanMapper extends BaseMapper<ZfClan> {
+}
diff --git a/zhang-content/src/main/java/com/ruoyi/service/ZfClanManageService.java b/zhang-content/src/main/java/com/ruoyi/service/ZfClanManageService.java
new file mode 100644
index 0000000..1657c96
--- /dev/null
+++ b/zhang-content/src/main/java/com/ruoyi/service/ZfClanManageService.java
@@ -0,0 +1,14 @@
+package com.ruoyi.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.domain.ZfClan;
+import com.ruoyi.domain.ZfClanManage;
+
+public interface ZfClanManageService extends IService<ZfClanManage> {
+    AjaxResult selectDataList(ZfClanManage zfClanManage, Integer pageNum, Integer pageSize);
+
+    AjaxResult addData(ZfClanManage zfClanManage);
+
+    AjaxResult deleteData(Long[] ids);
+}
diff --git a/zhang-content/src/main/java/com/ruoyi/service/ZfClanService.java b/zhang-content/src/main/java/com/ruoyi/service/ZfClanService.java
new file mode 100644
index 0000000..8012394
--- /dev/null
+++ b/zhang-content/src/main/java/com/ruoyi/service/ZfClanService.java
@@ -0,0 +1,17 @@
+package com.ruoyi.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.domain.Meeting;
+import com.ruoyi.domain.ZfClan;
+
+public interface ZfClanService extends IService<ZfClan> {
+
+    AjaxResult selectDataList(ZfClan zfClan, Integer pageNum, Integer pageSize);
+
+    AjaxResult addData(ZfClan zfClan);
+
+    AjaxResult updateData(ZfClan zfClan);
+
+    AjaxResult deleteData(Long[] ids);
+}
diff --git a/zhang-content/src/main/java/com/ruoyi/service/ZfDoctorShareService.java b/zhang-content/src/main/java/com/ruoyi/service/ZfDoctorShareService.java
index 99d9f36..11e068f 100644
--- a/zhang-content/src/main/java/com/ruoyi/service/ZfDoctorShareService.java
+++ b/zhang-content/src/main/java/com/ruoyi/service/ZfDoctorShareService.java
@@ -21,7 +21,7 @@
 
     AjaxResult listByUserId();
 
-    AjaxResult listUserId(ShareMore zfDoctorInteger,Integer pageNo ,Integer pageSize);
+    AjaxResult listUserId(Integer pageNo ,Integer pageSize);
 
     Long getShareId(ZfDoctorDownload zfDoctorDownload);
 
diff --git a/zhang-content/src/main/java/com/ruoyi/service/impl/ZfClanManageServiceImpl.java b/zhang-content/src/main/java/com/ruoyi/service/impl/ZfClanManageServiceImpl.java
new file mode 100644
index 0000000..8e753c5
--- /dev/null
+++ b/zhang-content/src/main/java/com/ruoyi/service/impl/ZfClanManageServiceImpl.java
@@ -0,0 +1,26 @@
+package com.ruoyi.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.domain.ZfClanManage;
+import com.ruoyi.mapper.ZfClanManageMapper;
+import com.ruoyi.service.ZfClanManageService;
+import org.springframework.stereotype.Service;
+
+@Service
+public class ZfClanManageServiceImpl extends ServiceImpl<ZfClanManageMapper, ZfClanManage> implements ZfClanManageService {
+    @Override
+    public AjaxResult selectDataList(ZfClanManage zfClanManage, Integer pageNum, Integer pageSize) {
+        return null;
+    }
+
+    @Override
+    public AjaxResult addData(ZfClanManage zfClanManage) {
+        return null;
+    }
+
+    @Override
+    public AjaxResult deleteData(Long[] ids) {
+        return null;
+    }
+}
diff --git a/zhang-content/src/main/java/com/ruoyi/service/impl/ZfClanServiceImpl.java b/zhang-content/src/main/java/com/ruoyi/service/impl/ZfClanServiceImpl.java
new file mode 100644
index 0000000..dc973e0
--- /dev/null
+++ b/zhang-content/src/main/java/com/ruoyi/service/impl/ZfClanServiceImpl.java
@@ -0,0 +1,203 @@
+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.utils.MapUtils;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.domain.ZInfoUser;
+import com.ruoyi.domain.ZfClan;
+import com.ruoyi.domain.ZfLog;
+import com.ruoyi.mapper.ZfClanMapper;
+import com.ruoyi.service.EsService;
+import com.ruoyi.service.ZInfoUserService;
+import com.ruoyi.service.ZfClanService;
+import com.ruoyi.service.ZfLogService;
+import org.elasticsearch.action.delete.DeleteRequest;
+import org.elasticsearch.action.update.UpdateRequest;
+import org.elasticsearch.client.RequestOptions;
+import org.elasticsearch.client.RestHighLevelClient;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.io.IOException;
+import java.time.LocalDateTime;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.UUID;
+
+@Service
+public class ZfClanServiceImpl extends ServiceImpl<ZfClanMapper,ZfClan> implements ZfClanService {
+
+    @Resource
+    private EsService esSer;
+
+    @Resource
+    ZfLogService zfLogService;
+
+    @Resource
+    ZInfoUserService zInfoUserService;
+
+    @Resource
+    private RestHighLevelClient restHighLevelClient;
+
+    @Resource
+    private ZfClanService zfClanService;
+
+
+    private LambdaQueryWrapper<ZfClan> buildCondition(ZfClan zfClan) {
+        LambdaQueryWrapper<ZfClan> lqw = new LambdaQueryWrapper<>();
+        lqw.orderByDesc(ZfClan::getClanId);
+        lqw.like(StringUtils.isNotEmpty(zfClan.getClanName()), ZfClan::getClanName, zfClan.getClanName())
+            .like(zfClan.getAdminId() !=0, ZfClan::getAdminId, zfClan.getAdminId())
+            .like(zfClan.getDadId() !=0 , ZfClan::getDadId, zfClan.getDadId())
+            .like(zfClan.getMomId() !=0, ZfClan::getMomId, zfClan.getMomId());
+        return lqw;
+    }
+
+    private LambdaQueryWrapper<ZfClan> uniqueCondition(ZfClan zfClan){
+        LambdaQueryWrapper<ZfClan> lqw = new LambdaQueryWrapper<>();
+        lqw.eq(!StringUtils.isEmpty(zfClan.getClanName()), ZfClan::getClanName, zfClan.getClanName());
+        lqw.eq(zfClan.getAdminId() !=0, ZfClan::getAdminId, zfClan.getAdminId());
+        lqw.eq(zfClan.getDadId() !=0 , ZfClan::getDadId, zfClan.getDadId());
+        lqw.eq(zfClan.getMomId() !=0, ZfClan::getMomId, zfClan.getMomId());
+        return lqw;
+    }
+
+    /**
+     *
+     * 鑾峰彇褰撳墠鐢ㄦ埛鐨剆ysUserId
+     * @return
+     */
+    public Long getUserId(){
+        ZInfoUser myself = zInfoUserService.getMyself();
+        return myself.getUserId();
+
+    }
+
+    @Override
+    public AjaxResult selectDataList(ZfClan zfClan, Integer pageNum, Integer pageSize) {
+        LambdaQueryWrapper<ZfClan> lqw = buildCondition(zfClan);
+
+
+        Page<ZfClan> zfClanPage = new Page<>(pageNum, pageSize);
+        Page<ZfClan> pageResult = page(zfClanPage, lqw);
+        List<ZfClan> beanRecords = pageResult.getRecords();//寰楀埌鏌ヨ鍑烘潵鐨勬暟鎹�
+//        System.out.println(beanRecords);
+
+        HashMap<String, Object> data = MapUtils.getResult(pageResult, beanRecords);
+        return AjaxResult.success(data);
+
+}
+
+    @Override
+    public AjaxResult addData(ZfClan zfClan) {
+        LambdaQueryWrapper<ZfClan> lqw = uniqueCondition(zfClan);
+        List<ZfClan> list = list(lqw);
+
+        if(list.size()>0){
+            throw new RuntimeException("璇峰嬁鏂板閲嶅瀹舵棌");
+        }
+
+        if (save(zfClan)) {
+            EsModel esModel = new EsModel();
+            Integer inte =zfClan.getClanId();
+            String uuid = UUID.randomUUID().toString().replace("-","");
+            esModel.setId(uuid);
+            esModel.setCtId(Long.valueOf(inte));
+            esModel.setCtTableName("瀹舵棌");
+            esModel.setBy1(zfClan.getClanName());
+
+            esModel.setBy5("/zfClan");
+//            esModel.setFid(familyId);
+            esSer.insertTable(esModel);
+//            System.out.println(esModel);
+
+            return AjaxResult.success();
+        } else {
+            return AjaxResult.error();
+
+        }
+    }
+
+
+    @Override
+    public AjaxResult updateData(ZfClan zfClan) {
+
+        List<ZfClan> lqw = list(buildCondition(zfClan));
+
+        ZfLog zfLog = new ZfLog();
+        zfLog.setUpdateTime(LocalDateTime.now());
+        zfLog.setModule("瀹舵棌");
+        zfLog.setUpdater(zInfoUserService.getMyself().getNickName());
+        zfLogService.save(zfLog);
+//        System.out.println("===================================="+meeting);
+        if(updateById(zfClan)){
+            //鍒版暟鎹簱涓煡璇㈠搴旂殑鏁版嵁
+            ZfClan dataById = getById(zfClan.getClanId());
+
+            //鍏堝埌es涓煡璇㈠埌瀵瑰簲閭f潯鏁版嵁鍦╡s鐨刬d
+            EsModel esResult = esSer.findByCtId(dataById.getClanId(), "瀹舵棌");
+//            System.out.println("===================================="+meeting);
+            if (esResult == null){
+                return AjaxResult.success();
+            }
+
+            //鎿嶄綔es淇敼鏁版嵁
+            EsModel newModel = new EsModel();
+            if(zfClan.getClanName()!=null){
+                newModel.setBy1(zfClan.getClanName());
+            }else {
+                newModel.setBy1(dataById.getClanName());
+            }
+//
+
+            UpdateRequest updateRequest = new UpdateRequest("allsearchdata", esResult.getId());
+            updateRequest.doc(
+                    "by1",newModel.getBy1()
+
+            );
+
+            try {
+                restHighLevelClient.update(updateRequest, RequestOptions.DEFAULT);
+            } catch (IOException e) {
+                throw new RuntimeException(e);
+            }
+
+            return AjaxResult.success();
+        }else {
+            return AjaxResult.error();
+        }
+    }
+
+    @Override
+    public AjaxResult deleteData(Long[] ids) {
+        List<ZfClan> zfClans = listByIds(Arrays.asList(ids));
+        for (ZfClan zfClan : zfClans) {
+            if (!zfClan.getAdminId().equals(getUserId())) {
+                throw new RuntimeException("鎮ㄤ笉鏄鐞嗗憳,娌℃湁鏉冨姏鍒犻櫎璇ュ鏃�");
+            }
+        }
+        if (zfClanService.removeByIds(Arrays.asList(ids))) {
+
+            //鍒犻櫎es涓殑鏁版嵁
+            zfClans.stream().forEach(zfClan -> {
+                EsModel esModel = esSer.findByCtId((zfClan.getClanId().intValue()), "浼氳");
+                if (esModel != null) {
+                    DeleteRequest deleteRequest = new DeleteRequest("allsearchdata", esModel.getId());
+                    try {
+                        restHighLevelClient.delete(deleteRequest, RequestOptions.DEFAULT);
+                    } catch (IOException e) {
+                        throw new RuntimeException(e);
+                    }
+                }
+            });
+
+            return AjaxResult.success();
+        } else {
+            return AjaxResult.error();
+        }
+    }}
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 7f203dc..48b9bec 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
@@ -162,7 +162,7 @@
      * 鐢ㄦ埛鑷繁鏌ョ湅鍒汉鍒嗕韩鐨勬暟鎹�==鐢ㄦ埛鑷繁鏌ョ湅鍒汉鍒嗕韩鐨勬暟鎹拰鍒嗕韩浜�
      */
     @Override
-    public AjaxResult listUserId(ShareMore zfDoctorInteger,Integer pageNo ,Integer pageSize) {
+    public AjaxResult listUserId(Integer pageNo ,Integer pageSize) {
         //鎵惧埌瀵瑰簲鐨勮祴浜堟暟鎹殑鐢ㄦ埛浠ュ強鏁版嵁鍐呭
         List<ZfDoctor>  bs = new ArrayList<>();
         LambdaQueryWrapper<ZfDoctorShare> lqw = new LambdaQueryWrapper<>();

--
Gitblit v1.9.1