mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2025-11-22 02:30:25 +08:00
支持更多的分组全局设置功能
This commit is contained in:
@@ -15,7 +15,7 @@ type HTTPWebDAO struct {
|
||||
BaseDAO
|
||||
}
|
||||
|
||||
// 根据ServerId查找Web配置
|
||||
// FindWebConfigWithServerId 根据ServerId查找Web配置
|
||||
func (this *HTTPWebDAO) FindWebConfigWithServerId(ctx context.Context, serverId int64) (*serverconfigs.HTTPWebConfig, error) {
|
||||
resp, err := this.RPC().ServerRPC().FindAndInitServerWebConfig(ctx, &pb.FindAndInitServerWebConfigRequest{ServerId: serverId})
|
||||
if err != nil {
|
||||
@@ -29,7 +29,7 @@ func (this *HTTPWebDAO) FindWebConfigWithServerId(ctx context.Context, serverId
|
||||
return config, nil
|
||||
}
|
||||
|
||||
// 根据LocationId查找Web配置
|
||||
// FindWebConfigWithLocationId 根据LocationId查找Web配置
|
||||
func (this *HTTPWebDAO) FindWebConfigWithLocationId(ctx context.Context, locationId int64) (*serverconfigs.HTTPWebConfig, error) {
|
||||
resp, err := this.RPC().HTTPLocationRPC().FindAndInitHTTPLocationWebConfig(ctx, &pb.FindAndInitHTTPLocationWebConfigRequest{LocationId: locationId})
|
||||
if err != nil {
|
||||
@@ -43,7 +43,21 @@ func (this *HTTPWebDAO) FindWebConfigWithLocationId(ctx context.Context, locatio
|
||||
return config, nil
|
||||
}
|
||||
|
||||
// 根据WebId查找Web配置
|
||||
// FindWebConfigWithServerGroupId 根据ServerGroupId查找Web配置
|
||||
func (this *HTTPWebDAO) FindWebConfigWithServerGroupId(ctx context.Context, serverGroupId int64) (*serverconfigs.HTTPWebConfig, error) {
|
||||
resp, err := this.RPC().ServerGroupRPC().FindAndInitServerGroupWebConfig(ctx, &pb.FindAndInitServerGroupWebConfigRequest{ServerGroupId: serverGroupId})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
config := &serverconfigs.HTTPWebConfig{}
|
||||
err = json.Unmarshal(resp.WebJSON, config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return config, nil
|
||||
}
|
||||
|
||||
// FindWebConfigWithId 根据WebId查找Web配置
|
||||
func (this *HTTPWebDAO) FindWebConfigWithId(ctx context.Context, webId int64) (*serverconfigs.HTTPWebConfig, error) {
|
||||
resp, err := this.RPC().HTTPWebRPC().FindEnabledHTTPWebConfig(ctx, &pb.FindEnabledHTTPWebConfigRequest{WebId: webId})
|
||||
if err != nil {
|
||||
@@ -57,14 +71,15 @@ func (this *HTTPWebDAO) FindWebConfigWithId(ctx context.Context, webId int64) (*
|
||||
return config, nil
|
||||
}
|
||||
|
||||
// 初始化防火墙设置
|
||||
func (this *HTTPWebDAO) InitEmptyHTTPFirewallPolicy(ctx context.Context, serverId int64, webId int64, isOn bool) (int64, error) {
|
||||
// InitEmptyHTTPFirewallPolicy 初始化防火墙设置
|
||||
func (this *HTTPWebDAO) InitEmptyHTTPFirewallPolicy(ctx context.Context, serverGroupId int64, serverId int64, webId int64, isOn bool) (int64, error) {
|
||||
// 创建FirewallPolicy
|
||||
firewallPolicyIdResp, err := this.RPC().HTTPFirewallPolicyRPC().CreateEmptyHTTPFirewallPolicy(ctx, &pb.CreateEmptyHTTPFirewallPolicyRequest{
|
||||
ServerId: serverId,
|
||||
IsOn: true,
|
||||
Name: "用户自定义",
|
||||
Description: "",
|
||||
ServerGroupId: serverGroupId,
|
||||
ServerId: serverId,
|
||||
IsOn: true,
|
||||
Name: "用户自定义",
|
||||
Description: "",
|
||||
})
|
||||
if err != nil {
|
||||
return 0, errors.Wrap(err)
|
||||
|
||||
Reference in New Issue
Block a user