From 4f9ddf55211744c91ae7675a3b35aa9f3e635561 Mon Sep 17 00:00:00 2001 From: wxz Date: Tue, 9 Jun 2020 16:54:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9D=83=E9=99=90sql=E7=94=9F=E6=88=90?= =?UTF-8?q?=EF=BC=8C=E5=A6=82=E6=9E=9C=E7=BD=91=E6=A0=BC=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E4=B8=BA=E7=A9=BA=E5=88=97=E8=A1=A8=EF=BC=8C=E9=82=A3=E4=B9=88?= =?UTF-8?q?=E4=B8=8D=E6=8A=A5=E9=94=99=EF=BC=8C=E4=B8=8D=E6=89=A7=E8=A1=8C?= =?UTF-8?q?sql=E6=8B=BC=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/service/impl/AccessServiceImpl.java | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java index f47ac58ef4..25afa314fa 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java @@ -161,21 +161,25 @@ public class AccessServiceImpl implements AccessService { } if (switchScopes.contains(OperationScopeConstant.SCOPE_IN_GRID)) { - if (CollectionUtils.isEmpty(gridIds)) { + if (gridIds == null) { String error = String.format("DataFilter:拼接SQL语句出错:需要in grid权限,但是代码中没有获取到gridIds"); logger.error(error); throw new RenException(error); } - genInGrid(sb, gridIds, tableAlias); + if (gridIds.size() != 0) { + genInGrid(sb, gridIds, tableAlias); + } } if (switchScopes.contains(OperationScopeConstant.SCOPE_IN_DEPARTMENT)) { - if (CollectionUtils.isEmpty(departmentIds)) { + if (departmentIds == null) { String error = String.format("DataFilter:拼接SQL语句出错:需要in department权限,但是代码中没有获取到, departmentIds"); logger.error(error); throw new RenException(error); } - genDepartmentFilterSql(sb, departmentIds, tableAlias); + if (departmentIds.size() != 0) { + genDepartmentFilterSql(sb, departmentIds, tableAlias); + } } } @@ -221,6 +225,21 @@ public class AccessServiceImpl implements AccessService { hasConditions.set(true); } + /** + * sql语句拼接FALSE + * @param sb + */ + private void genFalseCondition(StringBuilder sb) { + if (hasConditions.get()) { + // 之前没有条件 + sb.append(" OR "); + } + + sb.append(" FALSE "); + + hasConditions.set(true); + } + /** * 生成部门过滤sql *