修改初始化操作类型逻辑.
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package com.orion.ops.framework.biz.operator.log.core.annotation;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 模块
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023/10/9 18:44
|
||||
*/
|
||||
@Component
|
||||
@Target({ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface Module {
|
||||
|
||||
/**
|
||||
* 模块
|
||||
*/
|
||||
String value();
|
||||
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import com.orion.ops.framework.biz.operator.log.core.annotation.IgnoreParameter;
|
||||
import com.orion.ops.framework.biz.operator.log.core.annotation.OperatorLog;
|
||||
import com.orion.ops.framework.biz.operator.log.core.config.OperatorLogConfig;
|
||||
import com.orion.ops.framework.biz.operator.log.core.enums.ReturnType;
|
||||
import com.orion.ops.framework.biz.operator.log.core.holder.OperatorTypeHolder;
|
||||
import com.orion.ops.framework.biz.operator.log.core.factory.OperatorTypeHolder;
|
||||
import com.orion.ops.framework.biz.operator.log.core.model.OperatorLogModel;
|
||||
import com.orion.ops.framework.biz.operator.log.core.model.OperatorType;
|
||||
import com.orion.ops.framework.biz.operator.log.core.service.OperatorLogFrameworkService;
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.orion.ops.framework.biz.operator.log.core.factory;
|
||||
|
||||
import com.orion.lang.utils.Arrays1;
|
||||
import com.orion.ops.framework.biz.operator.log.core.annotation.Module;
|
||||
import com.orion.ops.framework.biz.operator.log.core.model.OperatorType;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
/**
|
||||
* 操作类型初始化器
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023/10/13 17:45
|
||||
*/
|
||||
public abstract class InitializingOperatorTypes implements OperatorTypeDefinition {
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
// 获取模块注解
|
||||
Module moduleDefinition = this.getClass().getAnnotation(Module.class);
|
||||
if (moduleDefinition == null) {
|
||||
return;
|
||||
}
|
||||
// 获取类型
|
||||
OperatorType[] types = this.types();
|
||||
if (Arrays1.isEmpty(types)) {
|
||||
return;
|
||||
}
|
||||
// 定义类型
|
||||
String module = moduleDefinition.value();
|
||||
for (OperatorType type : types) {
|
||||
type.setModule(module);
|
||||
OperatorTypeHolder.set(type);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.orion.ops.framework.biz.operator.log.core.factory;
|
||||
|
||||
import com.orion.ops.framework.biz.operator.log.core.model.OperatorType;
|
||||
|
||||
/**
|
||||
* 操作类型定义
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023/10/13 18:23
|
||||
*/
|
||||
public interface OperatorTypeDefinition {
|
||||
|
||||
/**
|
||||
* 获取操作类型
|
||||
*
|
||||
* @return 操作类型
|
||||
*/
|
||||
OperatorType[] types();
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.orion.ops.framework.biz.operator.log.core.holder;
|
||||
package com.orion.ops.framework.biz.operator.log.core.factory;
|
||||
|
||||
import com.orion.ops.framework.biz.operator.log.core.model.OperatorType;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.orion.ops.framework.biz.operator.log.core.model;
|
||||
|
||||
import com.orion.ops.framework.biz.operator.log.core.enums.OperatorRiskLevel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
@@ -14,7 +13,6 @@ import lombok.Getter;
|
||||
* @since 2023/10/10 10:29
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class OperatorType {
|
||||
|
||||
/**
|
||||
@@ -25,7 +23,7 @@ public class OperatorType {
|
||||
/**
|
||||
* 模块
|
||||
*/
|
||||
private final String module;
|
||||
private String module;
|
||||
|
||||
/**
|
||||
* 类型
|
||||
@@ -37,4 +35,19 @@ public class OperatorType {
|
||||
*/
|
||||
private final String template;
|
||||
|
||||
public OperatorType(OperatorRiskLevel riskLevel, String type, String template) {
|
||||
this(riskLevel, null, type, template);
|
||||
}
|
||||
|
||||
public OperatorType(OperatorRiskLevel riskLevel, String module, String type, String template) {
|
||||
this.riskLevel = riskLevel;
|
||||
this.module = module;
|
||||
this.type = type;
|
||||
this.template = template;
|
||||
}
|
||||
|
||||
public void setModule(String module) {
|
||||
this.module = module;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user