夏文涛 2 лет назад
Родитель
Сommit
1ffc081932

+ 5 - 9
src/main/java/com/template/controller/SmartAuthorGroupController.java

@@ -491,20 +491,16 @@ public class SmartAuthorGroupController implements SmartAuthorGroupControllerAPI
             return CommonResult.fail("有用户已删除");
         }
         if (!oldUserId.isEmpty()){
+            List<Integer> userIds = new ArrayList<>();
             for (int i = 0; i < oldUserId.size(); i++) {
                 System.out.println("-----"+oldUserId.get(i));
                 if (!userList.contains(String.valueOf(oldUserId.get(i)))) {
-                    QueryWrapper<SmartAuthority> queryWrapper1 = new QueryWrapper<>();
-                    queryWrapper1.eq("deleted", 0);
-                    queryWrapper1.eq("user_id", oldUserId.get(i));
-                    List<SmartAuthority> smartAuthority1 = smartAuthorityService.getAuthorByKey(queryWrapper1);
-                    if (smartAuthority1.size() > 0) {
-                        SmartAuthority smartAuthority = smartAuthority1.get(0);
-                        smartAuthority.setDeleted(1);
-                        smartAuthorityService.updateSmartAuthority(smartAuthority);
-                    }
+                    userIds.add(oldUserId.get(i));
                 }
             }
+            if(userIds != null && userIds.size() > 0){
+                smartAuthorityService.deleteAuthorityByUsergroup(userIds, id);
+            }
         }
         for (int i = 0; i < newUserId.length; i++) {
             if (!newUserId[i].equals("")){

+ 2 - 0
src/main/java/com/template/services/SmartAuthorityService.java

@@ -30,4 +30,6 @@ public interface SmartAuthorityService extends IService<SmartAuthority> {
     List<SmartAuthority> getAuthorByKey(QueryWrapper<SmartAuthority> queryWrapper);
 
     SmartAuthority getByUserId(String userId);
+
+    int deleteAuthorityByUsergroup(List<Integer> userIds,Integer groupId);
 }

+ 9 - 0
src/main/java/com/template/services/impl/SmartAuthorityServiceImpl.java

@@ -79,4 +79,13 @@ public class SmartAuthorityServiceImpl extends ServiceImpl<SmartAuthorityMapper,
         return one;
     }
 
+    @Override
+    public int deleteAuthorityByUsergroup(List<Integer> userIds, Integer groupId) {
+        QueryWrapper queryWrapper = new QueryWrapper();
+        queryWrapper.in(userIds != null && userIds.size() > 0,"user_id",userIds);
+        queryWrapper.eq("group_id",groupId);
+        int result = smartAuthorityMapper.delete(queryWrapper);
+        return result;
+    }
+
 }