mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-10-26 16:56:22 +08:00
fix: 修改数据库设置跳转路由 (#2320)
This commit is contained in:
parent
52198e9c0c
commit
8faa3b6e51
3 changed files with 22 additions and 23 deletions
|
|
@ -5,6 +5,14 @@ import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"path"
|
||||||
|
"reflect"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
|
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto/response"
|
"github.com/1Panel-dev/1Panel/backend/app/dto/response"
|
||||||
|
|
@ -19,12 +27,6 @@ import (
|
||||||
"github.com/1Panel-dev/1Panel/backend/utils/files"
|
"github.com/1Panel-dev/1Panel/backend/utils/files"
|
||||||
http2 "github.com/1Panel-dev/1Panel/backend/utils/http"
|
http2 "github.com/1Panel-dev/1Panel/backend/utils/http"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
"io"
|
|
||||||
"net/http"
|
|
||||||
"os"
|
|
||||||
"path"
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type AppService struct {
|
type AppService struct {
|
||||||
|
|
@ -282,6 +284,12 @@ func (a AppService) Install(ctx context.Context, req request.AppInstallCreate) (
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if DatabaseKeys[app.Key] > 0 {
|
||||||
|
if existDatabases, _ := databaseRepo.GetList(commonRepo.WithByName(req.Name)); len(existDatabases) > 0 {
|
||||||
|
err = buserr.New(constant.ErrRemoteExist)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
for key := range req.Params {
|
for key := range req.Params {
|
||||||
if !strings.Contains(key, "PANEL_APP_PORT") {
|
if !strings.Contains(key, "PANEL_APP_PORT") {
|
||||||
continue
|
continue
|
||||||
|
|
@ -389,22 +397,13 @@ func (a AppService) Install(ctx context.Context, req request.AppInstallCreate) (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
if dbHost, ok := req.Params["PANEL_DB_HOST"]; ok {
|
if hostName, ok := req.Params["PANEL_DB_HOST"]; ok {
|
||||||
var (
|
database, _ := databaseRepo.Get(commonRepo.WithByName(hostName.(string)))
|
||||||
databaseID int
|
if !reflect.DeepEqual(database, model.Database{}) {
|
||||||
database model.Database
|
|
||||||
)
|
|
||||||
databaseID, err = strconv.Atoi(dbHost.(string))
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
database, err = databaseRepo.Get(commonRepo.WithByID(uint(databaseID)))
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
req.Params["PANEL_DB_HOST"] = database.Address
|
req.Params["PANEL_DB_HOST"] = database.Address
|
||||||
req.Params["PANEL_DB_PORT"] = database.Port
|
req.Params["PANEL_DB_PORT"] = database.Port
|
||||||
req.Params["PANEL_DB_HOST_ID"] = uint(databaseID)
|
req.Params["PANEL_DB_HOST_NAME"] = hostName
|
||||||
|
}
|
||||||
}
|
}
|
||||||
paramByte, err = json.Marshal(req.Params)
|
paramByte, err = json.Marshal(req.Params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -150,7 +150,7 @@ func (u *MysqlService) LoadFromRemote(req dto.MysqlLoadDB) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
databases, err := mysqlRepo.List(databaseRepo.WithByFrom(req.From))
|
databases, err := mysqlRepo.List(mysqlRepo.WithByMysqlName(req.Database))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ const databaseRouter = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'mysql/setting/:type/:database/:databaseID',
|
path: 'mysql/setting/:type/:database',
|
||||||
name: 'MySQL-Setting',
|
name: 'MySQL-Setting',
|
||||||
component: () => import('@/views/database/mysql/setting/index.vue'),
|
component: () => import('@/views/database/mysql/setting/index.vue'),
|
||||||
props: true,
|
props: true,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue