mirror of https://github.com/1Panel-dev/1Panel
fix: 修改数据库重复校验判断 (#2195)
parent
f0eaee82b6
commit
3e33a4b16c
|
@ -5,6 +5,7 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
||||
"github.com/1Panel-dev/1Panel/backend/buserr"
|
||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
||||
"github.com/1Panel-dev/1Panel/backend/utils/encrypt"
|
||||
"github.com/1Panel-dev/1Panel/backend/utils/mysql"
|
||||
|
@ -89,6 +90,9 @@ func (u *DatabaseService) CheckDatabase(req dto.DatabaseCreate) bool {
|
|||
func (u *DatabaseService) Create(req dto.DatabaseCreate) error {
|
||||
db, _ := databaseRepo.Get(commonRepo.WithByName(req.Name))
|
||||
if db.ID != 0 {
|
||||
if db.From == "local" {
|
||||
return buserr.New(constant.ErrLocalExist)
|
||||
}
|
||||
return constant.ErrRecordExist
|
||||
}
|
||||
if _, err := mysql.NewMysqlClient(client.DBInfo{
|
||||
|
|
|
@ -96,6 +96,8 @@ var (
|
|||
ErrUserIsExist = "ErrUserIsExist"
|
||||
ErrDatabaseIsExist = "ErrDatabaseIsExist"
|
||||
ErrExecTimeOut = "ErrExecTimeOut"
|
||||
ErrRemoteExist = "ErrRemoteExist"
|
||||
ErrLocalExist = "ErrLocalExist"
|
||||
)
|
||||
|
||||
// redis
|
||||
|
|
|
@ -83,6 +83,8 @@ ErrOpenrestyPort: 'The default port of openresty is {{ .detail }}, HTTP mode can
|
|||
ErrUserIsExist: "The current user already exists. Please enter a new user"
|
||||
ErrDatabaseIsExist: "The current database already exists. Please enter a new database"
|
||||
ErrExecTimeOut: "SQL execution timed out, please check the database"
|
||||
ErrRemoteExist: "The remote database already exists with that name, please modify it and try again"
|
||||
ErrLocalExist: "The local database already exists with that name, please modify it and try again"
|
||||
|
||||
#redis
|
||||
ErrTypeOfRedis: "The recovery file type does not match the current persistence mode. Modify the file type and try again"
|
||||
|
|
|
@ -83,6 +83,8 @@ ErrOpenrestyPort: 'openresty 默認端口為 {{ .detail }},無法使用 HTTP
|
|||
ErrUserIsExist: "當前用戶已存在,請重新輸入"
|
||||
ErrDatabaseIsExist: "當前資料庫已存在,請重新輸入"
|
||||
ErrExecTimeOut: "SQL 執行超時,請檢查數據庫"
|
||||
ErrRemoteExist: "遠程數據庫已存在該名稱,請修改後重試"
|
||||
ErrLocalExist: "本地數據庫已存在該名稱,請修改後重試"
|
||||
|
||||
#redis
|
||||
ErrTypeOfRedis: "恢復文件類型與當前持久化方式不符,請修改後重試"
|
||||
|
|
|
@ -83,6 +83,8 @@ ErrOpenrestyPort: 'openresty 默认端口为 {{ .detail }},无法使用 HTTP
|
|||
ErrUserIsExist: "当前用户已存在,请重新输入"
|
||||
ErrDatabaseIsExist: "当前数据库已存在,请重新输入"
|
||||
ErrExecTimeOut: "SQL 执行超时,请检查数据库"
|
||||
ErrRemoteExist: "远程数据库已存在该名称,请修改后重试"
|
||||
ErrLocalExist: "本地数据库已存在该名称,请修改后重试"
|
||||
|
||||
#redis
|
||||
ErrTypeOfRedis: "恢复文件类型与当前持久化方式不符,请修改后重试"
|
||||
|
|
Loading…
Reference in New Issue