优化代码

This commit is contained in:
刘祥超
2022-03-22 19:30:30 +08:00
parent 8582715be7
commit 314362c24d
90 changed files with 294 additions and 294 deletions

View File

@@ -109,7 +109,7 @@ func (this *NSDomainService) FindEnabledNSDomain(ctx context.Context, req *pb.Fi
Id: int64(domain.Id),
Name: domain.Name,
IsOn: domain.IsOn == 1,
TsigJSON: []byte(domain.Tsig),
TsigJSON: domain.Tsig,
CreatedAt: int64(domain.CreatedAt),
NsCluster: &pb.NSCluster{
Id: int64(cluster.Id),
@@ -182,7 +182,7 @@ func (this *NSDomainService) ListEnabledNSDomains(ctx context.Context, req *pb.L
Name: domain.Name,
IsOn: domain.IsOn == 1,
CreatedAt: int64(domain.CreatedAt),
TsigJSON: []byte(domain.Tsig),
TsigJSON: domain.Tsig,
NsCluster: &pb.NSCluster{
Id: int64(cluster.Id),
IsOn: cluster.IsOn == 1,
@@ -220,7 +220,7 @@ func (this *NSDomainService) ListNSDomainsAfterVersion(ctx context.Context, req
IsOn: domain.IsOn == 1,
IsDeleted: domain.State == nameservers.NSDomainStateDisabled,
Version: int64(domain.Version),
TsigJSON: []byte(domain.Tsig),
TsigJSON: domain.Tsig,
NsCluster: &pb.NSCluster{Id: int64(domain.ClusterId)},
User: nil,
})

View File

@@ -127,7 +127,7 @@ func (this *NSNodeService) ListEnabledNSNodesMatch(ctx context.Context, req *pb.
IsInstalled: node.IsInstalled == 1,
InstallDir: node.InstallDir,
IsUp: node.IsUp == 1,
StatusJSON: []byte(node.Status),
StatusJSON: node.Status,
InstallStatus: installStatusResult,
NsCluster: nil,
})
@@ -242,7 +242,7 @@ func (this *NSNodeService) FindEnabledNSNode(ctx context.Context, req *pb.FindEn
Id: int64(login.Id),
Name: login.Name,
Type: login.Type,
Params: []byte(login.Params),
Params: login.Params,
}
}
@@ -266,7 +266,7 @@ func (this *NSNodeService) FindEnabledNSNode(ctx context.Context, req *pb.FindEn
return &pb.FindEnabledNSNodeResponse{NsNode: &pb.NSNode{
Id: int64(node.Id),
Name: node.Name,
StatusJSON: []byte(node.Status),
StatusJSON: node.Status,
UniqueId: node.UniqueId,
Secret: node.Secret,
IsInstalled: node.IsInstalled == 1,

View File

@@ -57,7 +57,7 @@ func (this *NSQuestionOptionService) FindNSQuestionOption(ctx context.Context, r
return &pb.FindNSQuestionOptionResponse{NsQuestionOption: &pb.NSQuestionOption{
Id: int64(option.Id),
Name: option.Name,
ValuesJSON: []byte(option.Values),
ValuesJSON: option.Values,
}}, nil
}

View File

@@ -109,7 +109,7 @@ func (this *NSRouteService) FindEnabledNSRoute(ctx context.Context, req *pb.Find
Id: int64(route.Id),
IsOn: route.IsOn == 1,
Name: route.Name,
RangesJSON: []byte(route.Ranges),
RangesJSON: route.Ranges,
NsCluster: pbCluster,
NsDomain: pbDomain,
}}, nil
@@ -164,7 +164,7 @@ func (this *NSRouteService) FindAllEnabledNSRoutes(ctx context.Context, req *pb.
Id: int64(route.Id),
IsOn: route.IsOn == 1,
Name: route.Name,
RangesJSON: []byte(route.Ranges),
RangesJSON: route.Ranges,
NsCluster: pbCluster,
NsDomain: pbDomain,
})
@@ -218,7 +218,7 @@ func (this *NSRouteService) ListNSRoutesAfterVersion(ctx context.Context, req *p
Id: int64(route.Id),
IsOn: route.IsOn == 1,
Name: "",
RangesJSON: []byte(route.Ranges),
RangesJSON: route.Ranges,
IsDeleted: route.State == nameservers.NSRouteStateDisabled,
Order: int64(route.Order),
Version: int64(route.Version),

View File

@@ -173,7 +173,7 @@ func (this *AdminService) FindEnabledAdmin(ctx context.Context, req *pb.FindEnab
pbOtpAuth = &pb.Login{
Id: int64(adminAuth.Id),
Type: adminAuth.Type,
ParamsJSON: []byte(adminAuth.Params),
ParamsJSON: adminAuth.Params,
IsOn: adminAuth.IsOn == 1,
}
}
@@ -393,7 +393,7 @@ func (this *AdminService) ListEnabledAdmins(ctx context.Context, req *pb.ListEna
pbOtpAuth = &pb.Login{
Id: int64(adminAuth.Id),
Type: adminAuth.Type,
ParamsJSON: []byte(adminAuth.Params),
ParamsJSON: adminAuth.Params,
IsOn: adminAuth.IsOn == 1,
}
}

View File

@@ -93,9 +93,9 @@ func (this *APINodeService) FindAllEnabledAPINodes(ctx context.Context, req *pb.
Secret: node.Secret,
Name: node.Name,
Description: node.Description,
HttpJSON: []byte(node.Http),
HttpsJSON: []byte(node.Https),
AccessAddrsJSON: []byte(node.AccessAddrs),
HttpJSON: node.Http,
HttpsJSON: node.Https,
AccessAddrsJSON: node.AccessAddrs,
AccessAddrs: accessAddrs,
})
}
@@ -166,14 +166,14 @@ func (this *APINodeService) ListEnabledAPINodes(ctx context.Context, req *pb.Lis
Secret: node.Secret,
Name: node.Name,
Description: node.Description,
HttpJSON: []byte(node.Http),
HttpsJSON: []byte(node.Https),
HttpJSON: node.Http,
HttpsJSON: node.Https,
RestIsOn: node.RestIsOn == 1,
RestHTTPJSON: []byte(node.RestHTTP),
RestHTTPSJSON: []byte(node.RestHTTPS),
AccessAddrsJSON: []byte(node.AccessAddrs),
RestHTTPJSON: node.RestHTTP,
RestHTTPSJSON: node.RestHTTPS,
AccessAddrsJSON: node.AccessAddrs,
AccessAddrs: accessAddrs,
StatusJSON: []byte(node.Status),
StatusJSON: node.Status,
})
}
@@ -211,12 +211,12 @@ func (this *APINodeService) FindEnabledAPINode(ctx context.Context, req *pb.Find
Secret: node.Secret,
Name: node.Name,
Description: node.Description,
HttpJSON: []byte(node.Http),
HttpsJSON: []byte(node.Https),
HttpJSON: node.Http,
HttpsJSON: node.Https,
RestIsOn: node.RestIsOn == 1,
RestHTTPJSON: []byte(node.RestHTTP),
RestHTTPSJSON: []byte(node.RestHTTPS),
AccessAddrsJSON: []byte(node.AccessAddrs),
RestHTTPJSON: node.RestHTTP,
RestHTTPSJSON: node.RestHTTPS,
AccessAddrsJSON: node.AccessAddrs,
AccessAddrs: accessAddrs,
}
return &pb.FindEnabledAPINodeResponse{ApiNode: result}, nil
@@ -267,7 +267,7 @@ func (this *APINodeService) FindCurrentAPINode(ctx context.Context, req *pb.Find
RestIsOn: false,
RestHTTPJSON: nil,
RestHTTPSJSON: nil,
AccessAddrsJSON: []byte(node.AccessAddrs),
AccessAddrsJSON: node.AccessAddrs,
AccessAddrs: accessAddrs,
StatusJSON: nil,
}}, nil

