提交 a87737ab authored 作者: taojinlong's avatar taojinlong

Merge branch 'dev' of github.com:dataease/dataease into dev

...@@ -26,12 +26,14 @@ import java.util.stream.Collectors; ...@@ -26,12 +26,14 @@ import java.util.stream.Collectors;
public class DePermissionAnnotationHandler { public class DePermissionAnnotationHandler {
@Around(value = "@annotation(io.dataease.auth.annotation.DePermissions)") @Around(value = "@annotation(io.dataease.auth.annotation.DePermissions)")
public Object PermissionsAround(ProceedingJoinPoint point) { public Object PermissionsAround(ProceedingJoinPoint point) throws Throwable{
if (AuthUtils.getUser().getIsAdmin()) {
return point.proceed(point.getArgs());
}
Boolean access = false;
try { try {
if (AuthUtils.getUser().getIsAdmin()) {
return point.proceed(point.getArgs());
}
MethodSignature ms = (MethodSignature) point.getSignature(); MethodSignature ms = (MethodSignature) point.getSignature();
Method method = ms.getMethod(); Method method = ms.getMethod();
DePermissions annotation = method.getAnnotation(DePermissions.class); DePermissions annotation = method.getAnnotation(DePermissions.class);
...@@ -43,37 +45,40 @@ public class DePermissionAnnotationHandler { ...@@ -43,37 +45,40 @@ public class DePermissionAnnotationHandler {
DePermission permission = dePermissions[i]; DePermission permission = dePermissions[i];
boolean currentAccess = access(args[permission.paramIndex()], permission, 0); boolean currentAccess = access(args[permission.paramIndex()], permission, 0);
if (!currentAccess) { if (!currentAccess) {
return null; access = false;
break;
} }
} }
} else { } else {
List<Exception> exceptions = new ArrayList<>(); List<Exception> exceptions = new ArrayList<>();
Boolean someAccess = false;
for (int i = 0; i < dePermissions.length; i++) { for (int i = 0; i < dePermissions.length; i++) {
DePermission permission = dePermissions[i]; DePermission permission = dePermissions[i];
try { try {
boolean currentAccess = access(args[permission.paramIndex()], permission, 0); boolean currentAccess = access(args[permission.paramIndex()], permission, 0);
if (currentAccess) { if (currentAccess) {
someAccess = true; access = true;
break; break;
} }
} catch (Exception e) { } catch (Exception e) {
exceptions.add(e); exceptions.add(e);
} }
} }
if (!someAccess) { if (!access && exceptions.size() > 0) {
throw exceptions.get(0); throw exceptions.get(0);
} }
} }
return point.proceed(point.getArgs());
} catch (Throwable throwable) { } catch (Throwable throwable) {
LogUtil.error(throwable.getMessage(), throwable); LogUtil.error(throwable.getMessage(), throwable);
throw new RuntimeException(throwable.getMessage()); throw new RuntimeException(throwable.getMessage());
} }
return access ? point.proceed(point.getArgs()) : null;
} }
@Around(value = "@annotation(io.dataease.auth.annotation.DePermission)") @Around(value = "@annotation(io.dataease.auth.annotation.DePermission)")
public Object PermissionAround(ProceedingJoinPoint point) { public Object PermissionAround(ProceedingJoinPoint point) throws Throwable{
Boolean access = false;
try { try {
if (AuthUtils.getUser().getIsAdmin()) { if (AuthUtils.getUser().getIsAdmin()) {
return point.proceed(point.getArgs()); return point.proceed(point.getArgs());
...@@ -84,14 +89,14 @@ public class DePermissionAnnotationHandler { ...@@ -84,14 +89,14 @@ public class DePermissionAnnotationHandler {
DePermission annotation = method.getAnnotation(DePermission.class); DePermission annotation = method.getAnnotation(DePermission.class);
Object arg = point.getArgs()[annotation.paramIndex()]; Object arg = point.getArgs()[annotation.paramIndex()];
if (access(arg, annotation, 0)) { if (access(arg, annotation, 0)) {
return point.proceed(point.getArgs()); access = true;
} }
return false;
} catch (Throwable throwable) { } catch (Throwable throwable) {
LogUtil.error(throwable.getMessage(), throwable); LogUtil.error(throwable.getMessage(), throwable);
throw new RuntimeException(throwable.getMessage()); throw new RuntimeException(throwable.getMessage());
} }
return access ? point.proceed(point.getArgs()) : null;
} }
private Boolean access(Object arg, DePermission annotation, int layer) throws Exception { private Boolean access(Object arg, DePermission annotation, int layer) throws Exception {
......
...@@ -42,7 +42,7 @@ public class DataSetGroupController { ...@@ -42,7 +42,7 @@ public class DataSetGroupController {
}, logical = Logical.AND) }, logical = Logical.AND)
@ApiOperation("保存") @ApiOperation("保存")
@PostMapping("/save") @PostMapping("/save")
public DataSetGroupDTO save(@RequestBody DatasetGroup datasetGroup) { public DataSetGroupDTO save(@RequestBody DatasetGroup datasetGroup) throws Exception {
return dataSetGroupService.save(datasetGroup); return dataSetGroupService.save(datasetGroup);
} }
......
...@@ -44,7 +44,10 @@ public class DataSetGroupService { ...@@ -44,7 +44,10 @@ public class DataSetGroupService {
private SysAuthService sysAuthService; private SysAuthService sysAuthService;
@DeCleaner(DePermissionType.DATASET) @DeCleaner(DePermissionType.DATASET)
public DataSetGroupDTO save(DatasetGroup datasetGroup) { public DataSetGroupDTO save(DatasetGroup datasetGroup) throws Exception {
if (StringUtils.isEmpty(datasetGroup.getType())) {
throw new Exception("type can not be empty");
}
checkName(datasetGroup); checkName(datasetGroup);
if (StringUtils.isEmpty(datasetGroup.getId())) { if (StringUtils.isEmpty(datasetGroup.getId())) {
datasetGroup.setId(UUID.randomUUID().toString()); datasetGroup.setId(UUID.randomUUID().toString());
...@@ -65,7 +68,7 @@ public class DataSetGroupService { ...@@ -65,7 +68,7 @@ public class DataSetGroupService {
public void delete(String id) throws Exception { public void delete(String id) throws Exception {
Assert.notNull(id, "id cannot be null"); Assert.notNull(id, "id cannot be null");
sysAuthService.checkTreeNoManageCount("dataset",id); sysAuthService.checkTreeNoManageCount("dataset", id);
DatasetGroup dg = datasetGroupMapper.selectByPrimaryKey(id); DatasetGroup dg = datasetGroupMapper.selectByPrimaryKey(id);
DataSetGroupRequest datasetGroup = new DataSetGroupRequest(); DataSetGroupRequest datasetGroup = new DataSetGroupRequest();
......
...@@ -151,6 +151,7 @@ div:focus { ...@@ -151,6 +151,7 @@ div:focus {
.el-tabs__content { .el-tabs__content {
height: calc(100% - 55px) !important; height: calc(100% - 55px) !important;
margin-top: 5px;
.el-tab-pane { .el-tab-pane {
height: 100% !important; height: 100% !important;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论