diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-biz-operator-log/src/main/java/com/orion/ops/framework/biz/operator/log/core/annotation/Module.java b/orion-ops-framework/orion-ops-spring-boot-starter-biz-operator-log/src/main/java/com/orion/ops/framework/biz/operator/log/core/annotation/Module.java new file mode 100644 index 00000000..f6fe5be3 --- /dev/null +++ b/orion-ops-framework/orion-ops-spring-boot-starter-biz-operator-log/src/main/java/com/orion/ops/framework/biz/operator/log/core/annotation/Module.java @@ -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(); + +} diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-biz-operator-log/src/main/java/com/orion/ops/framework/biz/operator/log/core/aspect/OperatorLogAspect.java b/orion-ops-framework/orion-ops-spring-boot-starter-biz-operator-log/src/main/java/com/orion/ops/framework/biz/operator/log/core/aspect/OperatorLogAspect.java index 7336606c..94a0c692 100644 --- a/orion-ops-framework/orion-ops-spring-boot-starter-biz-operator-log/src/main/java/com/orion/ops/framework/biz/operator/log/core/aspect/OperatorLogAspect.java +++ b/orion-ops-framework/orion-ops-spring-boot-starter-biz-operator-log/src/main/java/com/orion/ops/framework/biz/operator/log/core/aspect/OperatorLogAspect.java @@ -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; diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-biz-operator-log/src/main/java/com/orion/ops/framework/biz/operator/log/core/factory/InitializingOperatorTypes.java b/orion-ops-framework/orion-ops-spring-boot-starter-biz-operator-log/src/main/java/com/orion/ops/framework/biz/operator/log/core/factory/InitializingOperatorTypes.java new file mode 100644 index 00000000..2589baef --- /dev/null +++ b/orion-ops-framework/orion-ops-spring-boot-starter-biz-operator-log/src/main/java/com/orion/ops/framework/biz/operator/log/core/factory/InitializingOperatorTypes.java @@ -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); + } + } + +} diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-biz-operator-log/src/main/java/com/orion/ops/framework/biz/operator/log/core/factory/OperatorTypeDefinition.java b/orion-ops-framework/orion-ops-spring-boot-starter-biz-operator-log/src/main/java/com/orion/ops/framework/biz/operator/log/core/factory/OperatorTypeDefinition.java new file mode 100644 index 00000000..4d208152 --- /dev/null +++ b/orion-ops-framework/orion-ops-spring-boot-starter-biz-operator-log/src/main/java/com/orion/ops/framework/biz/operator/log/core/factory/OperatorTypeDefinition.java @@ -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(); + +} diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-biz-operator-log/src/main/java/com/orion/ops/framework/biz/operator/log/core/holder/OperatorTypeHolder.java b/orion-ops-framework/orion-ops-spring-boot-starter-biz-operator-log/src/main/java/com/orion/ops/framework/biz/operator/log/core/factory/OperatorTypeHolder.java similarity index 91% rename from orion-ops-framework/orion-ops-spring-boot-starter-biz-operator-log/src/main/java/com/orion/ops/framework/biz/operator/log/core/holder/OperatorTypeHolder.java rename to orion-ops-framework/orion-ops-spring-boot-starter-biz-operator-log/src/main/java/com/orion/ops/framework/biz/operator/log/core/factory/OperatorTypeHolder.java index bad0b116..8ca5061e 100644 --- a/orion-ops-framework/orion-ops-spring-boot-starter-biz-operator-log/src/main/java/com/orion/ops/framework/biz/operator/log/core/holder/OperatorTypeHolder.java +++ b/orion-ops-framework/orion-ops-spring-boot-starter-biz-operator-log/src/main/java/com/orion/ops/framework/biz/operator/log/core/factory/OperatorTypeHolder.java @@ -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; diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-biz-operator-log/src/main/java/com/orion/ops/framework/biz/operator/log/core/model/OperatorType.java b/orion-ops-framework/orion-ops-spring-boot-starter-biz-operator-log/src/main/java/com/orion/ops/framework/biz/operator/log/core/model/OperatorType.java index dc6c459a..465338f1 100644 --- a/orion-ops-framework/orion-ops-spring-boot-starter-biz-operator-log/src/main/java/com/orion/ops/framework/biz/operator/log/core/model/OperatorType.java +++ b/orion-ops-framework/orion-ops-spring-boot-starter-biz-operator-log/src/main/java/com/orion/ops/framework/biz/operator/log/core/model/OperatorType.java @@ -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; + } + } diff --git a/orion-ops-launch/src/main/java/com/orion/ops/launch/generator/engine/VelocityTemplateEngine.java b/orion-ops-launch/src/main/java/com/orion/ops/launch/generator/engine/VelocityTemplateEngine.java index e3b71b7f..34adf250 100644 --- a/orion-ops-launch/src/main/java/com/orion/ops/launch/generator/engine/VelocityTemplateEngine.java +++ b/orion-ops-launch/src/main/java/com/orion/ops/launch/generator/engine/VelocityTemplateEngine.java @@ -465,6 +465,11 @@ public class VelocityTemplateEngine extends AbstractTemplateEngine { Object value = safeGet(safeGet(meta.getValues(), j), i); enumInfo.put(name, field, value); } + // 检查是否有 value + if (!meta.getFields().contains("value")) { + // 没有 value 用 name + enumInfo.put(name, "value", name); + } } enumMap.put(tableField.getPropertyName(), new EnumMeta(meta.getClassName(), meta.getComment(), enumInfo)); } diff --git a/orion-ops-launch/src/main/java/com/orion/ops/launch/generator/template/EnumsTemplate.java b/orion-ops-launch/src/main/java/com/orion/ops/launch/generator/template/EnumsTemplate.java index 6ae9cf27..b7927484 100644 --- a/orion-ops-launch/src/main/java/com/orion/ops/launch/generator/template/EnumsTemplate.java +++ b/orion-ops-launch/src/main/java/com/orion/ops/launch/generator/template/EnumsTemplate.java @@ -118,6 +118,7 @@ public class EnumsTemplate extends VueTemplate { /** * 添加 value + * 如果 value 和 name 相同可以省略 (无 value 自动使用 name) * * @param values values * @return this diff --git a/orion-ops-launch/src/main/resources/templates/orion-server-module-operator-key-define.java.vm b/orion-ops-launch/src/main/resources/templates/orion-server-module-operator-key-define.java.vm index a283ca3b..f75bdd20 100644 --- a/orion-ops-launch/src/main/resources/templates/orion-server-module-operator-key-define.java.vm +++ b/orion-ops-launch/src/main/resources/templates/orion-server-module-operator-key-define.java.vm @@ -1,9 +1,10 @@ package ${currentPackage}; +import com.orion.ops.framework.biz.operator.log.core.annotation.Module; +import com.orion.ops.framework.biz.operator.log.core.factory.InitializingOperatorTypes; import com.orion.ops.framework.biz.operator.log.core.model.OperatorType; import static com.orion.ops.framework.biz.operator.log.core.enums.OperatorRiskLevel.*; -import static com.orion.ops.framework.biz.operator.log.core.holder.OperatorTypeHolder.set; /** * $!{table.comment} 操作日志类型 @@ -12,10 +13,9 @@ import static com.orion.ops.framework.biz.operator.log.core.holder.OperatorTypeH * @version ${since} * @since ${date} */ +@Module("${package.ModuleName}:${typeHyphen}") public class ${type}OperatorType { - private static final String MODULE = "${package.ModuleName}:${typeHyphen}"; - public static final String CREATE = "${typeHyphen}:create"; public static final String UPDATE = "${typeHyphen}:update"; @@ -24,11 +24,14 @@ public class ${type}OperatorType { public static final String EXPORT = "${typeHyphen}:export"; - public static void init() { - set(new OperatorType(L, MODULE, CREATE, "创建$!{table.comment}")); - set(new OperatorType(M, MODULE, UPDATE, "更新$!{table.comment}")); - set(new OperatorType(H, MODULE, DELETE, "删除$!{table.comment}")); - set(new OperatorType(L, MODULE, EXPORT, "导出$!{table.comment}")); + @Override + public OperatorType[] types() { + return new OperatorType[]{ + new OperatorType(L, CREATE, "创建$!{table.comment}"), + new OperatorType(M, UPDATE, "更新$!{table.comment}"), + new OperatorType(H, DELETE, "删除$!{table.comment}"), + new OperatorType(M, EXPORT, "导出$!{table.comment}"), + }; } } diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/define/operator/HostIdentityOperatorType.java b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/define/operator/HostIdentityOperatorType.java index b494abe5..6f52e902 100644 --- a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/define/operator/HostIdentityOperatorType.java +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/define/operator/HostIdentityOperatorType.java @@ -1,10 +1,11 @@ package com.orion.ops.module.asset.define.operator; +import com.orion.ops.framework.biz.operator.log.core.annotation.Module; +import com.orion.ops.framework.biz.operator.log.core.factory.InitializingOperatorTypes; import com.orion.ops.framework.biz.operator.log.core.model.OperatorType; import static com.orion.ops.framework.biz.operator.log.core.enums.OperatorRiskLevel.H; import static com.orion.ops.framework.biz.operator.log.core.enums.OperatorRiskLevel.L; -import static com.orion.ops.framework.biz.operator.log.core.holder.OperatorTypeHolder.set; /** * 主机身份 操作日志类型 @@ -13,9 +14,8 @@ import static com.orion.ops.framework.biz.operator.log.core.holder.OperatorTypeH * @version 1.0.0 * @since 2023/10/10 17:30 */ -public class HostIdentityOperatorType { - - private static final String MODULE = "asset:host-identity"; +@Module("asset:host-identity") +public class HostIdentityOperatorType extends InitializingOperatorTypes { public static final String CREATE = "host-identity:create"; @@ -23,10 +23,13 @@ public class HostIdentityOperatorType { public static final String DELETE = "host-identity:delete"; - public static void init() { - set(new OperatorType(L, MODULE, CREATE, "创建主机身份 ${name}")); - set(new OperatorType(L, MODULE, UPDATE, "修改主机身份 ${name}")); - set(new OperatorType(H, MODULE, DELETE, "删除主机身份 ${name}")); + @Override + public OperatorType[] types() { + return new OperatorType[]{ + new OperatorType(L, CREATE, "创建主机身份 ${name}"), + new OperatorType(L, UPDATE, "修改主机身份 ${name}"), + new OperatorType(H, DELETE, "删除主机身份 ${name}"), + }; } } diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/define/operator/HostKeyOperatorType.java b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/define/operator/HostKeyOperatorType.java index c3421522..4a6630f3 100644 --- a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/define/operator/HostKeyOperatorType.java +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/define/operator/HostKeyOperatorType.java @@ -1,10 +1,11 @@ package com.orion.ops.module.asset.define.operator; +import com.orion.ops.framework.biz.operator.log.core.annotation.Module; +import com.orion.ops.framework.biz.operator.log.core.factory.InitializingOperatorTypes; import com.orion.ops.framework.biz.operator.log.core.model.OperatorType; import static com.orion.ops.framework.biz.operator.log.core.enums.OperatorRiskLevel.H; import static com.orion.ops.framework.biz.operator.log.core.enums.OperatorRiskLevel.L; -import static com.orion.ops.framework.biz.operator.log.core.holder.OperatorTypeHolder.set; /** * 主机秘钥 操作日志类型 @@ -13,9 +14,8 @@ import static com.orion.ops.framework.biz.operator.log.core.holder.OperatorTypeH * @version 1.0.0 * @since 2023/10/10 17:30 */ -public class HostKeyOperatorType { - - private static final String MODULE = "asset:host-key"; +@Module("asset:host-key") +public class HostKeyOperatorType extends InitializingOperatorTypes { public static final String CREATE = "host-key:create"; @@ -23,10 +23,13 @@ public class HostKeyOperatorType { public static final String DELETE = "host-key:delete"; - public static void init() { - set(new OperatorType(L, MODULE, CREATE, "创建主机秘钥 ${name}")); - set(new OperatorType(L, MODULE, UPDATE, "修改主机秘钥 ${name}")); - set(new OperatorType(H, MODULE, DELETE, "删除主机秘钥 ${name}")); + @Override + public OperatorType[] types() { + return new OperatorType[]{ + new OperatorType(L, CREATE, "创建主机秘钥 ${name}"), + new OperatorType(L, UPDATE, "修改主机秘钥 ${name}"), + new OperatorType(H, DELETE, "删除主机秘钥 ${name}"), + }; } } diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/define/operator/HostOperatorType.java b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/define/operator/HostOperatorType.java index 146c6f5f..50a55596 100644 --- a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/define/operator/HostOperatorType.java +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/define/operator/HostOperatorType.java @@ -1,9 +1,10 @@ package com.orion.ops.module.asset.define.operator; +import com.orion.ops.framework.biz.operator.log.core.annotation.Module; +import com.orion.ops.framework.biz.operator.log.core.factory.InitializingOperatorTypes; import com.orion.ops.framework.biz.operator.log.core.model.OperatorType; import static com.orion.ops.framework.biz.operator.log.core.enums.OperatorRiskLevel.*; -import static com.orion.ops.framework.biz.operator.log.core.holder.OperatorTypeHolder.set; /** * 主机 操作日志类型 @@ -12,9 +13,8 @@ import static com.orion.ops.framework.biz.operator.log.core.holder.OperatorTypeH * @version 1.0.0 * @since 2023/10/10 17:30 */ -public class HostOperatorType { - - private static final String MODULE = "asset:host"; +@Module("asset:host") +public class HostOperatorType extends InitializingOperatorTypes { public static final String CREATE = "host:create"; @@ -26,12 +26,15 @@ public class HostOperatorType { public static final String UPDATE_CONFIG_STATUS = "host:update-config-status"; - public static void init() { - set(new OperatorType(L, MODULE, CREATE, "创建主机 ${name}")); - set(new OperatorType(L, MODULE, UPDATE, "修改主机 ${name}")); - set(new OperatorType(H, MODULE, DELETE, "删除主机 ${name}")); - set(new OperatorType(M, MODULE, UPDATE_CONFIG, "修改主机配置 ${name} | ${type}")); - set(new OperatorType(M, MODULE, UPDATE_CONFIG_STATUS, "修改主机配置状态 ${name} | ${type} - ${statusName}")); + @Override + public OperatorType[] types() { + return new OperatorType[]{ + new OperatorType(L, CREATE, "创建主机 ${name}"), + new OperatorType(L, UPDATE, "修改主机 ${name}"), + new OperatorType(H, DELETE, "删除主机 ${name}"), + new OperatorType(M, UPDATE_CONFIG, "修改主机配置 ${name} | ${type}"), + new OperatorType(M, UPDATE_CONFIG_STATUS, "修改主机配置状态 ${name} | ${type} - ${statusName}"), + }; } } diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/runner/AssetOperatorTypeRunner.java b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/runner/AssetOperatorTypeRunner.java deleted file mode 100644 index b50beec6..00000000 --- a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/runner/AssetOperatorTypeRunner.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.orion.ops.module.asset.runner; - -import com.orion.ops.module.asset.define.operator.HostIdentityOperatorType; -import com.orion.ops.module.asset.define.operator.HostKeyOperatorType; -import com.orion.ops.module.asset.define.operator.HostOperatorType; -import org.springframework.boot.CommandLineRunner; -import org.springframework.stereotype.Component; - -/** - * 资产模块 操作类型初始化 - * - * @author Jiahang Li - * @version 1.0.0 - * @since 2023/10/10 18:03 - */ -@Component -public class AssetOperatorTypeRunner implements CommandLineRunner { - - @Override - public void run(String... args) { - HostOperatorType.init(); - HostKeyOperatorType.init(); - HostIdentityOperatorType.init(); - } - -} diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/dao/OperatorLogDAO.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/dao/OperatorLogDAO.java index d5e0958d..46bd3804 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/dao/OperatorLogDAO.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/dao/OperatorLogDAO.java @@ -1,5 +1,6 @@ package com.orion.ops.module.infra.dao; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.orion.ops.framework.mybatis.core.mapper.IMapper; import com.orion.ops.module.infra.entity.domain.OperatorLogDO; import org.apache.ibatis.annotations.Mapper; @@ -14,4 +15,16 @@ import org.apache.ibatis.annotations.Mapper; @Mapper public interface OperatorLogDAO extends IMapper { + /** + * 通过 userId 删除 + * + * @param userId userId + * @return effect + */ + default int deleteByUserId(Long userId) { + LambdaQueryWrapper wrapper = this.wrapper() + .eq(OperatorLogDO::getUserId, userId); + return this.delete(wrapper); + } + } diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/define/operator/AuthenticationOperatorType.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/define/operator/AuthenticationOperatorType.java index 782c4b95..be7f5e1c 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/define/operator/AuthenticationOperatorType.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/define/operator/AuthenticationOperatorType.java @@ -1,9 +1,10 @@ package com.orion.ops.module.infra.define.operator; +import com.orion.ops.framework.biz.operator.log.core.annotation.Module; +import com.orion.ops.framework.biz.operator.log.core.factory.InitializingOperatorTypes; import com.orion.ops.framework.biz.operator.log.core.model.OperatorType; import static com.orion.ops.framework.biz.operator.log.core.enums.OperatorRiskLevel.L; -import static com.orion.ops.framework.biz.operator.log.core.holder.OperatorTypeHolder.set; /** * 认证服务 操作日志类型 @@ -12,9 +13,8 @@ import static com.orion.ops.framework.biz.operator.log.core.holder.OperatorTypeH * @version 1.0.0 * @since 2023-10-10 19:06 */ -public class AuthenticationOperatorType { - - private static final String MODULE = "infra:authentication"; +@Module("infra:authentication") +public class AuthenticationOperatorType extends InitializingOperatorTypes { public static final String LOGIN = "authentication:login"; @@ -22,10 +22,13 @@ public class AuthenticationOperatorType { public static final String UPDATE_PASSWORD = "authentication:update-password"; - public static void init() { - set(new OperatorType(L, MODULE, LOGIN, "登陆系统")); - set(new OperatorType(L, MODULE, LOGOUT, "登出系统")); - set(new OperatorType(L, MODULE, UPDATE_PASSWORD, "修改密码")); + @Override + public OperatorType[] types() { + return new OperatorType[]{ + new OperatorType(L, LOGIN, "登陆系统"), + new OperatorType(L, LOGOUT, "登出系统"), + new OperatorType(L, UPDATE_PASSWORD, "修改密码"), + }; } } diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/define/operator/SystemMenuOperatorType.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/define/operator/SystemMenuOperatorType.java index 3a7e1be5..9a032990 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/define/operator/SystemMenuOperatorType.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/define/operator/SystemMenuOperatorType.java @@ -1,9 +1,10 @@ package com.orion.ops.module.infra.define.operator; +import com.orion.ops.framework.biz.operator.log.core.annotation.Module; +import com.orion.ops.framework.biz.operator.log.core.factory.InitializingOperatorTypes; import com.orion.ops.framework.biz.operator.log.core.model.OperatorType; import static com.orion.ops.framework.biz.operator.log.core.enums.OperatorRiskLevel.*; -import static com.orion.ops.framework.biz.operator.log.core.holder.OperatorTypeHolder.set; /** * 系统菜单 操作日志类型 @@ -12,9 +13,8 @@ import static com.orion.ops.framework.biz.operator.log.core.holder.OperatorTypeH * @version 1.0.0 * @since 2023/10/10 17:30 */ -public class SystemMenuOperatorType { - - private static final String MODULE = "infra:system-menu"; +@Module("infra:system-menu") +public class SystemMenuOperatorType extends InitializingOperatorTypes { public static final String CREATE = "system-menu:create"; @@ -24,11 +24,14 @@ public class SystemMenuOperatorType { public static final String DELETE = "system-menu:delete"; - public static void init() { - set(new OperatorType(L, MODULE, CREATE, "创建菜单 ${name}")); - set(new OperatorType(L, MODULE, UPDATE, "修改菜单 ${name}")); - set(new OperatorType(M, MODULE, UPDATE_STATUS, "修改菜单状态 ${name} - ${label}")); - set(new OperatorType(H, MODULE, DELETE, "删除菜单 ${name}")); + @Override + public OperatorType[] types() { + return new OperatorType[]{ + new OperatorType(L, CREATE, "创建菜单 ${name}"), + new OperatorType(L, UPDATE, "修改菜单 ${name}"), + new OperatorType(M, UPDATE_STATUS, "修改菜单状态 ${name} - ${label}"), + new OperatorType(H, DELETE, "删除菜单 ${name}"), + }; } } diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/define/operator/SystemRoleOperatorType.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/define/operator/SystemRoleOperatorType.java index 7d886700..c5e6f8b8 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/define/operator/SystemRoleOperatorType.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/define/operator/SystemRoleOperatorType.java @@ -1,9 +1,10 @@ package com.orion.ops.module.infra.define.operator; +import com.orion.ops.framework.biz.operator.log.core.annotation.Module; +import com.orion.ops.framework.biz.operator.log.core.factory.InitializingOperatorTypes; import com.orion.ops.framework.biz.operator.log.core.model.OperatorType; import static com.orion.ops.framework.biz.operator.log.core.enums.OperatorRiskLevel.*; -import static com.orion.ops.framework.biz.operator.log.core.holder.OperatorTypeHolder.set; /** * 系统角色 操作日志类型 @@ -12,9 +13,8 @@ import static com.orion.ops.framework.biz.operator.log.core.holder.OperatorTypeH * @version 1.0.0 * @since 2023/10/10 17:30 */ -public class SystemRoleOperatorType { - - private static final String MODULE = "infra:system-role"; +@Module("infra:system-role") +public class SystemRoleOperatorType extends InitializingOperatorTypes { public static final String CREATE = "system-role:create"; @@ -26,12 +26,15 @@ public class SystemRoleOperatorType { public static final String GRANT_MENU = "system-role:grant-menu"; - public static void init() { - set(new OperatorType(L, MODULE, CREATE, "创建角色 ${name}(${code})")); - set(new OperatorType(M, MODULE, UPDATE, "修改角色 ${name}(${code})")); - set(new OperatorType(M, MODULE, UPDATE_STATUS, "修改角色状态 ${name}(${code}) - ${statusName}")); - set(new OperatorType(H, MODULE, DELETE, "删除角色 ${name}(${code})")); - set(new OperatorType(M, MODULE, GRANT_MENU, "分配角色菜单 ${name}(${code})")); + @Override + public OperatorType[] types() { + return new OperatorType[]{ + new OperatorType(L, CREATE, "创建角色 ${name}(${code})"), + new OperatorType(M, UPDATE, "修改角色 ${name}(${code})"), + new OperatorType(M, UPDATE_STATUS, "修改角色状态 ${name}(${code}) - ${statusName}"), + new OperatorType(H, DELETE, "删除角色 ${name}(${code})"), + new OperatorType(M, GRANT_MENU, "分配角色菜单 ${name}(${code})"), + }; } } diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/define/operator/SystemUserOperatorType.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/define/operator/SystemUserOperatorType.java index 9f810ba1..6b943897 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/define/operator/SystemUserOperatorType.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/define/operator/SystemUserOperatorType.java @@ -1,9 +1,10 @@ package com.orion.ops.module.infra.define.operator; +import com.orion.ops.framework.biz.operator.log.core.annotation.Module; +import com.orion.ops.framework.biz.operator.log.core.factory.InitializingOperatorTypes; import com.orion.ops.framework.biz.operator.log.core.model.OperatorType; import static com.orion.ops.framework.biz.operator.log.core.enums.OperatorRiskLevel.*; -import static com.orion.ops.framework.biz.operator.log.core.holder.OperatorTypeHolder.set; /** * 系统用户 操作日志类型 @@ -12,9 +13,8 @@ import static com.orion.ops.framework.biz.operator.log.core.holder.OperatorTypeH * @version 1.0.0 * @since 2023/10/10 17:30 */ -public class SystemUserOperatorType { - - private static final String MODULE = "infra:system-user"; +@Module("infra:system-user") +public class SystemUserOperatorType extends InitializingOperatorTypes { public static final String CREATE = "system-user:create"; @@ -28,13 +28,16 @@ public class SystemUserOperatorType { public static final String DELETE = "system-user:delete"; - public static void init() { - set(new OperatorType(L, MODULE, CREATE, "创建用户 ${username}")); - set(new OperatorType(M, MODULE, UPDATE, "修改用户 ${username}")); - set(new OperatorType(M, MODULE, UPDATE_STATUS, "修改用户状态 ${username} - ${statusName}")); - set(new OperatorType(M, MODULE, GRANT_ROLE, "用户分配角色 ${username}")); - set(new OperatorType(H, MODULE, RESET_PASSWORD, "重置用户密码 ${username}")); - set(new OperatorType(H, MODULE, DELETE, "删除用户 ${username}")); + @Override + public OperatorType[] types() { + return new OperatorType[]{ + new OperatorType(L, CREATE, "创建用户 ${username}"), + new OperatorType(M, UPDATE, "修改用户 ${username}"), + new OperatorType(M, UPDATE_STATUS, "修改用户状态 ${username} - ${statusName}"), + new OperatorType(M, GRANT_ROLE, "用户分配角色 ${username}"), + new OperatorType(H, RESET_PASSWORD, "重置用户密码 ${username}"), + new OperatorType(H, DELETE, "删除用户 ${username}"), + }; } } diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/domain/OperatorLogDO.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/domain/OperatorLogDO.java index 3c53a31d..1b312e39 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/domain/OperatorLogDO.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/domain/OperatorLogDO.java @@ -112,8 +112,4 @@ public class OperatorLogDO extends BaseDO { @TableField(exist = false) private String updater; - @Schema(description = "是否删除 0未删除 1已删除") - @TableField(exist = false) - private Boolean deleted; - } diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/runner/InfraOperatorTypeRunner.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/runner/InfraOperatorTypeRunner.java deleted file mode 100644 index a74796e6..00000000 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/runner/InfraOperatorTypeRunner.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.orion.ops.module.infra.runner; - -import com.orion.ops.module.infra.define.operator.AuthenticationOperatorType; -import com.orion.ops.module.infra.define.operator.SystemMenuOperatorType; -import com.orion.ops.module.infra.define.operator.SystemRoleOperatorType; -import com.orion.ops.module.infra.define.operator.SystemUserOperatorType; -import org.springframework.boot.CommandLineRunner; -import org.springframework.stereotype.Component; - -/** - * 基建模块 操作类型初始化 - * - * @author Jiahang Li - * @version 1.0.0 - * @since 2023/10/10 18:03 - */ -@Component -public class InfraOperatorTypeRunner implements CommandLineRunner { - - @Override - public void run(String... args) { - AuthenticationOperatorType.init(); - SystemMenuOperatorType.init(); - SystemRoleOperatorType.init(); - SystemUserOperatorType.init(); - } - -} diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/resources/mapper/OperatorLogMapper.xml b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/resources/mapper/OperatorLogMapper.xml index 04c0819e..188e0151 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/resources/mapper/OperatorLogMapper.xml +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/resources/mapper/OperatorLogMapper.xml @@ -23,11 +23,12 @@ + - id, user_id, username, trace_id, address, location, user_agent, risk_level, module, type, log_info, extra, result, error_message, return_value, duration, start_time, end_time, create_time + id, user_id, username, trace_id, address, location, user_agent, risk_level, module, type, log_info, extra, result, error_message, return_value, duration, start_time, end_time, create_time, deleted