View File

@@ -133,7 +133,7 @@ func (this *AuthorityNodeService) ListEnabledAuthorityNodes(ctx context.Context,
Secret: node.Secret,
Name: node.Name,
Description: node.Description,
StatusJSON: []byte(node.Status),
StatusJSON: node.Status,
})
}

View File

@@ -89,7 +89,7 @@ func (this *DNSProviderService) ListEnabledDNSProviders(ctx context.Context, req
Name: provider.Name,
Type: provider.Type,
TypeName: dnsclients.FindProviderTypeName(provider.Type),
ApiParamsJSON: []byte(provider.ApiParams),
ApiParamsJSON: provider.ApiParams,
DataUpdatedAt: int64(provider.DataUpdatedAt),
})
}
@@ -119,7 +119,7 @@ func (this *DNSProviderService) FindAllEnabledDNSProviders(ctx context.Context,
Name: provider.Name,
Type: provider.Type,
TypeName: dnsclients.FindProviderTypeName(provider.Type),
ApiParamsJSON: []byte(provider.ApiParams),
ApiParamsJSON: provider.ApiParams,
DataUpdatedAt: int64(provider.DataUpdatedAt),
})
}
@@ -168,7 +168,7 @@ func (this *DNSProviderService) FindEnabledDNSProvider(ctx context.Context, req
Name: provider.Name,
Type: provider.Type,
TypeName: dnsclients.FindProviderTypeName(provider.Type),
ApiParamsJSON: []byte(provider.ApiParams),
ApiParamsJSON: provider.ApiParams,
DataUpdatedAt: int64(provider.DataUpdatedAt),
}}, nil
}

View File

@@ -67,5 +67,5 @@ func (this *FileChunkService) DownloadFileChunk(ctx context.Context, req *pb.Dow
if chunk == nil {
return &pb.DownloadFileChunkResponse{FileChunk: nil}, nil
}
return &pb.DownloadFileChunkResponse{FileChunk: &pb.FileChunk{Data: []byte(chunk.Data)}}, nil
return &pb.DownloadFileChunkResponse{FileChunk: &pb.FileChunk{Data: chunk.Data}}, nil
}

