mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2026-02-04 10:35:48 +08:00
实现路径规则各项数据修改
This commit is contained in:
@@ -2,9 +2,8 @@ package web
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/serverutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/webutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
)
|
||||
|
||||
@@ -20,30 +19,11 @@ func (this *IndexAction) Init() {
|
||||
func (this *IndexAction) RunGet(params struct {
|
||||
ServerId int64
|
||||
}) {
|
||||
server, _, isOk := serverutils.FindServer(this.Parent(), params.ServerId)
|
||||
if !isOk {
|
||||
webConfig, err := webutils.FindWebConfigWithServerId(this.Parent(), params.ServerId)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
webId := server.WebId
|
||||
|
||||
webConfig := &serverconfigs.HTTPWebConfig{
|
||||
Id: webId,
|
||||
IsOn: true,
|
||||
}
|
||||
if webId > 0 {
|
||||
resp, err := this.RPC().HTTPWebRPC().FindEnabledHTTPWeb(this.AdminContext(), &pb.FindEnabledHTTPWebRequest{WebId: webId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
if resp.Web != nil {
|
||||
web := resp.Web
|
||||
|
||||
webConfig.Id = webId
|
||||
webConfig.IsOn = web.IsOn
|
||||
webConfig.Root = web.Root
|
||||
}
|
||||
}
|
||||
|
||||
this.Data["webConfig"] = webConfig
|
||||
|
||||
@@ -57,32 +37,14 @@ func (this *IndexAction) RunPost(params struct {
|
||||
|
||||
Must *actions.Must
|
||||
}) {
|
||||
if params.WebId <= 0 {
|
||||
resp, err := this.RPC().HTTPWebRPC().CreateHTTPWeb(this.AdminContext(), &pb.CreateHTTPWebRequest{
|
||||
Root: params.Root,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
webId := resp.WebId
|
||||
_, err = this.RPC().ServerRPC().UpdateServerWeb(this.AdminContext(), &pb.UpdateServerWebRequest{
|
||||
ServerId: params.ServerId,
|
||||
WebId: webId,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
_, err := this.RPC().HTTPWebRPC().UpdateHTTPWeb(this.AdminContext(), &pb.UpdateHTTPWebRequest{
|
||||
WebId: params.WebId,
|
||||
Root: params.Root,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
_, err := this.RPC().HTTPWebRPC().UpdateHTTPWeb(this.AdminContext(), &pb.UpdateHTTPWebRequest{
|
||||
WebId: params.WebId,
|
||||
Root: params.Root,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
this.Success()
|
||||
|
||||
Reference in New Issue
Block a user