From bbd649188abd60f4087739ef66a3b59f7e8c7058 Mon Sep 17 00:00:00 2001 From: ssongliu Date: Mon, 24 Jul 2023 14:55:26 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=9E=E7=8E=B0=E6=9C=AC=E5=9C=B0?= =?UTF-8?q?=E8=BF=9C=E7=A8=8B=E6=95=B0=E6=8D=AE=E5=BA=93=E5=88=87=E6=8D=A2?= 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/api/v1/remote_db.go | 6 +- backend/app/dto/database.go | 8 + backend/app/repo/databse_mysql.go | 10 + backend/app/service/database_mysql.go | 10 +- cmd/server/docs/docs.go | 355 +++++++++++++++++- cmd/server/docs/swagger.json | 351 ++++++++++++++++- cmd/server/docs/swagger.yaml | 231 +++++++++++- frontend/src/api/interface/database.ts | 8 + frontend/src/api/modules/database.ts | 4 +- frontend/src/lang/modules/en.ts | 8 + frontend/src/lang/modules/tw.ts | 8 + frontend/src/lang/modules/zh.ts | 1 + .../src/views/database/mysql/create/index.vue | 2 +- frontend/src/views/database/mysql/index.vue | 92 ++++- 15 files changed, 1071 insertions(+), 27 deletions(-) diff --git a/backend/app/api/v1/database_mysql.go b/backend/app/api/v1/database_mysql.go index 8602436c9..9d26b5a4a 100644 --- a/backend/app/api/v1/database_mysql.go +++ b/backend/app/api/v1/database_mysql.go @@ -188,12 +188,12 @@ func (b *BaseApi) UpdateMysqlConfByFile(c *gin.Context) { // @Summary Page mysql databases // @Description 获取 mysql 数据库列表分页 // @Accept json -// @Param request body dto.SearchWithPage true "request" +// @Param request body dto.MysqlDBSearch true "request" // @Success 200 {object} dto.PageResult // @Security ApiKeyAuth // @Router /databases/search [post] func (b *BaseApi) SearchMysql(c *gin.Context) { - var req dto.SearchWithPage + var req dto.MysqlDBSearch if err := c.ShouldBindJSON(&req); err != nil { helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err) return diff --git a/backend/app/api/v1/remote_db.go b/backend/app/api/v1/remote_db.go index 8ee60e9c8..53f060557 100644 --- a/backend/app/api/v1/remote_db.go +++ b/backend/app/api/v1/remote_db.go @@ -12,7 +12,7 @@ import ( // @Summary Create remote database // @Description 创建远程数据库 // @Accept json -// @Param request body dto.DatabaseCreate true "request" +// @Param request body dto.RemoteDBCreate true "request" // @Success 200 // @Security ApiKeyAuth // @Router /databases/remote [post] @@ -38,7 +38,7 @@ func (b *BaseApi) CreateRemoteDB(c *gin.Context) { // @Summary Page remote databases // @Description 获取远程数据库列表分页 // @Accept json -// @Param request body dto.SearchWithPage true "request" +// @Param request body dto.RemoteDBSearch true "request" // @Success 200 {object} dto.PageResult // @Security ApiKeyAuth // @Router /databases/remote/search [post] @@ -113,7 +113,7 @@ func (b *BaseApi) DeleteRemoteDB(c *gin.Context) { // @Summary Update remote database // @Description 更新远程数据库 // @Accept json -// @Param request body dto.DatabaseUpdate true "request" +// @Param request body dto.RemoteDBUpdate true "request" // @Success 200 // @Security ApiKeyAuth // @Router /databases/remote/update [post] diff --git a/backend/app/dto/database.go b/backend/app/dto/database.go index 1b23c0cc5..4e0aac76a 100644 --- a/backend/app/dto/database.go +++ b/backend/app/dto/database.go @@ -2,6 +2,14 @@ package dto import "time" +type MysqlDBSearch struct { + PageInfo + Info string `json:"info"` + From string `json:"from"` + OrderBy string `json:"orderBy"` + Order string `json:"order"` +} + type MysqlDBInfo struct { ID uint `json:"id"` CreatedAt time.Time `json:"createdAt"` diff --git a/backend/app/repo/databse_mysql.go b/backend/app/repo/databse_mysql.go index 281704953..b0e3e2b0e 100644 --- a/backend/app/repo/databse_mysql.go +++ b/backend/app/repo/databse_mysql.go @@ -13,6 +13,7 @@ type MysqlRepo struct{} type IMysqlRepo interface { Get(opts ...DBOption) (model.DatabaseMysql, error) WithByMysqlName(mysqlName string) DBOption + WithByFrom(from string) DBOption List(opts ...DBOption) ([]model.DatabaseMysql, error) Page(limit, offset int, opts ...DBOption) (int64, []model.DatabaseMysql, error) Create(ctx context.Context, mysql *model.DatabaseMysql) error @@ -86,3 +87,12 @@ func (u *MysqlRepo) WithByMysqlName(mysqlName string) DBOption { return g.Where("mysql_name = ?", mysqlName) } } + +func (u *MysqlRepo) WithByFrom(from string) DBOption { + return func(g *gorm.DB) *gorm.DB { + if len(from) != 0 { + return g.Where("`from` = ?", from) + } + return g + } +} diff --git a/backend/app/service/database_mysql.go b/backend/app/service/database_mysql.go index e2fcc4068..9df5c5e22 100644 --- a/backend/app/service/database_mysql.go +++ b/backend/app/service/database_mysql.go @@ -30,7 +30,7 @@ import ( type MysqlService struct{} type IMysqlService interface { - SearchWithPage(search dto.SearchWithPage) (int64, interface{}, error) + SearchWithPage(search dto.MysqlDBSearch) (int64, interface{}, error) ListDBName() ([]string, error) Create(ctx context.Context, req dto.MysqlDBCreate) (*model.DatabaseMysql, error) ChangeAccess(info dto.ChangeDBInfo) error @@ -50,8 +50,12 @@ func NewIMysqlService() IMysqlService { return &MysqlService{} } -func (u *MysqlService) SearchWithPage(search dto.SearchWithPage) (int64, interface{}, error) { - total, mysqls, err := mysqlRepo.Page(search.Page, search.PageSize, commonRepo.WithLikeName(search.Info), commonRepo.WithOrderRuleBy(search.OrderBy, search.Order)) +func (u *MysqlService) SearchWithPage(search dto.MysqlDBSearch) (int64, interface{}, error) { + total, mysqls, err := mysqlRepo.Page(search.Page, search.PageSize, + mysqlRepo.WithByFrom(search.From), + commonRepo.WithLikeName(search.Info), + commonRepo.WithOrderRuleBy(search.OrderBy, search.Order), + ) var dtoMysqls []dto.MysqlDBInfo for _, mysql := range mysqls { var item dto.MysqlDBInfo diff --git a/cmd/server/docs/docs.go b/cmd/server/docs/docs.go index 7ca210f48..b1753a3fc 100644 --- a/cmd/server/docs/docs.go +++ b/cmd/server/docs/docs.go @@ -1,5 +1,5 @@ -// Package docs GENERATED BY SWAG; DO NOT EDIT -// This file was generated by swaggo/swag +// Code generated by swaggo/swag. DO NOT EDIT. + package docs import "github.com/swaggo/swag" @@ -4217,6 +4217,201 @@ const docTemplate = `{ } } } + }, + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "创建远程数据库", + "consumes": [ + "application/json" + ], + "tags": [ + "Database" + ], + "summary": "Create remote database", + "parameters": [ + { + "description": "request", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.RemoteDBCreate" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + }, + "x-panel-log": { + "BeforeFuntions": [], + "bodyKeys": [ + "name", + "type" + ], + "formatEN": "create remote database [name][type]", + "formatZH": "创建远程数据库 [name][type]", + "paramKeys": [] + } + } + }, + "/databases/remote/del": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "删除远程数据库", + "consumes": [ + "application/json" + ], + "tags": [ + "Database" + ], + "summary": "Delete remote database", + "parameters": [ + { + "description": "request", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.OperateByID" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + }, + "x-panel-log": { + "BeforeFuntions": [ + { + "db": "databases", + "input_column": "id", + "input_value": "ids", + "isList": true, + "output_column": "name", + "output_value": "names" + } + ], + "bodyKeys": [ + "ids" + ], + "formatEN": "delete remote database [names]", + "formatZH": "删除远程数据库 [names]", + "paramKeys": [] + } + } + }, + "/databases/remote/list/:type": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "获取快速命令列表", + "tags": [ + "Database" + ], + "summary": "List remote databases", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/dto.RemoteDBOption" + } + } + } + } + } + }, + "/databases/remote/search": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "获取远程数据库列表分页", + "consumes": [ + "application/json" + ], + "tags": [ + "Database" + ], + "summary": "Page remote databases", + "parameters": [ + { + "description": "request", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.RemoteDBSearch" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/dto.PageResult" + } + } + } + } + }, + "/databases/remote/update": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "更新远程数据库", + "consumes": [ + "application/json" + ], + "tags": [ + "Database" + ], + "summary": "Update remote database", + "parameters": [ + { + "description": "request", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.RemoteDBUpdate" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + }, + "x-panel-log": { + "BeforeFuntions": [], + "bodyKeys": [ + "name" + ], + "formatEN": "update remote database [name]", + "formatZH": "更新远程数据库 [name]", + "paramKeys": [] + } } }, "/databases/search": { @@ -4241,7 +4436,7 @@ const docTemplate = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/dto.SearchWithPage" + "$ref": "#/definitions/dto.MysqlDBSearch" } } ], @@ -10898,9 +11093,13 @@ const docTemplate = `{ "dto.ChangeDBInfo": { "type": "object", "required": [ + "from", "value" ], "properties": { + "from": { + "type": "string" + }, "id": { "type": "integer" }, @@ -12348,6 +12547,7 @@ const docTemplate = `{ "type": "object", "required": [ "format", + "from", "name", "password", "permission", @@ -12366,6 +12566,9 @@ const docTemplate = `{ "big5" ] }, + "from": { + "type": "string" + }, "name": { "type": "string" }, @@ -12397,6 +12600,33 @@ const docTemplate = `{ } } }, + "dto.MysqlDBSearch": { + "type": "object", + "required": [ + "page", + "pageSize" + ], + "properties": { + "from": { + "type": "string" + }, + "info": { + "type": "string" + }, + "order": { + "type": "string" + }, + "orderBy": { + "type": "string" + }, + "page": { + "type": "integer" + }, + "pageSize": { + "type": "integer" + } + } + }, "dto.MysqlStatus": { "type": "object", "properties": { @@ -12972,6 +13202,125 @@ const docTemplate = `{ } } }, + "dto.RemoteDBCreate": { + "type": "object", + "required": [ + "from", + "name", + "password", + "type", + "username", + "version" + ], + "properties": { + "address": { + "type": "string" + }, + "description": { + "type": "string" + }, + "from": { + "type": "string", + "enum": [ + "local", + "remote" + ] + }, + "name": { + "type": "string" + }, + "password": { + "type": "string" + }, + "port": { + "type": "integer" + }, + "type": { + "type": "string", + "enum": [ + "mysql" + ] + }, + "username": { + "type": "string" + }, + "version": { + "type": "string" + } + } + }, + "dto.RemoteDBOption": { + "type": "object", + "properties": { + "address": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + } + }, + "dto.RemoteDBSearch": { + "type": "object", + "required": [ + "page", + "pageSize" + ], + "properties": { + "info": { + "type": "string" + }, + "order": { + "type": "string" + }, + "orderBy": { + "type": "string" + }, + "page": { + "type": "integer" + }, + "pageSize": { + "type": "integer" + }, + "type": { + "type": "string" + } + } + }, + "dto.RemoteDBUpdate": { + "type": "object", + "required": [ + "password", + "username", + "version" + ], + "properties": { + "address": { + "type": "string" + }, + "description": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "password": { + "type": "string" + }, + "port": { + "type": "integer" + }, + "username": { + "type": "string" + }, + "version": { + "type": "string" + } + } + }, "dto.ResourceLimit": { "type": "object", "properties": { diff --git a/cmd/server/docs/swagger.json b/cmd/server/docs/swagger.json index 0fc92d62a..0bdab66dc 100644 --- a/cmd/server/docs/swagger.json +++ b/cmd/server/docs/swagger.json @@ -4210,6 +4210,201 @@ } } } + }, + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "创建远程数据库", + "consumes": [ + "application/json" + ], + "tags": [ + "Database" + ], + "summary": "Create remote database", + "parameters": [ + { + "description": "request", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.RemoteDBCreate" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + }, + "x-panel-log": { + "BeforeFuntions": [], + "bodyKeys": [ + "name", + "type" + ], + "formatEN": "create remote database [name][type]", + "formatZH": "创建远程数据库 [name][type]", + "paramKeys": [] + } + } + }, + "/databases/remote/del": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "删除远程数据库", + "consumes": [ + "application/json" + ], + "tags": [ + "Database" + ], + "summary": "Delete remote database", + "parameters": [ + { + "description": "request", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.OperateByID" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + }, + "x-panel-log": { + "BeforeFuntions": [ + { + "db": "databases", + "input_column": "id", + "input_value": "ids", + "isList": true, + "output_column": "name", + "output_value": "names" + } + ], + "bodyKeys": [ + "ids" + ], + "formatEN": "delete remote database [names]", + "formatZH": "删除远程数据库 [names]", + "paramKeys": [] + } + } + }, + "/databases/remote/list/:type": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "获取快速命令列表", + "tags": [ + "Database" + ], + "summary": "List remote databases", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/dto.RemoteDBOption" + } + } + } + } + } + }, + "/databases/remote/search": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "获取远程数据库列表分页", + "consumes": [ + "application/json" + ], + "tags": [ + "Database" + ], + "summary": "Page remote databases", + "parameters": [ + { + "description": "request", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.RemoteDBSearch" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/dto.PageResult" + } + } + } + } + }, + "/databases/remote/update": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "更新远程数据库", + "consumes": [ + "application/json" + ], + "tags": [ + "Database" + ], + "summary": "Update remote database", + "parameters": [ + { + "description": "request", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.RemoteDBUpdate" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + }, + "x-panel-log": { + "BeforeFuntions": [], + "bodyKeys": [ + "name" + ], + "formatEN": "update remote database [name]", + "formatZH": "更新远程数据库 [name]", + "paramKeys": [] + } } }, "/databases/search": { @@ -4234,7 +4429,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/dto.SearchWithPage" + "$ref": "#/definitions/dto.MysqlDBSearch" } } ], @@ -10891,9 +11086,13 @@ "dto.ChangeDBInfo": { "type": "object", "required": [ + "from", "value" ], "properties": { + "from": { + "type": "string" + }, "id": { "type": "integer" }, @@ -12341,6 +12540,7 @@ "type": "object", "required": [ "format", + "from", "name", "password", "permission", @@ -12359,6 +12559,9 @@ "big5" ] }, + "from": { + "type": "string" + }, "name": { "type": "string" }, @@ -12390,6 +12593,33 @@ } } }, + "dto.MysqlDBSearch": { + "type": "object", + "required": [ + "page", + "pageSize" + ], + "properties": { + "from": { + "type": "string" + }, + "info": { + "type": "string" + }, + "order": { + "type": "string" + }, + "orderBy": { + "type": "string" + }, + "page": { + "type": "integer" + }, + "pageSize": { + "type": "integer" + } + } + }, "dto.MysqlStatus": { "type": "object", "properties": { @@ -12965,6 +13195,125 @@ } } }, + "dto.RemoteDBCreate": { + "type": "object", + "required": [ + "from", + "name", + "password", + "type", + "username", + "version" + ], + "properties": { + "address": { + "type": "string" + }, + "description": { + "type": "string" + }, + "from": { + "type": "string", + "enum": [ + "local", + "remote" + ] + }, + "name": { + "type": "string" + }, + "password": { + "type": "string" + }, + "port": { + "type": "integer" + }, + "type": { + "type": "string", + "enum": [ + "mysql" + ] + }, + "username": { + "type": "string" + }, + "version": { + "type": "string" + } + } + }, + "dto.RemoteDBOption": { + "type": "object", + "properties": { + "address": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + } + }, + "dto.RemoteDBSearch": { + "type": "object", + "required": [ + "page", + "pageSize" + ], + "properties": { + "info": { + "type": "string" + }, + "order": { + "type": "string" + }, + "orderBy": { + "type": "string" + }, + "page": { + "type": "integer" + }, + "pageSize": { + "type": "integer" + }, + "type": { + "type": "string" + } + } + }, + "dto.RemoteDBUpdate": { + "type": "object", + "required": [ + "password", + "username", + "version" + ], + "properties": { + "address": { + "type": "string" + }, + "description": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "password": { + "type": "string" + }, + "port": { + "type": "integer" + }, + "username": { + "type": "string" + }, + "version": { + "type": "string" + } + } + }, "dto.ResourceLimit": { "type": "object", "properties": { diff --git a/cmd/server/docs/swagger.yaml b/cmd/server/docs/swagger.yaml index 8cd9ccfb4..b189673c9 100644 --- a/cmd/server/docs/swagger.yaml +++ b/cmd/server/docs/swagger.yaml @@ -120,11 +120,14 @@ definitions: type: object dto.ChangeDBInfo: properties: + from: + type: string id: type: integer value: type: string required: + - from - value type: object dto.ChangeHostGroup: @@ -1104,6 +1107,8 @@ definitions: - gbk - big5 type: string + from: + type: string name: type: string password: @@ -1114,6 +1119,7 @@ definitions: type: string required: - format + - from - name - password - permission @@ -1130,6 +1136,24 @@ definitions: required: - id type: object + dto.MysqlDBSearch: + properties: + from: + type: string + info: + type: string + order: + type: string + orderBy: + type: string + page: + type: integer + pageSize: + type: integer + required: + - page + - pageSize + type: object dto.MysqlStatus: properties: Aborted_clients: @@ -1515,6 +1539,87 @@ definitions: used_memory_rss: type: string type: object + dto.RemoteDBCreate: + properties: + address: + type: string + description: + type: string + from: + enum: + - local + - remote + type: string + name: + type: string + password: + type: string + port: + type: integer + type: + enum: + - mysql + type: string + username: + type: string + version: + type: string + required: + - from + - name + - password + - type + - username + - version + type: object + dto.RemoteDBOption: + properties: + address: + type: string + id: + type: integer + name: + type: string + type: object + dto.RemoteDBSearch: + properties: + info: + type: string + order: + type: string + orderBy: + type: string + page: + type: integer + pageSize: + type: integer + type: + type: string + required: + - page + - pageSize + type: object + dto.RemoteDBUpdate: + properties: + address: + type: string + description: + type: string + id: + type: integer + password: + type: string + port: + type: integer + username: + type: string + version: + type: string + required: + - password + - username + - version + type: object dto.ResourceLimit: properties: cpu: @@ -6288,6 +6393,130 @@ paths: summary: Load mysql remote access tags: - Database Mysql + post: + consumes: + - application/json + description: 创建远程数据库 + parameters: + - description: request + in: body + name: request + required: true + schema: + $ref: '#/definitions/dto.RemoteDBCreate' + responses: + "200": + description: OK + security: + - ApiKeyAuth: [] + summary: Create remote database + tags: + - Database + x-panel-log: + BeforeFuntions: [] + bodyKeys: + - name + - type + formatEN: create remote database [name][type] + formatZH: 创建远程数据库 [name][type] + paramKeys: [] + /databases/remote/del: + post: + consumes: + - application/json + description: 删除远程数据库 + parameters: + - description: request + in: body + name: request + required: true + schema: + $ref: '#/definitions/dto.OperateByID' + responses: + "200": + description: OK + security: + - ApiKeyAuth: [] + summary: Delete remote database + tags: + - Database + x-panel-log: + BeforeFuntions: + - db: databases + input_column: id + input_value: ids + isList: true + output_column: name + output_value: names + bodyKeys: + - ids + formatEN: delete remote database [names] + formatZH: 删除远程数据库 [names] + paramKeys: [] + /databases/remote/list/:type: + get: + description: 获取快速命令列表 + responses: + "200": + description: OK + schema: + items: + $ref: '#/definitions/dto.RemoteDBOption' + type: array + security: + - ApiKeyAuth: [] + summary: List remote databases + tags: + - Database + /databases/remote/search: + post: + consumes: + - application/json + description: 获取远程数据库列表分页 + parameters: + - description: request + in: body + name: request + required: true + schema: + $ref: '#/definitions/dto.RemoteDBSearch' + responses: + "200": + description: OK + schema: + $ref: '#/definitions/dto.PageResult' + security: + - ApiKeyAuth: [] + summary: Page remote databases + tags: + - Database + /databases/remote/update: + post: + consumes: + - application/json + description: 更新远程数据库 + parameters: + - description: request + in: body + name: request + required: true + schema: + $ref: '#/definitions/dto.RemoteDBUpdate' + responses: + "200": + description: OK + security: + - ApiKeyAuth: [] + summary: Update remote database + tags: + - Database + x-panel-log: + BeforeFuntions: [] + bodyKeys: + - name + formatEN: update remote database [name] + formatZH: 更新远程数据库 [name] + paramKeys: [] /databases/search: post: consumes: @@ -6299,7 +6528,7 @@ paths: name: request required: true schema: - $ref: '#/definitions/dto.SearchWithPage' + $ref: '#/definitions/dto.MysqlDBSearch' responses: "200": description: OK diff --git a/frontend/src/api/interface/database.ts b/frontend/src/api/interface/database.ts index 758b75fc0..82f926934 100644 --- a/frontend/src/api/interface/database.ts +++ b/frontend/src/api/interface/database.ts @@ -1,6 +1,14 @@ import { ReqPage } from '.'; export namespace Database { + export interface SearchDBWithPage { + info: string; + from: string; + page: number; + pageSize: number; + orderBy?: string; + order?: string; + } export interface SearchBackupRecord extends ReqPage { mysqlName: string; dbName: string; diff --git a/frontend/src/api/modules/database.ts b/frontend/src/api/modules/database.ts index 609884c6a..7fe1a56c5 100644 --- a/frontend/src/api/modules/database.ts +++ b/frontend/src/api/modules/database.ts @@ -1,10 +1,10 @@ import http from '@/api'; import { deepCopy } from '@/utils/util'; import { Base64 } from 'js-base64'; -import { SearchWithPage, ResPage, DescriptionUpdate } from '../interface'; +import { ResPage, DescriptionUpdate } from '../interface'; import { Database } from '../interface/database'; -export const searchMysqlDBs = (params: SearchWithPage) => { +export const searchMysqlDBs = (params: Database.SearchDBWithPage) => { return http.post>(`/databases/search`, params); }; diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index 2bf9788b7..cb75610e0 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -335,6 +335,14 @@ const message = { portHelper: 'This port is the exposed port of the container. You need to save the modification separately and restart the container!', + remote: 'Remote', + remoteDB: 'Remote DB', + createRemoteDB: 'Create Remote DB', + editRemoteDB: 'Edit Remote DB', + localDB: 'Local DB', + address: 'DB address', + version: 'DB version', + selectFile: 'Select file', dropHelper: 'You can drag and drop the uploaded file here or', clickHelper: 'click to upload', diff --git a/frontend/src/lang/modules/tw.ts b/frontend/src/lang/modules/tw.ts index a364981bd..87c2a775a 100644 --- a/frontend/src/lang/modules/tw.ts +++ b/frontend/src/lang/modules/tw.ts @@ -330,6 +330,14 @@ const message = { confChange: '配置修改', + remote: '遠程', + remoteDB: '遠程數據庫', + createRemoteDB: '創建遠程數據庫', + editRemoteDB: '編輯遠程數據庫', + localDB: '本地數據庫', + address: '數據庫地址', + version: '數據庫版本', + selectFile: '選擇文件', dropHelper: '將上傳文件拖拽到此處,或者', clickHelper: '點擊上傳', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index 9d849ee2d..092a13887 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -330,6 +330,7 @@ const message = { confChange: '配置修改', + remote: '远程', remoteDB: '远程数据库', createRemoteDB: '创建远程数据库', editRemoteDB: '编辑远程数据库', diff --git a/frontend/src/views/database/mysql/create/index.vue b/frontend/src/views/database/mysql/create/index.vue index 56fce5d04..4e18b8b58 100644 --- a/frontend/src/views/database/mysql/create/index.vue +++ b/frontend/src/views/database/mysql/create/index.vue @@ -133,7 +133,7 @@ const handleClose = () => { const loadDBOptions = async () => { const res = await listRemoteDBs('mysql'); - dbOptions.value = res.data; + dbOptions.value = res.data || []; }; function loadLabel(item: any) { diff --git a/frontend/src/views/database/mysql/index.vue b/frontend/src/views/database/mysql/index.vue index 1172613c9..fc5046f10 100644 --- a/frontend/src/views/database/mysql/index.vue +++ b/frontend/src/views/database/mysql/index.vue @@ -1,7 +1,7 @@