View File

@@ -45,8 +45,8 @@ func (this *HTTPAccessLogPolicyService) ListEnabledHTTPAccessLogPolicies(ctx con
Name: policy.Name,
IsOn: policy.IsOn == 1,
Type: policy.Type,
OptionsJSON: []byte(policy.Options),
CondsJSON: []byte(policy.Conds),
OptionsJSON: policy.Options,
CondsJSON: policy.Conds,
IsPublic: policy.IsPublic == 1,
})
}
@@ -123,8 +123,8 @@ func (this *HTTPAccessLogPolicyService) FindEnabledHTTPAccessLogPolicy(ctx conte
Name: policy.Name,
IsOn: policy.IsOn == 1,
Type: policy.Type,
OptionsJSON: []byte(policy.Options),
CondsJSON: []byte(policy.Conds),
OptionsJSON: policy.Options,
CondsJSON: policy.Conds,
IsPublic: policy.IsPublic == 1,
}}, nil
}

View File

@@ -64,6 +64,6 @@ func (this *HTTPAuthPolicyService) FindEnabledHTTPAuthPolicy(ctx context.Context
IsOn: policy.IsOn == 1,
Name: policy.Name,
Type: policy.Type,
ParamsJSON: []byte(policy.Params),
ParamsJSON: policy.Params,
}}, nil
}

View File

@@ -77,9 +77,9 @@ func (this *HTTPFastcgiService) FindEnabledHTTPFastcgi(ctx context.Context, req
Id: int64(fastcgi.Id),
IsOn: fastcgi.IsOn == 1,
Address: fastcgi.Address,
ParamsJSON: []byte(fastcgi.Params),
ReadTimeoutJSON: []byte(fastcgi.ReadTimeout),
ConnTimeoutJSON: []byte(fastcgi.ConnTimeout),
ParamsJSON: fastcgi.Params,
ReadTimeoutJSON: fastcgi.ReadTimeout,
ConnTimeoutJSON: fastcgi.ConnTimeout,
PoolSize: types.Int32(fastcgi.PoolSize),
PathInfoPattern: fastcgi.PathInfoPattern,
}}, nil

View File

@@ -41,8 +41,8 @@ func (this *HTTPFirewallPolicyService) FindAllEnabledHTTPFirewallPolicies(ctx co
Name: p.Name,
Description: p.Description,
IsOn: p.IsOn == 1,
InboundJSON: []byte(p.Inbound),
OutboundJSON: []byte(p.Outbound),
InboundJSON: p.Inbound,
OutboundJSON: p.Outbound,
Mode: p.Mode,
UseLocalFirewall: p.UseLocalFirewall == 1,
})
@@ -390,8 +390,8 @@ func (this *HTTPFirewallPolicyService) ListEnabledHTTPFirewallPolicies(ctx conte
Name: p.Name,
Description: p.Description,
IsOn: p.IsOn == 1,
InboundJSON: []byte(p.Inbound),
OutboundJSON: []byte(p.Outbound),
InboundJSON: p.Inbound,
OutboundJSON: p.Outbound,
Mode: p.Mode,
UseLocalFirewall: p.UseLocalFirewall == 1,
})
@@ -482,10 +482,10 @@ func (this *HTTPFirewallPolicyService) FindEnabledHTTPFirewallPolicy(ctx context
Name: policy.Name,
Description: policy.Description,
IsOn: policy.IsOn == 1,
InboundJSON: []byte(policy.Inbound),
OutboundJSON: []byte(policy.Outbound),
InboundJSON: policy.Inbound,
OutboundJSON: policy.Outbound,
Mode: policy.Mode,
SynFloodJSON: []byte(policy.SynFlood),
SynFloodJSON: policy.SynFlood,
}}, nil
}

View File

