|
@@ -133,17 +133,22 @@ public class PermissionAspect implements Interceptor {
|
|
|
|
|
|
|
|
|
//人员和部门数据为空
|
|
|
- if ( user == null || dept == null ||null == post) {
|
|
|
- try {
|
|
|
- return invocation.proceed();
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("数据权限隔离异常:", e);
|
|
|
- }
|
|
|
+ if ( user == null || (dept == null && null == post)) {
|
|
|
+// try {
|
|
|
+// return invocation.proceed();
|
|
|
+// } catch (Exception e) {
|
|
|
+// log.error("数据权限隔离异常:", e);
|
|
|
+// }
|
|
|
return invocation.proceed();
|
|
|
+// throw new CustomException("暂无权限");
|
|
|
}
|
|
|
|
|
|
if (scope.equals(DATA_SCOPE_DEPT)) {
|
|
|
- String deptId = dept.getDataKey();
|
|
|
+ String deptId = "";
|
|
|
+ if(null != dept){
|
|
|
+ deptId = dept.getDataKey();
|
|
|
+ }
|
|
|
+
|
|
|
try {
|
|
|
//反射扫包会比较慢,这里做了个懒加载
|
|
|
if (classNames == null) {
|
|
@@ -194,9 +199,9 @@ public class PermissionAspect implements Interceptor {
|
|
|
// 解析并返回新的SQL语句,只处理查询sql
|
|
|
if (mappedStatement.getSqlCommandType().toString().equals("SELECT")) {
|
|
|
sql = getSql(sql, deptId);
|
|
|
+ // 修改sql
|
|
|
+ metaObject.setValue("delegate.boundSql.sql", sql);
|
|
|
}
|
|
|
- // 修改sql
|
|
|
- metaObject.setValue("delegate.boundSql.sql", sql);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
log.error("数据权限隔离异常:", e);
|
|
@@ -284,7 +289,7 @@ public class PermissionAspect implements Interceptor {
|
|
|
public DataDictionary getSysDept(MyuserResDTO user){
|
|
|
if (user != null && CacheContext.ddSuperKeyMap.containsKey(DEPT_MARK)){
|
|
|
Optional<DataDictionary> any = CacheContext.ddSuperKeyMap.get(DEPT_MARK).stream().filter(t -> t.getKeyName().equals(user.getDeptName())).findAny();
|
|
|
- return any.isPresent() ? any.get() : null;
|
|
|
+ return any.isPresent() ? any.get() : CacheContext.ddMap.get("LSBM");//如果没有匹配上部门,赋予零时部门权限
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
@@ -298,7 +303,9 @@ public class PermissionAspect implements Interceptor {
|
|
|
DataDictionary maxScopeData = list.stream().min(Comparator.comparing(DataDictionary::getScope))
|
|
|
.orElse(null);
|
|
|
return maxScopeData;
|
|
|
+ }else {
|
|
|
+ //没有查到对应的岗位,赋值一般用户岗位
|
|
|
+ return CacheContext.ddMap.get("61138");
|
|
|
}
|
|
|
- return null;
|
|
|
}
|
|
|
}
|