支持更多的分组全局设置功能

This commit is contained in:
GoEdgeLab
2021-10-07 16:47:31 +08:00
parent 5e49ccaf75
commit c8daee237f
9 changed files with 787 additions and 344 deletions

View File

@@ -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)