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