Class ApiProcessingInterceptor
- java.lang.Object
-
- net.cofcool.chaos.server.core.aop.AbstractScannedMethodInterceptor
-
- net.cofcool.chaos.server.core.aop.ApiProcessingInterceptor
-
- All Implemented Interfaces:
ScannedMethodInterceptor,org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware
public class ApiProcessingInterceptor extends AbstractScannedMethodInterceptor implements org.springframework.context.ApplicationContextAware
接口拦截, 包括User数据注入, 设备检查, 版本对比以及覆盖ID等, 通过拦截Controller实现, 被代理类需使用Scanned注解. 注意:AuthService实例名必须为authService- Author:
- CofCool
- See Also:
Scanned,Api,DataAuthExclude,ApiVersion
-
-
Field Summary
Fields Modifier and Type Field Description protected org.slf4j.Loggerlog
-
Constructor Summary
Constructors Constructor Description ApiProcessingInterceptor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcheckApi(org.aopalliance.intercept.MethodInvocation invocation, User user)protected voidcheckDevice(String[] devices, User user)protected voidcheckRole(String[] roles, User user)protected voidcheckVersion(ApiVersion apiVersion)protected booleancompareApiVersion(ApiVersion apiVersion)项目当前版本是否大于apiVersion定义的版本protected voidcopyIdsToCondition(Page page, Class<?> clazz, String key, Object val)把User.getDetail()数据注入到condition对象中, 如果Page.getCondition()为null则会创建该实例 。 注意: 如果没有在方法参数中指定Page.getCondition()的类型,则不会创建protected voiddoBefore(org.aopalliance.intercept.MethodInvocation invocation)invocation 调用前调用protected booleandoSupport(Method method, Class<?> targetClass)是否支持protected ConfigurationSupportgetConfiguration()String[]getDefinedCheckedKeys()protected UsergetUser()获取UserintgetVersion()voidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext)voidsetAuthService(AuthService authService)voidsetConfiguration(ConfigurationSupport configuration)voidsetDefinedCheckedKeys(String[] definedCheckedKeys)protected voidsetTheId(Object obj, Auth authData, org.springframework.core.ResolvableType type, String property)protected voidsetupAuth(User user, org.aopalliance.intercept.MethodInvocation invocation, DataAuthExclude authExclude)voidsetVersion(int version)-
Methods inherited from class net.cofcool.chaos.server.core.aop.AbstractScannedMethodInterceptor
doAfter, postAfter, postBefore, supports
-
-
-
-
Method Detail
-
getConfiguration
protected ConfigurationSupport getConfiguration()
-
setConfiguration
public void setConfiguration(ConfigurationSupport configuration)
-
setAuthService
public void setAuthService(AuthService authService)
-
getVersion
public int getVersion()
-
setVersion
public void setVersion(int version)
-
getDefinedCheckedKeys
public String[] getDefinedCheckedKeys()
-
setDefinedCheckedKeys
public void setDefinedCheckedKeys(String[] definedCheckedKeys)
-
getUser
protected User getUser()
获取User- Returns:
- user
-
checkApi
protected void checkApi(org.aopalliance.intercept.MethodInvocation invocation, User user)
-
checkVersion
protected void checkVersion(ApiVersion apiVersion)
-
compareApiVersion
protected boolean compareApiVersion(ApiVersion apiVersion)
项目当前版本是否大于apiVersion定义的版本- Parameters:
apiVersion- apiVersion
-
setupAuth
protected void setupAuth(User user, org.aopalliance.intercept.MethodInvocation invocation, DataAuthExclude authExclude)
-
setTheId
protected void setTheId(Object obj, Auth authData, org.springframework.core.ResolvableType type, String property) throws Throwable
- Throws:
Throwable
-
copyIdsToCondition
protected void copyIdsToCondition(Page page, @Nullable Class<?> clazz, String key, Object val) throws Throwable
把User.getDetail()数据注入到condition对象中, 如果Page.getCondition()为null则会创建该实例 。 注意: 如果没有在方法参数中指定Page.getCondition()的类型,则不会创建- Parameters:
page- 分页对象clazz- Tkey- 属性名val- 属性值- Throws:
Throwable
-
doSupport
protected boolean doSupport(Method method, Class<?> targetClass)
Description copied from class:AbstractScannedMethodInterceptor是否支持- Specified by:
doSupportin classAbstractScannedMethodInterceptor- Parameters:
method- methodtargetClass- targetClass- Returns:
- 是否支持
-
doBefore
protected void doBefore(org.aopalliance.intercept.MethodInvocation invocation)
Description copied from class:AbstractScannedMethodInterceptorinvocation 调用前调用- Overrides:
doBeforein classAbstractScannedMethodInterceptor
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException- Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware- Throws:
org.springframework.beans.BeansException
-
-