From 312e09da912a5d5bee2228af3f888e06088902ec Mon Sep 17 00:00:00 2001
From: feige <791364011@qq.com>
Date: 星期五, 18 十月 2024 10:35:38 +0800
Subject: [PATCH] 修改了bug

---
 zhang-content/src/main/java/com/ruoyi/mapper/ZfAncestorMapper.java            |    4 ++--
 zhang-content/src/main/java/com/ruoyi/service/impl/ZAuthorityServiceImpl.java |   24 +++++++++++++++++-------
 zhang-content/src/main/java/com/ruoyi/service/impl/ZfContactServiceImpl.java  |   13 ++++++++++++-
 zhang-content/pom.xml                                                         |   13 +++++++++++++
 zhang-content/src/main/java/com/ruoyi/service/impl/ZfAncestorServiceImpl.java |    1 +
 5 files changed, 45 insertions(+), 10 deletions(-)

diff --git a/zhang-content/pom.xml b/zhang-content/pom.xml
index 64a15f0..12643cd 100644
--- a/zhang-content/pom.xml
+++ b/zhang-content/pom.xml
@@ -28,6 +28,19 @@
             <groupId>com.baomidou</groupId>
             <artifactId>mybatis-plus-boot-starter</artifactId>
             <version>3.5.2</version>
+            <exclusions>
+                <!-- 瑙e喅jsqlparser 渚濊禆鐗堟湰瑙f瀽闂-->
+                <exclusion>
+                    <artifactId>jsqlparser</artifactId>
+                    <groupId>com.github.jsqlparser</groupId>
+                </exclusion>
+            </exclusions>
+
+        </dependency>
+        <dependency>
+            <groupId>com.github.jsqlparser</groupId>
+            <artifactId>jsqlparser</artifactId>
+            <version>4.6</version>
         </dependency>
 
         <!-- MyBatis浠g爜鐢熸垚鍣ㄤ緷璧栵紝瑕佷娇鐢ㄤ唬鐮佺敓鎴愬櫒锛屽氨闇�瑕佸鍏ヤ唬鐮佺敓鎴愬櫒渚濊禆 -->
diff --git a/zhang-content/src/main/java/com/ruoyi/mapper/ZfAncestorMapper.java b/zhang-content/src/main/java/com/ruoyi/mapper/ZfAncestorMapper.java
index 892dcdc..8d296ff 100644
--- a/zhang-content/src/main/java/com/ruoyi/mapper/ZfAncestorMapper.java
+++ b/zhang-content/src/main/java/com/ruoyi/mapper/ZfAncestorMapper.java
@@ -19,11 +19,11 @@
 @Mapper
 public interface ZfAncestorMapper extends BaseMapper<ZfAncestor> {
 
-    @Select("select * , zf_role.name as roleName from zf_ancestor, zf_clan,zf_role where zf_ancestor.clan_id = zf_clan.clan_id and zf_ancestor.role_id = zf_role.id ${ew.customSqlSegment}")
+    @Select("select * , zf_role.name as roleName from zf_ancestor inner join zf_clan on  zf_ancestor.clan_id = zf_clan.clan_id inner join zf_role on zf_ancestor.role_id = zf_role.id ${ew.customSqlSegment}")
     Page<AncestorClan> selectInfo(Page page, @Param(Constants.WRAPPER) Wrapper<Object> queryWrapper);
 
 
-    @Select("select * , zf_role.name as roleName from zf_ancestor, zf_clan,zf_role where zf_ancestor.clan_id = zf_clan.clan_id and zf_ancestor.role_id = zf_role.id ${ew.customSqlSegment}")
+    @Select("select * , zf_role.name as roleName from zf_ancestor inner join zf_clan on  zf_ancestor.clan_id = zf_clan.clan_id inner join zf_role on zf_ancestor.role_id = zf_role.id  ${ew.customSqlSegment}")
     List<AncestorClan> selectAllInfo( @Param(Constants.WRAPPER) Wrapper<Object> queryWrapper);
 
 }
diff --git a/zhang-content/src/main/java/com/ruoyi/service/impl/ZAuthorityServiceImpl.java b/zhang-content/src/main/java/com/ruoyi/service/impl/ZAuthorityServiceImpl.java
index f4620d2..9feff3f 100644
--- a/zhang-content/src/main/java/com/ruoyi/service/impl/ZAuthorityServiceImpl.java
+++ b/zhang-content/src/main/java/com/ruoyi/service/impl/ZAuthorityServiceImpl.java
@@ -5,10 +5,8 @@
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.utils.SecurityUtils;
-import com.ruoyi.domain.ZAuthority;
-import com.ruoyi.domain.ZInfoUser;
-import com.ruoyi.domain.ZfCode;
-import com.ruoyi.domain.ZfFamily;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.domain.*;
 import com.ruoyi.domain.dto.AuthorityDto;
 import com.ruoyi.domain.dto.AuthorityDto2;
 import com.ruoyi.domain.dto.AuthorityDtoWithName;
