use of com.paascloud.core.annotation.ValidateAnnotation in project paascloud-master by paascloud.
the class UacActionMainController method save.
/**
* 保存权限信息.
*
* @param action the action
*
* @return the wrapper
*/
@PostMapping(value = "/save")
@ApiOperation(httpMethod = "POST", value = "新增角色")
@ValidateAnnotation
@LogAnnotation
public Wrapper save(@ApiParam(name = "action", value = "角色信息") @RequestBody UacAction action) {
LoginAuthDto loginAuthDto = RequestUtil.getLoginUser();
uacActionService.saveAction(action, loginAuthDto);
return WrapMapper.ok();
}
use of com.paascloud.core.annotation.ValidateAnnotation in project paascloud-master by paascloud.
the class UacRoleMainController method save.
/**
* 保存用户.
*
* @param role the role
*
* @return the wrapper
*/
@PostMapping(value = "/save")
@ApiOperation(httpMethod = "POST", value = "新增角色")
@ValidateAnnotation
@LogAnnotation
public Wrapper save(@ApiParam(name = "role", value = "角色信息") @RequestBody UacRole role) {
LoginAuthDto loginAuthDto = RequestUtil.getLoginUser();
uacRoleService.saveRole(role, loginAuthDto);
return WrapMapper.ok();
}
use of com.paascloud.core.annotation.ValidateAnnotation in project paascloud-master by paascloud.
the class BindingResultAop method doAfter.
/**
* Do after.
*
* @param joinPoint the join point
*/
@AfterReturning(pointcut = "validateAnnotation()")
public void doAfter(final JoinPoint joinPoint) {
String methodName = joinPoint.getSignature().getName();
Object target = joinPoint.getTarget();
// 得到拦截的方法
Method method = getMethodByClassAndName(target.getClass(), methodName);
Object[] objects = joinPoint.getArgs();
// 方法的参数
assert method != null;
ValidateAnnotation annotation = (ValidateAnnotation) getAnnotationByMethod(method, ValidateAnnotation.class);
if (annotation != null) {
BindingResult bindingResult = null;
for (Object arg : objects) {
if (arg instanceof BindingResult) {
bindingResult = (BindingResult) arg;
}
}
if (bindingResult != null && bindingResult.hasErrors()) {
String errorInfo = bindingResult.getFieldError().getDefaultMessage();
throw new IllegalArgumentException(errorInfo);
}
}
}
Aggregations