From 400dd79b9ff2dc5e3f7e584f34f5a3c940c4145d Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Fri, 31 May 2024 17:35:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20Redis=20=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5=E4=BF=A1=E6=81=AF=E7=A7=BB=E9=99=A4=E5=AF=86?= =?UTF-8?q?=E7=A0=81=E9=99=90=E5=88=B6=20(#5239)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/dto/database.go | 2 +- backend/app/service/command.go | 10 ++++++-- .../views/database/redis/command/index.vue | 4 +-- .../src/views/database/redis/conn/index.vue | 25 +++++++++++++------ 4 files changed, 28 insertions(+), 13 deletions(-) diff --git a/backend/app/dto/database.go b/backend/app/dto/database.go index 852285e3c..d40c2fe6a 100644 --- a/backend/app/dto/database.go +++ b/backend/app/dto/database.go @@ -166,7 +166,7 @@ type MysqlVariablesUpdateHelper struct { // redis type ChangeRedisPass struct { Database string `json:"database" validate:"required"` - Value string `json:"value" validate:"required"` + Value string `json:"value"` } type RedisConfUpdate struct { diff --git a/backend/app/service/command.go b/backend/app/service/command.go index 3156ad7d1..d32e8f2c8 100644 --- a/backend/app/service/command.go +++ b/backend/app/service/command.go @@ -154,9 +154,15 @@ func (u *CommandService) ListRedisCommand() ([]dto.RedisCommand, error) { return dtoCommands, err } -func (u *CommandService) SaveRedisCommand(commandDto dto.RedisCommand) error { +func (u *CommandService) SaveRedisCommand(req dto.RedisCommand) error { + if req.ID == 0 { + command, _ := commandRepo.GetRedis(commonRepo.WithByName(req.Name)) + if command.ID != 0 { + return constant.ErrRecordExist + } + } var command model.RedisCommand - if err := copier.Copy(&command, &commandDto); err != nil { + if err := copier.Copy(&command, &req); err != nil { return errors.WithMessage(constant.ErrStructTransform, err.Error()) } if err := commandRepo.SaveRedis(&command); err != nil { diff --git a/frontend/src/views/database/redis/command/index.vue b/frontend/src/views/database/redis/command/index.vue index c77552ca4..417a7f82f 100644 --- a/frontend/src/views/database/redis/command/index.vue +++ b/frontend/src/views/database/redis/command/index.vue @@ -19,13 +19,13 @@ - + - + - + @@ -66,12 +66,7 @@ - +