Просмотр исходного кода

Merge branch 'master' of https://e.coding.net/chuanghaikeji/smartCampus/backend_code

溪鸭夏 2 лет назад
Родитель
Сommit
294af265a2
1 измененных файлов с 21 добавлено и 17 удалено
  1. 21 17
      src/main/java/com/template/controller/SmartAuthorGroupController.java

+ 21 - 17
src/main/java/com/template/controller/SmartAuthorGroupController.java

@@ -17,8 +17,6 @@ import com.template.model.weixin.AuthorAndGroup2;
 import com.template.model.weixin.AuthorListGroup;
 import com.template.model.weixin.AuthorListGroup;
 import com.template.model.weixin.userAuthor;
 import com.template.model.weixin.userAuthor;
 import com.template.services.*;
 import com.template.services.*;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 
 
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.bind.annotation.RestController;
@@ -40,7 +38,6 @@ import java.util.stream.Collectors;
 @DESRespondSecret
 @DESRespondSecret
 public class SmartAuthorGroupController implements SmartAuthorGroupControllerAPI {
 public class SmartAuthorGroupController implements SmartAuthorGroupControllerAPI {
 
 
-    private static Logger logger = LoggerFactory.getLogger(SmartAuthorGroupController.class);
     @Autowired
     @Autowired
     private SmartAuthorGroupService smartAuthorGroupService;
     private SmartAuthorGroupService smartAuthorGroupService;
     @Autowired
     @Autowired
@@ -229,7 +226,7 @@ public class SmartAuthorGroupController implements SmartAuthorGroupControllerAPI
                     if (smartAuthorityC.size() > 0) {
                     if (smartAuthorityC.size() > 0) {
                         SmartAuthority smartAuthority = smartAuthorityC.get(0);
                         SmartAuthority smartAuthority = smartAuthorityC.get(0);
                         smartAuthority.setDeleted(1);
                         smartAuthority.setDeleted(1);
-                        logger.info(")))" + smartAuthority.getId());
+                        System.out.println(")))" + smartAuthority.getId());
                         smartAuthorityService.updateSmartAuthority(smartAuthority);
                         smartAuthorityService.updateSmartAuthority(smartAuthority);
                     }
                     }
                 }
                 }
@@ -463,7 +460,6 @@ public class SmartAuthorGroupController implements SmartAuthorGroupControllerAPI
         if (sa.getUserId()==null){
         if (sa.getUserId()==null){
             sa.setUserId("");
             sa.setUserId("");
         }
         }
-        String[] oldUserId = sa.getUserId().split(",");
         String[] newUserId = userId.split(",");
         String[] newUserId = userId.split(",");
         List<String> userList = Arrays.asList(newUserId);
         List<String> userList = Arrays.asList(newUserId);
         Set<String> set = new HashSet<>(userList);
         Set<String> set = new HashSet<>(userList);
@@ -479,6 +475,11 @@ public class SmartAuthorGroupController implements SmartAuthorGroupControllerAPI
         if (querySmart.size() > 0) {
         if (querySmart.size() > 0) {
             return CommonResult.fail("该用户已分配其他权限组");
             return CommonResult.fail("该用户已分配其他权限组");
         }
         }
+        QueryWrapper<SmartAuthority> queryWrapperA2 = new QueryWrapper<>();
+        queryWrapperA2.eq("deleted", 0);
+        queryWrapperA2.eq("group_id", sa.getId());
+        List<SmartAuthority> oldUser = smartAuthorityService.getAuthorByKey(queryWrapperA2);
+        List<Integer> oldUserId = oldUser.stream().map(SmartAuthority::getUserId).collect(Collectors.toList());
         QueryWrapper<SmartUser> queryWrapperB = new QueryWrapper<>();
         QueryWrapper<SmartUser> queryWrapperB = new QueryWrapper<>();
         List<String> users = Arrays.asList(newUserId);
         List<String> users = Arrays.asList(newUserId);
         queryWrapperB.in("id", users);
         queryWrapperB.in("id", users);
@@ -487,16 +488,19 @@ public class SmartAuthorGroupController implements SmartAuthorGroupControllerAPI
         if (!userId.equals("") && (ulist.isEmpty() || ulist.size()!=newUserId.length)){
         if (!userId.equals("") && (ulist.isEmpty() || ulist.size()!=newUserId.length)){
             return CommonResult.fail("有用户已删除");
             return CommonResult.fail("有用户已删除");
         }
         }
-        for (int i = 0; i < oldUserId.length; i++) {
-            if (!oldUserId[i].equals("") && !userList.contains(oldUserId[i])) {
-                QueryWrapper<SmartAuthority> queryWrapper1 = new QueryWrapper<>();
-                queryWrapper1.eq("deleted", 0);
-                queryWrapper1.eq("user_id", Integer.parseInt(oldUserId[i]));
-                List<SmartAuthority> smartAuthority1 = smartAuthorityService.getAuthorByKey(queryWrapper1);
-                if (smartAuthority1.size() > 0) {
-                    SmartAuthority smartAuthority = smartAuthority1.get(0);
-                    smartAuthority.setDeleted(1);
-                    smartAuthorityService.updateSmartAuthority(smartAuthority);
+        if (!oldUserId.isEmpty()){
+            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);
+                    }
                 }
                 }
             }
             }
         }
         }
@@ -617,9 +621,9 @@ public class SmartAuthorGroupController implements SmartAuthorGroupControllerAPI
     @PassToken
     @PassToken
     @Override
     @Override
     @DESRespondSecret(validated = false)
     @DESRespondSecret(validated = false)
-    public CommonResult queryUserAuthor(String userId,String userhead) {
+    public CommonResult queryUserAuthor(String userId,String userHead) {
         if (userId==null || userId.equals("")){
         if (userId==null || userId.equals("")){
-            userId = AesUtils.decrypt(userhead);
+            userId = AesUtils.decrypt(userHead);
         }
         }
         String[] userids = userId.split(",");
         String[] userids = userId.split(",");
         QueryWrapper<SmartAuthority> queryWrapper1 = new QueryWrapper<>();
         QueryWrapper<SmartAuthority> queryWrapper1 = new QueryWrapper<>();