From e03ceecd9aac427526c18a141bbbe1d1e961dd04 Mon Sep 17 00:00:00 2001 From: "meilin.huang" <954537473@qq.com> Date: Thu, 21 Nov 2024 13:20:45 +0800 Subject: [PATCH] fix: redis set command causes ttl loss --- frontend/src/common/assert.ts | 22 ++++++++++++++++++ frontend/src/i18n/en/common.ts | 1 + frontend/src/i18n/en/db.ts | 2 +- frontend/src/i18n/zh-cn/common.ts | 1 + .../src/views/ops/redis/KeyValueString.vue | 22 ++++++++++++++---- server/internal/db/application/db.go | 2 +- server/resources/data/mayfly-go.sqlite | Bin 335872 -> 335872 bytes server/resources/script/sql/mayfly-go.sql | 16 ++++++------- 8 files changed, 50 insertions(+), 16 deletions(-) diff --git a/frontend/src/common/assert.ts b/frontend/src/common/assert.ts index 4d17a631..16e8808e 100644 --- a/frontend/src/common/assert.ts +++ b/frontend/src/common/assert.ts @@ -1,3 +1,5 @@ +import { i18n } from '@/i18n'; + /** * 不符合业务断言错误 */ @@ -31,6 +33,16 @@ export function notBlank(obj: any, msg: string) { isTrue(obj, msg); } +/** + * 断言不能为空值,即null,0,''等 + * + * @param obj 对象 + * @param field 字段(支持i18n msgKey) + */ +export function notBlankI18n(obj: any, field: string) { + notBlank(obj, i18n.global.t('common.fieldNotEmpty', { field: i18n.global.t(field) })); +} + /** * 断言两对象相等 * @@ -65,3 +77,13 @@ export function notEmpty(str: string, msg: string) { throw new AssertError(msg); } } + +/** + * 断言字符串不能为空 + * + * @param str 字符串 + * @param field 字段(支持i18n msgKey) + */ +export function notEmptyI18n(str: string, field: string) { + notEmpty(str, i18n.global.t('common.fieldNotEmpty', { field: i18n.global.t(field) })); +} diff --git a/frontend/src/i18n/en/common.ts b/frontend/src/i18n/en/common.ts index fad77da0..8ce26ab2 100644 --- a/frontend/src/i18n/en/common.ts +++ b/frontend/src/i18n/en/common.ts @@ -55,6 +55,7 @@ export default { saveSuccess: 'save successfully', deleteSuccess: 'delete successfully', operateSuccess: 'operate successfully', + fieldNotEmpty: '{field} cannot be empty', }, layout: { user: { diff --git a/frontend/src/i18n/en/db.ts b/frontend/src/i18n/en/db.ts index 9413c757..4e374fd0 100644 --- a/frontend/src/i18n/en/db.ts +++ b/frontend/src/i18n/en/db.ts @@ -99,7 +99,7 @@ export default { columnName: 'Column Name', homePage: 'Home Page', previousPage: 'Previous Page', - rowsPage: 'rows/page', + rowsPage: ' rows/page', rows: 'rows', conditionInputDialogTitle: 'Enter the value of [{columnName}]', addDataDialogTitle: 'Add `{tableName}` table data', diff --git a/frontend/src/i18n/zh-cn/common.ts b/frontend/src/i18n/zh-cn/common.ts index a0f03cde..5ed88fc3 100644 --- a/frontend/src/i18n/zh-cn/common.ts +++ b/frontend/src/i18n/zh-cn/common.ts @@ -55,6 +55,7 @@ export default { saveSuccess: '保存成功', deleteSuccess: '删除成功', operateSuccess: '操作成功', + fieldNotEmpty: '{field}不能为空', }, layout: { user: { diff --git a/frontend/src/views/ops/redis/KeyValueString.vue b/frontend/src/views/ops/redis/KeyValueString.vue index 258e7d65..2119c96b 100644 --- a/frontend/src/views/ops/redis/KeyValueString.vue +++ b/frontend/src/views/ops/redis/KeyValueString.vue @@ -12,10 +12,11 @@