mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2025-11-03 12:20:27 +08:00
优化脚本代码配置
This commit is contained in:
@@ -3,20 +3,20 @@
|
||||
package serverconfigs
|
||||
|
||||
type HTTPRequestScriptsConfig struct {
|
||||
OnInitScript *JSScriptConfig `yaml:"onInitScript" json:"onInitScript"` // 接收到请求之后
|
||||
OnRequestScript *JSScriptConfig `yaml:"onRequestScript" json:"onRequestScript"` // 准备转发请求之前
|
||||
InitGroup *ScriptGroupConfig `yaml:"initGroup" json:"initGroup"`
|
||||
RequestGroup *ScriptGroupConfig `yaml:"requestGroup" json:"requestGroup"`
|
||||
}
|
||||
|
||||
func (this *HTTPRequestScriptsConfig) Init() error {
|
||||
if this.OnInitScript != nil {
|
||||
err := this.OnInitScript.Init()
|
||||
if this.InitGroup != nil {
|
||||
err := this.InitGroup.Init()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if this.OnRequestScript != nil {
|
||||
err := this.OnRequestScript.Init()
|
||||
if this.RequestGroup != nil {
|
||||
err := this.RequestGroup.Init()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -26,8 +26,6 @@ func (this *HTTPRequestScriptsConfig) Init() error {
|
||||
}
|
||||
|
||||
func (this *HTTPRequestScriptsConfig) IsEmpty() bool {
|
||||
if (this.OnInitScript == nil || !this.OnInitScript.IsOn) && (this.OnRequestScript == nil || !this.OnRequestScript.IsOn) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
return (this.InitGroup == nil || this.InitGroup.IsEmpty()) &&
|
||||
(this.RequestGroup == nil || this.RequestGroup.IsEmpty())
|
||||
}
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
|
||||
package serverconfigs
|
||||
|
||||
type JSScriptConfig struct {
|
||||
IsPrior bool `yaml:"isPrior" json:"isPrior"`
|
||||
IsOn bool `yaml:"isOn" json:"isOn"`
|
||||
Code string `yaml:"code" json:"code"`
|
||||
}
|
||||
|
||||
func (this *JSScriptConfig) Init() error {
|
||||
return nil
|
||||
}
|
||||
14
pkg/serverconfigs/script_config.go
Normal file
14
pkg/serverconfigs/script_config.go
Normal file
@@ -0,0 +1,14 @@
|
||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
|
||||
package serverconfigs
|
||||
|
||||
type ScriptConfig struct {
|
||||
IsPrior bool `yaml:"isPrior" json:"isPrior"`
|
||||
IsOn bool `yaml:"isOn" json:"isOn"`
|
||||
|
||||
Code string `yaml:"code" json:"code"`
|
||||
}
|
||||
|
||||
func (this *ScriptConfig) Init() error {
|
||||
return nil
|
||||
}
|
||||
30
pkg/serverconfigs/script_group_config.go
Normal file
30
pkg/serverconfigs/script_group_config.go
Normal file
@@ -0,0 +1,30 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
|
||||
package serverconfigs
|
||||
|
||||
type ScriptGroupConfig struct {
|
||||
IsOn bool `yaml:"isOn" json:"isOn"`
|
||||
IsPrior bool `yaml:"isPrior" json:"isPrior"`
|
||||
Scripts []*ScriptConfig `yaml:"scripts" json:"scripts"`
|
||||
|
||||
isEmpty bool
|
||||
}
|
||||
|
||||
func (this *ScriptGroupConfig) Init() error {
|
||||
this.isEmpty = true
|
||||
|
||||
for _, script := range this.Scripts {
|
||||
err := script.Init()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if script.IsOn {
|
||||
this.isEmpty = false
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *ScriptGroupConfig) IsEmpty() bool {
|
||||
return this.isEmpty
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package systemconfigs
|
||||
|
||||
// 用户模块权限
|
||||
// AdminModule 管理用户模块权限
|
||||
type AdminModule struct {
|
||||
Code string `json:"code"` // 模块代号
|
||||
AllowAll bool `json:"allowAll"` // 允许所有的动作
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package systemconfigs
|
||||
|
||||
// 数据库相关配置
|
||||
// DatabaseConfig 数据库相关配置
|
||||
type DatabaseConfig struct {
|
||||
ServerAccessLog struct {
|
||||
Clean struct {
|
||||
|
||||
@@ -2,7 +2,7 @@ package systemconfigs
|
||||
|
||||
import "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
|
||||
|
||||
// 默认日志配置
|
||||
// DefaultLogConfig 默认日志配置
|
||||
func DefaultLogConfig() *LogConfig {
|
||||
return &LogConfig{
|
||||
CanDelete: false,
|
||||
@@ -16,7 +16,7 @@ func DefaultLogConfig() *LogConfig {
|
||||
}
|
||||
}
|
||||
|
||||
// 操作日志相关配置
|
||||
// LogConfig 操作日志相关配置
|
||||
type LogConfig struct {
|
||||
CanDelete bool `json:"canDelete"` // 是否可删除
|
||||
CanClean bool `json:"canClean"` // 是否可清理
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package systemconfigs
|
||||
|
||||
// 用户界面相关配置
|
||||
// UserUIConfig 用户界面相关配置
|
||||
type UserUIConfig struct {
|
||||
ProductName string `json:"productName"` // 产品名
|
||||
UserSystemName string `json:"userSystemName"` // 管理员系统名称
|
||||
|
||||
Reference in New Issue
Block a user