From eb2c8eb719a1a658c8d4deefacea60297aab3ac0 Mon Sep 17 00:00:00 2001 From: lijiahangmax Date: Sat, 21 Oct 2023 02:26:36 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=9D=E5=AD=98=E5=AD=97=E5=85=B8?= =?UTF-8?q?=E5=80=BC.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/common/constant/ValidConst.java | 4 + .../infra/controller/DictValueController.java | 8 +- .../request/dict/DictValueCreateRequest.java | 2 +- .../request/dict/DictValueUpdateRequest.java | 2 +- .../infra/service/DictValueService.java | 8 +- .../service/impl/DictValueServiceImpl.java | 12 +-- .../system/dict-key/dict-key-selector.vue | 23 ++++- .../user/role/user-role-selector.vue | 5 +- .../components/dict-key-form-modal.vue | 3 +- .../dict-key/components/dict-key-table.vue | 19 +++- .../system/dict-key/types/table.columns.ts | 2 +- .../components/dict-value-form-modal.vue | 89 +++++++++++++++++-- .../components/dict-value-table.vue | 32 +++++-- 13 files changed, 168 insertions(+), 41 deletions(-) diff --git a/orion-ops-framework/orion-ops-framework-common/src/main/java/com/orion/ops/framework/common/constant/ValidConst.java b/orion-ops-framework/orion-ops-framework-common/src/main/java/com/orion/ops/framework/common/constant/ValidConst.java index 0d922edd..072d6156 100644 --- a/orion-ops-framework/orion-ops-framework-common/src/main/java/com/orion/ops/framework/common/constant/ValidConst.java +++ b/orion-ops-framework/orion-ops-framework-common/src/main/java/com/orion/ops/framework/common/constant/ValidConst.java @@ -9,6 +9,10 @@ package com.orion.ops.framework.common.constant; */ public interface ValidConst { + String CHAR_NUMBER_1_32_PATTERN = "^[a-zA-Z0-9]{1,32}$"; + + String CHAR_NUMBER_1_32_MESSAGE = "只能为 1-32 位的数字或字母"; + String CHAR_NUMBER_2_32_PATTERN = "^[a-zA-Z0-9]{2,32}$"; String CHAR_NUMBER_2_32_MESSAGE = "只能为 2-32 位的数字或字母"; 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 140b1b9d..bfa5af15 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 @@ -71,15 +71,15 @@ public class DictValueController { @IgnoreLog(IgnoreLogMode.RET) @GetMapping("/list") @Operation(summary = "查询字典配置值") - public List getDictValueList(@RequestParam("key") String key) { - return dictValueService.getDictValueList(key); + public List getDictValueList(@RequestParam("keyName") String keyName) { + return dictValueService.getDictValueList(keyName); } @IgnoreLog(IgnoreLogMode.RET) @GetMapping("/enum") @Operation(summary = "查询字典配置值枚举") - public Map> getDictValueEnum(@RequestParam("key") String key) { - return dictValueService.getDictValueEnum(key); + public Map> getDictValueEnum(@RequestParam("keyName") String keyName) { + return dictValueService.getDictValueEnum(keyName); } @IgnoreLog(IgnoreLogMode.RET) 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 cabab672..b556a27e 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 @@ -33,7 +33,7 @@ public class DictValueCreateRequest implements Serializable { @NotBlank @Size(max = 32) - @Pattern(regexp = ValidConst.CHAR_NUMBER_2_32_PATTERN, message = ValidConst.CHAR_NUMBER_2_32_MESSAGE) + @Pattern(regexp = ValidConst.CHAR_NUMBER_1_32_PATTERN, message = ValidConst.CHAR_NUMBER_1_32_MESSAGE) @Schema(description = "配置名称") private String name; 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 b7b7654a..9c9e52a1 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 @@ -37,7 +37,7 @@ public class DictValueUpdateRequest implements Serializable { @NotBlank @Size(max = 32) - @Pattern(regexp = ValidConst.CHAR_NUMBER_2_32_PATTERN, message = ValidConst.CHAR_NUMBER_2_32_MESSAGE) + @Pattern(regexp = ValidConst.CHAR_NUMBER_1_32_PATTERN, message = ValidConst.CHAR_NUMBER_1_32_MESSAGE) @Schema(description = "配置名称") private String name; 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 99d8a03b..830a9dba 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 @@ -46,18 +46,18 @@ public interface DictValueService { /** * 查询全部字典配置值 * - * @param key key + * @param keyName keyName * @return rows */ - List getDictValueList(String key); + List getDictValueList(String keyName); /** * 查询全部字典配置值枚举 * - * @param key key + * @param keyName keyName * @return enum */ - Map> getDictValueEnum(String key); + Map> getDictValueEnum(String keyName); /** * 分页查询字典配置值 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 5ce65b1b..675607c1 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 @@ -140,15 +140,15 @@ public class DictValueServiceImpl implements DictValueService { @Override @SuppressWarnings("unchecked") - public List getDictValueList(String key) { + public List getDictValueList(String keyName) { // 查询缓存 - String cacheKey = DictCacheKeyDefine.DICT_VALUE.format(key); + String cacheKey = DictCacheKeyDefine.DICT_VALUE.format(keyName); List list = RedisMaps.valuesJson(cacheKey, (Class) DictCacheKeyDefine.DICT_VALUE.getType()); if (list.isEmpty()) { // 查询数据库 list = dictValueDAO.of() .createWrapper() - .eq(DictValueDO::getKeyName, key) + .eq(DictValueDO::getKeyName, keyName) .then() .list(DictValueConvert.MAPPER::toCache); // 添加默认值 防止穿透 @@ -170,14 +170,14 @@ public class DictValueServiceImpl implements DictValueService { } @Override - public Map> getDictValueEnum(String key) { + public Map> getDictValueEnum(String keyName) { // 查询配置值 - List values = this.getDictValueList(key); + List values = this.getDictValueList(keyName); if (values.isEmpty()) { return Maps.empty(); } // 查询配置项 - Map schema = dictKeyService.getDictSchema(key); + Map schema = dictKeyService.getDictSchema(keyName); // 返回 Map> result = Maps.newLinkedMap(); for (DictValueVO value : values) { diff --git a/orion-ops-ui/src/components/system/dict-key/dict-key-selector.vue b/orion-ops-ui/src/components/system/dict-key/dict-key-selector.vue index 1aae37ec..29968d32 100644 --- a/orion-ops-ui/src/components/system/dict-key/dict-key-selector.vue +++ b/orion-ops-ui/src/components/system/dict-key/dict-key-selector.vue @@ -5,6 +5,7 @@ :loading="loading" :disabled="loading" :filter-option="filterOption" + :allow-create="allowCreate" placeholder="请选择配置项" /> @@ -23,6 +24,10 @@ const props = defineProps({ modelValue: Number, loading: Boolean, + allowCreate: { + type: Boolean, + default: false + } }); const emits = defineEmits(['update:modelValue', 'change']); @@ -32,8 +37,21 @@ return props.modelValue; }, set(e) { - emits('update:modelValue', e); - emits('change', e); + if (typeof e === 'string') { + // 创建的值 + emits('update:modelValue', undefined); + emits('change', { + id: undefined, + keyName: e + }); + } else { + // 已有的值 + emits('update:modelValue', e); + const find = cacheStore.dictKeys.find(s => s.id === e); + if (find) { + emits('change', find); + } + } } }); @@ -44,7 +62,6 @@ return { label: `${s.keyName} - ${s.description || ''}`, value: s.id, - origin: s, }; }); }; diff --git a/orion-ops-ui/src/components/user/role/user-role-selector.vue b/orion-ops-ui/src/components/user/role/user-role-selector.vue index ecdb7cb2..9aedd807 100644 --- a/orion-ops-ui/src/components/user/role/user-role-selector.vue +++ b/orion-ops-ui/src/components/user/role/user-role-selector.vue @@ -16,14 +16,13 @@ diff --git a/orion-ops-ui/src/views/system/dict-value/components/dict-value-table.vue b/orion-ops-ui/src/views/system/dict-value/components/dict-value-table.vue index e5bd7351..95b9dfb5 100644 --- a/orion-ops-ui/src/views/system/dict-value/components/dict-value-table.vue +++ b/orion-ops-ui/src/views/system/dict-value/components/dict-value-table.vue @@ -4,11 +4,13 @@ - - + + @@ -100,12 +102,12 @@ @click="emits('openUpdate', record)"> 修改 - + - 回滚 + @click="emits('openHistory', record)"> + 历史 ([]); const { loading, setLoading } = useLoading(); - const emits = defineEmits(['openAdd', 'openUpdate']); + const emits = defineEmits(['openAdd', 'openUpdate', 'openHistory']); const pagination = usePagination(); const selectedKeys = ref([]); @@ -210,6 +213,21 @@ addedCallback, updatedCallback }); + // 修改 key + const changeKey = ({ id, keyName }: { id: number, keyName: string }) => { + if (id) { + formModel.keyId = id; + } else { + formModel.keyName = keyName; + } + }; + + // 清空表单 + const resetForm = () => { + formModel.keyName = undefined; + fetchTableData(); + }; + // 加载数据 const doFetchTableData = async (request: DictValueQueryRequest) => { try {