将限制项提高到框架common模块

This commit is contained in:
Chopper 2021-11-30 16:53:37 +08:00
parent 30d53fa41e
commit 323bc6b775
2 changed files with 52 additions and 0 deletions

View File

@ -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 {
}

View File

@ -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);
}
}
}