优化代码

This commit is contained in:
GoEdgeLab
2021-01-03 20:25:15 +08:00
parent 900815c509
commit 6ceefaa100
36 changed files with 122 additions and 119 deletions

View File

@@ -2,7 +2,7 @@ package accessLog
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/webutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
"github.com/iwind/TeaGo/actions"
@@ -20,7 +20,7 @@ func (this *IndexAction) RunGet(params struct {
LocationId int64
}) {
// 获取配置
webConfig, err := webutils.FindWebConfigWithLocationId(this.Parent(), params.LocationId)
webConfig, err := dao.SharedHTTPWebDAO.FindWebConfigWithLocationId(this.AdminContext(), params.LocationId)
if err != nil {
this.ErrorPage(err)
return

View File

@@ -3,7 +3,6 @@ package cache
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/webutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
@@ -22,7 +21,7 @@ func (this *IndexAction) RunGet(params struct {
ServerId int64
LocationId int64
}) {
webConfig, err := webutils.FindWebConfigWithLocationId(this.Parent(), params.LocationId)
webConfig, err := dao.SharedHTTPWebDAO.FindWebConfigWithLocationId(this.AdminContext(), params.LocationId)
if err != nil {
this.ErrorPage(err)
return

View File

@@ -2,8 +2,8 @@ package charset
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/webutils"
"github.com/TeaOSLab/EdgeCommon/pkg/configutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/actions"
)
@@ -18,7 +18,7 @@ func (this *IndexAction) Init() {
func (this *IndexAction) RunGet(params struct {
LocationId int64
}) {
webConfig, err := webutils.FindWebConfigWithLocationId(this.Parent(), params.LocationId)
webConfig, err := dao.SharedHTTPWebDAO.FindWebConfigWithLocationId(this.AdminContext(), params.LocationId)
if err != nil {
this.ErrorPage(err)
return

View File

@@ -3,7 +3,7 @@ package locations
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/webutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
"github.com/iwind/TeaGo/actions"
@@ -25,7 +25,7 @@ func (this *CreateAction) RunGet(params struct {
ServerId int64
ParentId int64 // 父节点
}) {
webConfig, err := webutils.FindWebConfigWithServerId(this.Parent(), params.ServerId)
webConfig, err := dao.SharedHTTPWebDAO.FindWebConfigWithServerId(this.AdminContext(), params.ServerId)
if err != nil {
this.ErrorPage(err)
return
@@ -88,7 +88,7 @@ func (this *CreateAction) RunPost(params struct {
locationId := locationResp.LocationId
// Web中Location
webConfig, err := webutils.FindWebConfigWithId(this.Parent(), params.WebId)
webConfig, err := dao.SharedHTTPWebDAO.FindWebConfigWithId(this.AdminContext(), params.WebId)
if err != nil {
this.ErrorPage(err)
return

View File

@@ -3,7 +3,7 @@ package locations
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/webutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
)
@@ -15,7 +15,7 @@ func (this *DeleteAction) RunPost(params struct {
WebId int64
LocationId int64
}) {
webConfig, err := webutils.FindWebConfigWithId(this.Parent(), params.WebId)
webConfig, err := dao.SharedHTTPWebDAO.FindWebConfigWithId(this.AdminContext(), params.WebId)
if err != nil {
this.ErrorPage(err)
return

View File

@@ -3,7 +3,7 @@ package gzip
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/webutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
"github.com/iwind/TeaGo/actions"
@@ -22,7 +22,7 @@ func (this *IndexAction) Init() {
func (this *IndexAction) RunGet(params struct {
LocationId int64
}) {
webConfig, err := webutils.FindWebConfigWithLocationId(this.Parent(), params.LocationId)
webConfig, err := dao.SharedHTTPWebDAO.FindWebConfigWithLocationId(this.AdminContext(), params.LocationId)
if err != nil {
this.ErrorPage(err)
return

View File

@@ -3,7 +3,7 @@ package headers
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/webutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
"github.com/iwind/TeaGo/actions"
@@ -19,7 +19,7 @@ func (this *IndexAction) Init() {
func (this *IndexAction) RunGet(params struct {
LocationId int64
}) {
webConfig, err := webutils.FindWebConfigWithLocationId(this.Parent(), params.LocationId)
webConfig, err := dao.SharedHTTPWebDAO.FindWebConfigWithLocationId(this.AdminContext(), params.LocationId)
if err != nil {
this.ErrorPage(err)
return
@@ -79,7 +79,7 @@ func (this *IndexAction) RunGet(params struct {
// 重新获取配置
if isChanged {
webConfig, err = webutils.FindWebConfigWithLocationId(this.Parent(), params.LocationId)
webConfig, err = dao.SharedHTTPWebDAO.FindWebConfigWithLocationId(this.AdminContext(), params.LocationId)
if err != nil {
this.ErrorPage(err)
return

View File

@@ -2,7 +2,7 @@ package http
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/webutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/actions"
)
@@ -18,7 +18,7 @@ func (this *IndexAction) RunGet(params struct {
LocationId int64
}) {
// 跳转相关设置
webConfig, err := webutils.FindWebConfigWithLocationId(this.Parent(), params.LocationId)
webConfig, err := dao.SharedHTTPWebDAO.FindWebConfigWithLocationId(this.AdminContext(), params.LocationId)
if err != nil {
this.ErrorPage(err)
return

View File

@@ -2,7 +2,7 @@ package locations
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/webutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao"
)
type IndexAction struct {
@@ -17,7 +17,7 @@ func (this *IndexAction) Init() {
func (this *IndexAction) RunGet(params struct {
ServerId int64
}) {
webConfig, err := webutils.FindWebConfigWithServerId(this.Parent(), params.ServerId)
webConfig, err := dao.SharedHTTPWebDAO.FindWebConfigWithServerId(this.AdminContext(), params.ServerId)
if err != nil {
this.ErrorPage(err)
return

View File

@@ -2,7 +2,7 @@ package pages
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/webutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/actions"
)
@@ -17,7 +17,7 @@ func (this *IndexAction) Init() {
func (this *IndexAction) RunGet(params struct {
LocationId int64
}) {
webConfig, err := webutils.FindWebConfigWithLocationId(this.Parent(), params.LocationId)
webConfig, err := dao.SharedHTTPWebDAO.FindWebConfigWithLocationId(this.AdminContext(), params.LocationId)
if err != nil {
this.ErrorPage(err)
return

View File

@@ -2,7 +2,7 @@ package rewrite
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/webutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao"
)
type IndexAction struct {
@@ -15,7 +15,7 @@ func (this *IndexAction) Init() {
func (this *IndexAction) RunGet(params struct {
LocationId int64
}) {
webConfig, err := webutils.FindWebConfigWithLocationId(this.Parent(), params.LocationId)
webConfig, err := dao.SharedHTTPWebDAO.FindWebConfigWithLocationId(this.AdminContext(), params.LocationId)
if err != nil {
this.ErrorPage(err)
return

View File

@@ -3,7 +3,7 @@ package locations
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/webutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
)
@@ -20,7 +20,7 @@ func (this *SortAction) RunPost(params struct {
this.Success()
}
webConfig, err := webutils.FindWebConfigWithId(this.Parent(), params.WebId)
webConfig, err := dao.SharedHTTPWebDAO.FindWebConfigWithId(this.AdminContext(), params.WebId)
if err != nil {
this.ErrorPage(err)
return

View File

@@ -2,7 +2,7 @@ package stat
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/webutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/actions"
)
@@ -17,7 +17,7 @@ func (this *IndexAction) Init() {
func (this *IndexAction) RunGet(params struct {
LocationId int64
}) {
webConfig, err := webutils.FindWebConfigWithLocationId(this.Parent(), params.LocationId)
webConfig, err := dao.SharedHTTPWebDAO.FindWebConfigWithLocationId(this.AdminContext(), params.LocationId)
if err != nil {
this.ErrorPage(err)
return

View File

@@ -2,7 +2,6 @@ package waf
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/webutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/actions"
@@ -20,7 +19,7 @@ func (this *IndexAction) RunGet(params struct {
ServerId int64
LocationId int64
}) {
webConfig, err := webutils.FindWebConfigWithLocationId(this.Parent(), params.LocationId)
webConfig, err := dao.SharedHTTPWebDAO.FindWebConfigWithLocationId(this.AdminContext(), params.LocationId)
if err != nil {
this.ErrorPage(err)
return

View File

@@ -2,7 +2,7 @@ package web
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/webutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/actions"
)
@@ -17,7 +17,7 @@ func (this *IndexAction) Init() {
func (this *IndexAction) RunGet(params struct {
LocationId int64
}) {
webConfig, err := webutils.FindWebConfigWithLocationId(this.Parent(), params.LocationId)
webConfig, err := dao.SharedHTTPWebDAO.FindWebConfigWithLocationId(this.AdminContext(), params.LocationId)
if err != nil {
this.ErrorPage(err)
return

View File

@@ -3,7 +3,7 @@ package websocket
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/webutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
"github.com/iwind/TeaGo/actions"
@@ -20,7 +20,7 @@ func (this *IndexAction) Init() {
func (this *IndexAction) RunGet(params struct {
LocationId int64
}) {
webConfig, err := webutils.FindWebConfigWithLocationId(this.Parent(), params.LocationId)
webConfig, err := dao.SharedHTTPWebDAO.FindWebConfigWithLocationId(this.AdminContext(), params.LocationId)
if err != nil {
this.ErrorPage(err)
return