mirror of
				https://github.com/TeaOSLab/EdgeCommon.git
				synced 2025-11-04 21:50:26 +08:00 
			
		
		
		
	优化脚本代码配置
This commit is contained in:
		@@ -3,20 +3,20 @@
 | 
				
			|||||||
package serverconfigs
 | 
					package serverconfigs
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type HTTPRequestScriptsConfig struct {
 | 
					type HTTPRequestScriptsConfig struct {
 | 
				
			||||||
	OnInitScript    *JSScriptConfig `yaml:"onInitScript" json:"onInitScript"`       // 接收到请求之后
 | 
						InitGroup    *ScriptGroupConfig `yaml:"initGroup" json:"initGroup"`
 | 
				
			||||||
	OnRequestScript *JSScriptConfig `yaml:"onRequestScript" json:"onRequestScript"` // 准备转发请求之前
 | 
						RequestGroup *ScriptGroupConfig `yaml:"requestGroup" json:"requestGroup"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (this *HTTPRequestScriptsConfig) Init() error {
 | 
					func (this *HTTPRequestScriptsConfig) Init() error {
 | 
				
			||||||
	if this.OnInitScript != nil {
 | 
						if this.InitGroup != nil {
 | 
				
			||||||
		err := this.OnInitScript.Init()
 | 
							err := this.InitGroup.Init()
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return err
 | 
								return err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if this.OnRequestScript != nil {
 | 
						if this.RequestGroup != nil {
 | 
				
			||||||
		err := this.OnRequestScript.Init()
 | 
							err := this.RequestGroup.Init()
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return err
 | 
								return err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -26,8 +26,6 @@ func (this *HTTPRequestScriptsConfig) Init() error {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (this *HTTPRequestScriptsConfig) IsEmpty() bool {
 | 
					func (this *HTTPRequestScriptsConfig) IsEmpty() bool {
 | 
				
			||||||
	if (this.OnInitScript == nil || !this.OnInitScript.IsOn) && (this.OnRequestScript == nil || !this.OnRequestScript.IsOn) {
 | 
						return (this.InitGroup == nil || this.InitGroup.IsEmpty()) &&
 | 
				
			||||||
		return true
 | 
							(this.RequestGroup == nil || this.RequestGroup.IsEmpty())
 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return false
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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
 | 
					package systemconfigs
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// 用户模块权限
 | 
					// AdminModule 管理用户模块权限
 | 
				
			||||||
type AdminModule struct {
 | 
					type AdminModule struct {
 | 
				
			||||||
	Code     string   `json:"code"`     // 模块代号
 | 
						Code     string   `json:"code"`     // 模块代号
 | 
				
			||||||
	AllowAll bool     `json:"allowAll"` // 允许所有的动作
 | 
						AllowAll bool     `json:"allowAll"` // 允许所有的动作
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,6 @@
 | 
				
			|||||||
package systemconfigs
 | 
					package systemconfigs
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// 数据库相关配置
 | 
					// DatabaseConfig 数据库相关配置
 | 
				
			||||||
type DatabaseConfig struct {
 | 
					type DatabaseConfig struct {
 | 
				
			||||||
	ServerAccessLog struct {
 | 
						ServerAccessLog struct {
 | 
				
			||||||
		Clean struct {
 | 
							Clean struct {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,7 +2,7 @@ package systemconfigs
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
 | 
					import "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// 默认日志配置
 | 
					// DefaultLogConfig 默认日志配置
 | 
				
			||||||
func DefaultLogConfig() *LogConfig {
 | 
					func DefaultLogConfig() *LogConfig {
 | 
				
			||||||
	return &LogConfig{
 | 
						return &LogConfig{
 | 
				
			||||||
		CanDelete: false,
 | 
							CanDelete: false,
 | 
				
			||||||
@@ -16,7 +16,7 @@ func DefaultLogConfig() *LogConfig {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// 操作日志相关配置
 | 
					// LogConfig 操作日志相关配置
 | 
				
			||||||
type LogConfig struct {
 | 
					type LogConfig struct {
 | 
				
			||||||
	CanDelete bool                 `json:"canDelete"` // 是否可删除
 | 
						CanDelete bool                 `json:"canDelete"` // 是否可删除
 | 
				
			||||||
	CanClean  bool                 `json:"canClean"`  // 是否可清理
 | 
						CanClean  bool                 `json:"canClean"`  // 是否可清理
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,6 @@
 | 
				
			|||||||
package systemconfigs
 | 
					package systemconfigs
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// 用户界面相关配置
 | 
					// UserUIConfig 用户界面相关配置
 | 
				
			||||||
type UserUIConfig struct {
 | 
					type UserUIConfig struct {
 | 
				
			||||||
	ProductName        string `json:"productName"`        // 产品名
 | 
						ProductName        string `json:"productName"`        // 产品名
 | 
				
			||||||
	UserSystemName     string `json:"userSystemName"`     // 管理员系统名称
 | 
						UserSystemName     string `json:"userSystemName"`     // 管理员系统名称
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user