@@ -70,7 +70,7 @@ func (this *IPListService) FindEnabledIPList(ctx context.Context, req *pb.FindEn
Type: list.Type,
Name: list.Name,
Code: list.Code,
TimeoutJSON: []byte(list.Timeout),
TimeoutJSON: list.Timeout,
Description: list.Description,
IsGlobal: list.IsGlobal == 1,
}}, nil
@@ -111,7 +111,7 @@ func (this *IPListService) ListEnabledIPLists(ctx context.Context, req *pb.ListE
Type: list.Type,
Name: list.Name,
Code: list.Code,
TimeoutJSON: []byte(list.Timeout),
TimeoutJSON: list.Timeout,
IsPublic: list.IsPublic == 1,
Description: list.Description,
IsGlobal: list.IsGlobal == 1,

View File

@@ -9,12 +9,12 @@ import (
"github.com/iwind/TeaGo/maps"
)
// 管理员认证相关服务
// LoginService 管理员认证相关服务
type LoginService struct {
BaseService
}
// 查找认证
// FindEnabledLogin 查找认证
func (this *LoginService) FindEnabledLogin(ctx context.Context, req *pb.FindEnabledLoginRequest) (*pb.FindEnabledLoginResponse, error) {
_, err := this.ValidateAdmin(ctx, 0)
if err != nil {
@@ -33,14 +33,14 @@ func (this *LoginService) FindEnabledLogin(ctx context.Context, req *pb.FindEnab
return &pb.FindEnabledLoginResponse{Login: &pb.Login{
Id: int64(login.Id),
Type: login.Type,
ParamsJSON: []byte(login.Params),
ParamsJSON: login.Params,
IsOn: login.IsOn == 1,
AdminId: int64(login.AdminId),
UserId: int64(login.UserId),
}}, nil
}
// 修改认证
// UpdateLogin 修改认证
func (this *LoginService) UpdateLogin(ctx context.Context, req *pb.UpdateLoginRequest) (*pb.RPCSuccess, error) {
_, err := this.ValidateAdmin(ctx, 0)
if err != nil {

View File

@@ -108,7 +108,7 @@ func (this *MessageService) ListUnreadMessages(ctx context.Context, req *pb.List
Type: message.Type,
Body: message.Body,
Level: message.Level,
ParamsJSON: []byte(message.Params),
ParamsJSON: message.Params,
IsRead: message.IsRead == 1,
CreatedAt: int64(message.CreatedAt),
NodeCluster: pbCluster,

View File

@@ -131,9 +131,9 @@ func (this *MessageMediaInstanceService) ListEnabledMessageMediaInstances(ctx co
Name: instance.Name,
IsOn: instance.IsOn == 1,
MessageMedia: pbMedia,
ParamsJSON: []byte(instance.Params),
ParamsJSON: instance.Params,
Description: instance.Description,
RateJSON: []byte(instance.Rate),
RateJSON: instance.Rate,
})
}
@@ -179,9 +179,9 @@ func (this *MessageMediaInstanceService) FindEnabledMessageMediaInstance(ctx con
Name: instance.Name,
IsOn: instance.IsOn == 1,
MessageMedia: pbMedia,
ParamsJSON: []byte(instance.Params),
ParamsJSON: instance.Params,
Description: instance.Description,
RateJSON: []byte(instance.Rate),
RateJSON: instance.Rate,
HashLife: types.Int32(instance.HashLife),
}}, nil
}

View File

@@ -150,7 +150,7 @@ func (this *MessageReceiverService) FindAllEnabledMessageReceivers(ctx context.C
NodeId: int64(receiver.NodeId),
ServerId: int64(receiver.ServerId),
Type: receiver.Type,
ParamsJSON: []byte(receiver.Params),
ParamsJSON: receiver.Params,
MessageRecipient: pbRecipient,
MessageRecipientGroup: pbRecipientGroup,
})

View File

@@ -82,8 +82,8 @@ func (this *MessageTaskService) FindSendingMessageTasks(ctx context.Context, req
MessageMedia: &pb.MessageMedia{
Type: instance.MediaType,
},
ParamsJSON: []byte(instance.Params),
RateJSON: []byte(instance.Rate),
ParamsJSON: instance.Params,
RateJSON: instance.Rate,
},
}
} else { // 没有指定既定的接收人
@@ -107,8 +107,8 @@ func (this *MessageTaskService) FindSendingMessageTasks(ctx context.Context, req
MessageMedia: &pb.MessageMedia{
Type: instance.MediaType,
},
ParamsJSON: []byte(instance.Params),
RateJSON: []byte(instance.Rate),
ParamsJSON: instance.Params,
RateJSON: instance.Rate,
},
}
}
@@ -232,7 +232,7 @@ func (this *MessageTaskService) FindEnabledMessageTask(ctx context.Context, req
MessageMedia: &pb.MessageMedia{
Type: instance.MediaType,
},
ParamsJSON: []byte(instance.Params),
ParamsJSON: instance.Params,
},
}
} else { // 没有指定既定的接收人
@@ -256,14 +256,14 @@ func (this *MessageTaskService) FindEnabledMessageTask(ctx context.Context, req
MessageMedia: &pb.MessageMedia{
Type: instance.MediaType,
},
ParamsJSON: []byte(instance.Params),
ParamsJSON: instance.Params,
},
}
}
var result = &pb.MessageTaskResult{}
if len(task.Result) > 0 {
err = json.Unmarshal([]byte(task.Result), result)
err = json.Unmarshal(task.Result, result)
if err != nil {
return nil, err
}
@@ -352,8 +352,8 @@ func (this *MessageTaskService) ListMessageTasksWithStatus(ctx context.Context,
MessageMedia: &pb.MessageMedia{
Type: instance.MediaType,
},
ParamsJSON: []byte(instance.Params),
RateJSON: []byte(instance.Rate),
ParamsJSON: instance.Params,
RateJSON: instance.Rate,
},
}
} else { // 没有指定既定的接收人
@@ -378,15 +378,15 @@ func (this *MessageTaskService) ListMessageTasksWithStatus(ctx context.Context,
MessageMedia: &pb.MessageMedia{
Type: instance.MediaType,
},
ParamsJSON: []byte(instance.Params),
RateJSON: []byte(instance.Rate),
ParamsJSON: instance.Params,
RateJSON: instance.Rate,
},
}
}
var result = &pb.MessageTaskResult{}
if len(task.Result) > 0 {
err = json.Unmarshal([]byte(task.Result), result)
err = json.Unmarshal(task.Result, result)
if err != nil {
return nil, err
}

View File

@@ -82,7 +82,7 @@ func (this *MetricChartService) FindEnabledMetricChart(ctx context.Context, req
Type: chart.Type,
WidthDiv: types.Int32(chart.WidthDiv),
MaxItems: types.Int32(chart.MaxItems),
ParamsJSON: []byte(chart.Params),
ParamsJSON: chart.Params,
IgnoreEmptyKeys: chart.IgnoreEmptyKeys == 1,
IgnoredKeys: chart.DecodeIgnoredKeys(),
IsOn: chart.IsOn == 1,
@@ -126,7 +126,7 @@ func (this *MetricChartService) ListEnabledMetricCharts(ctx context.Context, req
Type: chart.Type,
WidthDiv: types.Int32(chart.WidthDiv),
MaxItems: types.Int32(chart.MaxItems),
ParamsJSON: []byte(chart.Params),
ParamsJSON: chart.Params,
IgnoreEmptyKeys: chart.IgnoreEmptyKeys == 1,
IgnoredKeys: chart.DecodeIgnoredKeys(),
IsOn: chart.IsOn == 1,

View File

@@ -133,7 +133,7 @@ func (this *MonitorNodeService) ListEnabledMonitorNodes(ctx context.Context, req
Secret: node.Secret,
Name: node.Name,
Description: node.Description,
StatusJSON: []byte(node.Status),
StatusJSON: node.Status,
})
}

View File

@@ -314,7 +314,7 @@ func (this *NodeService) ListEnabledNodesMatch(ctx context.Context, req *pb.List
Name: node.Name,
Version: int64(node.Version),
IsInstalled: node.IsInstalled == 1,
StatusJSON: []byte(node.Status),
StatusJSON: node.Status,
NodeCluster: &pb.NodeCluster{
Id: int64(node.ClusterId),
Name: clusterName,
@@ -356,7 +356,7 @@ func (this *NodeService) FindAllEnabledNodesWithNodeClusterId(ctx context.Contex
for _, node := range nodes {
apiNodeIds := []int64{}
if models.IsNotNull(node.ConnectedAPINodes) {
err = json.Unmarshal([]byte(node.ConnectedAPINodes), &apiNodeIds)
err = json.Unmarshal(node.ConnectedAPINodes, &apiNodeIds)
if err != nil {
return nil, err
}
@@ -482,7 +482,7 @@ func (this *NodeService) FindEnabledNode(ctx context.Context, req *pb.FindEnable
Id: int64(login.Id),
Name: login.Name,
Type: login.Type,
Params: []byte(login.Params),
Params: login.Params,
}
}
@@ -536,9 +536,9 @@ func (this *NodeService) FindEnabledNode(ctx context.Context, req *pb.FindEnable
// 最大硬盘容量
var pbMaxCacheDiskCapacity *pb.SizeCapacity
if len(node.MaxCacheDiskCapacity) > 0 {
if models.IsNotNull(node.MaxCacheDiskCapacity) {
pbMaxCacheDiskCapacity = &pb.SizeCapacity{}
err = json.Unmarshal([]byte(node.MaxCacheDiskCapacity), pbMaxCacheDiskCapacity)
err = json.Unmarshal(node.MaxCacheDiskCapacity, pbMaxCacheDiskCapacity)
if err != nil {
return nil, err
}
@@ -546,9 +546,9 @@ func (this *NodeService) FindEnabledNode(ctx context.Context, req *pb.FindEnable
// 最大内存容量
var pbMaxCacheMemoryCapacity *pb.SizeCapacity
if len(node.MaxCacheMemoryCapacity) > 0 {
if models.IsNotNull(node.MaxCacheMemoryCapacity) {
pbMaxCacheMemoryCapacity = &pb.SizeCapacity{}
err = json.Unmarshal([]byte(node.MaxCacheMemoryCapacity), pbMaxCacheMemoryCapacity)
err = json.Unmarshal(node.MaxCacheMemoryCapacity, pbMaxCacheMemoryCapacity)
if err != nil {
return nil, err
}
@@ -557,7 +557,7 @@ func (this *NodeService) FindEnabledNode(ctx context.Context, req *pb.FindEnable
return &pb.FindEnabledNodeResponse{Node: &pb.Node{
Id: int64(node.Id),
Name: node.Name,
StatusJSON: []byte(node.Status),
StatusJSON: node.Status,
UniqueId: node.UniqueId,
Version: int64(node.Version),
LatestVersion: int64(node.LatestVersion),
@@ -876,7 +876,7 @@ func (this *NodeService) FindAllEnabledNodesWithNodeGrantId(ctx context.Context,
Name: node.Name,
Version: int64(node.Version),
IsInstalled: node.IsInstalled == 1,
StatusJSON: []byte(node.Status),
StatusJSON: node.Status,
NodeCluster: &pb.NodeCluster{
Id: int64(node.ClusterId),
Name: clusterName,
@@ -928,7 +928,7 @@ func (this *NodeService) FindAllNotInstalledNodesWithNodeClusterId(ctx context.C
Id: int64(login.Id),
Name: login.Name,
Type: login.Type,
Params: []byte(login.Params),
Params: login.Params,
}
}
@@ -974,7 +974,7 @@ func (this *NodeService) FindAllNotInstalledNodesWithNodeClusterId(ctx context.C
Name: node.Name,
Version: int64(node.Version),
IsInstalled: node.IsInstalled == 1,
StatusJSON: []byte(node.Status),
StatusJSON: node.Status,
IsOn: node.IsOn == 1,
NodeLogin: pbLogin,
IpAddresses: pbAddresses,
@@ -1037,7 +1037,7 @@ func (this *NodeService) FindAllUpgradeNodesWithNodeClusterId(ctx context.Contex
Id: int64(login.Id),
Name: login.Name,
Type: login.Type,
Params: []byte(login.Params),
Params: login.Params,
}
}
@@ -1092,7 +1092,7 @@ func (this *NodeService) FindAllUpgradeNodesWithNodeClusterId(ctx context.Contex
Name: node.Name,
Version: int64(node.Version),
IsInstalled: node.IsInstalled == 1,
StatusJSON: []byte(node.Status),
StatusJSON: node.Status,
IsOn: node.IsOn == 1,
IpAddresses: pbAddresses,
NodeLogin: pbLogin,

View File

@@ -94,7 +94,7 @@ func (this *NodeClusterFirewallActionService) FindAllEnabledNodeClusterFirewallA
Name: action.Name,
EventLevel: action.EventLevel,
Type: action.Type,
ParamsJSON: []byte(action.Params),
ParamsJSON: action.Params,
})
}
return &pb.FindAllEnabledNodeClusterFirewallActionsResponse{NodeClusterFirewallActions: pbActions}, nil
@@ -121,7 +121,7 @@ func (this *NodeClusterFirewallActionService) FindEnabledNodeClusterFirewallActi
Name: action.Name,
EventLevel: action.EventLevel,
Type: action.Type,
ParamsJSON: []byte(action.Params),
ParamsJSON: action.Params,
}}, nil
}

View File

@@ -109,8 +109,8 @@ func (this *NodeIPAddressThresholdService) FindAllEnabledNodeIPAddressThresholds
for _, threshold := range thresholds {
pbThresholds = append(pbThresholds, &pb.NodeIPAddressThreshold{
Id: int64(threshold.Id),
ItemsJSON: []byte(threshold.Items),
ActionsJSON: []byte(threshold.Actions),
ItemsJSON: threshold.Items,
ActionsJSON: threshold.Actions,
})
}
return &pb.FindAllEnabledNodeIPAddressThresholdsResponse{NodeIPAddressThresholds: pbThresholds}, nil

View File

@@ -6,12 +6,12 @@ import (
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
)
// 节点区域相关服务
// NodeRegionService 节点区域相关服务
type NodeRegionService struct {
BaseService
}
// 创建区域
// CreateNodeRegion 创建区域
func (this *NodeRegionService) CreateNodeRegion(ctx context.Context, req *pb.CreateNodeRegionRequest) (*pb.CreateNodeRegionResponse, error) {
adminId, err := this.ValidateAdmin(ctx, 0)
if err != nil {
@@ -27,7 +27,7 @@ func (this *NodeRegionService) CreateNodeRegion(ctx context.Context, req *pb.Cre
return &pb.CreateNodeRegionResponse{NodeRegionId: regionId}, nil
}
// 修改区域
// UpdateNodeRegion 修改区域
func (this *NodeRegionService) UpdateNodeRegion(ctx context.Context, req *pb.UpdateNodeRegionRequest) (*pb.RPCSuccess, error) {
_, err := this.ValidateAdmin(ctx, 0)
if err != nil {
@@ -43,7 +43,7 @@ func (this *NodeRegionService) UpdateNodeRegion(ctx context.Context, req *pb.Upd
return this.Success()
}
// 删除区域
// DeleteNodeRegion 删除区域
func (this *NodeRegionService) DeleteNodeRegion(ctx context.Context, req *pb.DeleteNodeRegionRequest) (*pb.RPCSuccess, error) {
_, err := this.ValidateAdmin(ctx, 0)
if err != nil {
@@ -59,7 +59,7 @@ func (this *NodeRegionService) DeleteNodeRegion(ctx context.Context, req *pb.Del
return this.Success()
}
// 查找所有区域
// FindAllEnabledNodeRegions 查找所有区域
func (this *NodeRegionService) FindAllEnabledNodeRegions(ctx context.Context, req *pb.FindAllEnabledNodeRegionsRequest) (*pb.FindAllEnabledNodeRegionsResponse, error) {
_, err := this.ValidateAdmin(ctx, 0)
if err != nil {
@@ -79,13 +79,13 @@ func (this *NodeRegionService) FindAllEnabledNodeRegions(ctx context.Context, re
IsOn: region.IsOn == 1,
Name: region.Name,
Description: region.Description,
PricesJSON: []byte(region.Prices),
PricesJSON: region.Prices,
})
}
return &pb.FindAllEnabledNodeRegionsResponse{NodeRegions: result}, nil
}
// 查找所有启用的区域
// FindAllEnabledAndOnNodeRegions 查找所有启用的区域
func (this *NodeRegionService) FindAllEnabledAndOnNodeRegions(ctx context.Context, req *pb.FindAllEnabledAndOnNodeRegionsRequest) (*pb.FindAllEnabledAndOnNodeRegionsResponse, error) {
_, err := this.ValidateAdmin(ctx, 0)
if err != nil {
@@ -105,13 +105,13 @@ func (this *NodeRegionService) FindAllEnabledAndOnNodeRegions(ctx context.Contex
IsOn: region.IsOn == 1,
Name: region.Name,
Description: region.Description,
PricesJSON: []byte(region.Prices),
PricesJSON: region.Prices,
})
}
return &pb.FindAllEnabledAndOnNodeRegionsResponse{NodeRegions: result}, nil
}
// 排序
// UpdateNodeRegionOrders 排序
func (this *NodeRegionService) UpdateNodeRegionOrders(ctx context.Context, req *pb.UpdateNodeRegionOrdersRequest) (*pb.RPCSuccess, error) {
_, err := this.ValidateAdmin(ctx, 0)
if err != nil {
@@ -127,7 +127,7 @@ func (this *NodeRegionService) UpdateNodeRegionOrders(ctx context.Context, req *
return this.Success()
}
// 查找单个区域信息
// FindEnabledNodeRegion 查找单个区域信息
func (this *NodeRegionService) FindEnabledNodeRegion(ctx context.Context, req *pb.FindEnabledNodeRegionRequest) (*pb.FindEnabledNodeRegionResponse, error) {
_, err := this.ValidateAdmin(ctx, 0)
if err != nil {
@@ -148,11 +148,11 @@ func (this *NodeRegionService) FindEnabledNodeRegion(ctx context.Context, req *p
IsOn: region.IsOn == 1,
Name: region.Name,
Description: region.Description,
PricesJSON: []byte(region.Prices),
PricesJSON: region.Prices,
}}, nil
}
// 修改价格项价格
// UpdateNodeRegionPrice 修改价格项价格
func (this *NodeRegionService) UpdateNodeRegionPrice(ctx context.Context, req *pb.UpdateNodeRegionPriceRequest) (*pb.RPCSuccess, error) {
_, err := this.ValidateAdmin(ctx, 0)
if err != nil {

View File

@@ -94,7 +94,7 @@ func (this *NodeThresholdService) FindAllEnabledNodeThresholds(ctx context.Conte
Item: threshold.Item,
Param: threshold.Param,
Operator: threshold.Operator,
ValueJSON: []byte(threshold.Value),
ValueJSON: threshold.Value,
Message: threshold.Message,
Duration: types.Int32(threshold.Duration),
DurationUnit: threshold.DurationUnit,
@@ -160,7 +160,7 @@ func (this *NodeThresholdService) FindEnabledNodeThreshold(ctx context.Context,
Item: threshold.Item,
Param: threshold.Param,
Operator: threshold.Operator,
ValueJSON: []byte(threshold.Value),
ValueJSON: threshold.Value,
Message: threshold.Message,
Duration: types.Int32(threshold.Duration),
DurationUnit: threshold.DurationUnit,

View File

@@ -63,7 +63,7 @@ func (this *NodeValueService) ListNodeValues(ctx context.Context, req *pb.ListNo
pbValues := []*pb.NodeValue{}
for _, value := range values {
pbValues = append(pbValues, &pb.NodeValue{
ValueJSON: []byte(value.Value),
ValueJSON: value.Value,
CreatedAt: int64(value.CreatedAt),
})
}

View File

@@ -30,7 +30,7 @@ func (this *RegionCountryService) FindAllEnabledRegionCountries(ctx context.Cont
result := []*pb.RegionCountry{}
for _, country := range countries {
pinyinStrings := []string{}
err = json.Unmarshal([]byte(country.Pinyin), &pinyinStrings)
err = json.Unmarshal(country.Pinyin, &pinyinStrings)
if err != nil {
return nil, err
}

View File

@@ -62,9 +62,9 @@ func (this *ReverseProxyService) FindEnabledReverseProxy(ctx context.Context, re
result := &pb.ReverseProxy{
Id: int64(reverseProxy.Id),
SchedulingJSON: []byte(reverseProxy.Scheduling),
PrimaryOriginsJSON: []byte(reverseProxy.PrimaryOrigins),
BackupOriginsJSON: []byte(reverseProxy.BackupOrigins),
SchedulingJSON: reverseProxy.Scheduling,
PrimaryOriginsJSON: reverseProxy.PrimaryOrigins,
BackupOriginsJSON: reverseProxy.BackupOrigins,
}
return &pb.FindEnabledReverseProxyResponse{ReverseProxy: result}, nil
}

View File

@@ -435,7 +435,7 @@ func (this *ServerGroupService) FindEnabledServerGroupConfigInfo(ctx context.Con
if len(group.HttpReverseProxy) > 0 {
var ref = &serverconfigs.ReverseProxyRef{}
err = json.Unmarshal([]byte(group.HttpReverseProxy), ref)
err = json.Unmarshal(group.HttpReverseProxy, ref)
if err != nil {
return nil, err
}
@@ -444,7 +444,7 @@ func (this *ServerGroupService) FindEnabledServerGroupConfigInfo(ctx context.Con
if len(group.TcpReverseProxy) > 0 {
var ref = &serverconfigs.ReverseProxyRef{}
err = json.Unmarshal([]byte(group.TcpReverseProxy), ref)
err = json.Unmarshal(group.TcpReverseProxy, ref)
if err != nil {
return nil, err
}
@@ -453,7 +453,7 @@ func (this *ServerGroupService) FindEnabledServerGroupConfigInfo(ctx context.Con
if len(group.UdpReverseProxy) > 0 {
var ref = &serverconfigs.ReverseProxyRef{}
err = json.Unmarshal([]byte(group.UdpReverseProxy), ref)
err = json.Unmarshal(group.UdpReverseProxy, ref)
if err != nil {
return nil, err
}

View File

@@ -436,7 +436,7 @@ func (this *ServerStatBoardService) ComposeServerStatNodeBoard(ctx context.Conte
}
for _, v := range cacheDirValues {
result.CacheDirsValues = append(result.CacheDirsValues, &pb.NodeValue{
ValueJSON: []byte(v.Value),
ValueJSON: v.Value,
CreatedAt: int64(v.CreatedAt),
})
}

View File

@@ -222,7 +222,7 @@ func (this *SSLCertService) ListSSLCertsWithOCSPError(ctx context.Context, req *
CommonNames: cert.DecodeCommonNames(),
IsACME: cert.IsACME == 1,
AcmeTaskId: int64(cert.AcmeTaskId),
Ocsp: []byte(cert.Ocsp),
Ocsp: cert.Ocsp,
OcspIsUpdated: cert.OcspIsUpdated == 1,
OcspError: cert.OcspError,
Description: cert.Description,
@@ -300,7 +300,7 @@ func (this *SSLCertService) ListUpdatedSSLCertOCSP(ctx context.Context, req *pb.
for _, cert := range certs {
result = append(result, &pb.ListUpdatedSSLCertOCSPResponse_SSLCertOCSP{
SslCertId: int64(cert.Id),
Data: []byte(cert.Ocsp),
Data: cert.Ocsp,
ExpiresAt: int64(cert.OcspExpiresAt),
Version: int64(cert.OcspUpdatedVersion),
})

View File

@@ -92,9 +92,9 @@ func (this *UserNodeService) FindAllEnabledUserNodes(ctx context.Context, req *p
Secret: node.Secret,
Name: node.Name,
Description: node.Description,
HttpJSON: []byte(node.Http),
HttpsJSON: []byte(node.Https),
AccessAddrsJSON: []byte(node.AccessAddrs),
HttpJSON: node.Http,
HttpsJSON: node.Https,
AccessAddrsJSON: node.AccessAddrs,
AccessAddrs: accessAddrs,
})
}
@@ -147,11 +147,11 @@ func (this *UserNodeService) ListEnabledUserNodes(ctx context.Context, req *pb.L
Secret: node.Secret,
Name: node.Name,
Description: node.Description,
HttpJSON: []byte(node.Http),
HttpsJSON: []byte(node.Https),
AccessAddrsJSON: []byte(node.AccessAddrs),
HttpJSON: node.Http,
HttpsJSON: node.Https,
AccessAddrsJSON: node.AccessAddrs,
AccessAddrs: accessAddrs,
StatusJSON: []byte(node.Status),
StatusJSON: node.Status,
})
}
@@ -188,9 +188,9 @@ func (this *UserNodeService) FindEnabledUserNode(ctx context.Context, req *pb.Fi
Secret: node.Secret,
Name: node.Name,
Description: node.Description,
HttpJSON: []byte(node.Http),
HttpsJSON: []byte(node.Https),
AccessAddrsJSON: []byte(node.AccessAddrs),
HttpJSON: node.Http,
HttpsJSON: node.Https,
AccessAddrsJSON: node.AccessAddrs,
AccessAddrs: accessAddrs,
}
return &pb.FindEnabledUserNodeResponse{UserNode: result}, nil
@@ -235,9 +235,9 @@ func (this *UserNodeService) FindCurrentUserNode(ctx context.Context, req *pb.Fi
Secret: node.Secret,
Name: node.Name,
Description: node.Description,
HttpJSON: []byte(node.Http),
HttpsJSON: []byte(node.Https),
AccessAddrsJSON: []byte(node.AccessAddrs),
HttpJSON: node.Http,
HttpsJSON: node.Https,
AccessAddrsJSON: node.AccessAddrs,
AccessAddrs: accessAddrs,
}
return &pb.FindCurrentUserNodeResponse{UserNode: result}, nil