将限制项提高到框架common模块
This commit is contained in:
parent
30d53fa41e
commit
323bc6b775
@ -0,0 +1,18 @@
|
||||
package cn.lili.common.aop.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 演示站点注解
|
||||
*
|
||||
* @author Bulbasaur
|
||||
* @since 2021/7/9 1:40 上午
|
||||
*/
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Inherited
|
||||
public @interface DemoSite {
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package cn.lili.common.aop.interceptor;
|
||||
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.properties.SystemSettingProperties;
|
||||
import cn.lili.common.aop.annotation.DemoSite;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Before;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 演示站点拦截
|
||||
* DemoInterceptor
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v1.0
|
||||
* 2021-05-12 17:55
|
||||
*/
|
||||
@Component
|
||||
@Aspect
|
||||
public class DemoInterceptor {
|
||||
|
||||
@Autowired
|
||||
private SystemSettingProperties systemSettingProperties;
|
||||
|
||||
@Before("@annotation(demoSite)")
|
||||
public void doAfter(DemoSite demoSite) {
|
||||
if (systemSettingProperties.getIsDemoSite()) {
|
||||
throw new ServiceException(ResultCode.DEMO_SITE_EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user