✨ 添加预览模式.
This commit is contained in:
@@ -86,6 +86,8 @@ public enum ErrorCode implements CodeInfo {
|
||||
|
||||
UNSUPPOETED(915, "不支持此操作"),
|
||||
|
||||
PREVIEW_DISABLE_API(916, "预览模式不支持此功能"),
|
||||
|
||||
;
|
||||
|
||||
ErrorCode(int code, String message) {
|
||||
|
||||
@@ -72,7 +72,7 @@ public class OrionOperatorLogAutoConfiguration {
|
||||
OperatorLogs.setSerializeFilters(serializeFilters);
|
||||
OperatorLogFiller.setSerializeFilters(serializeFilters);
|
||||
OperatorLogFiller.setOperatorLogConfig(operatorLogConfig);
|
||||
return new OperatorLogAspect(operatorLogConfig, service, serializeFilters);
|
||||
return new OperatorLogAspect(service);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
package com.orion.visor.framework.biz.operator.log.core.aspect;
|
||||
|
||||
import com.alibaba.fastjson.serializer.SerializeFilter;
|
||||
import com.orion.lang.define.thread.ExecutorBuilder;
|
||||
import com.orion.lang.utils.Arrays1;
|
||||
import com.orion.lang.utils.Strings;
|
||||
import com.orion.visor.framework.biz.operator.log.configuration.config.OperatorLogConfig;
|
||||
import com.orion.visor.framework.biz.operator.log.core.annotation.IgnoreParameter;
|
||||
import com.orion.visor.framework.biz.operator.log.core.annotation.OperatorLog;
|
||||
import com.orion.visor.framework.biz.operator.log.core.factory.OperatorTypeHolder;
|
||||
@@ -53,21 +51,13 @@ public class OperatorLogAspect {
|
||||
.useLinkedBlockingQueue()
|
||||
.build();
|
||||
|
||||
private final OperatorLogConfig operatorLogConfig;
|
||||
|
||||
private final OperatorLogFrameworkService operatorLogFrameworkService;
|
||||
|
||||
private final SerializeFilter[] serializeFilters;
|
||||
|
||||
@Resource
|
||||
private SecurityHolder securityHolder;
|
||||
|
||||
public OperatorLogAspect(OperatorLogConfig operatorLogConfig,
|
||||
OperatorLogFrameworkService operatorLogFrameworkService,
|
||||
SerializeFilter[] serializeFilters) {
|
||||
this.operatorLogConfig = operatorLogConfig;
|
||||
public OperatorLogAspect(OperatorLogFrameworkService operatorLogFrameworkService) {
|
||||
this.operatorLogFrameworkService = operatorLogFrameworkService;
|
||||
this.serializeFilters = serializeFilters;
|
||||
}
|
||||
|
||||
@Around("@annotation(o)")
|
||||
|
||||
@@ -27,6 +27,7 @@ public class ServerTemplate extends Template {
|
||||
table.bizPackage = bizPackage;
|
||||
table.enableUnitTest = true;
|
||||
table.enableOperatorLog = true;
|
||||
table.enablePreviewApi = true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,6 +103,16 @@ public class ServerTemplate extends Template {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否生成预览 api 注解
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
public ServerTemplate disablePreviewApi() {
|
||||
table.enablePreviewApi = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 cache
|
||||
*
|
||||
|
||||
@@ -58,6 +58,11 @@ public class Table {
|
||||
*/
|
||||
protected boolean enableOperatorLog;
|
||||
|
||||
/**
|
||||
* 是否生成预览 api 注解
|
||||
*/
|
||||
protected boolean enablePreviewApi;
|
||||
|
||||
/**
|
||||
* 缓存的 key
|
||||
*/
|
||||
|
||||
@@ -6,6 +6,9 @@ import com.orion.visor.framework.biz.operator.log.core.annotation.OperatorLog;
|
||||
#end
|
||||
import com.orion.visor.framework.common.validator.group.Page;
|
||||
import com.orion.visor.framework.log.core.annotation.IgnoreLog;
|
||||
#if($meta.enablePreviewApi)
|
||||
import com.orion.visor.framework.web.core.annotation.PreviewDisableApi;
|
||||
#end
|
||||
import com.orion.visor.framework.log.core.enums.IgnoreLogMode;
|
||||
import com.orion.visor.framework.web.core.annotation.RestWrapper;
|
||||
import ${package.Service}.*;
|
||||
@@ -51,6 +54,9 @@ public class ${table.controllerName} {
|
||||
@Resource
|
||||
private ${type}Service ${typeLower}Service;
|
||||
|
||||
#if($meta.enablePreviewApi)
|
||||
@PreviewDisableApi
|
||||
#end
|
||||
#if($meta.enableOperatorLog)
|
||||
@OperatorLog(${type}OperatorType.CREATE)
|
||||
#end
|
||||
@@ -61,6 +67,9 @@ public class ${table.controllerName} {
|
||||
return ${typeLower}Service.create${type}(request);
|
||||
}
|
||||
|
||||
#if($meta.enablePreviewApi)
|
||||
@PreviewDisableApi
|
||||
#end
|
||||
#if($meta.enableOperatorLog)
|
||||
@OperatorLog(${type}OperatorType.UPDATE)
|
||||
#end
|
||||
@@ -105,6 +114,9 @@ public class ${table.controllerName} {
|
||||
return ${typeLower}Service.get${type}Page(request);
|
||||
}
|
||||
|
||||
#if($meta.enablePreviewApi)
|
||||
@PreviewDisableApi
|
||||
#end
|
||||
#if($meta.enableOperatorLog)
|
||||
@OperatorLog(${type}OperatorType.DELETE)
|
||||
#end
|
||||
@@ -116,6 +128,9 @@ public class ${table.controllerName} {
|
||||
return ${typeLower}Service.delete${type}ById(id);
|
||||
}
|
||||
|
||||
#if($meta.enablePreviewApi)
|
||||
@PreviewDisableApi
|
||||
#end
|
||||
#if($meta.enableOperatorLog)
|
||||
@OperatorLog(${type}OperatorType.DELETE)
|
||||
#end
|
||||
|
||||
@@ -126,9 +126,11 @@ public class OrionSecurityAutoConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return security holder 代理用于内部 framework 调用
|
||||
* <p>
|
||||
* - mybatis fill
|
||||
* - operator log
|
||||
* - log printer
|
||||
*
|
||||
* @return security holder 代理用于内部 framework 调用
|
||||
*/
|
||||
@Bean
|
||||
public SecurityHolderDelegate securityHolder() {
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.orion.lang.utils.collect.Lists;
|
||||
import com.orion.visor.framework.common.constant.AutoConfigureOrderConst;
|
||||
import com.orion.visor.framework.common.constant.FilterOrderConst;
|
||||
import com.orion.visor.framework.common.web.filter.FilterCreator;
|
||||
import com.orion.visor.framework.web.core.aspect.PreviewDisableApiAspect;
|
||||
import com.orion.visor.framework.web.core.filter.TraceIdFilter;
|
||||
import com.orion.visor.framework.web.core.handler.GlobalExceptionHandler;
|
||||
import com.orion.visor.framework.web.core.handler.WrapperResultHandler;
|
||||
@@ -139,4 +140,13 @@ public class OrionWebAutoConfiguration implements WebMvcConfigurer {
|
||||
return FilterCreator.create(new TraceIdFilter(), FilterOrderConst.TRICE_ID_FILTER);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 预览模式禁用 api 切面
|
||||
*/
|
||||
@Bean
|
||||
@ConditionalOnProperty(value = "orion.preview", havingValue = "true")
|
||||
public PreviewDisableApiAspect previewDisableApiAspect() {
|
||||
return new PreviewDisableApiAspect();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.orion.visor.framework.web.core.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 预览禁用 api
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2024/5/21 16:44
|
||||
*/
|
||||
@Target({ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface PreviewDisableApi {
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.orion.visor.framework.web.core.aspect;
|
||||
|
||||
import com.orion.visor.framework.common.constant.ErrorCode;
|
||||
import com.orion.visor.framework.web.core.annotation.PreviewDisableApi;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
|
||||
/**
|
||||
* 预览禁用 api 切面
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2024/5/21 16:52
|
||||
*/
|
||||
@Aspect
|
||||
@Slf4j
|
||||
public class PreviewDisableApiAspect {
|
||||
|
||||
public PreviewDisableApiAspect() {
|
||||
}
|
||||
|
||||
@Around("@annotation(o)")
|
||||
public Object around(ProceedingJoinPoint joinPoint, PreviewDisableApi o) {
|
||||
throw ErrorCode.PREVIEW_DISABLE_API.exception();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,6 +5,12 @@
|
||||
"type": "java.lang.String",
|
||||
"description": "项目版本."
|
||||
},
|
||||
{
|
||||
"name": "orion.preview",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "是否为预览模式.",
|
||||
"defaultValue": false
|
||||
},
|
||||
{
|
||||
"name": "orion.api.prefix",
|
||||
"type": "java.lang.String",
|
||||
|
||||
Reference in New Issue
Block a user