修改自定义权限实现

pull/20/MERGE
RuoYi 4 years ago
parent d42a6751e3
commit f9d537b567

@ -17,6 +17,11 @@ import com.ruoyi.common.security.annotation.PreAuthorize;
import com.ruoyi.common.security.service.TokenService; import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.system.api.model.LoginUser; import com.ruoyi.system.api.model.LoginUser;
/**
*
*
* @author ruoyi
*/
@Aspect @Aspect
@Component @Component
public class PreAuthorizeAspect public class PreAuthorizeAspect
@ -42,34 +47,56 @@ public class PreAuthorizeAspect
return point.proceed(); return point.proceed();
} }
if (StringUtils.isEmpty(annotation.hasPermi()) && hasPermi(annotation.hasPermi())) if (!StringUtils.isEmpty(annotation.hasPermi()))
{
if (hasPermi(annotation.hasPermi()))
{ {
return point.proceed(); return point.proceed();
} }
else if (StringUtils.isEmpty(annotation.lacksPermi()) && hasPermi(annotation.lacksPermi())) throw new PreAuthorizeException();
}
else if (!StringUtils.isEmpty(annotation.lacksPermi()))
{
if (lacksPermi(annotation.lacksPermi()))
{ {
return point.proceed(); return point.proceed();
} }
else if (StringUtils.isEmpty(annotation.hasAnyPermi()) && hasAnyPermi(annotation.hasAnyPermi())) throw new PreAuthorizeException();
}
else if (!StringUtils.isEmpty(annotation.hasAnyPermi()))
{
if (hasAnyPermi(annotation.hasAnyPermi()))
{ {
return point.proceed(); return point.proceed();
} }
else if (StringUtils.isEmpty(annotation.hasRole()) && hasRole(annotation.hasRole())) throw new PreAuthorizeException();
}
else if (!StringUtils.isEmpty(annotation.hasRole()))
{
if (hasRole(annotation.hasRole()))
{ {
return point.proceed(); return point.proceed();
} }
else if (StringUtils.isEmpty(annotation.lacksRole()) && lacksRole(annotation.lacksRole())) throw new PreAuthorizeException();
}
else if (StringUtils.isEmpty(annotation.lacksRole()))
{
if (lacksRole(annotation.lacksRole()))
{ {
return point.proceed(); return point.proceed();
} }
else if (StringUtils.isEmpty(annotation.hasAnyRoles()) && hasAnyRoles(annotation.hasAnyRoles())) throw new PreAuthorizeException();
}
else if (StringUtils.isEmpty(annotation.hasAnyRoles()))
{
if (hasAnyRoles(annotation.hasAnyRoles()))
{ {
return point.proceed(); return point.proceed();
} }
else
{
throw new PreAuthorizeException(); throw new PreAuthorizeException();
} }
return point.proceed();
} }
/** /**

Loading…
Cancel
Save