From 6acee0d1d79a05f7a3a3c386e9df02e9a741f544 Mon Sep 17 00:00:00 2001 From: ZQN <364596817@qq.com> Date: 星期五, 21 六月 2024 17:21:16 +0800 Subject: [PATCH] 执法单节点添加,审批修改 --- project-framework/src/main/java/com/project/framework/aspectj/DataScopeAspect.java | 34 ++++++++++++++++++++++------------ 1 files changed, 22 insertions(+), 12 deletions(-) diff --git a/project-framework/src/main/java/com/project/framework/aspectj/DataScopeAspect.java b/project-framework/src/main/java/com/project/framework/aspectj/DataScopeAspect.java index f890106..9c86359 100644 --- a/project-framework/src/main/java/com/project/framework/aspectj/DataScopeAspect.java +++ b/project-framework/src/main/java/com/project/framework/aspectj/DataScopeAspect.java @@ -1,13 +1,8 @@ package com.project.framework.aspectj; -import java.util.ArrayList; -import java.util.List; -import org.aspectj.lang.JoinPoint; -import org.aspectj.lang.annotation.Aspect; -import org.aspectj.lang.annotation.Before; -import org.springframework.stereotype.Component; import com.project.common.annotation.DataScope; import com.project.common.core.domain.BaseEntity; +import com.project.common.core.domain.BaseQuery; import com.project.common.core.domain.entity.SysRole; import com.project.common.core.domain.entity.SysUser; import com.project.common.core.domain.model.LoginUser; @@ -15,6 +10,13 @@ import com.project.common.utils.SecurityUtils; import com.project.common.utils.StringUtils; import com.project.framework.security.context.PermissionContextHolder; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Before; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.List; /** * 鏁版嵁杩囨护澶勭悊 @@ -49,6 +51,11 @@ * 浠呮湰浜烘暟鎹潈闄� */ public static final String DATA_SCOPE_SELF = "5"; + + /** + * 鏈満鏋勬暟鎹潈闄� + */ + public static final String DATA_SCOPE_ORG = "6"; /** * 鏁版嵁鏉冮檺杩囨护鍏抽敭瀛� @@ -113,29 +120,29 @@ else if (DATA_SCOPE_CUSTOM.equals(dataScope)) { sqlString.append(StringUtils.format( - " OR {}.dept_id IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = {} ) ", deptAlias, + " OR {} IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = {} ) ", deptAlias, role.getRoleId())); } else if (DATA_SCOPE_DEPT.equals(dataScope)) { - sqlString.append(StringUtils.format(" OR {}.dept_id = {} ", deptAlias, user.getDeptId())); + sqlString.append(StringUtils.format(" OR {} = {} ", deptAlias, user.getDeptId())); } else if (DATA_SCOPE_DEPT_AND_CHILD.equals(dataScope)) { sqlString.append(StringUtils.format( - " OR {}.dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = {} or find_in_set( {} , ancestors ) )", + " OR {} IN ( SELECT dept_id FROM sys_dept WHERE dept_id = {} or find_in_set( {} , ancestors ) )", deptAlias, user.getDeptId(), user.getDeptId())); } else if (DATA_SCOPE_SELF.equals(dataScope)) { if (StringUtils.isNotBlank(userAlias)) { - sqlString.append(StringUtils.format(" OR {}.user_id = {} ", userAlias, user.getUserId())); + sqlString.append(StringUtils.format(" OR {} = {} ", userAlias, user.getUserId())); } else { // 鏁版嵁鏉冮檺涓轰粎鏈汉涓旀病鏈塽serAlias鍒悕涓嶆煡璇换浣曟暟鎹� - sqlString.append(StringUtils.format(" OR {}.dept_id = 0 ", deptAlias)); + sqlString.append(StringUtils.format(" OR {}= = 0 ", deptAlias)); } } conditions.add(dataScope); @@ -147,7 +154,10 @@ if (StringUtils.isNotNull(params) && params instanceof BaseEntity) { BaseEntity baseEntity = (BaseEntity) params; - baseEntity.getParams().put(DATA_SCOPE, " AND (" + sqlString.substring(4) + ")"); + baseEntity.getParams().put(DATA_SCOPE, " (" + sqlString.substring(4) + ")"); + } else if (StringUtils.isNotNull(params) && params instanceof BaseQuery) { + BaseQuery baseQuery = (BaseQuery) params; + baseQuery.getParams().put(DATA_SCOPE, " (" + sqlString.substring(4) + ")"); } } } -- Gitblit v1.9.1