Explorar o código

[task-2328]【后端】数据列表查询接口过滤条件增强

Li Yuan hai 1 ano
pai
achega
7f14a22fd6

+ 25 - 0
ibps-excessive-root/modules/platform-excessive/src/main/java/com/lc/ibps/platform/script/script/CommonScript.java

@@ -850,7 +850,32 @@ public class CommonScript extends BaseScript {
 
 		return result;
 	}
+	public List<String> findPositionId(String roleName) {
+		if(StringUtil.isNotBlank(roleName)) {
+			List<String> roles = Arrays.asList(roleName.toLowerCase().split(","));
+			for (DefaultPartyRolePo partyRolePo : PartyUtil.findRoleByUserId(currentContext.getCurrentUserId())) {
+				if (roles.contains(partyRolePo.getAlias().toLowerCase())) {
+					List<String> result = new ArrayList<String>();
+					//find all position nodes
+					APIResult<List<PartyEntityTreePo>> tree = PartyUtil.findAllPositions();
+					if (!tree.isSuccess()) {
+						result.add("0");
+						return result;
+					}
+					List<PartyEntityTreePo> treeData = tree.getData();
+					//remove root node
+					treeData = treeData.stream().filter(x -> !x.getId().equals(StringPool.ZERO)).collect(Collectors.toList());
+					//get all position
+					List<String> posWithChild = treeData.stream()
+							.map(PartyEntityTreePo::getId)
+							.collect(Collectors.toList());
+					return posWithChild;
+				}
+			}
+		}
+		return findPositionId();
 
+	}
 	/**
 	 * 脚本获取用户的岗位ID 只能用于in 或者 not in 在。。之内和 不在。。之内
 	 * cscript.findPositionId()