mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-12-01 14:00:25 +08:00
优化代码
This commit is contained in:
@@ -47,9 +47,9 @@ func (this *NSNodeService) FindAllEnabledNSNodesWithNSClusterId(ctx context.Cont
|
||||
IsOn: node.IsOn,
|
||||
UniqueId: node.UniqueId,
|
||||
Secret: node.Secret,
|
||||
IsInstalled: node.IsInstalled == 1,
|
||||
IsInstalled: node.IsInstalled,
|
||||
InstallDir: node.InstallDir,
|
||||
IsUp: node.IsUp == 1,
|
||||
IsUp: node.IsUp,
|
||||
NsCluster: nil,
|
||||
})
|
||||
}
|
||||
@@ -123,10 +123,10 @@ func (this *NSNodeService) ListEnabledNSNodesMatch(ctx context.Context, req *pb.
|
||||
IsOn: node.IsOn,
|
||||
UniqueId: node.UniqueId,
|
||||
Secret: node.Secret,
|
||||
IsActive: node.IsActive == 1,
|
||||
IsInstalled: node.IsInstalled == 1,
|
||||
IsActive: node.IsActive,
|
||||
IsInstalled: node.IsInstalled,
|
||||
InstallDir: node.InstallDir,
|
||||
IsUp: node.IsUp == 1,
|
||||
IsUp: node.IsUp,
|
||||
StatusJSON: node.Status,
|
||||
InstallStatus: installStatusResult,
|
||||
NsCluster: nil,
|
||||
@@ -269,7 +269,7 @@ func (this *NSNodeService) FindEnabledNSNode(ctx context.Context, req *pb.FindEn
|
||||
StatusJSON: node.Status,
|
||||
UniqueId: node.UniqueId,
|
||||
Secret: node.Secret,
|
||||
IsInstalled: node.IsInstalled == 1,
|
||||
IsInstalled: node.IsInstalled,
|
||||
InstallDir: node.InstallDir,
|
||||
NsCluster: &pb.NSCluster{
|
||||
Id: int64(node.ClusterId),
|
||||
@@ -277,7 +277,7 @@ func (this *NSNodeService) FindEnabledNSNode(ctx context.Context, req *pb.FindEn
|
||||
},
|
||||
InstallStatus: installStatusResult,
|
||||
IsOn: node.IsOn,
|
||||
IsActive: node.IsActive == 1,
|
||||
IsActive: node.IsActive,
|
||||
NodeLogin: respLogin,
|
||||
}}, nil
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ func (this *ACMETaskService) ListEnabledACMETasks(ctx context.Context, req *pb.L
|
||||
if taskLog != nil {
|
||||
pbTaskLog = &pb.ACMETaskLog{
|
||||
Id: int64(taskLog.Id),
|
||||
IsOk: taskLog.IsOk == 1,
|
||||
IsOk: taskLog.IsOk,
|
||||
Error: taskLog.Error,
|
||||
CreatedAt: int64(taskLog.CreatedAt),
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ func (this *AdminService) FindEnabledAdmin(ctx context.Context, req *pb.FindEnab
|
||||
Fullname: admin.Fullname,
|
||||
Username: admin.Username,
|
||||
IsOn: admin.IsOn,
|
||||
IsSuper: admin.IsSuper == 1,
|
||||
IsSuper: admin.IsSuper,
|
||||
Modules: pbModules,
|
||||
OtpLogin: pbOtpAuth,
|
||||
CanLogin: admin.CanLogin == 1,
|
||||
@@ -298,7 +298,7 @@ func (this *AdminService) FindAllAdminModules(ctx context.Context, req *pb.FindA
|
||||
|
||||
list := &pb.AdminModuleList{
|
||||
AdminId: int64(admin.Id),
|
||||
IsSuper: admin.IsSuper == 1,
|
||||
IsSuper: admin.IsSuper,
|
||||
Fullname: admin.Fullname,
|
||||
Theme: admin.Theme,
|
||||
Modules: pbModules,
|
||||
@@ -404,7 +404,7 @@ func (this *AdminService) ListEnabledAdmins(ctx context.Context, req *pb.ListEna
|
||||
Fullname: admin.Fullname,
|
||||
Username: admin.Username,
|
||||
IsOn: admin.IsOn,
|
||||
IsSuper: admin.IsSuper == 1,
|
||||
IsSuper: admin.IsSuper,
|
||||
CreatedAt: int64(admin.CreatedAt),
|
||||
OtpLogin: pbOtpAuth,
|
||||
CanLogin: admin.CanLogin == 1,
|
||||
|
||||
@@ -260,8 +260,8 @@ func (this *DNSDomainService) FindAllEnabledBasicDNSDomainsWithDNSProviderId(ctx
|
||||
Id: int64(domain.Id),
|
||||
Name: domain.Name,
|
||||
IsOn: domain.IsOn,
|
||||
IsUp: domain.IsUp == 1,
|
||||
IsDeleted: domain.IsDeleted == 1,
|
||||
IsUp: domain.IsUp,
|
||||
IsDeleted: domain.IsDeleted,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -390,8 +390,8 @@ func (this *DNSDomainService) convertDomainToPB(tx *dbs.Tx, domain *dns.DNSDomai
|
||||
ProviderId: int64(domain.ProviderId),
|
||||
Name: domain.Name,
|
||||
IsOn: domain.IsOn,
|
||||
IsUp: domain.IsUp == 1,
|
||||
IsDeleted: domain.IsDeleted == 1,
|
||||
IsUp: domain.IsUp,
|
||||
IsDeleted: domain.IsDeleted,
|
||||
DataUpdatedAt: int64(domain.DataUpdatedAt),
|
||||
CountNodeRecords: int64(countNodeRecords),
|
||||
NodesChanged: nodesChanged,
|
||||
@@ -834,7 +834,7 @@ func (this *DNSDomainService) SyncDNSDomainsFromProvider(ctx context.Context, re
|
||||
return nil, err
|
||||
}
|
||||
hasChanges = true
|
||||
} else if domain.IsUp == 0 {
|
||||
} else if !domain.IsUp {
|
||||
err = dns.SharedDNSDomainDAO.UpdateDomainIsUp(tx, int64(domain.Id), true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -846,7 +846,7 @@ func (this *DNSDomainService) SyncDNSDomainsFromProvider(ctx context.Context, re
|
||||
// 将老的域名置为下线
|
||||
for _, oldDomain := range oldDomains {
|
||||
var domainName = oldDomain.Name
|
||||
if oldDomain.IsUp == 1 && !lists.ContainsString(domainNames, domainName) {
|
||||
if oldDomain.IsUp && !lists.ContainsString(domainNames, domainName) {
|
||||
err = dns.SharedDNSDomainDAO.UpdateDomainIsUp(tx, int64(oldDomain.Id), false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -55,8 +55,8 @@ func (this *DNSTaskService) FindAllDoingDNSTasks(ctx context.Context, req *pb.Fi
|
||||
pbTask := &pb.DNSTask{
|
||||
Id: int64(task.Id),
|
||||
Type: task.Type,
|
||||
IsDone: task.IsDone == 1,
|
||||
IsOk: task.IsOk == 1,
|
||||
IsDone: task.IsDone,
|
||||
IsOk: task.IsOk,
|
||||
Error: task.Error,
|
||||
UpdatedAt: int64(task.UpdatedAt),
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ func (this *FileService) FindEnabledFile(ctx context.Context, req *pb.FindEnable
|
||||
return &pb.FindEnabledFileResponse{File: nil}, nil
|
||||
}
|
||||
|
||||
if file.IsPublic != 1 {
|
||||
if !file.IsPublic {
|
||||
// 校验权限
|
||||
if userId > 0 && int64(file.UserId) != userId {
|
||||
return nil, this.PermissionError()
|
||||
@@ -40,7 +40,7 @@ func (this *FileService) FindEnabledFile(ctx context.Context, req *pb.FindEnable
|
||||
Filename: file.Filename,
|
||||
Size: int64(file.Size),
|
||||
CreatedAt: int64(file.CreatedAt),
|
||||
IsPublic: file.IsPublic == 1,
|
||||
IsPublic: file.IsPublic,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ func (this *HTTPAccessLogPolicyService) ListEnabledHTTPAccessLogPolicies(ctx con
|
||||
Type: policy.Type,
|
||||
OptionsJSON: policy.Options,
|
||||
CondsJSON: policy.Conds,
|
||||
IsPublic: policy.IsPublic == 1,
|
||||
IsPublic: policy.IsPublic,
|
||||
})
|
||||
}
|
||||
return &pb.ListEnabledHTTPAccessLogPoliciesResponse{HttpAccessLogPolicies: pbPolicies}, nil
|
||||
@@ -125,7 +125,7 @@ func (this *HTTPAccessLogPolicyService) FindEnabledHTTPAccessLogPolicy(ctx conte
|
||||
Type: policy.Type,
|
||||
OptionsJSON: policy.Options,
|
||||
CondsJSON: policy.Conds,
|
||||
IsPublic: policy.IsPublic == 1,
|
||||
IsPublic: policy.IsPublic,
|
||||
}}, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -280,7 +280,7 @@ func (this *IPItemService) ListIPItemsWithListId(ctx context.Context, req *pb.Li
|
||||
SourceHTTPFirewallPolicy: pbSourcePolicy,
|
||||
SourceHTTPFirewallRuleGroup: pbSourceGroup,
|
||||
SourceHTTPFirewallRuleSet: pbSourceSet,
|
||||
IsRead: item.IsRead == 1,
|
||||
IsRead: item.IsRead,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -383,7 +383,7 @@ func (this *IPItemService) ListIPItemsAfterVersion(ctx context.Context, req *pb.
|
||||
Type: item.Type,
|
||||
EventLevel: item.EventLevel,
|
||||
ListType: list.Type,
|
||||
IsGlobal: list.IsPublic == 1 && list.IsGlobal == 1,
|
||||
IsGlobal: list.IsPublic && list.IsGlobal,
|
||||
NodeId: int64(item.NodeId),
|
||||
ServerId: int64(item.ServerId),
|
||||
})
|
||||
@@ -604,7 +604,7 @@ func (this *IPItemService) ListAllEnabledIPItems(ctx context.Context, req *pb.Li
|
||||
SourceHTTPFirewallRuleGroup: pbSourceGroup,
|
||||
SourceHTTPFirewallRuleSet: pbSourceSet,
|
||||
SourceNode: pbSourceNode,
|
||||
IsRead: item.IsRead == 1,
|
||||
IsRead: item.IsRead,
|
||||
}
|
||||
|
||||
// 所属名单
|
||||
@@ -623,8 +623,8 @@ func (this *IPItemService) ListAllEnabledIPItems(ctx context.Context, req *pb.Li
|
||||
Id: int64(list.Id),
|
||||
Name: list.Name,
|
||||
Type: list.Type,
|
||||
IsPublic: list.IsPublic == 1,
|
||||
IsGlobal: list.IsGlobal == 1,
|
||||
IsPublic: list.IsPublic,
|
||||
IsGlobal: list.IsGlobal,
|
||||
}
|
||||
|
||||
// 所属服务(注意同SourceServer不同)
|
||||
@@ -632,7 +632,7 @@ func (this *IPItemService) ListAllEnabledIPItems(ctx context.Context, req *pb.Li
|
||||
|
||||
// 所属策略(注意同SourceHTTPFirewallPolicy不同)
|
||||
var pbFirewallPolicy *pb.HTTPFirewallPolicy
|
||||
if list.IsPublic == 0 {
|
||||
if !list.IsPublic {
|
||||
policy, err := models.SharedHTTPFirewallPolicyDAO.FindEnabledFirewallPolicyWithIPListId(tx, int64(list.Id))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -72,7 +72,7 @@ func (this *IPListService) FindEnabledIPList(ctx context.Context, req *pb.FindEn
|
||||
Code: list.Code,
|
||||
TimeoutJSON: list.Timeout,
|
||||
Description: list.Description,
|
||||
IsGlobal: list.IsGlobal == 1,
|
||||
IsGlobal: list.IsGlobal,
|
||||
}}, nil
|
||||
}
|
||||
|
||||
@@ -112,9 +112,9 @@ func (this *IPListService) ListEnabledIPLists(ctx context.Context, req *pb.ListE
|
||||
Name: list.Name,
|
||||
Code: list.Code,
|
||||
TimeoutJSON: list.Timeout,
|
||||
IsPublic: list.IsPublic == 1,
|
||||
IsPublic: list.IsPublic,
|
||||
Description: list.Description,
|
||||
IsGlobal: list.IsGlobal == 1,
|
||||
IsGlobal: list.IsGlobal,
|
||||
})
|
||||
}
|
||||
return &pb.ListEnabledIPListsResponse{IpLists: pbLists}, nil
|
||||
@@ -185,7 +185,7 @@ func (this *IPListService) FindEnabledIPListContainsIP(ctx context.Context, req
|
||||
if list == nil {
|
||||
continue
|
||||
}
|
||||
if list.IsPublic != 1 {
|
||||
if !list.IsPublic {
|
||||
continue
|
||||
}
|
||||
pbLists = append(pbLists, &pb.IPList{
|
||||
@@ -194,8 +194,8 @@ func (this *IPListService) FindEnabledIPListContainsIP(ctx context.Context, req
|
||||
Type: list.Type,
|
||||
Name: list.Name,
|
||||
Code: list.Code,
|
||||
IsPublic: list.IsPublic == 1,
|
||||
IsGlobal: list.IsGlobal == 1,
|
||||
IsPublic: list.IsPublic,
|
||||
IsGlobal: list.IsGlobal,
|
||||
Description: "",
|
||||
})
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ func (this *MessageService) ListUnreadMessages(ctx context.Context, req *pb.List
|
||||
Body: message.Body,
|
||||
Level: message.Level,
|
||||
ParamsJSON: message.Params,
|
||||
IsRead: message.IsRead == 1,
|
||||
IsRead: message.IsRead,
|
||||
CreatedAt: int64(message.CreatedAt),
|
||||
NodeCluster: pbCluster,
|
||||
Node: pbNode,
|
||||
|
||||
@@ -75,7 +75,7 @@ func (this *MessageTaskLogService) ListMessageTaskLogs(ctx context.Context, req
|
||||
pbLogs = append(pbLogs, &pb.MessageTaskLog{
|
||||
Id: int64(log.Id),
|
||||
CreatedAt: int64(log.CreatedAt),
|
||||
IsOk: log.IsOk == 1,
|
||||
IsOk: log.IsOk,
|
||||
Error: log.Error,
|
||||
Response: log.Response,
|
||||
MessageTask: &pb.MessageTask{
|
||||
|
||||
@@ -69,7 +69,7 @@ func (this *MetricItemService) FindEnabledMetricItem(ctx context.Context, req *p
|
||||
Period: types.Int32(item.Period),
|
||||
PeriodUnit: item.PeriodUnit,
|
||||
Value: item.Value,
|
||||
IsPublic: item.IsPublic == 1,
|
||||
IsPublic: item.IsPublic,
|
||||
}}, nil
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ func (this *MetricItemService) ListEnabledMetricItems(ctx context.Context, req *
|
||||
Period: types.Int32(item.Period),
|
||||
PeriodUnit: item.PeriodUnit,
|
||||
Value: item.Value,
|
||||
IsPublic: item.IsPublic == 1,
|
||||
IsPublic: item.IsPublic,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -313,7 +313,7 @@ func (this *NodeService) ListEnabledNodesMatch(ctx context.Context, req *pb.List
|
||||
Id: int64(node.Id),
|
||||
Name: node.Name,
|
||||
Version: int64(node.Version),
|
||||
IsInstalled: node.IsInstalled == 1,
|
||||
IsInstalled: node.IsInstalled,
|
||||
StatusJSON: node.Status,
|
||||
NodeCluster: &pb.NodeCluster{
|
||||
Id: int64(node.ClusterId),
|
||||
@@ -323,7 +323,7 @@ func (this *NodeService) ListEnabledNodesMatch(ctx context.Context, req *pb.List
|
||||
InstallStatus: installStatusResult,
|
||||
MaxCPU: types.Int32(node.MaxCPU),
|
||||
IsOn: node.IsOn,
|
||||
IsUp: node.IsUp == 1,
|
||||
IsUp: node.IsUp,
|
||||
NodeGroup: pbGroup,
|
||||
NodeRegion: pbRegion,
|
||||
DnsRoutes: pbRoutes,
|
||||
@@ -563,7 +563,7 @@ func (this *NodeService) FindEnabledNode(ctx context.Context, req *pb.FindEnable
|
||||
LatestVersion: int64(node.LatestVersion),
|
||||
Secret: node.Secret,
|
||||
InstallDir: node.InstallDir,
|
||||
IsInstalled: node.IsInstalled == 1,
|
||||
IsInstalled: node.IsInstalled,
|
||||
NodeCluster: &pb.NodeCluster{
|
||||
Id: int64(node.ClusterId),
|
||||
Name: clusterName,
|
||||
@@ -573,7 +573,7 @@ func (this *NodeService) FindEnabledNode(ctx context.Context, req *pb.FindEnable
|
||||
InstallStatus: installStatusResult,
|
||||
MaxCPU: types.Int32(node.MaxCPU),
|
||||
IsOn: node.IsOn,
|
||||
IsUp: node.IsUp == 1,
|
||||
IsUp: node.IsUp,
|
||||
NodeGroup: pbGroup,
|
||||
NodeRegion: pbRegion,
|
||||
MaxCacheDiskCapacity: pbMaxCacheDiskCapacity,
|
||||
@@ -607,7 +607,7 @@ func (this *NodeService) FindEnabledBasicNode(ctx context.Context, req *pb.FindE
|
||||
Id: int64(node.Id),
|
||||
Name: node.Name,
|
||||
IsOn: node.IsOn,
|
||||
IsUp: node.IsUp == 1,
|
||||
IsUp: node.IsUp,
|
||||
NodeCluster: &pb.NodeCluster{
|
||||
Id: int64(node.ClusterId),
|
||||
Name: clusterName,
|
||||
@@ -875,7 +875,7 @@ func (this *NodeService) FindAllEnabledNodesWithNodeGrantId(ctx context.Context,
|
||||
Id: int64(node.Id),
|
||||
Name: node.Name,
|
||||
Version: int64(node.Version),
|
||||
IsInstalled: node.IsInstalled == 1,
|
||||
IsInstalled: node.IsInstalled,
|
||||
StatusJSON: node.Status,
|
||||
NodeCluster: &pb.NodeCluster{
|
||||
Id: int64(node.ClusterId),
|
||||
@@ -948,7 +948,7 @@ func (this *NodeService) FindAllNotInstalledNodesWithNodeClusterId(ctx context.C
|
||||
Description: address.Description,
|
||||
State: int64(address.State),
|
||||
Order: int64(address.Order),
|
||||
CanAccess: address.CanAccess == 1,
|
||||
CanAccess: address.CanAccess,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -973,7 +973,7 @@ func (this *NodeService) FindAllNotInstalledNodesWithNodeClusterId(ctx context.C
|
||||
Id: int64(node.Id),
|
||||
Name: node.Name,
|
||||
Version: int64(node.Version),
|
||||
IsInstalled: node.IsInstalled == 1,
|
||||
IsInstalled: node.IsInstalled,
|
||||
StatusJSON: node.Status,
|
||||
IsOn: node.IsOn,
|
||||
NodeLogin: pbLogin,
|
||||
@@ -1057,7 +1057,7 @@ func (this *NodeService) FindAllUpgradeNodesWithNodeClusterId(ctx context.Contex
|
||||
Description: address.Description,
|
||||
State: int64(address.State),
|
||||
Order: int64(address.Order),
|
||||
CanAccess: address.CanAccess == 1,
|
||||
CanAccess: address.CanAccess,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1091,7 +1091,7 @@ func (this *NodeService) FindAllUpgradeNodesWithNodeClusterId(ctx context.Contex
|
||||
Id: int64(node.Id),
|
||||
Name: node.Name,
|
||||
Version: int64(node.Version),
|
||||
IsInstalled: node.IsInstalled == 1,
|
||||
IsInstalled: node.IsInstalled,
|
||||
StatusJSON: node.Status,
|
||||
IsOn: node.IsOn,
|
||||
IpAddresses: pbAddresses,
|
||||
@@ -1452,7 +1452,7 @@ func (this *NodeService) FindEnabledNodesWithIds(ctx context.Context, req *pb.Fi
|
||||
pbNodes = append(pbNodes, &pb.Node{
|
||||
Id: int64(node.Id),
|
||||
IsOn: node.IsOn,
|
||||
IsActive: node.IsActive == 1,
|
||||
IsActive: node.IsActive,
|
||||
ConnectedAPINodeIds: connectedAPINodeIds,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -298,7 +298,7 @@ func (this *NodeClusterService) ListEnabledNodeClusters(ctx context.Context, req
|
||||
DnsDomainId: int64(cluster.DnsDomainId),
|
||||
IsOn: cluster.IsOn,
|
||||
TimeZone: cluster.TimeZone,
|
||||
IsPinned: cluster.IsPinned == 1,
|
||||
IsPinned: cluster.IsPinned,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ func (this *NodeClusterMetricItemService) FindAllNodeClusterMetricItems(ctx cont
|
||||
Period: types.Int32(item.Period),
|
||||
PeriodUnit: item.PeriodUnit,
|
||||
Value: item.Value,
|
||||
IsPublic: item.IsPublic == 1,
|
||||
IsPublic: item.IsPublic,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,9 +155,9 @@ func (this *NodeIPAddressService) FindEnabledNodeIPAddress(ctx context.Context,
|
||||
Description: address.Description,
|
||||
State: int64(address.State),
|
||||
Order: int64(address.Order),
|
||||
CanAccess: address.CanAccess == 1,
|
||||
CanAccess: address.CanAccess,
|
||||
IsOn: address.IsOn,
|
||||
IsUp: address.IsUp == 1,
|
||||
IsUp: address.IsUp,
|
||||
BackupIP: address.DecodeBackupIP(),
|
||||
}
|
||||
}
|
||||
@@ -191,9 +191,9 @@ func (this *NodeIPAddressService) FindAllEnabledNodeIPAddressesWithNodeId(ctx co
|
||||
Description: address.Description,
|
||||
State: int64(address.State),
|
||||
Order: int64(address.Order),
|
||||
CanAccess: address.CanAccess == 1,
|
||||
CanAccess: address.CanAccess,
|
||||
IsOn: address.IsOn,
|
||||
IsUp: address.IsUp == 1,
|
||||
IsUp: address.IsUp,
|
||||
BackupIP: address.DecodeBackupIP(),
|
||||
})
|
||||
}
|
||||
@@ -241,9 +241,9 @@ func (this *NodeIPAddressService) ListEnabledNodeIPAddresses(ctx context.Context
|
||||
Name: addr.Name,
|
||||
Ip: addr.Ip,
|
||||
Description: addr.Description,
|
||||
CanAccess: addr.CanAccess == 1,
|
||||
CanAccess: addr.CanAccess,
|
||||
IsOn: addr.IsOn,
|
||||
IsUp: addr.IsUp == 1,
|
||||
IsUp: addr.IsUp,
|
||||
BackupIP: addr.DecodeBackupIP(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -79,8 +79,8 @@ func (this *NodeIPAddressLogService) ListNodeIPAddressLogs(ctx context.Context,
|
||||
Description: log.Description,
|
||||
CreatedAt: int64(log.CreatedAt),
|
||||
IsOn: log.IsOn,
|
||||
IsUp: log.IsUp == 1,
|
||||
CanAccess: log.CanAccess == 1,
|
||||
IsUp: log.IsUp,
|
||||
CanAccess: log.CanAccess,
|
||||
BackupIP: log.BackupIP,
|
||||
NodeIPAddress: pbAddr,
|
||||
Admin: pbAdmin,
|
||||
|
||||
@@ -84,8 +84,8 @@ func (this *NodeLogService) ListNodeLogs(ctx context.Context, req *pb.ListNodeLo
|
||||
ServerId: int64(log.ServerId),
|
||||
CreatedAt: int64(log.CreatedAt),
|
||||
Count: types.Int32(log.Count),
|
||||
IsFixed: log.IsFixed == 1,
|
||||
IsRead: log.IsRead == 1,
|
||||
IsFixed: log.IsFixed,
|
||||
IsRead: log.IsRead,
|
||||
})
|
||||
}
|
||||
return &pb.ListNodeLogsResponse{NodeLogs: result}, nil
|
||||
|
||||
@@ -126,16 +126,16 @@ func (this *NodeTaskService) FindNodeClusterTasks(ctx context.Context, req *pb.F
|
||||
|
||||
// 是否超时(N秒内没有更新)
|
||||
if int64(task.UpdatedAt) < time.Now().Unix()-120 {
|
||||
task.IsDone = 1
|
||||
task.IsOk = 0
|
||||
task.IsDone = true
|
||||
task.IsOk = false
|
||||
task.Error = "节点响应超时"
|
||||
}
|
||||
|
||||
pbNodeTasks = append(pbNodeTasks, &pb.NodeTask{
|
||||
Id: int64(task.Id),
|
||||
Type: task.Type,
|
||||
IsDone: task.IsDone == 1,
|
||||
IsOk: task.IsOk == 1,
|
||||
IsDone: task.IsDone,
|
||||
IsOk: task.IsOk,
|
||||
Error: task.Error,
|
||||
UpdatedAt: int64(task.UpdatedAt),
|
||||
ServerId: int64(task.ServerId),
|
||||
@@ -258,8 +258,8 @@ func (this *NodeTaskService) FindNotifyingNodeTasks(ctx context.Context, req *pb
|
||||
pbTasks = append(pbTasks, &pb.NodeTask{
|
||||
Id: int64(task.Id),
|
||||
Type: task.Type,
|
||||
IsDone: task.IsDone == 1,
|
||||
IsOk: task.IsOk == 1,
|
||||
IsDone: task.IsDone,
|
||||
IsOk: task.IsOk,
|
||||
Error: task.Error,
|
||||
UpdatedAt: int64(task.UpdatedAt),
|
||||
Node: &pb.Node{Id: int64(task.NodeId)},
|
||||
|
||||
@@ -700,7 +700,7 @@ func (this *ServerService) ListEnabledServersMatch(ctx context.Context, req *pb.
|
||||
IncludeNodes: server.IncludeNodes,
|
||||
ExcludeNodes: server.ExcludeNodes,
|
||||
ServerNamesJSON: server.ServerNames,
|
||||
IsAuditing: server.IsAuditing == 1,
|
||||
IsAuditing: server.IsAuditing,
|
||||
AuditingAt: int64(server.AuditingAt),
|
||||
AuditingServerNamesJSON: server.AuditingServerNames,
|
||||
AuditingResult: auditingResult,
|
||||
|
||||
@@ -220,13 +220,13 @@ func (this *SSLCertService) ListSSLCertsWithOCSPError(ctx context.Context, req *
|
||||
TimeEndAt: types.Int64(cert.TimeEndAt),
|
||||
DnsNames: cert.DecodeDNSNames(),
|
||||
CommonNames: cert.DecodeCommonNames(),
|
||||
IsACME: cert.IsACME == 1,
|
||||
IsACME: cert.IsACME,
|
||||
AcmeTaskId: int64(cert.AcmeTaskId),
|
||||
Ocsp: cert.Ocsp,
|
||||
OcspIsUpdated: cert.OcspIsUpdated == 1,
|
||||
OcspError: cert.OcspError,
|
||||
Description: cert.Description,
|
||||
IsCA: cert.IsCA == 1,
|
||||
IsCA: cert.IsCA,
|
||||
ServerName: cert.ServerName,
|
||||
CreatedAt: int64(cert.CreatedAt),
|
||||
UpdatedAt: int64(cert.UpdatedAt),
|
||||
|
||||
@@ -221,8 +221,8 @@ func (this *UserService) ListEnabledUsers(ctx context.Context, req *pb.ListEnabl
|
||||
Remark: user.Remark,
|
||||
IsOn: user.IsOn,
|
||||
RegisteredIP: user.RegisteredIP,
|
||||
IsVerified: user.IsVerified == 1,
|
||||
IsRejected: user.IsRejected == 1,
|
||||
IsVerified: user.IsVerified,
|
||||
IsRejected: user.IsRejected,
|
||||
CreatedAt: int64(user.CreatedAt),
|
||||
NodeCluster: pbCluster,
|
||||
})
|
||||
@@ -272,8 +272,8 @@ func (this *UserService) FindEnabledUser(ctx context.Context, req *pb.FindEnable
|
||||
IsOn: user.IsOn,
|
||||
CreatedAt: int64(user.CreatedAt),
|
||||
RegisteredIP: user.RegisteredIP,
|
||||
IsVerified: user.IsVerified == 1,
|
||||
IsRejected: user.IsRejected == 1,
|
||||
IsVerified: user.IsVerified,
|
||||
IsRejected: user.IsRejected,
|
||||
RejectReason: user.RejectReason,
|
||||
NodeCluster: pbCluster,
|
||||
}}, nil
|
||||
|
||||
@@ -95,8 +95,8 @@ func (this *UserBillService) ListUserBills(ctx context.Context, req *pb.ListUser
|
||||
Description: bill.Description,
|
||||
Amount: float32(bill.Amount),
|
||||
Month: bill.Month,
|
||||
CanPay: bill.CanPay == 1,
|
||||
IsPaid: bill.IsPaid == 1,
|
||||
CanPay: bill.CanPay,
|
||||
IsPaid: bill.IsPaid,
|
||||
PaidAt: int64(bill.PaidAt),
|
||||
Code: bill.Code,
|
||||
})
|
||||
@@ -153,8 +153,8 @@ func (this *UserBillService) FindUserBill(ctx context.Context, req *pb.FindUserB
|
||||
Description: bill.Description,
|
||||
Amount: float32(bill.Amount),
|
||||
Month: bill.Month,
|
||||
CanPay: bill.CanPay == 1,
|
||||
IsPaid: bill.IsPaid == 1,
|
||||
CanPay: bill.CanPay,
|
||||
IsPaid: bill.IsPaid,
|
||||
PaidAt: int64(bill.PaidAt),
|
||||
Code: bill.Code,
|
||||
},
|
||||
@@ -188,7 +188,7 @@ func (this *UserBillService) PayUserBill(ctx context.Context, req *pb.PayUserBil
|
||||
userId = int64(bill.UserId)
|
||||
|
||||
// 是否已支付
|
||||
if bill.IsPaid == 1 {
|
||||
if bill.IsPaid {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ func (this *UserBillService) PayUserBill(ctx context.Context, req *pb.PayUserBil
|
||||
return models.SharedUserBillDAO.UpdateUserBillIsPaid(tx, req.UserBillId, true)
|
||||
}
|
||||
|
||||
if bill.CanPay == 0 {
|
||||
if !bill.CanPay {
|
||||
return errors.New("can not pay now")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user