@@ -53,9 +51,9 @@
     public List<ZAuthority> getAuthority() {
         SysUser user = SecurityUtils.getLoginUser().getUser();
         Long userId = user.getUserId();
-
+        ZInfoUser zInfoUser = zInfoUserService.getInfoBysysId(userId);
         LambdaQueryWrapper<ZAuthority> lqw = new LambdaQueryWrapper<>();
-        lqw.eq(ZAuthority::getUid,userId);
+        lqw.eq(ZAuthority::getUid,zInfoUser.getUserId());
 
         return list(lqw);
     }
@@ -276,12 +274,24 @@
         return AjaxResult.success(returnData);
 
     }
+    private LambdaQueryWrapper<ZAuthority> uniqueCondition(ZAuthority zAuthority) {
+        LambdaQueryWrapper<ZAuthority> lqw = new LambdaQueryWrapper<>();
+        lqw.eq(zAuthority.getUid()!=null,ZAuthority::getUid,zAuthority.getUid());
+        lqw.eq(zAuthority.getFid()!=null,ZAuthority::getFid,zAuthority.getFid());
 
+        lqw.eq(zAuthority.getAuthority()!=null,ZAuthority::getAuthority,zAuthority.getAuthority());
+
+        return lqw;
+    }
     public void addData(ZAuthority za)
     {
         //鍒ゆ柇鏄惁閲嶅鎺堟潈
-
+        LambdaQueryWrapper<ZAuthority> lqw = uniqueCondition(za);
+        List<ZAuthority> list = list(lqw);
         //
+        if(list.size()>0){
+            throw new RuntimeException("璇峰嬁鏂板閲嶅鏁版嵁");
+        }
         zAuthorityService.save(za);
 
     }
diff --git a/zhang-content/src/main/java/com/ruoyi/service/impl/ZfAncestorServiceImpl.java b/zhang-content/src/main/java/com/ruoyi/service/impl/ZfAncestorServiceImpl.java
index e059439..8a9342e 100644
--- a/zhang-content/src/main/java/com/ruoyi/service/impl/ZfAncestorServiceImpl.java
+++ b/zhang-content/src/main/java/com/ruoyi/service/impl/ZfAncestorServiceImpl.java
@@ -134,6 +134,7 @@
     @Override
     public List<AncestorClan> selectByCondition(ZfAncestor zfAncestor) {
         QueryWrapper<Object> lqw = new QueryWrapper<>();
+        lqw.eq(zfAncestor.getClanId() !=null , " zf_ancestor.clan_id", zfAncestor.getClanId());
 
         lqw.like(StringUtils.isNotEmpty(zfAncestor.getName()),"zf_ancestor.name",zfAncestor.getName());
 
diff --git a/zhang-content/src/main/java/com/ruoyi/service/impl/ZfContactServiceImpl.java b/zhang-content/src/main/java/com/ruoyi/service/impl/ZfContactServiceImpl.java
index 429131d..629d521 100644
--- a/zhang-content/src/main/java/com/ruoyi/service/impl/ZfContactServiceImpl.java
+++ b/zhang-content/src/main/java/com/ruoyi/service/impl/ZfContactServiceImpl.java
@@ -208,11 +208,11 @@
         //瑕佹煡鑷繁瀹跺涵鐨�
         ZInfoUser myself = zInfoUserService.getMyself();
         Long familyId = myself.getFamilyId();
+
         //涔熻鏌ュ埆浜烘巿鏉冪殑
         List<ZAuthority> authority = zAuthorityService.getAuthority();
         List<Long> idList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(CONTACT_LIST)).map(ZAuthority::getFid).collect(Collectors.toList());
         //鍔犱笂鑷繁瀹跺涵鐨刬d
-        idList.add(familyId);
 
         LambdaQueryWrapper<ZfContact> lambdaQueryWrapper = buildCondition(zfContact, idList);
         List<ZfContact> beanRecords = list(lambdaQueryWrapper);
@@ -285,10 +285,21 @@
         }
         Long familyId = myself.getFamilyId();
         //涔熻鏌ュ埆浜烘巿鏉冪殑
+//
+//        System.out.println("--------------7777----------------");
+//
+//        System.out.println(familyId);
         List<ZAuthority> authority = zAuthorityService.getAuthority();
         List<Long> idList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(CONTACT_LIST)).map(ZAuthority::getFid).collect(Collectors.toList());
         //鍔犱笂鑷繁瀹跺涵鐨刬d
         idList.add(familyId);
+//
+//        System.out.println(idList.size());
+//        System.out.println(idList.get(0));
+//
+//        System.out.println("------------------------------");
+        idList.add(familyId);
+
 //        String familyIds = listFamilyIds();
 //        String secondFamilyAuthority = listSecondFamilyIds();
         LambdaQueryWrapper<ZfContact> lqw = buildCondition(zfContact, idList);

--
Gitblit v1.9.1