|
|
@@ -2,6 +2,7 @@ package com.template.controller;
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.template.annotation.PassToken;
|
|
|
import com.template.api.SmartAuthorGroupControllerAPI;
|
|
|
import com.template.common.utils.TimeExchange2;
|
|
|
@@ -21,7 +22,10 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import java.text.ParseException;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
|
@@ -49,7 +53,7 @@ public class SmartAuthorGroupController implements SmartAuthorGroupControllerAPI
|
|
|
@PassToken
|
|
|
public CommonResult insertSmartAuthorGroup(JSONObject jsonObject, Integer samePower) throws ParseException {
|
|
|
if (samePower==null){
|
|
|
- return CommonResult.errorMsg("samePower不能为空");
|
|
|
+ return CommonResult.fail("samePower不能为空");
|
|
|
}
|
|
|
// 所有管理员权限一样
|
|
|
if (samePower==1){
|
|
|
@@ -57,6 +61,23 @@ public class SmartAuthorGroupController implements SmartAuthorGroupControllerAPI
|
|
|
SmartAuthorGroup sa = authorAndGroup.getSmartAuthorGroup();
|
|
|
sa.setId((int) UUIDUtil.generateID());
|
|
|
String[] userId = sa.getUserId().split(",");
|
|
|
+ // 相关判断
|
|
|
+ QueryWrapper<SmartAuthorGroup> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("deleted", 0);
|
|
|
+ queryWrapper.eq("parent_id", sa.getParentId());
|
|
|
+ queryWrapper.eq("name", sa.getName());
|
|
|
+ List<SmartAuthorGroup> querySmartGroup = smartAuthorGroupService.getAuthorGroupByKey(queryWrapper);
|
|
|
+ if (querySmartGroup.size()>0){
|
|
|
+ return CommonResult.fail("该管理员已存在,请勿重复添加");
|
|
|
+ }
|
|
|
+ QueryWrapper<SmartAuthority> queryWrapper2 = new QueryWrapper<>();
|
|
|
+ List<String> typeList = Arrays.asList(userId);
|
|
|
+ queryWrapper2.in("user_id", typeList);
|
|
|
+ queryWrapper2.eq("deleted", 0);
|
|
|
+ List<SmartAuthority> querySmart = smartAuthorityService.getAuthorByKey(queryWrapper2);
|
|
|
+ if (querySmart.size()>0){
|
|
|
+ return CommonResult.fail("该用户已分配其他权限组");
|
|
|
+ }
|
|
|
for (int i = 0; i < userId.length; i++) {
|
|
|
SmartAuthority smartAuthority = new SmartAuthority();
|
|
|
smartAuthority.setUserId(Integer.parseInt(userId[i]));
|
|
|
@@ -82,6 +103,23 @@ public class SmartAuthorGroupController implements SmartAuthorGroupControllerAPI
|
|
|
SmartAuthorGroup sa = authorAndGroup2.getSmartAuthorGroup();
|
|
|
sa.setId((int) UUIDUtil.generateID());
|
|
|
List<userAuthor> userAuthors = authorAndGroup2.getUserAuthors();
|
|
|
+ // 相关查询
|
|
|
+ QueryWrapper<SmartAuthorGroup> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("deleted", 0);
|
|
|
+ queryWrapper.eq("parent_id", sa.getParentId());
|
|
|
+ queryWrapper.eq("name", sa.getName());
|
|
|
+ List<SmartAuthorGroup> querySmartGroup = smartAuthorGroupService.getAuthorGroupByKey(queryWrapper);
|
|
|
+ if (querySmartGroup.size()>0){
|
|
|
+ return CommonResult.fail("该管理员已存在,请勿重复添加");
|
|
|
+ }
|
|
|
+ List<Integer> uid =userAuthors.stream().map(userAuthor::getUserId).collect(Collectors.toList());
|
|
|
+ QueryWrapper<SmartAuthority> queryWrapper2 = new QueryWrapper<>();
|
|
|
+ queryWrapper2.in("user_id", uid);
|
|
|
+ queryWrapper2.eq("deleted", 0);
|
|
|
+ List<SmartAuthority> querySmart = smartAuthorityService.getAuthorByKey(queryWrapper2);
|
|
|
+ if (querySmart.size()>0){
|
|
|
+ return CommonResult.fail("该用户已分配其他权限组");
|
|
|
+ }
|
|
|
for (int i = 0; i < userAuthors.size(); i++) {
|
|
|
SmartAuthority smartAuthority = new SmartAuthority();
|
|
|
smartAuthority.setUserId(userAuthors.get(i).getUserId());
|