ocr施工日志施工单位权限bug修复
This commit is contained in:
parent
897d2c7f99
commit
c914692236
@ -152,11 +152,12 @@ public class DataScopeHandler implements DataPermissionHandler {
|
|||||||
List<Expression> expressions = new ArrayList<>();
|
List<Expression> expressions = new ArrayList<>();
|
||||||
if (!DataScopeInterceptor.findIgnoreDataScope(parameter, ds)) {
|
if (!DataScopeInterceptor.findIgnoreDataScope(parameter, ds)) {
|
||||||
if (Objects.equals(user.getAccountType(), SystemUserAccountTypeEnum.PROJECT_SUB_ACCOUNT.getValue())) {
|
if (Objects.equals(user.getAccountType(), SystemUserAccountTypeEnum.PROJECT_SUB_ACCOUNT.getValue())) {
|
||||||
|
List<String> authEnterpriseIds = userEnterpriseService.getEnterpriseIdsIfSubProject();
|
||||||
|
authEnterpriseIds.add("0");
|
||||||
List<String> filterEnterprises = getNeedFilterLeftExpression(plainSelect, getFieldEnterpriseTables(), ds);
|
List<String> filterEnterprises = getNeedFilterLeftExpression(plainSelect, getFieldEnterpriseTables(), ds);
|
||||||
if (CollUtil.isNotEmpty(filterEnterprises)) {
|
if (CollUtil.isNotEmpty(filterEnterprises)) {
|
||||||
List<String> enterpriseIds = userEnterpriseService.getEnterpriseIdsIfSubProject();
|
|
||||||
for (String filterEnterprise : filterEnterprises) {
|
for (String filterEnterprise : filterEnterprises) {
|
||||||
inExpression(filterEnterprise, enterpriseIds, plainSelect);
|
inExpression(filterEnterprise, authEnterpriseIds, plainSelect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,29 +194,15 @@ public class DataScopeHandler implements DataPermissionHandler {
|
|||||||
ocrBuildLogTables.put("ocr_build_log", "id");
|
ocrBuildLogTables.put("ocr_build_log", "id");
|
||||||
List<String> filterOcrBuildLogTables = getNeedFilterLeftExpression(plainSelect, ocrBuildLogTables, ds);
|
List<String> filterOcrBuildLogTables = getNeedFilterLeftExpression(plainSelect, ocrBuildLogTables, ds);
|
||||||
if (CollUtil.isNotEmpty(filterOcrBuildLogTables)) {
|
if (CollUtil.isNotEmpty(filterOcrBuildLogTables)) {
|
||||||
List<String> ids = ocrBuildLogService.getIdsIfSubProject().stream().map(Convert::toStr).collect(Collectors.toList());
|
|
||||||
ids.add("0");
|
|
||||||
for (String filterEnterprise : filterOcrBuildLogTables) {
|
for (String filterEnterprise : filterOcrBuildLogTables) {
|
||||||
//( (xxx.id in ()) OR ( xxx.uploader_id = 123))
|
String uploaderIdField = StrUtil.subBefore(filterEnterprise, ".", false) + "." + "uploader_id";
|
||||||
InExpression inExpr = new InExpression();
|
String sql = StrUtil.format(" ( ({} in (select ocr_build_log_id from ocr_build_log_enterprise where enterprise_id in ({}))) OR ( {} = {}))",
|
||||||
ItemsList itemsList = new ExpressionList(ids.stream().map(StringValue::new).collect(Collectors.toList()));
|
filterEnterprise, StrUtil.join(",", authEnterpriseIds), uploaderIdField, SecurityUtils.getUser().getUserId());
|
||||||
inExpr.setLeftExpression(new Column(filterEnterprise));
|
try {
|
||||||
inExpr.setRightItemsList(itemsList);
|
Expression expression = CCJSqlParserUtil.parseCondExpression(sql);
|
||||||
inExpression(filterEnterprise, ids, plainSelect);
|
expressions.add(expression);
|
||||||
// 假设这是你的inExpression方法返回的表达式
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
EqualsTo equalsExpr = new EqualsTo();
|
|
||||||
equalsExpr.setLeftExpression(new Column(StrUtil.subBefore(filterEnterprise, ".", false) + "." + "uploader_id"));
|
|
||||||
equalsExpr.setRightExpression(new LongValue(SecurityUtils.getUser().getUserId()));
|
|
||||||
// 创建OR表达式组合两者
|
|
||||||
OrExpression orExpr = new OrExpression(inExpr, equalsExpr);
|
|
||||||
// 将整个OR表达式添加到WHERE子句中
|
|
||||||
if (plainSelect.getWhere() == null) {
|
|
||||||
plainSelect.setWhere(orExpr);
|
|
||||||
} else {
|
|
||||||
// 如果已有WHERE条件,可能需要用AND连接
|
|
||||||
AndExpression andExpr = new AndExpression(plainSelect.getWhere(), orExpr);
|
|
||||||
plainSelect.setWhere(andExpr);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user