ZQN
2024-06-21 6acee0d1d79a05f7a3a3c386e9df02e9a741f544
project-framework/src/main/java/com/project/framework/aspectj/DataScopeAspect.java
@@ -2,6 +2,7 @@
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;
@@ -124,19 +125,13 @@
            }
            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 {} IN ( SELECT dept_id FROM sys_dept WHERE dept_id = {} or find_in_set( {} , ancestors ) )",
                        deptAlias, user.getDeptId(), user.getDeptId()));
            }
            else if (DATA_SCOPE_ORG.equals(dataScope))
            {
                sqlString.append(StringUtils.format(
                        " OR {} IN ( SELECT dept_id FROM sys_dept WHERE dept_id = {} or find_in_set( {} , ancestors ) )",
                        deptAlias, user.getRecommendUser(), user.getRecommendUser()));
            }
            else if (DATA_SCOPE_SELF.equals(dataScope))
            {
@@ -159,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) + ")");
            }
        }
    }