mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-12-28 00:06:36 +08:00
优化代码
This commit is contained in:
@@ -74,7 +74,7 @@ func (this *NSAccessLogService) ListNSAccessLogs(ctx context.Context, req *pb.Li
|
||||
if route != nil {
|
||||
a.NsRoutes = append(a.NsRoutes, &pb.NSRoute{
|
||||
Id: types.Int64(route.Id),
|
||||
IsOn: route.IsOn == 1,
|
||||
IsOn: route.IsOn,
|
||||
Name: route.Name,
|
||||
Code: routeCode,
|
||||
NsCluster: nil,
|
||||
|
||||
@@ -112,7 +112,7 @@ func (this *NSClusterService) FindEnabledNSCluster(ctx context.Context, req *pb.
|
||||
}
|
||||
return &pb.FindEnabledNSClusterResponse{NsCluster: &pb.NSCluster{
|
||||
Id: int64(cluster.Id),
|
||||
IsOn: cluster.IsOn == 1,
|
||||
IsOn: cluster.IsOn,
|
||||
Name: cluster.Name,
|
||||
InstallDir: cluster.InstallDir,
|
||||
}}, nil
|
||||
@@ -147,7 +147,7 @@ func (this *NSClusterService) ListEnabledNSClusters(ctx context.Context, req *pb
|
||||
for _, cluster := range clusters {
|
||||
pbClusters = append(pbClusters, &pb.NSCluster{
|
||||
Id: int64(cluster.Id),
|
||||
IsOn: cluster.IsOn == 1,
|
||||
IsOn: cluster.IsOn,
|
||||
Name: cluster.Name,
|
||||
InstallDir: cluster.InstallDir,
|
||||
})
|
||||
@@ -170,7 +170,7 @@ func (this *NSClusterService) FindAllEnabledNSClusters(ctx context.Context, req
|
||||
for _, cluster := range clusters {
|
||||
pbClusters = append(pbClusters, &pb.NSCluster{
|
||||
Id: int64(cluster.Id),
|
||||
IsOn: cluster.IsOn == 1,
|
||||
IsOn: cluster.IsOn,
|
||||
Name: cluster.Name,
|
||||
InstallDir: cluster.InstallDir,
|
||||
})
|
||||
|
||||
@@ -108,12 +108,12 @@ func (this *NSDomainService) FindEnabledNSDomain(ctx context.Context, req *pb.Fi
|
||||
NsDomain: &pb.NSDomain{
|
||||
Id: int64(domain.Id),
|
||||
Name: domain.Name,
|
||||
IsOn: domain.IsOn == 1,
|
||||
IsOn: domain.IsOn,
|
||||
TsigJSON: domain.Tsig,
|
||||
CreatedAt: int64(domain.CreatedAt),
|
||||
NsCluster: &pb.NSCluster{
|
||||
Id: int64(cluster.Id),
|
||||
IsOn: cluster.IsOn == 1,
|
||||
IsOn: cluster.IsOn,
|
||||
Name: cluster.Name,
|
||||
},
|
||||
User: pbUser,
|
||||
@@ -180,12 +180,12 @@ func (this *NSDomainService) ListEnabledNSDomains(ctx context.Context, req *pb.L
|
||||
pbDomains = append(pbDomains, &pb.NSDomain{
|
||||
Id: int64(domain.Id),
|
||||
Name: domain.Name,
|
||||
IsOn: domain.IsOn == 1,
|
||||
IsOn: domain.IsOn,
|
||||
CreatedAt: int64(domain.CreatedAt),
|
||||
TsigJSON: domain.Tsig,
|
||||
NsCluster: &pb.NSCluster{
|
||||
Id: int64(cluster.Id),
|
||||
IsOn: cluster.IsOn == 1,
|
||||
IsOn: cluster.IsOn,
|
||||
Name: cluster.Name,
|
||||
},
|
||||
User: pbUser,
|
||||
@@ -217,7 +217,7 @@ func (this *NSDomainService) ListNSDomainsAfterVersion(ctx context.Context, req
|
||||
pbDomains = append(pbDomains, &pb.NSDomain{
|
||||
Id: int64(domain.Id),
|
||||
Name: domain.Name,
|
||||
IsOn: domain.IsOn == 1,
|
||||
IsOn: domain.IsOn,
|
||||
IsDeleted: domain.State == nameservers.NSDomainStateDisabled,
|
||||
Version: int64(domain.Version),
|
||||
TsigJSON: domain.Tsig,
|
||||
|
||||
@@ -76,7 +76,7 @@ func (this *NSKeyService) FindEnabledNSKey(ctx context.Context, req *pb.FindEnab
|
||||
return &pb.FindEnabledNSKeyResponse{
|
||||
NsKey: &pb.NSKey{
|
||||
Id: int64(key.Id),
|
||||
IsOn: key.IsOn == 1,
|
||||
IsOn: key.IsOn,
|
||||
Name: key.Name,
|
||||
Algo: key.Algo,
|
||||
Secret: key.Secret,
|
||||
@@ -116,7 +116,7 @@ func (this *NSKeyService) ListEnabledNSKeys(ctx context.Context, req *pb.ListEna
|
||||
for _, key := range keys {
|
||||
pbKeys = append(pbKeys, &pb.NSKey{
|
||||
Id: int64(key.Id),
|
||||
IsOn: key.IsOn == 1,
|
||||
IsOn: key.IsOn,
|
||||
Name: key.Name,
|
||||
Algo: key.Algo,
|
||||
Secret: key.Secret,
|
||||
@@ -155,7 +155,7 @@ func (this *NSKeyService) ListNSKeysAfterVersion(ctx context.Context, req *pb.Li
|
||||
|
||||
pbKeys = append(pbKeys, &pb.NSKey{
|
||||
Id: int64(key.Id),
|
||||
IsOn: key.IsOn == 1,
|
||||
IsOn: key.IsOn,
|
||||
Name: "",
|
||||
Algo: key.Algo,
|
||||
Secret: key.Secret,
|
||||
|
||||
@@ -44,7 +44,7 @@ func (this *NSNodeService) FindAllEnabledNSNodesWithNSClusterId(ctx context.Cont
|
||||
pbNodes = append(pbNodes, &pb.NSNode{
|
||||
Id: int64(node.Id),
|
||||
Name: node.Name,
|
||||
IsOn: node.IsOn == 1,
|
||||
IsOn: node.IsOn,
|
||||
UniqueId: node.UniqueId,
|
||||
Secret: node.Secret,
|
||||
IsInstalled: node.IsInstalled == 1,
|
||||
@@ -120,7 +120,7 @@ func (this *NSNodeService) ListEnabledNSNodesMatch(ctx context.Context, req *pb.
|
||||
pbNodes = append(pbNodes, &pb.NSNode{
|
||||
Id: int64(node.Id),
|
||||
Name: node.Name,
|
||||
IsOn: node.IsOn == 1,
|
||||
IsOn: node.IsOn,
|
||||
UniqueId: node.UniqueId,
|
||||
Secret: node.Secret,
|
||||
IsActive: node.IsActive == 1,
|
||||
@@ -276,7 +276,7 @@ func (this *NSNodeService) FindEnabledNSNode(ctx context.Context, req *pb.FindEn
|
||||
Name: clusterName,
|
||||
},
|
||||
InstallStatus: installStatusResult,
|
||||
IsOn: node.IsOn == 1,
|
||||
IsOn: node.IsOn,
|
||||
IsActive: node.IsActive == 1,
|
||||
NodeLogin: respLogin,
|
||||
}}, nil
|
||||
|
||||
@@ -120,7 +120,7 @@ func (this *NSRecordService) ListEnabledNSRecords(ctx context.Context, req *pb.L
|
||||
Ttl: types.Int32(record.Ttl),
|
||||
Weight: types.Int32(record.Weight),
|
||||
CreatedAt: int64(record.CreatedAt),
|
||||
IsOn: record.IsOn == 1,
|
||||
IsOn: record.IsOn,
|
||||
NsDomain: nil,
|
||||
NsRoutes: pbRoutes,
|
||||
})
|
||||
@@ -155,7 +155,7 @@ func (this *NSRecordService) FindEnabledNSRecord(ctx context.Context, req *pb.Fi
|
||||
var pbDomain = &pb.NSDomain{
|
||||
Id: int64(domain.Id),
|
||||
Name: domain.Name,
|
||||
IsOn: domain.IsOn == 1,
|
||||
IsOn: domain.IsOn,
|
||||
}
|
||||
|
||||
// 线路
|
||||
@@ -186,7 +186,7 @@ func (this *NSRecordService) FindEnabledNSRecord(ctx context.Context, req *pb.Fi
|
||||
Ttl: types.Int32(record.Ttl),
|
||||
Weight: types.Int32(record.Weight),
|
||||
CreatedAt: int64(record.CreatedAt),
|
||||
IsOn: record.IsOn == 1,
|
||||
IsOn: record.IsOn,
|
||||
NsDomain: pbDomain,
|
||||
NsRoutes: pbRoutes,
|
||||
}}, nil
|
||||
@@ -237,7 +237,7 @@ func (this *NSRecordService) ListNSRecordsAfterVersion(ctx context.Context, req
|
||||
Ttl: types.Int32(record.Ttl),
|
||||
Weight: types.Int32(record.Weight),
|
||||
IsDeleted: record.State == nameservers.NSRecordStateDisabled,
|
||||
IsOn: record.IsOn == 1,
|
||||
IsOn: record.IsOn,
|
||||
Version: int64(record.Version),
|
||||
NsDomain: &pb.NSDomain{Id: int64(record.DomainId)},
|
||||
NsRoutes: pbRoutes,
|
||||
|
||||
@@ -83,7 +83,7 @@ func (this *NSRouteService) FindEnabledNSRoute(ctx context.Context, req *pb.Find
|
||||
if cluster != nil {
|
||||
pbCluster = &pb.NSCluster{
|
||||
Id: int64(cluster.Id),
|
||||
IsOn: cluster.IsOn == 1,
|
||||
IsOn: cluster.IsOn,
|
||||
Name: cluster.Name,
|
||||
}
|
||||
}
|
||||
@@ -100,14 +100,14 @@ func (this *NSRouteService) FindEnabledNSRoute(ctx context.Context, req *pb.Find
|
||||
pbDomain = &pb.NSDomain{
|
||||
Id: int64(domain.Id),
|
||||
Name: domain.Name,
|
||||
IsOn: domain.IsOn == 1,
|
||||
IsOn: domain.IsOn,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return &pb.FindEnabledNSRouteResponse{NsRoute: &pb.NSRoute{
|
||||
Id: int64(route.Id),
|
||||
IsOn: route.IsOn == 1,
|
||||
IsOn: route.IsOn,
|
||||
Name: route.Name,
|
||||
RangesJSON: route.Ranges,
|
||||
NsCluster: pbCluster,
|
||||
@@ -138,7 +138,7 @@ func (this *NSRouteService) FindAllEnabledNSRoutes(ctx context.Context, req *pb.
|
||||
if cluster != nil {
|
||||
pbCluster = &pb.NSCluster{
|
||||
Id: int64(cluster.Id),
|
||||
IsOn: cluster.IsOn == 1,
|
||||
IsOn: cluster.IsOn,
|
||||
Name: cluster.Name,
|
||||
}
|
||||
}
|
||||
@@ -155,14 +155,14 @@ func (this *NSRouteService) FindAllEnabledNSRoutes(ctx context.Context, req *pb.
|
||||
pbDomain = &pb.NSDomain{
|
||||
Id: int64(domain.Id),
|
||||
Name: domain.Name,
|
||||
IsOn: domain.IsOn == 1,
|
||||
IsOn: domain.IsOn,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pbRoutes = append(pbRoutes, &pb.NSRoute{
|
||||
Id: int64(route.Id),
|
||||
IsOn: route.IsOn == 1,
|
||||
IsOn: route.IsOn,
|
||||
Name: route.Name,
|
||||
RangesJSON: route.Ranges,
|
||||
NsCluster: pbCluster,
|
||||
@@ -216,7 +216,7 @@ func (this *NSRouteService) ListNSRoutesAfterVersion(ctx context.Context, req *p
|
||||
|
||||
pbRoutes = append(pbRoutes, &pb.NSRoute{
|
||||
Id: int64(route.Id),
|
||||
IsOn: route.IsOn == 1,
|
||||
IsOn: route.IsOn,
|
||||
Name: "",
|
||||
RangesJSON: route.Ranges,
|
||||
IsDeleted: route.State == nameservers.NSRouteStateDisabled,
|
||||
|
||||
Reference in New Issue
Block a user