From b9befc72a38d233292b11ed87f75ec38fa7b53ea Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Wed, 13 Sep 2023 17:32:12 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E8=AE=A1=E5=88=92?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=A4=87=E4=BB=BD=E6=89=80=E6=9C=89=E5=BA=94?= =?UTF-8?q?=E7=94=A8=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98=20(#2278?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/api/v1/database_mysql.go | 4 ++-- backend/app/dto/database.go | 2 +- backend/app/service/cornjob.go | 1 + backend/app/service/cronjob_helper.go | 1 - backend/app/service/database_mysql.go | 6 +++--- cmd/server/docs/docs.go | 4 ++-- cmd/server/docs/swagger.json | 4 ++-- cmd/server/docs/swagger.yaml | 4 ++-- frontend/src/api/interface/cronjob.ts | 1 + frontend/src/api/interface/database.ts | 2 +- frontend/src/api/modules/database.ts | 20 +++++++++---------- frontend/src/views/cronjob/record/index.vue | 22 ++++++++++++--------- 12 files changed, 38 insertions(+), 33 deletions(-) diff --git a/backend/app/api/v1/database_mysql.go b/backend/app/api/v1/database_mysql.go index 84bdf5da4..ff2853db5 100644 --- a/backend/app/api/v1/database_mysql.go +++ b/backend/app/api/v1/database_mysql.go @@ -233,11 +233,11 @@ func (b *BaseApi) ListDBName(c *gin.Context) { // @Summary Load mysql database from remote // @Description 从服务器获取 // @Accept json -// @Param request body dto.MysqlLodaDB true "request" +// @Param request body dto.MysqlLoadDB true "request" // @Security ApiKeyAuth // @Router /databases/load [post] func (b *BaseApi) LoadDBFromRemote(c *gin.Context) { - var req dto.MysqlLodaDB + var req dto.MysqlLoadDB if err := c.ShouldBindJSON(&req); err != nil { helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err) return diff --git a/backend/app/dto/database.go b/backend/app/dto/database.go index 11a7defb5..e17304b8f 100644 --- a/backend/app/dto/database.go +++ b/backend/app/dto/database.go @@ -43,7 +43,7 @@ type MysqlDBCreate struct { Description string `json:"description"` } -type MysqlLodaDB struct { +type MysqlLoadDB struct { From string `json:"from" validate:"required,oneof=local remote"` Type string `json:"type" validate:"required,oneof=mysql mariadb"` Database string `json:"database" validate:"required"` diff --git a/backend/app/service/cornjob.go b/backend/app/service/cornjob.go index acc9c9f2f..0c331b076 100644 --- a/backend/app/service/cornjob.go +++ b/backend/app/service/cornjob.go @@ -261,6 +261,7 @@ func (u *CronjobService) Update(id uint, req dto.CronjobUpdate) error { upMap["hour"] = req.Hour upMap["minute"] = req.Minute upMap["second"] = req.Second + upMap["app_id"] = req.AppID upMap["website"] = req.Website upMap["exclusion_rules"] = req.ExclusionRules upMap["db_name"] = req.DBName diff --git a/backend/app/service/cronjob_helper.go b/backend/app/service/cronjob_helper.go index c4bbb6c90..c41c39f4b 100644 --- a/backend/app/service/cronjob_helper.go +++ b/backend/app/service/cronjob_helper.go @@ -456,7 +456,6 @@ func (u *CronjobService) handleApp(cronjob model.Cronjob, backup model.BackupAcc if err := handleAppBackup(&app, backupDir, record.FileName); err != nil { return paths, err } - record.Name = app.Name if err := backupRepo.CreateRecord(&record); err != nil { global.LOG.Errorf("save backup record failed, err: %v", err) return paths, err diff --git a/backend/app/service/database_mysql.go b/backend/app/service/database_mysql.go index e60c8e203..4cd802238 100644 --- a/backend/app/service/database_mysql.go +++ b/backend/app/service/database_mysql.go @@ -35,7 +35,7 @@ type IMysqlService interface { SearchWithPage(search dto.MysqlDBSearch) (int64, interface{}, error) ListDBOption() ([]dto.MysqlOption, error) Create(ctx context.Context, req dto.MysqlDBCreate) (*model.DatabaseMysql, error) - LoadFromRemote(req dto.MysqlLodaDB) error + LoadFromRemote(req dto.MysqlLoadDB) error ChangeAccess(info dto.ChangeDBInfo) error ChangePassword(info dto.ChangeDBInfo) error UpdateVariables(req dto.MysqlVariablesUpdate) error @@ -144,7 +144,7 @@ func (u *MysqlService) Create(ctx context.Context, req dto.MysqlDBCreate) (*mode return &createItem, nil } -func (u *MysqlService) LoadFromRemote(req dto.MysqlLodaDB) error { +func (u *MysqlService) LoadFromRemote(req dto.MysqlLoadDB) error { client, version, err := LoadMysqlClientByFrom(req.Database) if err != nil { return err @@ -314,7 +314,7 @@ func (u *MysqlService) ChangePassword(req dto.ChangeDBInfo) error { return err } } - global.LOG.Info("excute password change sql successful") + global.LOG.Info("execute password change sql successful") pass, err := encrypt.StringEncrypt(req.Value) if err != nil { return fmt.Errorf("decrypt database db password failed, err: %v", err) diff --git a/cmd/server/docs/docs.go b/cmd/server/docs/docs.go index cd820d515..0a4ad7f8c 100644 --- a/cmd/server/docs/docs.go +++ b/cmd/server/docs/docs.go @@ -4322,7 +4322,7 @@ const docTemplate = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/dto.MysqlLodaDB" + "$ref": "#/definitions/dto.MysqlLoadDB" } } ], @@ -13690,7 +13690,7 @@ const docTemplate = `{ } } }, - "dto.MysqlLodaDB": { + "dto.MysqlLoadDB": { "type": "object", "required": [ "database", diff --git a/cmd/server/docs/swagger.json b/cmd/server/docs/swagger.json index abe74420e..7c4f125b1 100644 --- a/cmd/server/docs/swagger.json +++ b/cmd/server/docs/swagger.json @@ -4315,7 +4315,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/dto.MysqlLodaDB" + "$ref": "#/definitions/dto.MysqlLoadDB" } } ], @@ -13683,7 +13683,7 @@ } } }, - "dto.MysqlLodaDB": { + "dto.MysqlLoadDB": { "type": "object", "required": [ "database", diff --git a/cmd/server/docs/swagger.yaml b/cmd/server/docs/swagger.yaml index 93f9c38f7..06e280663 100644 --- a/cmd/server/docs/swagger.yaml +++ b/cmd/server/docs/swagger.yaml @@ -1344,7 +1344,7 @@ definitions: - page - pageSize type: object - dto.MysqlLodaDB: + dto.MysqlLoadDB: properties: database: type: string @@ -6783,7 +6783,7 @@ paths: name: request required: true schema: - $ref: '#/definitions/dto.MysqlLodaDB' + $ref: '#/definitions/dto.MysqlLoadDB' responses: {} security: - ApiKeyAuth: [] diff --git a/frontend/src/api/interface/cronjob.ts b/frontend/src/api/interface/cronjob.ts index 78df708bf..5a4f32a3a 100644 --- a/frontend/src/api/interface/cronjob.ts +++ b/frontend/src/api/interface/cronjob.ts @@ -82,6 +82,7 @@ export namespace Cronjob { } export interface Record { id: number; + file: string; startTime: Date; endTime: Date; records: string; diff --git a/frontend/src/api/interface/database.ts b/frontend/src/api/interface/database.ts index 6b9d4d1d6..c94203187 100644 --- a/frontend/src/api/interface/database.ts +++ b/frontend/src/api/interface/database.ts @@ -48,7 +48,7 @@ export namespace Database { permission: string; description: string; } - export interface MysqlLodaDB { + export interface MysqlLoadDB { from: string; type: string; database: string; diff --git a/frontend/src/api/modules/database.ts b/frontend/src/api/modules/database.ts index 16afa4a2f..363c308d8 100644 --- a/frontend/src/api/modules/database.ts +++ b/frontend/src/api/modules/database.ts @@ -13,24 +13,24 @@ export const loadDatabaseFile = (type: string, database: string) => { }; export const addMysqlDB = (params: Database.MysqlDBCreate) => { - let reqest = deepCopy(params) as Database.MysqlDBCreate; - if (reqest.password) { - reqest.password = Base64.encode(reqest.password); + let request = deepCopy(params) as Database.MysqlDBCreate; + if (request.password) { + request.password = Base64.encode(request.password); } - return http.post(`/databases`, reqest); + return http.post(`/databases`, request); }; -export const loadDBFromRemote = (params: Database.MysqlLodaDB) => { +export const loadDBFromRemote = (params: Database.MysqlLoadDB) => { return http.post(`/databases/load`, params); }; export const updateMysqlAccess = (params: Database.ChangeInfo) => { return http.post(`/databases/change/access`, params); }; export const updateMysqlPassword = (params: Database.ChangeInfo) => { - let reqest = deepCopy(params) as Database.ChangeInfo; - if (reqest.value) { - reqest.value = Base64.encode(reqest.value); + let request = deepCopy(params) as Database.ChangeInfo; + if (request.value) { + request.value = Base64.encode(request.value); } - return http.post(`/databases/change/password`, reqest); + return http.post(`/databases/change/password`, request); }; export const updateMysqlDescription = (params: DescriptionUpdate) => { return http.post(`/databases/description/update`, params); @@ -90,7 +90,7 @@ export const updateRedisConfByFile = (params: Database.RedisConfUpdateByFile) => return http.post(`/databases/redis/conffile/update`, params); }; -// databasae +// database export const getDatabase = (name: string) => { return http.get(`/databases/db/${name}`); }; diff --git a/frontend/src/views/cronjob/record/index.vue b/frontend/src/views/cronjob/record/index.vue index 8c4e7280b..a4e965136 100644 --- a/frontend/src/views/cronjob/record/index.vue +++ b/frontend/src/views/cronjob/record/index.vue @@ -587,16 +587,20 @@ const search = async () => { }; const onDownload = async (record: any, backupID: number) => { - if (dialogData.value.rowData.dbName === 'all') { - MsgInfo(i18n.global.t('cronjob.allOptionHelper', [i18n.global.t('database.database')])); - return; + let type = ''; + switch (dialogData.value.rowData.type) { + case 'database': + type = i18n.global.t('database.database'); + break; + case 'app': + type = i18n.global.t('app.app'); + break; + case 'website': + type = i18n.global.t('website.website'); + break; } - if (dialogData.value.rowData.app === 'all') { - MsgInfo(i18n.global.t('cronjob.allOptionHelper', [i18n.global.t('app.app')])); - return; - } - if (dialogData.value.rowData.website === 'all') { - MsgInfo(i18n.global.t('cronjob.allOptionHelper', [i18n.global.t('website.website')])); + if (currentRecord.value.file.indexOf(',') !== 0) { + MsgInfo(i18n.global.t('cronjob.allOptionHelper', [type])); return; } if (!record.file || record.file.indexOf('/') === -1) {