first commit
This commit is contained in:
@ -5,6 +5,7 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.qiaoba.auth.annotation.DataScope;
|
||||
import com.qiaoba.auth.entity.LoginUser;
|
||||
import com.qiaoba.auth.entity.dto.RoleDto;
|
||||
import com.qiaoba.common.base.utils.DatabaseUtil;
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Before;
|
||||
@ -59,10 +60,10 @@ public class DataScopeAspect {
|
||||
/**
|
||||
* 数据范围过滤
|
||||
*
|
||||
* @param joinPoint 切点
|
||||
* @param user 用户
|
||||
* @param deptAlias 部门别名
|
||||
* @param userAlias 用户别名
|
||||
* @param joinPoint 切点
|
||||
* @param user 用户
|
||||
* @param deptAlias 部门别名
|
||||
* @param userAlias 用户别名
|
||||
*/
|
||||
public static void dataScopeFilter(JoinPoint joinPoint, LoginUser user, String deptAlias, String userAlias) {
|
||||
StringBuilder sqlString = new StringBuilder();
|
||||
@ -86,9 +87,8 @@ public class DataScopeAspect {
|
||||
sqlString.append(StrUtil.format(" OR {}.dept_id = {} ", deptAlias, user.getDeptId()));
|
||||
} else if (DATA_SCOPE_DEPT_AND_CHILD.equals(dataScope)) {
|
||||
sqlString.append(StrUtil.format(
|
||||
// todo
|
||||
" OR {}.dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = {} or {} )",
|
||||
deptAlias, user.getDeptId(), user.getDeptId()));
|
||||
deptAlias, user.getDeptId(), DatabaseUtil.handleFindInSet(user.getDeptId(), "ancestors")));
|
||||
} else if (DATA_SCOPE_SELF.equals(dataScope)) {
|
||||
if (StrUtil.isNotBlank(userAlias)) {
|
||||
sqlString.append(StrUtil.format(" OR {}.user_id = {} ", userAlias, user.getUserId()));
|
||||
@ -104,7 +104,6 @@ public class DataScopeAspect {
|
||||
if (CollUtil.isEmpty(conditions)) {
|
||||
sqlString.append(StrUtil.format(" OR {}.dept_id = 0 ", deptAlias));
|
||||
}
|
||||
//find_in_set( {} , ancestors )
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user