|
@@ -1,21 +1,29 @@
|
|
|
package com.template.controller;
|
|
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.api.SmartAuthorGroupControllerAPI;
|
|
|
-import com.template.common.utils.paramUtils;
|
|
|
|
|
-import com.template.model.pojo.SmartAuthorGroup;
|
|
|
|
|
|
|
+import com.template.common.utils.TimeExchange2;
|
|
|
|
|
+import com.template.common.utils.TreeRecordsUtil;
|
|
|
|
|
+import com.template.common.utils.UUIDUtil;
|
|
|
import com.template.model.pojo.SmartAuthorGroup;
|
|
import com.template.model.pojo.SmartAuthorGroup;
|
|
|
|
|
+import com.template.model.pojo.SmartAuthority;
|
|
|
import com.template.model.result.CommonResult;
|
|
import com.template.model.result.CommonResult;
|
|
|
-import com.template.model.result.PageUtils;
|
|
|
|
|
-import com.template.model.vo.ApplyVo;
|
|
|
|
|
|
|
+import com.template.model.weixin.AuthorAndGroup;
|
|
|
|
|
+import com.template.model.weixin.AuthorAndGroup2;
|
|
|
|
|
+import com.template.model.weixin.AuthorListGroup;
|
|
|
|
|
+import com.template.model.weixin.userAuthor;
|
|
|
import com.template.services.SmartAuthorGroupService;
|
|
import com.template.services.SmartAuthorGroupService;
|
|
|
|
|
+import com.template.services.SmartAuthorityService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.validation.BindingResult;
|
|
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
-import java.util.List;
|
|
|
|
|
|
|
+import java.text.ParseException;
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* <p>
|
|
* <p>
|
|
@@ -30,54 +38,335 @@ public class SmartAuthorGroupController implements SmartAuthorGroupControllerAPI
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private SmartAuthorGroupService smartAuthorGroupService;
|
|
private SmartAuthorGroupService smartAuthorGroupService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ public SmartAuthorityService smartAuthorityService;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 新增权限组
|
|
* 新增权限组
|
|
|
- * @param smartApply 权限组数据
|
|
|
|
|
- * @param bindingResult
|
|
|
|
|
|
|
+ * @param
|
|
|
|
|
+ * @param
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- public CommonResult insertSmartAuthorGroup(SmartAuthorGroup smartApply, BindingResult bindingResult) {
|
|
|
|
|
- if (bindingResult.hasErrors()) {
|
|
|
|
|
- String st = paramUtils.getParamError(bindingResult);
|
|
|
|
|
- return CommonResult.fail(st);
|
|
|
|
|
|
|
+ @PassToken
|
|
|
|
|
+ public CommonResult insertSmartAuthorGroup(JSONObject jsonObject, Integer samePower) throws ParseException {
|
|
|
|
|
+ if (samePower==null){
|
|
|
|
|
+ return CommonResult.fail("samePower不能为空");
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- int result = smartAuthorGroupService.insertSmartAuthorGroup(smartApply);
|
|
|
|
|
-
|
|
|
|
|
- return result > 0 ? CommonResult.ok("添加成功") : CommonResult.fail("添加失败");
|
|
|
|
|
|
|
+ // 所有管理员权限一样
|
|
|
|
|
+ if (samePower==1){
|
|
|
|
|
+ AuthorAndGroup authorAndGroup = JSONObject.parseObject(jsonObject.toString(), AuthorAndGroup.class);
|
|
|
|
|
+ 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("该用户已分配其他权限组");
|
|
|
|
|
+ }
|
|
|
|
|
+ Set<String> set = new HashSet<>(typeList);
|
|
|
|
|
+ if (typeList.size()!=set.size()){
|
|
|
|
|
+ return CommonResult.fail("请勿选择重复用户");
|
|
|
|
|
+ }
|
|
|
|
|
+ for (int i = 0; i < userId.length; i++) {
|
|
|
|
|
+ SmartAuthority smartAuthority = new SmartAuthority();
|
|
|
|
|
+ smartAuthority.setUserId(Integer.parseInt(userId[i]));
|
|
|
|
|
+ smartAuthority.setGroupId(sa.getId());
|
|
|
|
|
+ smartAuthority.setDepartmentView(authorAndGroup.getDepartment_view());
|
|
|
|
|
+ smartAuthority.setDepartmentManage(authorAndGroup.getDepartment_manage());
|
|
|
|
|
+ smartAuthority.setCreateTime(TimeExchange2.StringToDate(TimeExchange2.getTime(),"yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
+ smartAuthority.setUpdateTime(TimeExchange2.StringToDate(TimeExchange2.getTime(),"yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
+ smartAuthority.setCreateUser("admin");
|
|
|
|
|
+ smartAuthority.setUpdateUser("admin");
|
|
|
|
|
+ smartAuthority.setDeleted(0);
|
|
|
|
|
+ smartAuthorityService.insertSmartAuthority(smartAuthority);
|
|
|
|
|
+ }
|
|
|
|
|
+ sa.setUpdateTime(TimeExchange2.StringToDate(TimeExchange2.getTime(),"yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
+ sa.setCreateUser("admin");
|
|
|
|
|
+ sa.setUpdateUser("admin");
|
|
|
|
|
+ sa.setDeleted(0);
|
|
|
|
|
+ int result = smartAuthorGroupService.insertSmartAuthorGroup(sa);
|
|
|
|
|
+ return result > 0 ? CommonResult.ok("添加成功") : CommonResult.fail("添加失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ // 每个管理员权限不一样
|
|
|
|
|
+ if (samePower==2){
|
|
|
|
|
+ AuthorAndGroup2 authorAndGroup2 = JSONObject.parseObject(jsonObject.toString(), AuthorAndGroup2.class);
|
|
|
|
|
+ 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("该用户已分配其他权限组");
|
|
|
|
|
+ }
|
|
|
|
|
+ Set<Integer> set = new HashSet<>(uid);
|
|
|
|
|
+ if (uid.size()!=set.size()){
|
|
|
|
|
+ return CommonResult.fail("请勿选择重复用户");
|
|
|
|
|
+ }
|
|
|
|
|
+ for (int i = 0; i < userAuthors.size(); i++) {
|
|
|
|
|
+ SmartAuthority smartAuthority = new SmartAuthority();
|
|
|
|
|
+ smartAuthority.setUserId(userAuthors.get(i).getUserId());
|
|
|
|
|
+ smartAuthority.setGroupId(sa.getId());
|
|
|
|
|
+ smartAuthority.setDepartmentView(userAuthors.get(i).getDepartment_view());
|
|
|
|
|
+ smartAuthority.setDepartmentManage(userAuthors.get(i).getDepartment_manage());
|
|
|
|
|
+ smartAuthority.setCreateTime(TimeExchange2.StringToDate(TimeExchange2.getTime(),"yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
+ smartAuthority.setUpdateTime(TimeExchange2.StringToDate(TimeExchange2.getTime(),"yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
+ smartAuthority.setCreateUser("admin");
|
|
|
|
|
+ smartAuthority.setUpdateUser("admin");
|
|
|
|
|
+ smartAuthority.setDeleted(0);
|
|
|
|
|
+ smartAuthorityService.insertSmartAuthority(smartAuthority);
|
|
|
|
|
+ }
|
|
|
|
|
+ sa.setUpdateTime(TimeExchange2.StringToDate(TimeExchange2.getTime(),"yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
+ sa.setCreateUser("admin");
|
|
|
|
|
+ sa.setUpdateUser("admin");
|
|
|
|
|
+ sa.setDeleted(0);
|
|
|
|
|
+ int result = smartAuthorGroupService.insertSmartAuthorGroup(sa);
|
|
|
|
|
+ return result > 0 ? CommonResult.ok("添加成功") : CommonResult.fail("添加失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ return CommonResult.errorMsg("参数格式错误");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 更新权限组
|
|
* 更新权限组
|
|
|
- * @param sa 权限组数据
|
|
|
|
|
- * @param bindingResult
|
|
|
|
|
|
|
+ * @param
|
|
|
|
|
+ * @param
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- public CommonResult updateSmartAuthorGroupById(SmartAuthorGroup sa, BindingResult bindingResult) {
|
|
|
|
|
- if (bindingResult.hasErrors()) {
|
|
|
|
|
- String st = paramUtils.getParamError(bindingResult);
|
|
|
|
|
- return CommonResult.fail(st);
|
|
|
|
|
|
|
+ @PassToken
|
|
|
|
|
+ public CommonResult updateSmartAuthorGroup(JSONObject jsonObject, Integer samePower) throws ParseException {
|
|
|
|
|
+ if (samePower==null){
|
|
|
|
|
+ return CommonResult.errorMsg("samePower不能为空");
|
|
|
}
|
|
}
|
|
|
|
|
+ // 所有管理员权限一样
|
|
|
|
|
+ if (samePower==1){
|
|
|
|
|
+ AuthorAndGroup authorAndGroup = JSONObject.parseObject(jsonObject.toString(), AuthorAndGroup.class);
|
|
|
|
|
+ SmartAuthorGroup sa = authorAndGroup.getSmartAuthorGroup();
|
|
|
|
|
+ String[] userId = sa.getUserId().split(",");
|
|
|
|
|
+ // 相关判断
|
|
|
|
|
+ QueryWrapper<SmartAuthorGroup> queryWrapperA = new QueryWrapper<>();
|
|
|
|
|
+ queryWrapperA.eq("deleted", 0);
|
|
|
|
|
+ queryWrapperA.eq("id",sa.getId());
|
|
|
|
|
+ List<SmartAuthorGroup> querySmartGroupA = smartAuthorGroupService.getAuthorGroupByKey(queryWrapperA);
|
|
|
|
|
+ if (querySmartGroupA.size()<=0){
|
|
|
|
|
+ return CommonResult.fail("该条信息已删除");
|
|
|
|
|
+ }
|
|
|
|
|
+ QueryWrapper<SmartAuthorGroup> queryWrapperB = new QueryWrapper<>();
|
|
|
|
|
+ queryWrapperB.eq("deleted", 0);
|
|
|
|
|
+ queryWrapperB.eq("id",sa.getParentId());
|
|
|
|
|
+ List<SmartAuthorGroup> querySmartGroupB = smartAuthorGroupService.getAuthorGroupByKey(queryWrapperB);
|
|
|
|
|
+ if (querySmartGroupB.size()<=0 && sa.getParentId()!=0){
|
|
|
|
|
+ return CommonResult.fail("父ID不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ QueryWrapper<SmartAuthorGroup> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
+ queryWrapper.eq("deleted", 0);
|
|
|
|
|
+ queryWrapper.eq("parent_id", sa.getParentId());
|
|
|
|
|
+ queryWrapper.eq("name", sa.getName());
|
|
|
|
|
+ queryWrapper.ne("id",sa.getId());
|
|
|
|
|
+ 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);
|
|
|
|
|
+ queryWrapper2.ne("group_id", sa.getId());
|
|
|
|
|
+ List<SmartAuthority> querySmart = smartAuthorityService.getAuthorByKey(queryWrapper2);
|
|
|
|
|
+ if (querySmart.size()>0){
|
|
|
|
|
+ return CommonResult.fail("该用户已分配其他权限组");
|
|
|
|
|
+ }
|
|
|
|
|
+ Set<String> set = new HashSet<>(typeList);
|
|
|
|
|
+ if (typeList.size()!=set.size()){
|
|
|
|
|
+ return CommonResult.fail("请勿选择重复用户");
|
|
|
|
|
+ }
|
|
|
|
|
+ String[] old_userId = querySmartGroupA.get(0).getUserId().split(",");
|
|
|
|
|
+ for (int i = 0; i < old_userId.length; i++) {
|
|
|
|
|
+ if (!typeList.contains(old_userId[i])){
|
|
|
|
|
+ QueryWrapper<SmartAuthority> queryWrapperC = new QueryWrapper<>();
|
|
|
|
|
+ queryWrapperC.eq("deleted", 0);
|
|
|
|
|
+ queryWrapperC.eq("user_id",Integer.parseInt(old_userId[i]));
|
|
|
|
|
+ List<SmartAuthority> smartAuthorityC = smartAuthorityService.getAuthorByKey(queryWrapperC);
|
|
|
|
|
+ if (smartAuthorityC.size()>0){
|
|
|
|
|
+ SmartAuthority smartAuthority = smartAuthorityC.get(0);
|
|
|
|
|
+ smartAuthority.setDeleted(1);
|
|
|
|
|
+ System.out.println(")))"+smartAuthority.getId());
|
|
|
|
|
+ smartAuthorityService.updateSmartAuthority(smartAuthority);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ for (int i = 0; i < userId.length; i++) {
|
|
|
|
|
+ QueryWrapper<SmartAuthority> queryWrapper3 = new QueryWrapper<>();
|
|
|
|
|
+ queryWrapper3.eq("deleted", 0);
|
|
|
|
|
+ queryWrapper3.eq("user_id",Integer.parseInt(userId[i]));
|
|
|
|
|
+ List<SmartAuthority> smartAuthoritys = smartAuthorityService.getAuthorByKey(queryWrapper3);
|
|
|
|
|
+ if (smartAuthoritys.size()>0){
|
|
|
|
|
+ SmartAuthority smartAuthority = smartAuthoritys.get(0);
|
|
|
|
|
+ smartAuthority.setGroupId(sa.getId());
|
|
|
|
|
+ smartAuthority.setDepartmentView(authorAndGroup.getDepartment_view());
|
|
|
|
|
+ smartAuthority.setDepartmentManage(authorAndGroup.getDepartment_manage());
|
|
|
|
|
+ smartAuthority.setCreateTime(TimeExchange2.StringToDate(TimeExchange2.getTime(),"yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
+ smartAuthority.setUpdateTime(TimeExchange2.StringToDate(TimeExchange2.getTime(),"yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
+ smartAuthority.setCreateUser("admin");
|
|
|
|
|
+ smartAuthority.setUpdateUser("admin");
|
|
|
|
|
+ smartAuthority.setDeleted(0);
|
|
|
|
|
+ smartAuthorityService.updateSmartAuthority(smartAuthority);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ SmartAuthority smartAuthority = new SmartAuthority();
|
|
|
|
|
+ smartAuthority.setUserId(Integer.parseInt(userId[i]));
|
|
|
|
|
+ smartAuthority.setGroupId(sa.getId());
|
|
|
|
|
+ smartAuthority.setDepartmentView(authorAndGroup.getDepartment_view());
|
|
|
|
|
+ smartAuthority.setDepartmentManage(authorAndGroup.getDepartment_manage());
|
|
|
|
|
+ smartAuthority.setCreateTime(TimeExchange2.StringToDate(TimeExchange2.getTime(),"yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
+ smartAuthority.setUpdateTime(TimeExchange2.StringToDate(TimeExchange2.getTime(),"yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
+ smartAuthority.setCreateUser("admin");
|
|
|
|
|
+ smartAuthority.setUpdateUser("admin");
|
|
|
|
|
+ smartAuthority.setDeleted(0);
|
|
|
|
|
+ smartAuthorityService.insertSmartAuthority(smartAuthority);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- int result = smartAuthorGroupService.updateSmartAuthorGroup(sa);
|
|
|
|
|
- return result > 0 ? CommonResult.ok("修改成功") : CommonResult.fail("修改失败");
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ int result = smartAuthorGroupService.updateSmartAuthorGroup(sa);
|
|
|
|
|
+ return result > 0 ? CommonResult.ok("修改成功") : CommonResult.fail("修改失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ // 每个管理员权限不一样
|
|
|
|
|
+ if (samePower==2){
|
|
|
|
|
+ AuthorAndGroup2 authorAndGroup2 = JSONObject.parseObject(jsonObject.toString(), AuthorAndGroup2.class);
|
|
|
|
|
+ SmartAuthorGroup sa = authorAndGroup2.getSmartAuthorGroup();
|
|
|
|
|
+ List<userAuthor> userAuthors = authorAndGroup2.getUserAuthors();
|
|
|
|
|
+ // 相关查询
|
|
|
|
|
+ QueryWrapper<SmartAuthorGroup> queryWrapperA = new QueryWrapper<>();
|
|
|
|
|
+ queryWrapperA.eq("deleted", 0);
|
|
|
|
|
+ queryWrapperA.eq("id",sa.getId());
|
|
|
|
|
+ List<SmartAuthorGroup> querySmartGroupA = smartAuthorGroupService.getAuthorGroupByKey(queryWrapperA);
|
|
|
|
|
+ if (querySmartGroupA.size()<=0){
|
|
|
|
|
+ return CommonResult.fail("该条信息已删除");
|
|
|
|
|
+ }
|
|
|
|
|
+ QueryWrapper<SmartAuthorGroup> queryWrapperB = new QueryWrapper<>();
|
|
|
|
|
+ queryWrapperB.eq("deleted", 0);
|
|
|
|
|
+ queryWrapperB.eq("id",sa.getParentId());
|
|
|
|
|
+ List<SmartAuthorGroup> querySmartGroupB = smartAuthorGroupService.getAuthorGroupByKey(queryWrapperB);
|
|
|
|
|
+ if (querySmartGroupB.size()<=0 && sa.getParentId()!=0){
|
|
|
|
|
+ return CommonResult.fail("父ID不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ QueryWrapper<SmartAuthorGroup> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
+ queryWrapper.eq("deleted", 0);
|
|
|
|
|
+ queryWrapper.eq("parent_id", sa.getParentId());
|
|
|
|
|
+ queryWrapper.eq("name", sa.getName());
|
|
|
|
|
+ queryWrapper.ne("id",sa.getId());
|
|
|
|
|
+ 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);
|
|
|
|
|
+ queryWrapper2.ne("group_id", sa.getId());
|
|
|
|
|
+ List<SmartAuthority> querySmart = smartAuthorityService.getAuthorByKey(queryWrapper2);
|
|
|
|
|
+ if (querySmart.size()>0){
|
|
|
|
|
+ return CommonResult.fail("该用户已分配其他权限组");
|
|
|
|
|
+ }
|
|
|
|
|
+ Set<Integer> set = new HashSet<>(uid);
|
|
|
|
|
+ if (uid.size()!=set.size()){
|
|
|
|
|
+ return CommonResult.fail("请勿选择重复用户");
|
|
|
|
|
+ }
|
|
|
|
|
+ String[] old_userId = querySmartGroupA.get(0).getUserId().split(",");
|
|
|
|
|
+ for (int i = 0; i < old_userId.length; i++) {
|
|
|
|
|
+ if (!uid.contains(Integer.parseInt(old_userId[i]))){
|
|
|
|
|
+ QueryWrapper<SmartAuthority> queryWrapperC = new QueryWrapper<>();
|
|
|
|
|
+ queryWrapperC.eq("deleted", 0);
|
|
|
|
|
+ queryWrapperC.eq("user_id",Integer.parseInt(old_userId[i]));
|
|
|
|
|
+ List<SmartAuthority> smartAuthorityC = smartAuthorityService.getAuthorByKey(queryWrapperC);
|
|
|
|
|
+ if (smartAuthorityC.size()>0){
|
|
|
|
|
+ SmartAuthority smartAuthority = smartAuthorityC.get(0);
|
|
|
|
|
+ smartAuthority.setDeleted(1);
|
|
|
|
|
+ smartAuthorityService.updateSmartAuthority(smartAuthority);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ String userid = "";
|
|
|
|
|
+ for (int i = 0; i < userAuthors.size(); i++) {
|
|
|
|
|
+ if (i==userAuthors.size()-1){
|
|
|
|
|
+ userid+=userAuthors.get(i).getUserId();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ userid+=userAuthors.get(i).getUserId()+",";
|
|
|
|
|
+ }
|
|
|
|
|
+ QueryWrapper<SmartAuthority> queryWrapper3 = new QueryWrapper<>();
|
|
|
|
|
+ queryWrapper3.eq("deleted", 0);
|
|
|
|
|
+ queryWrapper3.eq("user_id",userAuthors.get(i).getUserId());
|
|
|
|
|
+ List<SmartAuthority> smartAuthoritys = smartAuthorityService.getAuthorByKey(queryWrapper3);
|
|
|
|
|
+ if (smartAuthoritys.size()>0){
|
|
|
|
|
+ SmartAuthority smartAuthority = smartAuthoritys.get(0);
|
|
|
|
|
+ smartAuthority.setUserId(userAuthors.get(i).getUserId());
|
|
|
|
|
+ smartAuthority.setGroupId(sa.getId());
|
|
|
|
|
+ smartAuthority.setDepartmentView(userAuthors.get(i).getDepartment_view());
|
|
|
|
|
+ smartAuthority.setDepartmentManage(userAuthors.get(i).getDepartment_manage());
|
|
|
|
|
+ smartAuthority.setCreateTime(TimeExchange2.StringToDate(TimeExchange2.getTime(),"yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
+ smartAuthority.setUpdateTime(TimeExchange2.StringToDate(TimeExchange2.getTime(),"yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
+ smartAuthority.setCreateUser("admin");
|
|
|
|
|
+ smartAuthority.setUpdateUser("admin");
|
|
|
|
|
+ smartAuthority.setDeleted(userAuthors.get(i).getDeleted());
|
|
|
|
|
+ smartAuthorityService.updateSmartAuthority(smartAuthority);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ SmartAuthority smartAuthority = new SmartAuthority();
|
|
|
|
|
+ smartAuthority.setUserId(userAuthors.get(i).getUserId());
|
|
|
|
|
+ smartAuthority.setGroupId(sa.getId());
|
|
|
|
|
+ smartAuthority.setDepartmentView(userAuthors.get(i).getDepartment_view());
|
|
|
|
|
+ smartAuthority.setDepartmentManage(userAuthors.get(i).getDepartment_manage());
|
|
|
|
|
+ smartAuthority.setCreateTime(TimeExchange2.StringToDate(TimeExchange2.getTime(),"yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
+ smartAuthority.setUpdateTime(TimeExchange2.StringToDate(TimeExchange2.getTime(),"yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
+ smartAuthority.setCreateUser("admin");
|
|
|
|
|
+ smartAuthority.setUpdateUser("admin");
|
|
|
|
|
+ smartAuthority.setDeleted(0);
|
|
|
|
|
+ smartAuthorityService.insertSmartAuthority(smartAuthority);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ sa.setUserId(userid);
|
|
|
|
|
+ int result = smartAuthorGroupService.updateSmartAuthorGroup(sa);
|
|
|
|
|
+ return result > 0 ? CommonResult.ok("修改成功") : CommonResult.fail("修改失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ return CommonResult.errorMsg("参数格式错误");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 权限组分页数据查询
|
|
|
|
|
- * @param currentPage 当前页数
|
|
|
|
|
- * @param pageCount 一页数据条数
|
|
|
|
|
- * @param name 查询名称
|
|
|
|
|
|
|
+ * 查看权限列表
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- public CommonResult queryPageSmartAuthorGroups(int currentPage, int pageCount, String name) {
|
|
|
|
|
- PageUtils<SmartAuthorGroup> result = smartAuthorGroupService.queryPageSmartAuthorGroups(currentPage, pageCount, name);
|
|
|
|
|
-
|
|
|
|
|
- return CommonResult.ok(result);
|
|
|
|
|
|
|
+ @PassToken
|
|
|
|
|
+ public CommonResult querySmartAuthorGroup(Integer authorGroupId) {
|
|
|
|
|
+ List<SmartAuthorGroup> smartAuthorGroups = smartAuthorGroupService.getAuthorGroupList();
|
|
|
|
|
+ List<AuthorListGroup> authorListGroupList = null;
|
|
|
|
|
+ if (smartAuthorGroups.size()>0) {
|
|
|
|
|
+ authorListGroupList = TreeRecordsUtil.queryCommentTreeRecords(authorGroupId, smartAuthorGroups);
|
|
|
|
|
+ }
|
|
|
|
|
+ return CommonResult.ok(authorListGroupList);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|