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/constant/OperatorLogKeys.java b/orion-ops-framework/orion-ops-spring-boot-starter-biz-operator-log/src/main/java/com/orion/ops/framework/biz/operator/log/core/constant/OperatorLogKeys.java index 34864e50..4f8e7977 100644 --- a/orion-ops-framework/orion-ops-spring-boot-starter-biz-operator-log/src/main/java/com/orion/ops/framework/biz/operator/log/core/constant/OperatorLogKeys.java +++ b/orion-ops-framework/orion-ops-spring-boot-starter-biz-operator-log/src/main/java/com/orion/ops/framework/biz/operator/log/core/constant/OperatorLogKeys.java @@ -17,4 +17,6 @@ public interface OperatorLogKeys extends ConstField { String STATUS_NAME = "statusName"; + String KEY_NAME = "keyName"; + } diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/controller/DictValueController.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/controller/DictValueController.java index 4ecfdf7d..140b1b9d 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/controller/DictValueController.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/controller/DictValueController.java @@ -23,6 +23,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.List; +import java.util.Map; /** * 字典配置值 api @@ -74,6 +75,13 @@ public class DictValueController { return dictValueService.getDictValueList(key); } + @IgnoreLog(IgnoreLogMode.RET) + @GetMapping("/enum") + @Operation(summary = "查询字典配置值枚举") + public Map> getDictValueEnum(@RequestParam("key") String key) { + return dictValueService.getDictValueEnum(key); + } + @IgnoreLog(IgnoreLogMode.RET) @PostMapping("/query") @Operation(summary = "分页查询字典配置值") diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/dao/DictKeyDAO.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/dao/DictKeyDAO.java index f34da6a5..15dd9109 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/dao/DictKeyDAO.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/dao/DictKeyDAO.java @@ -1,5 +1,7 @@ package com.orion.ops.module.infra.dao; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.orion.ops.framework.common.constant.Const; import com.orion.ops.framework.mybatis.core.mapper.IMapper; import com.orion.ops.module.infra.entity.domain.DictKeyDO; import org.apache.ibatis.annotations.Mapper; @@ -14,4 +16,17 @@ import org.apache.ibatis.annotations.Mapper; @Mapper public interface DictKeyDAO extends IMapper { + /** + * 通过 key 查询 + * + * @param key key + * @return dictKey + */ + default DictKeyDO selectByKey(String key) { + LambdaQueryWrapper wrapper = this.lambda() + .eq(DictKeyDO::getKeyName, key) + .last(Const.LIMIT_1); + return this.selectOne(wrapper); + } + } diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/define/cache/DictCacheKeyDefine.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/define/cache/DictCacheKeyDefine.java index bd9cf635..93bbc1d6 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/define/cache/DictCacheKeyDefine.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/define/cache/DictCacheKeyDefine.java @@ -1,5 +1,6 @@ package com.orion.ops.module.infra.define.cache; +import com.alibaba.fastjson.JSONObject; import com.orion.lang.define.cache.CacheKeyBuilder; import com.orion.lang.define.cache.CacheKeyDefine; import com.orion.ops.module.infra.entity.dto.DictKeyCacheDTO; @@ -23,8 +24,15 @@ public interface DictCacheKeyDefine { .timeout(1, TimeUnit.DAYS) .build(); + CacheKeyDefine DICT_SCHEMA = new CacheKeyBuilder() + .key("dict:schema:{}") + .desc("字典配置项 schema ${key}") + .type(JSONObject.class) + .timeout(1, TimeUnit.DAYS) + .build(); + CacheKeyDefine DICT_VALUE = new CacheKeyBuilder() - .key("dict:value:{}") + .key("dict:values:{}") .desc("字典配置值 ${key}") .type(DictValueCacheDTO.class) .timeout(1, TimeUnit.DAYS) diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/define/operator/DictKeyOperatorType.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/define/operator/DictKeyOperatorType.java index 1f93546d..92f5422d 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/define/operator/DictKeyOperatorType.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/define/operator/DictKeyOperatorType.java @@ -25,9 +25,9 @@ public class DictKeyOperatorType extends InitializingOperatorTypes { @Override public OperatorType[] types() { return new OperatorType[]{ - new OperatorType(L, CREATE, "创建字典配置项 ${key}"), - new OperatorType(M, UPDATE, "更新字典配置项 ${key}"), - new OperatorType(H, DELETE, "删除字典配置项 ${key}"), + new OperatorType(L, CREATE, "创建字典配置项 ${keyName}"), + new OperatorType(M, UPDATE, "更新字典配置项 ${keyName}"), + new OperatorType(H, DELETE, "删除字典配置项 ${keyName}"), }; } diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/define/operator/DictValueOperatorType.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/define/operator/DictValueOperatorType.java index 175fa9f5..c09a894e 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/define/operator/DictValueOperatorType.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/define/operator/DictValueOperatorType.java @@ -25,8 +25,8 @@ public class DictValueOperatorType extends InitializingOperatorTypes { @Override public OperatorType[] types() { return new OperatorType[]{ - new OperatorType(L, CREATE, "创建字典配置值 ${key} ${label}=${value}"), - new OperatorType(M, UPDATE, "更新字典配置值 ${key} ${label}=${value}"), + new OperatorType(L, CREATE, "创建字典配置值 ${keyName} ${label}=${value}"), + new OperatorType(M, UPDATE, "更新字典配置值 ${keyName} ${label}=${value}"), new OperatorType(H, DELETE, "删除字典配置值 ${value}"), }; } diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/domain/DictKeyDO.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/domain/DictKeyDO.java index 04f6fcf9..cc4ffb56 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/domain/DictKeyDO.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/domain/DictKeyDO.java @@ -31,8 +31,8 @@ public class DictKeyDO extends BaseDO { private Long id; @Schema(description = "配置项") - @TableField("key") - private String key; + @TableField("key_name") + private String keyName; @Schema(description = "配置值定义") @TableField("value_type") @@ -43,7 +43,7 @@ public class DictKeyDO extends BaseDO { private String extraSchema; @Schema(description = "配置描述") - @TableField("desc") - private String desc; + @TableField("description") + private String description; } diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/domain/DictValueDO.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/domain/DictValueDO.java index 20b2b562..862e85fa 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/domain/DictValueDO.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/domain/DictValueDO.java @@ -35,20 +35,20 @@ public class DictValueDO extends BaseDO { private Long keyId; @Schema(description = "配置项") - @TableField("key") - private String key; + @TableField("key_name") + private String keyName; @Schema(description = "配置名称") - @TableField("label") - private String label; + @TableField("name") + private String name; @Schema(description = "配置值") @TableField("value") private String value; @Schema(description = "配置描述") - @TableField("desc") - private String desc; + @TableField("label") + private String label; @Schema(description = "额外参数") @TableField("extra") diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/dto/DictKeyCacheDTO.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/dto/DictKeyCacheDTO.java index 57945148..497a5855 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/dto/DictKeyCacheDTO.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/dto/DictKeyCacheDTO.java @@ -29,7 +29,7 @@ public class DictKeyCacheDTO implements Serializable { private Long id; @Schema(description = "配置项") - private String key; + private String keyName; @Schema(description = "配置值定义") private String valueType; @@ -38,18 +38,6 @@ public class DictKeyCacheDTO implements Serializable { private String extraSchema; @Schema(description = "配置描述") - private String desc; - - @Schema(description = "创建时间") - private Date createTime; - - @Schema(description = "修改时间") - private Date updateTime; - - @Schema(description = "创建人") - private String creator; - - @Schema(description = "修改人") - private String updater; + private String description; } diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/dto/DictValueCacheDTO.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/dto/DictValueCacheDTO.java index 48ed1332..a879d9c9 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/dto/DictValueCacheDTO.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/dto/DictValueCacheDTO.java @@ -32,16 +32,16 @@ public class DictValueCacheDTO implements Serializable { private Long keyId; @Schema(description = "配置项") - private String key; + private String keyName; @Schema(description = "配置名称") - private String label; + private String name; @Schema(description = "配置值") private String value; @Schema(description = "配置描述") - private String desc; + private String label; @Schema(description = "额外参数") private String extra; diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/dict/DictKeyCreateRequest.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/dict/DictKeyCreateRequest.java index 9e84e6ad..26be0f37 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/dict/DictKeyCreateRequest.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/dict/DictKeyCreateRequest.java @@ -29,7 +29,7 @@ public class DictKeyCreateRequest implements Serializable { @Size(max = 32) @Pattern(regexp = "^[a-zA-Z0-9]{4,32}$") @Schema(description = "配置项") - private String key; + private String keyName; @NotBlank @Size(max = 12) @@ -43,6 +43,6 @@ public class DictKeyCreateRequest implements Serializable { @NotBlank @Size(max = 64) @Schema(description = "配置描述") - private String desc; + private String description; } diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/dict/DictKeyUpdateRequest.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/dict/DictKeyUpdateRequest.java index 45f8d97c..51e0fbe0 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/dict/DictKeyUpdateRequest.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/dict/DictKeyUpdateRequest.java @@ -34,7 +34,7 @@ public class DictKeyUpdateRequest implements Serializable { @Size(max = 32) @Pattern(regexp = "^[a-zA-Z0-9]{4,32}$") @Schema(description = "配置项") - private String key; + private String keyName; @NotBlank @Size(max = 12) @@ -48,6 +48,6 @@ public class DictKeyUpdateRequest implements Serializable { @NotBlank @Size(max = 64) @Schema(description = "配置描述") - private String desc; + private String description; } diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/dict/DictValueCreateRequest.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/dict/DictValueCreateRequest.java index 1bf43902..282be4d2 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/dict/DictValueCreateRequest.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/dict/DictValueCreateRequest.java @@ -34,7 +34,7 @@ public class DictValueCreateRequest implements Serializable { @Size(max = 32) @Pattern(regexp = "^[a-zA-Z0-9]{4,32}$") @Schema(description = "配置名称") - private String label; + private String name; @NotBlank @Size(max = 512) @@ -44,7 +44,7 @@ public class DictValueCreateRequest implements Serializable { @NotBlank @Size(max = 64) @Schema(description = "配置描述") - private String desc; + private String label; @NotBlank @Schema(description = "额外参数") diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/dict/DictValueQueryRequest.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/dict/DictValueQueryRequest.java index c4d5911c..5c58f3ce 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/dict/DictValueQueryRequest.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/dict/DictValueQueryRequest.java @@ -26,7 +26,7 @@ public class DictValueQueryRequest extends PageRequest { @Size(max = 32) @Schema(description = "配置名称") - private String label; + private String name; @Size(max = 512) @Schema(description = "配置值") @@ -34,6 +34,6 @@ public class DictValueQueryRequest extends PageRequest { @Size(max = 64) @Schema(description = "配置描述") - private String desc; + private String label; } diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/dict/DictValueUpdateRequest.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/dict/DictValueUpdateRequest.java index 56e5a045..fd64f25f 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/dict/DictValueUpdateRequest.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/dict/DictValueUpdateRequest.java @@ -38,7 +38,7 @@ public class DictValueUpdateRequest implements Serializable { @Size(max = 32) @Pattern(regexp = "^[a-zA-Z0-9]{4,32}$") @Schema(description = "配置名称") - private String label; + private String name; @NotBlank @Size(max = 512) @@ -48,7 +48,7 @@ public class DictValueUpdateRequest implements Serializable { @NotBlank @Size(max = 64) @Schema(description = "配置描述") - private String desc; + private String label; @NotBlank @Schema(description = "额外参数") diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/vo/DictKeyVO.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/vo/DictKeyVO.java index e1d3ab57..204540e5 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/vo/DictKeyVO.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/vo/DictKeyVO.java @@ -29,7 +29,7 @@ public class DictKeyVO implements Serializable { private Long id; @Schema(description = "配置项") - private String key; + private String keyName; @Schema(description = "配置值定义") private String valueType; @@ -38,18 +38,6 @@ public class DictKeyVO implements Serializable { private String extraSchema; @Schema(description = "配置描述") - private String desc; - - @Schema(description = "创建时间") - private Date createTime; - - @Schema(description = "修改时间") - private Date updateTime; - - @Schema(description = "创建人") - private String creator; - - @Schema(description = "修改人") - private String updater; + private String description; } diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/vo/DictValueEnumVO.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/vo/DictValueEnumVO.java new file mode 100644 index 00000000..16bb7ae8 --- /dev/null +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/vo/DictValueEnumVO.java @@ -0,0 +1,64 @@ +package com.orion.ops.module.infra.entity.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.Date; + +/** + * 字典配置值 视图响应对象 + * + * @author Jiahang Li + * @version 1.0.0 + * @since 2023-10-16 16:33 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Schema(name = "DictValueEnumVO", description = "字典配置值 枚举视图响应对象") +public class DictValueEnumVO implements Serializable { + + private static final long serialVersionUID = 1L; + + @Schema(description = "id") + private Long id; + + @Schema(description = "配置项id") + private Long keyId; + + @Schema(description = "配置项") + private String keyName; + + @Schema(description = "配置名称") + private String name; + + @Schema(description = "配置值") + private String value; + + @Schema(description = "配置描述") + private String label; + + @Schema(description = "额外参数") + private String extra; + + @Schema(description = "排序") + private Integer sort; + + @Schema(description = "创建时间") + private Date createTime; + + @Schema(description = "修改时间") + private Date updateTime; + + @Schema(description = "创建人") + private String creator; + + @Schema(description = "修改人") + private String updater; + +} diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/vo/DictValueVO.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/vo/DictValueVO.java index 93b015df..edbcbf23 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/vo/DictValueVO.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/vo/DictValueVO.java @@ -32,16 +32,16 @@ public class DictValueVO implements Serializable { private Long keyId; @Schema(description = "配置项") - private String key; + private String keyName; @Schema(description = "配置名称") - private String label; + private String name; @Schema(description = "配置值") private String value; @Schema(description = "配置描述") - private String desc; + private String label; @Schema(description = "额外参数") private String extra; diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/enums/DictValueTypeEnum.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/enums/DictValueTypeEnum.java index 7e4ec7b3..5667b5b6 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/enums/DictValueTypeEnum.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/enums/DictValueTypeEnum.java @@ -1,7 +1,10 @@ package com.orion.ops.module.infra.enums; +import com.orion.lang.utils.convert.Converts; import lombok.Getter; +import java.math.BigDecimal; + /** * 字典值类型 * @@ -18,14 +21,46 @@ public enum DictValueTypeEnum { STRING, /** - * 数值 + * 整数 */ - NUMBER, + INTEGER { + @Override + public Object parse(String s) { + try { + return Integer.valueOf(s); + } catch (Exception e) { + return super.parse(s); + } + } + }, + + /** + * 小数 + */ + DECIMAL { + @Override + public Object parse(String s) { + try { + return BigDecimal.valueOf(Double.valueOf(s)); + } catch (Exception e) { + return super.parse(s); + } + } + }, /** * 布尔值 */ - BOOLEAN, + BOOLEAN { + @Override + public Object parse(String s) { + try { + return Converts.toBoolean(s); + } catch (Exception e) { + return super.parse(s); + } + } + }, /** * 颜色 @@ -34,6 +69,16 @@ public enum DictValueTypeEnum { ; + /** + * 转换 + * + * @param s s + * @return value + */ + public Object parse(String s) { + return s; + } + public static DictValueTypeEnum of(String type) { if (type == null) { return STRING; diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/DictKeyService.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/DictKeyService.java index aa9a86a3..616acb33 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/DictKeyService.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/DictKeyService.java @@ -5,6 +5,7 @@ import com.orion.ops.module.infra.entity.request.dict.DictKeyUpdateRequest; import com.orion.ops.module.infra.entity.vo.DictKeyVO; import java.util.List; +import java.util.Map; /** * 字典配置项 服务类 @@ -38,6 +39,14 @@ public interface DictKeyService { */ List getDictKeyList(); + /** + * 查询字典配置项 schema + * + * @param key key + * @return schema + */ + Map getDictSchema(String key); + /** * 删除字典配置项 * diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/DictValueService.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/DictValueService.java index 2e26748b..99d8a03b 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/DictValueService.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/DictValueService.java @@ -8,6 +8,7 @@ import com.orion.ops.module.infra.entity.request.dict.DictValueUpdateRequest; import com.orion.ops.module.infra.entity.vo.DictValueVO; import java.util.List; +import java.util.Map; /** * 字典配置值 服务类 @@ -50,6 +51,14 @@ public interface DictValueService { */ List getDictValueList(String key); + /** + * 查询全部字典配置值枚举 + * + * @param key key + * @return enum + */ + Map> getDictValueEnum(String key); + /** * 分页查询字典配置值 * diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/impl/DictKeyServiceImpl.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/impl/DictKeyServiceImpl.java index a6719e95..cecff44d 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/impl/DictKeyServiceImpl.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/impl/DictKeyServiceImpl.java @@ -1,13 +1,16 @@ package com.orion.ops.module.infra.service.impl; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.orion.lang.utils.Objects1; +import com.orion.lang.utils.collect.Maps; import com.orion.ops.framework.biz.operator.log.core.uitls.OperatorLogs; import com.orion.ops.framework.common.constant.Const; import com.orion.ops.framework.common.constant.ErrorMessage; import com.orion.ops.framework.common.utils.Valid; import com.orion.ops.framework.redis.core.utils.RedisMaps; +import com.orion.ops.framework.redis.core.utils.RedisStrings; import com.orion.ops.module.infra.convert.DictKeyConvert; import com.orion.ops.module.infra.dao.DictKeyDAO; import com.orion.ops.module.infra.define.cache.DictCacheKeyDefine; @@ -26,6 +29,8 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.Comparator; import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.stream.Collectors; /** @@ -78,11 +83,12 @@ public class DictKeyServiceImpl implements DictKeyService { // 更新 int effect = dictKeyDAO.updateById(updateRecord); // 如果修改了 key 则需要修改 dictValue.key - if (!Objects1.eq(record.getKey(), request.getKey())) { - dictValueService.updateKeyNameByKeyId(id, record.getKey(), request.getKey()); + if (!Objects1.eq(record.getKeyName(), request.getKeyName())) { + dictValueService.updateKeyNameByKeyId(id, record.getKeyName(), request.getKeyName()); } // 删除缓存 - RedisMaps.delete(DictCacheKeyDefine.DICT_KEY); + RedisMaps.delete(DictCacheKeyDefine.DICT_KEY, + DictCacheKeyDefine.DICT_SCHEMA.format(record.getKeyName())); log.info("DictKeyService-updateDictKeyById effect: {}", effect); return effect; } @@ -108,23 +114,54 @@ public class DictKeyServiceImpl implements DictKeyService { return list.stream() .filter(s -> !s.getId().equals(Const.NONE_ID)) .map(DictKeyConvert.MAPPER::to) - .sorted(Comparator.comparing(DictKeyVO::getKey)) + .sorted(Comparator.comparing(DictKeyVO::getKeyName)) .collect(Collectors.toList()); } + @Override + public Map getDictSchema(String key) { + // 查询缓存 + String cacheKey = DictCacheKeyDefine.DICT_SCHEMA.format(key); + JSONObject cacheResult = RedisStrings.getJson(cacheKey); + if (cacheResult == null) { + cacheResult = new JSONObject(); + // 查询数据库 + DictKeyDO dictKey = dictKeyDAO.selectByKey(key); + if (dictKey == null) { + return Maps.newMap(); + } + // 构建缓存数据 + cacheResult.put(Const.VALUE, dictKey.getValueType()); + String extraSchema = dictKey.getExtraSchema(); + if (extraSchema != null) { + cacheResult.putAll(JSON.parseObject(extraSchema)); + } + // 设置缓存 + RedisStrings.setJson(cacheKey, DictCacheKeyDefine.DICT_SCHEMA, cacheResult); + } + // 返回 + Map result = Maps.newMap(); + Set schemaKeys = cacheResult.keySet(); + for (String schemaKey : schemaKeys) { + result.put(schemaKey, cacheResult.getString(schemaKey)); + } + return result; + } + @Override public Integer deleteDictKeyById(Long id) { log.info("DictKeyService-deleteDictKeyById id: {}", id); // 检查数据是否存在 DictKeyDO record = dictKeyDAO.selectById(id); Valid.notNull(record, ErrorMessage.CONFIG_ABSENT); - OperatorLogs.add(OperatorLogs.KEY, record.getKey()); + OperatorLogs.add(OperatorLogs.KEY_NAME, record.getKeyName()); // 删除配置项 int effect = dictKeyDAO.deleteById(id); // 删除配置值 dictValueService.deleteDictValueByKeyId(id); // 删除缓存 RedisMaps.delete(DictCacheKeyDefine.DICT_KEY, id); + RedisMaps.delete(DictCacheKeyDefine.DICT_SCHEMA.format(record.getKeyName())); log.info("DictKeyService-deleteDictKeyById id: {}, effect: {}", id, effect); return effect; } @@ -138,9 +175,9 @@ public class DictKeyServiceImpl implements DictKeyService { return 0; } String keys = dictKeys.stream() - .map(DictKeyDO::getKey) + .map(DictKeyDO::getKeyName) .collect(Collectors.joining(Const.COMMA)); - OperatorLogs.add(OperatorLogs.KEY, keys); + OperatorLogs.add(OperatorLogs.KEY_NAME, keys); // 删除配置项 int effect = dictKeyDAO.deleteBatchIds(idList); // 删除配置值 @@ -148,6 +185,11 @@ public class DictKeyServiceImpl implements DictKeyService { log.info("DictKeyService-deleteDictKeyByIdList effect: {}", effect); // 删除缓存 RedisMaps.delete(DictCacheKeyDefine.DICT_KEY, idList); + List schemaKeys = dictKeys.stream() + .map(DictKeyDO::getKeyName) + .map(DictCacheKeyDefine.DICT_SCHEMA::format) + .collect(Collectors.toList()); + RedisMaps.delete(schemaKeys); return effect; } @@ -162,7 +204,7 @@ public class DictKeyServiceImpl implements DictKeyService { // 更新时忽略当前记录 .ne(DictKeyDO::getId, domain.getId()) // 用其他字段做重复校验 - .eq(DictKeyDO::getKey, domain.getKey()); + .eq(DictKeyDO::getKeyName, domain.getKeyName()); // 检查是否存在 boolean present = dictKeyDAO.of(wrapper).present(); Valid.isFalse(present, ErrorMessage.DATA_PRESENT); diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/impl/DictValueServiceImpl.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/impl/DictValueServiceImpl.java index b885082d..28624bac 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/impl/DictValueServiceImpl.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/impl/DictValueServiceImpl.java @@ -1,9 +1,12 @@ package com.orion.ops.module.infra.service.impl; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.orion.lang.define.wrapper.DataGrid; +import com.orion.lang.utils.Strings; import com.orion.lang.utils.collect.Lists; +import com.orion.lang.utils.collect.Maps; import com.orion.ops.framework.biz.operator.log.core.uitls.OperatorLogs; import com.orion.ops.framework.common.constant.Const; import com.orion.ops.framework.common.constant.ErrorMessage; @@ -24,7 +27,9 @@ import com.orion.ops.module.infra.entity.request.dict.DictValueRollbackRequest; import com.orion.ops.module.infra.entity.request.dict.DictValueUpdateRequest; import com.orion.ops.module.infra.entity.request.history.HistoryValueCreateRequest; import com.orion.ops.module.infra.entity.vo.DictValueVO; +import com.orion.ops.module.infra.enums.DictValueTypeEnum; import com.orion.ops.module.infra.enums.HistoryValueTypeEnum; +import com.orion.ops.module.infra.service.DictKeyService; import com.orion.ops.module.infra.service.DictValueService; import com.orion.ops.module.infra.service.HistoryValueService; import lombok.extern.slf4j.Slf4j; @@ -33,6 +38,7 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.Comparator; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; /** @@ -52,6 +58,9 @@ public class DictValueServiceImpl implements DictValueService { @Resource private DictValueDAO dictValueDAO; + @Resource + private DictKeyService dictKeyService; + @Resource private HistoryValueService historyValueService; @@ -62,12 +71,12 @@ public class DictValueServiceImpl implements DictValueService { DictValueDO record = DictValueConvert.MAPPER.to(request); // 查询 dictKey 是否存在 DictKeyDO dictKey = dictKeyDAO.selectById(request.getKeyId()); - String key = Valid.notNull(dictKey, ErrorMessage.CONFIG_ABSENT).getKey(); + String key = Valid.notNull(dictKey, ErrorMessage.CONFIG_ABSENT).getKeyName(); // 查询数据是否冲突 this.checkDictValuePresent(record); // 插入 - OperatorLogs.add(OperatorLogs.KEY, dictKey); - record.setKey(key); + OperatorLogs.add(OperatorLogs.KEY_NAME, dictKey); + record.setKeyName(key); int effect = dictValueDAO.insert(record); Long id = record.getId(); log.info("DictValueService-createDictValue id: {}, effect: {}", id, effect); @@ -85,14 +94,14 @@ public class DictValueServiceImpl implements DictValueService { Valid.notNull(record, ErrorMessage.CONFIG_ABSENT); // 查询 dictKey 是否存在 DictKeyDO dictKey = dictKeyDAO.selectById(request.getKeyId()); - String key = Valid.notNull(dictKey, ErrorMessage.CONFIG_ABSENT).getKey(); + String key = Valid.notNull(dictKey, ErrorMessage.CONFIG_ABSENT).getKeyName(); // 转换 DictValueDO updateRecord = DictValueConvert.MAPPER.to(request); // 查询数据是否冲突 this.checkDictValuePresent(updateRecord); // 更新 - OperatorLogs.add(OperatorLogs.KEY, dictKey); - updateRecord.setKey(key); + OperatorLogs.add(OperatorLogs.KEY_NAME, dictKey); + updateRecord.setKeyName(key); int effect = dictValueDAO.updateById(updateRecord); log.info("DictValueService-updateDictValueById effect: {}", effect); // 删除缓存 @@ -113,8 +122,8 @@ public class DictValueServiceImpl implements DictValueService { HistoryValueDO history = historyValueService.getHistoryByRelId(request.getValueId(), id, HistoryValueTypeEnum.DICT.name()); Valid.notNull(history, ErrorMessage.HISTORY_ABSENT); // 记录日志参数 - OperatorLogs.add(OperatorLogs.KEY, record.getKey()); - OperatorLogs.add(OperatorLogs.LABEL, record.getLabel()); + OperatorLogs.add(OperatorLogs.KEY_NAME, record.getKeyName()); + OperatorLogs.add(OperatorLogs.LABEL, record.getName()); OperatorLogs.add(OperatorLogs.VALUE, history.getBeforeValue()); // 更新 DictValueDO updateRecord = new DictValueDO(); @@ -123,7 +132,7 @@ public class DictValueServiceImpl implements DictValueService { int effect = dictValueDAO.updateById(updateRecord); log.info("DictValueService-rollbackDictValueById effect: {}", effect); // 删除缓存 - RedisMaps.delete(DictCacheKeyDefine.DICT_VALUE.format(record.getKey())); + RedisMaps.delete(DictCacheKeyDefine.DICT_VALUE.format(record.getKeyName())); // 记录历史归档 this.checkRecordHistory(updateRecord, record); return effect; @@ -139,7 +148,7 @@ public class DictValueServiceImpl implements DictValueService { // 查询数据库 list = dictValueDAO.of() .createWrapper() - .eq(DictValueDO::getKey, key) + .eq(DictValueDO::getKeyName, key) .then() .list(DictValueConvert.MAPPER::toCache); // 添加默认值 防止穿透 @@ -160,6 +169,34 @@ public class DictValueServiceImpl implements DictValueService { .collect(Collectors.toList()); } + @Override + public Map> getDictValueEnum(String key) { + // 查询配置值 + List values = this.getDictValueList(key); + if (values.isEmpty()) { + return Maps.empty(); + } + // 查询配置项 + Map schema = dictKeyService.getDictSchema(key); + // 返回 + Map> result = Maps.newLinkedMap(); + for (DictValueVO value : values) { + Map item = Maps.newMap(); + item.put(Const.LABEL, value.getLabel()); + item.put(Const.VALUE, DictValueTypeEnum.of(schema.get(Const.VALUE)).parse(value.getValue())); + // 额外值 + String extra = value.getExtra(); + if (!Strings.isBlank(extra)) { + JSONObject extraObject = JSON.parseObject(extra); + for (String extraKey : extraObject.keySet()) { + item.put(extraKey, DictValueTypeEnum.of(schema.get(extraKey)).parse(extraObject.getString(extraKey))); + } + } + result.put(value.getName(), item); + } + return result; + } + @Override public DataGrid getDictValuePage(DictValueQueryRequest request) { // 条件 @@ -174,7 +211,7 @@ public class DictValueServiceImpl implements DictValueService { public Integer updateKeyNameByKeyId(Long keyId, String beforeKey, String newKey) { // 修改数据库 DictValueDO updateRecord = new DictValueDO(); - updateRecord.setKey(newKey); + updateRecord.setKeyName(newKey); LambdaQueryWrapper wrapper = dictValueDAO.lambda() .eq(DictValueDO::getKeyId, beforeKey); int effect = dictValueDAO.update(updateRecord, wrapper); @@ -192,7 +229,7 @@ public class DictValueServiceImpl implements DictValueService { DictValueDO record = dictValueDAO.selectById(id); Valid.notNull(record, ErrorMessage.CONFIG_ABSENT); // 添加日志参数 - OperatorLogs.add(OperatorLogs.VALUE, record.getKey() + "-" + record.getLabel()); + OperatorLogs.add(OperatorLogs.VALUE, record.getKeyName() + "-" + record.getName()); // 删除 return this.deleteDictValue(Lists.singleton(id), Lists.singleton(record)); } @@ -204,7 +241,7 @@ public class DictValueServiceImpl implements DictValueService { List records = dictValueDAO.selectBatchIds(idList); // 添加日志参数 String value = records.stream() - .map(s -> s.getKey() + "-" + s.getLabel()) + .map(s -> s.getKeyName() + "-" + s.getName()) .collect(Collectors.joining(Const.COMMA)); OperatorLogs.add(OperatorLogs.VALUE, value); // 删除 @@ -251,7 +288,7 @@ public class DictValueServiceImpl implements DictValueService { log.info("DictValueService-deleteDictValue effect: {}", effect); // 删除缓存 List keyList = records.stream() - .map(DictValueDO::getKey) + .map(DictValueDO::getKeyName) .distinct() .map(DictCacheKeyDefine.DICT_VALUE::format) .collect(Collectors.toList()); @@ -292,7 +329,7 @@ public class DictValueServiceImpl implements DictValueService { .ne(DictValueDO::getId, domain.getId()) // 用其他字段做重复校验 .eq(DictValueDO::getKeyId, domain.getKeyId()) - .eq(DictValueDO::getLabel, domain.getLabel()); + .eq(DictValueDO::getName, domain.getName()); // 检查是否存在 boolean present = dictValueDAO.of(wrapper).present(); Valid.isFalse(present, ErrorMessage.CONFIG_PRESENT); @@ -307,9 +344,9 @@ public class DictValueServiceImpl implements DictValueService { private LambdaQueryWrapper buildQueryWrapper(DictValueQueryRequest request) { return dictValueDAO.wrapper() .eq(DictValueDO::getKeyId, request.getKeyId()) + .like(DictValueDO::getName, request.getName()) + .eq(DictValueDO::getValue, request.getValue()) .like(DictValueDO::getLabel, request.getLabel()) - .like(DictValueDO::getValue, request.getValue()) - .like(DictValueDO::getDesc, request.getDesc()) .orderByDesc(DictValueDO::getId); } diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/resources/mapper/DictKeyMapper.xml b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/resources/mapper/DictKeyMapper.xml index 14d02fa6..51f7082b 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/resources/mapper/DictKeyMapper.xml +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/resources/mapper/DictKeyMapper.xml @@ -5,10 +5,10 @@ - + - + @@ -18,7 +18,7 @@ - id, key, value_type, extra_schema, desc, create_time, update_time, creator, updater, deleted + id, key_name, value_type, extra_schema, description, create_time, update_time, creator, updater, deleted diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/resources/mapper/DictValueMapper.xml b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/resources/mapper/DictValueMapper.xml index 414f7ff4..6203cb9d 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/resources/mapper/DictValueMapper.xml +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/resources/mapper/DictValueMapper.xml @@ -6,10 +6,10 @@ - - + + - + @@ -21,7 +21,7 @@ - id, key_id, key, label, value, desc, extra, sort, create_time, update_time, creator, updater, deleted + id, key_id, key_name, name, value, label, extra, sort, create_time, update_time, creator, updater, deleted diff --git a/orion-ops-ui/src/api/meta/history-value.ts b/orion-ops-ui/src/api/meta/history-value.ts new file mode 100644 index 00000000..d3074569 --- /dev/null +++ b/orion-ops-ui/src/api/meta/history-value.ts @@ -0,0 +1,30 @@ +import axios from 'axios'; +import { DataGrid, Pagination } from '@/types/global'; +import { TableData } from '@arco-design/web-vue/es/table/interface'; + +/** + * 历史归档查询请求 + */ +export interface HistoryValueQueryRequest extends Pagination { + searchValue?: string; + relId?: number; + type?: string; +} + +/** + * 历史归档查询响应 + */ +export interface HistoryValueQueryResponse extends TableData { + id?: number; + beforeValue?: string; + afterValue?: string; + createTime: number; + creator: string; +} + +/** + * 分页查询历史归档 + */ +export function getHistoryValuePage(request: HistoryValueQueryRequest) { + return axios.post>('/infra/history-value/query', request); +} diff --git a/orion-ops-ui/src/api/system/dict-key.ts b/orion-ops-ui/src/api/system/dict-key.ts new file mode 100644 index 00000000..e290bb95 --- /dev/null +++ b/orion-ops-ui/src/api/system/dict-key.ts @@ -0,0 +1,71 @@ +import axios from 'axios'; +import qs from 'query-string'; +import { TableData } from '@arco-design/web-vue/es/table/interface'; + +/** + * 字典配置项创建请求 + */ +export interface DictKeyCreateRequest { + keyName?: string; + valueType?: string; + extraSchema?: string; + description?: string; +} + +/** + * 字典配置项更新请求 + */ +export interface DictKeyUpdateRequest extends DictKeyCreateRequest { + id?: number; +} + +/** + * 字典配置项查询响应 + */ +export interface DictKeyQueryResponse extends TableData { + id?: number; + keyName?: string; + valueType?: string; + extraSchema?: string; + description?: string; +} + +/** + * 创建字典配置项 + */ +export function createDictKey(request: DictKeyCreateRequest) { + return axios.post('/infra/dict-key/create', request); +} + +/** + * 更新字典配置项 + */ +export function updateDictKey(request: DictKeyUpdateRequest) { + return axios.put('/infra/dict-key/update', request); +} + +/** + * 查询全部字典配置项 + */ +export function getDictKeyList() { + return axios.post>('/infra/dict-key/list'); +} + +/** + * 删除字典配置项 + */ +export function deleteDictKey(id: number) { + return axios.delete('/infra/dict-key/delete', { params: { id } }); +} + +/** + * 批量删除字典配置项 + */ +export function batchDeleteDictKey(idList: Array) { + return axios.delete('/infra/dict-key/batch-delete', { + params: { idList }, + paramsSerializer: params => { + return qs.stringify(params, { arrayFormat: 'comma' }); + } + }); +} diff --git a/orion-ops-ui/src/api/system/dict-value.ts b/orion-ops-ui/src/api/system/dict-value.ts new file mode 100644 index 00000000..5a8db8d3 --- /dev/null +++ b/orion-ops-ui/src/api/system/dict-value.ts @@ -0,0 +1,134 @@ +import axios from 'axios'; +import qs from 'query-string'; +import { AnyObject, DataGrid, Options, Pagination } from '@/types/global'; +import { TableData } from '@arco-design/web-vue/es/table/interface'; + +/** + * 字典配置值创建请求 + */ +export interface DictValueCreateRequest { + keyId?: number; + keyName?: string; + name?: string; + value?: string; + label?: string; + extra?: string; + sort?: number; +} + +/** + * 字典配置值更新请求 + */ +export interface DictValueUpdateRequest extends DictValueCreateRequest { + id?: number; +} + +/** + * 字典配置值回滚请求 + */ +export interface DictValueRollbackRequest { + id?: number; + relId?: number; +} + +/** + * 字典配置值查询请求 + */ +export interface DictValueQueryRequest extends Pagination { + searchValue?: string; + id?: number; + keyId?: number; + keyName?: string; + name?: string; + value?: string; + label?: string; + extra?: string; + sort?: number; +} + +/** + * 字典配置值查询响应 + */ +export interface DictValueQueryResponse extends TableData { + id?: number; + keyId?: number; + keyName?: string; + name?: string; + value?: string; + label?: string; + extra?: string; + sort?: number; + createTime: number; + updateTime: number; + creator: string; + updater: string; +} + +/** + * 字典配置值枚举查询响应 + */ +export interface DictValueEnumQueryResponse extends Options { + + [key: string]: unknown; +} + +/** + * 创建字典配置值 + */ +export function createDictValue(request: DictValueCreateRequest) { + return axios.post('/infra/dict-value/create', request); +} + +/** + * 更新字典配置值 + */ +export function updateDictValue(request: DictValueUpdateRequest) { + return axios.put('/infra/dict-value/update', request); +} + +/** + * 回滚字典配置值 + */ +export function rollbackDictValue(request: DictValueRollbackRequest) { + return axios.put('/infra/dict-value/rollback', request); +} + +/** + * 查询字典配置值 + */ +export function getDictValue(keyName: string) { + return axios.get>('/infra/dict-value/list', { params: { keyName } }); +} + +/** + * 查询字典配置值枚举 + */ +export function getDictValueEnum(keyName: string) { + return axios.get>('/infra/dict-value/enum', { params: { keyName } }); +} + +/** + * 分页查询字典配置值 + */ +export function getDictValuePage(request: DictValueQueryRequest) { + return axios.post>('/infra/dict-value/query', request); +} + +/** + * 删除字典配置值 + */ +export function deleteDictValue(id: number) { + return axios.delete('/infra/dict-value/delete', { params: { id } }); +} + +/** + * 批量删除字典配置值 + */ +export function batchDeleteDictValue(idList: Array) { + return axios.delete('/infra/dict-value/batch-delete', { + params: { idList }, + paramsSerializer: params => { + return qs.stringify(params, { arrayFormat: 'comma' }); + } + }); +} diff --git a/orion-ops-ui/src/router/routes/modules/system.ts b/orion-ops-ui/src/router/routes/modules/system.ts index 405a00c9..f58fadd2 100644 --- a/orion-ops-ui/src/router/routes/modules/system.ts +++ b/orion-ops-ui/src/router/routes/modules/system.ts @@ -11,6 +11,11 @@ const SYSTEM: AppRouteRecordRaw = { path: '/system/menu', component: () => import('@/views/system/menu/index.vue'), }, + { + name: 'systemDict', + path: '/system/dict', + component: () => import('@/views/system/dict/index.vue'), + }, ], }; diff --git a/orion-ops-ui/src/views/system/dict/components/dict-value-form-modal.vue b/orion-ops-ui/src/views/system/dict/components/dict-value-form-modal.vue new file mode 100644 index 00000000..f81a47fa --- /dev/null +++ b/orion-ops-ui/src/views/system/dict/components/dict-value-form-modal.vue @@ -0,0 +1,168 @@ + + + + + + + diff --git a/orion-ops-ui/src/views/system/dict/components/dict-value-table.vue b/orion-ops-ui/src/views/system/dict/components/dict-value-table.vue new file mode 100644 index 00000000..84d368f7 --- /dev/null +++ b/orion-ops-ui/src/views/system/dict/components/dict-value-table.vue @@ -0,0 +1,224 @@ + + + + + + + diff --git a/orion-ops-ui/src/views/system/dict/index.vue b/orion-ops-ui/src/views/system/dict/index.vue new file mode 100644 index 00000000..4e7aff24 --- /dev/null +++ b/orion-ops-ui/src/views/system/dict/index.vue @@ -0,0 +1,43 @@ + + + + + + + diff --git a/orion-ops-ui/src/views/system/dict/types/const.ts b/orion-ops-ui/src/views/system/dict/types/const.ts new file mode 100644 index 00000000..e69de29b diff --git a/orion-ops-ui/src/views/system/dict/types/enum.types.ts b/orion-ops-ui/src/views/system/dict/types/enum.types.ts new file mode 100644 index 00000000..e69de29b diff --git a/orion-ops-ui/src/views/system/dict/types/form.rules.ts b/orion-ops-ui/src/views/system/dict/types/form.rules.ts new file mode 100644 index 00000000..10202173 --- /dev/null +++ b/orion-ops-ui/src/views/system/dict/types/form.rules.ts @@ -0,0 +1,64 @@ +import { FieldRule } from '@arco-design/web-vue'; + +export const keyId = [{ + required: true, + message: '请输入配置项id' +}] as FieldRule[]; + +export const keyName = [{ + required: true, + message: '请输入配置项' +}, { + maxLength: 32, + message: '配置项长度不能大于32位' +}, { + match: /^[a-zA-Z0-9]{4,32}$/, + message: '配置项需要为 4-32 位的数字以及字母' +}] as FieldRule[]; + +export const name = [{ + required: true, + message: '请输入配置名称' +}, { + maxLength: 32, + message: '配置名称长度不能大于32位' +}, { + match: /^[a-zA-Z0-9]{4,32}$/, + message: '配置名称需要为 4-32 位的数字以及字母' +}] as FieldRule[]; + +export const value = [{ + required: true, + message: '请输入配置值' +}, { + maxLength: 512, + message: '配置值长度不能大于512位' +}] as FieldRule[]; + +export const label = [{ + required: true, + message: '请输入配置描述' +}, { + maxLength: 64, + message: '配置描述长度不能大于64位' +}] as FieldRule[]; + +export const extra = [{ + required: true, + message: '请输入额外参数' +}] as FieldRule[]; + +export const sort = [{ + required: true, + message: '请输入排序' +}] as FieldRule[]; + +export default { + keyId, + keyName, + name, + value, + label, + extra, + sort, +} as Record; diff --git a/orion-ops-ui/src/views/system/dict/types/table.columns.ts b/orion-ops-ui/src/views/system/dict/types/table.columns.ts new file mode 100644 index 00000000..f8f0c8b0 --- /dev/null +++ b/orion-ops-ui/src/views/system/dict/types/table.columns.ts @@ -0,0 +1,64 @@ +import { TableColumnData } from '@arco-design/web-vue/es/table/interface'; +import { dateFormat } from '@/utils'; + +const columns = [ + { + title: 'id', + dataIndex: 'id', + slotName: 'id', + width: 70, + align: 'left', + fixed: 'left', + }, { + title: '配置项', + dataIndex: 'keyName', + slotName: 'keyName', + ellipsis: true, + tooltip: true, + }, { + title: '配置名称', + dataIndex: 'name', + slotName: 'name', + ellipsis: true, + tooltip: true, + }, { + title: '配置描述', + dataIndex: 'label', + slotName: 'label', + ellipsis: true, + tooltip: true, + }, { + title: '配置值', + dataIndex: 'value', + slotName: 'value', + ellipsis: true, + tooltip: true, + }, { + title: '额外参数', + dataIndex: 'extra', + slotName: 'extra', + ellipsis: true, + tooltip: true, + }, { + title: '排序', + dataIndex: 'sort', + slotName: 'sort', + width: 70, + }, { + title: '修改时间', + dataIndex: 'updateTime', + slotName: 'updateTime', + width: 180, + render: ({ record }) => { + return dateFormat(new Date(record.updateTime)); + }, + }, { + title: '操作', + slotName: 'handle', + width: 160, + align: 'center', + fixed: 'right', + }, +] as TableColumnData[]; + +export default columns;