|
@@ -23,14 +23,16 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
import org.springblade.core.log.exception.ServiceException;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
-import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.constant.BladeConstant;
|
|
|
import org.springblade.core.tool.constant.RoleConstant;
|
|
|
import org.springblade.core.tool.node.ForestNodeMerger;
|
|
|
import org.springblade.core.tool.utils.CollectionUtil;
|
|
|
import org.springblade.core.tool.utils.Func;
|
|
|
+import org.springblade.manager.entity.WbsTableOwnerRole;
|
|
|
+import org.springblade.manager.vo.WbsTableOwnerRoleVO;
|
|
|
import org.springblade.system.dto.RoleDTO;
|
|
|
import org.springblade.system.entity.Role;
|
|
|
import org.springblade.system.entity.RoleMenu;
|
|
@@ -46,9 +48,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
import javax.validation.constraints.NotEmpty;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Collections;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import static org.springblade.common.constant.CommonConstant.API_SCOPE_CATEGORY;
|
|
@@ -248,7 +248,7 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IR
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<Role> seleteParentRole() {
|
|
|
+ public List<Role> selectParentRole() {
|
|
|
return baseMapper.selectList(Wrappers.<Role>query().lambda().eq(Role::getParentId, 0));
|
|
|
}
|
|
|
|
|
@@ -260,5 +260,86 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IR
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Boolean submitRoleAndTableOwner(String roleId, String tableOwners, String tableOwnerIds) {
|
|
|
+ List<WbsTableOwnerRole> list = baseMapper.selectRoleAndTableOwnerListByRoleId(roleId);
|
|
|
+
|
|
|
+ List<String> tableOwnerValuesIn = list.stream().map(WbsTableOwnerRole::getTableOwnerNumber).collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<String> tableOwnerValuesOut = Func.toStrList(tableOwners);
|
|
|
+
|
|
|
+ List<String> diffRent = getDiffRent(tableOwnerValuesOut, tableOwnerValuesIn);
|
|
|
+
|
|
|
+ System.out.println("list: " + list);
|
|
|
+ System.out.println("tableOwnerValuesIn: " + tableOwnerValuesIn);
|
|
|
+ System.out.println("tableOwnerValuesOut: " + tableOwnerValuesOut);
|
|
|
+ System.out.println("diffRent: " + diffRent);
|
|
|
+
|
|
|
+ List<String> ids = new ArrayList<>();
|
|
|
+
|
|
|
+ //获取ids
|
|
|
+ for (WbsTableOwnerRole wbsTableOwnerRole : list) {
|
|
|
+ for (String diff : diffRent) {
|
|
|
+ if (wbsTableOwnerRole.getTableOwnerNumber().equals(diff)) {
|
|
|
+ ids.add(String.valueOf(wbsTableOwnerRole.getId()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ System.out.println("ids: " + ids);
|
|
|
+
|
|
|
+ if (diffRent.size() == 0) {
|
|
|
+ throw new ServiceException("未进行任何操作");
|
|
|
+ } else {
|
|
|
+ if (tableOwnerValuesOut.size() > tableOwnerValuesIn.size()) {
|
|
|
+ //新增
|
|
|
+ for (String tableOwner : diffRent) {
|
|
|
+ Long id = SnowFlakeUtil.getId();
|
|
|
+ baseMapper.insertRoleAndTableOwner(id, roleId, tableOwner);
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+
|
|
|
+ } else if (tableOwnerValuesOut.size() < tableOwnerValuesIn.size()) {
|
|
|
+ //删除
|
|
|
+ Integer row = baseMapper.deleteRoleAndTableOwner(ids);
|
|
|
+ return row > 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<WbsTableOwnerRole> searchRoleAndTableOwnerList(String roleId) {
|
|
|
+ return baseMapper.selectRoleAndTableOwnerList(roleId);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private static List<String> getDiffRent(List<String> list1, List<String> list2) {
|
|
|
+ List<String> diff = new ArrayList<String>();
|
|
|
+ List<String> maxList = list1;
|
|
|
+ List<String> minList = list2;
|
|
|
+ if (list2.size() > list1.size()) {
|
|
|
+ maxList = list2;
|
|
|
+ minList = list1;
|
|
|
+ }
|
|
|
+ Map<String, Integer> map = new HashMap<String, Integer>(maxList.size());
|
|
|
+ for (String string : maxList) {
|
|
|
+ map.put(string, 1);
|
|
|
+ }
|
|
|
+ for (String string : minList) {
|
|
|
+ if (map.get(string) != null) {
|
|
|
+ map.put(string, 2);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ diff.add(string);
|
|
|
+ }
|
|
|
+ for (Map.Entry<String, Integer> entry : map.entrySet()) {
|
|
|
+ if (entry.getValue() == 1) {
|
|
|
+ diff.add(entry.getKey());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return diff;
|
|
|
+ }
|
|
|
|
|
|
}
|