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 )
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -60,13 +60,14 @@ public class LoginUser implements UserDetails {
|
||||
public LoginUser() {
|
||||
}
|
||||
|
||||
public LoginUser(String userId, String deptId, String username, String nickname, List<String> roleKeys, Set<String> permissions) {
|
||||
public LoginUser(String userId, String deptId, String username, String nickname, List<RoleDto> roles, List<String> roleKeys, Set<String> permissions) {
|
||||
this.userId = userId;
|
||||
this.deptId = deptId;
|
||||
this.username = username;
|
||||
this.permissions = permissions;
|
||||
this.nickname = nickname;
|
||||
this.roleKeys = roleKeys;
|
||||
this.roles = roles;
|
||||
}
|
||||
|
||||
public List<RoleDto> getRoles() {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.qiaoba.auth.entity;
|
||||
|
||||
import com.qiaoba.auth.entity.dto.RoleDto;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
@ -40,16 +41,20 @@ public class SecurityUser implements Serializable {
|
||||
*/
|
||||
private String nickname;
|
||||
|
||||
|
||||
/**
|
||||
* 角色列表
|
||||
*/
|
||||
private List<String> roleKeys;
|
||||
private List<RoleDto> roles;
|
||||
|
||||
/**
|
||||
* 角色Key列表
|
||||
*/
|
||||
private List<String> roleKeys;
|
||||
|
||||
/**
|
||||
* 权限列表
|
||||
*/
|
||||
private Set<String> permissions;
|
||||
|
||||
|
||||
}
|
||||
|
@ -14,5 +14,6 @@ public class RoleDto {
|
||||
|
||||
private String roleId;
|
||||
private String roleKey;
|
||||
private String roleName;
|
||||
private String dataScope;
|
||||
}
|
||||
|
Reference in New Issue
Block a user