mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-14 08:20:25 +08:00
字段中的blob和JSON类型映射为[]byte和dbs.JSON
This commit is contained in:
@@ -148,8 +148,8 @@ func (this *AdminService) FindEnabledAdmin(ctx context.Context, req *pb.FindEnab
|
||||
|
||||
pbModules := []*pb.AdminModule{}
|
||||
modules := []*systemconfigs.AdminModule{}
|
||||
if len(admin.Modules) > 0 && admin.Modules != "null" {
|
||||
err = json.Unmarshal([]byte(admin.Modules), &modules)
|
||||
if len(admin.Modules) > 0 {
|
||||
err = json.Unmarshal(admin.Modules, &modules)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -281,8 +281,8 @@ func (this *AdminService) FindAllAdminModules(ctx context.Context, req *pb.FindA
|
||||
result := []*pb.AdminModuleList{}
|
||||
for _, admin := range admins {
|
||||
modules := []*systemconfigs.AdminModule{}
|
||||
if len(admin.Modules) > 0 && admin.Modules != "null" {
|
||||
err = json.Unmarshal([]byte(admin.Modules), &modules)
|
||||
if len(admin.Modules) > 0 {
|
||||
err = json.Unmarshal(admin.Modules, &modules)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -331,8 +331,8 @@ func (this *DNSDomainService) convertDomainToPB(tx *dbs.Tx, domain *dns.DNSDomai
|
||||
}
|
||||
|
||||
records := []*dnstypes.Record{}
|
||||
if len(domain.Records) > 0 && domain.Records != "null" {
|
||||
err := json.Unmarshal([]byte(domain.Records), &records)
|
||||
if models.IsNotNull(domain.Records) {
|
||||
err := json.Unmarshal(domain.Records, &records)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -653,8 +653,8 @@ func (this *DNSDomainService) syncClusterDNS(req *pb.SyncDNSDomainDataRequest) (
|
||||
return &pb.SyncDNSDomainDataResponse{IsOk: false, Error: "域名没有设置服务商"}, nil
|
||||
}
|
||||
apiParams := maps.Map{}
|
||||
if len(provider.ApiParams) > 0 && provider.ApiParams != "null" {
|
||||
err = json.Unmarshal([]byte(provider.ApiParams), &apiParams)
|
||||
if models.IsNotNull(provider.ApiParams) {
|
||||
err = json.Unmarshal(provider.ApiParams, &apiParams)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -189,8 +189,8 @@ func (this *NodeClusterService) FindAPINodesWithNodeCluster(ctx context.Context,
|
||||
result.UseAllAPINodes = cluster.UseAllAPINodes == 1
|
||||
|
||||
apiNodeIds := []int64{}
|
||||
if len(cluster.ApiNodes) > 0 && cluster.ApiNodes != "null" {
|
||||
err = json.Unmarshal([]byte(cluster.ApiNodes), &apiNodeIds)
|
||||
if models.IsNotNull(cluster.ApiNodes) {
|
||||
err = json.Unmarshal(cluster.ApiNodes, &apiNodeIds)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -978,9 +978,9 @@ func (this *NodeClusterService) FindEnabledNodeClusterConfigInfo(ctx context.Con
|
||||
var result = &pb.FindEnabledNodeClusterConfigInfoResponse{}
|
||||
|
||||
// health check
|
||||
if len(cluster.HealthCheck) > 0 {
|
||||
if models.IsNotNull(cluster.HealthCheck) {
|
||||
healthCheckConfig := &serverconfigs.HealthCheckConfig{}
|
||||
err = json.Unmarshal([]byte(cluster.HealthCheck), healthCheckConfig)
|
||||
err = json.Unmarshal(cluster.HealthCheck, healthCheckConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1009,9 +1009,9 @@ func (this *NodeClusterService) FindEnabledNodeClusterConfigInfo(ctx context.Con
|
||||
result.HasMessageReceivers = countReceivers > 0
|
||||
|
||||
// toa
|
||||
if len(cluster.Toa) > 0 {
|
||||
if models.IsNotNull(cluster.Toa) {
|
||||
var toaConfig = &nodeconfigs.TOAConfig{}
|
||||
err = json.Unmarshal([]byte(cluster.Toa), toaConfig)
|
||||
err = json.Unmarshal(cluster.Toa, toaConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ func (this *ServerService) CreateServer(ctx context.Context, req *pb.CreateServe
|
||||
}
|
||||
}
|
||||
|
||||
serverId, err := models.SharedServerDAO.CreateServer(tx, req.AdminId, req.UserId, req.Type, req.Name, req.Description, serverNamesJSON, isAuditing, auditingServerNamesJSON, string(req.HttpJSON), string(req.HttpsJSON), string(req.TcpJSON), string(req.TlsJSON), string(req.UnixJSON), string(req.UdpJSON), req.WebId, req.ReverseProxyJSON, req.NodeClusterId, string(req.IncludeNodesJSON), string(req.ExcludeNodesJSON), req.ServerGroupIds, req.UserPlanId)
|
||||
serverId, err := models.SharedServerDAO.CreateServer(tx, req.AdminId, req.UserId, req.Type, req.Name, req.Description, serverNamesJSON, isAuditing, auditingServerNamesJSON, req.HttpJSON, req.HttpsJSON, req.TcpJSON, req.TlsJSON, req.UnixJSON, req.UdpJSON, req.WebId, req.ReverseProxyJSON, req.NodeClusterId, string(req.IncludeNodesJSON), string(req.ExcludeNodesJSON), req.ServerGroupIds, req.UserPlanId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -629,9 +629,9 @@ func (this *ServerService) ListEnabledServersMatch(ctx context.Context, req *pb.
|
||||
|
||||
// 分组信息
|
||||
pbGroups := []*pb.ServerGroup{}
|
||||
if len(server.GroupIds) > 0 {
|
||||
if models.IsNotNull(server.GroupIds) {
|
||||
groupIds := []int64{}
|
||||
err = json.Unmarshal([]byte(server.GroupIds), &groupIds)
|
||||
err = json.Unmarshal(server.GroupIds, &groupIds)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -666,7 +666,7 @@ func (this *ServerService) ListEnabledServersMatch(ctx context.Context, req *pb.
|
||||
// 审核结果
|
||||
auditingResult := &pb.ServerNameAuditingResult{}
|
||||
if len(server.AuditingResult) > 0 {
|
||||
err = json.Unmarshal([]byte(server.AuditingResult), auditingResult)
|
||||
err = json.Unmarshal(server.AuditingResult, auditingResult)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -691,18 +691,18 @@ func (this *ServerService) ListEnabledServersMatch(ctx context.Context, req *pb.
|
||||
Config: configJSON,
|
||||
Name: server.Name,
|
||||
Description: server.Description,
|
||||
HttpJSON: []byte(server.Http),
|
||||
HttpsJSON: []byte(server.Https),
|
||||
TcpJSON: []byte(server.Tcp),
|
||||
TlsJSON: []byte(server.Tls),
|
||||
UnixJSON: []byte(server.Unix),
|
||||
UdpJSON: []byte(server.Udp),
|
||||
IncludeNodes: []byte(server.IncludeNodes),
|
||||
ExcludeNodes: []byte(server.ExcludeNodes),
|
||||
ServerNamesJSON: []byte(server.ServerNames),
|
||||
HttpJSON: server.Http,
|
||||
HttpsJSON: server.Https,
|
||||
TcpJSON: server.Tcp,
|
||||
TlsJSON: server.Tls,
|
||||
UnixJSON: server.Unix,
|
||||
UdpJSON: server.Udp,
|
||||
IncludeNodes: server.IncludeNodes,
|
||||
ExcludeNodes: server.ExcludeNodes,
|
||||
ServerNamesJSON: server.ServerNames,
|
||||
IsAuditing: server.IsAuditing == 1,
|
||||
AuditingAt: int64(server.AuditingAt),
|
||||
AuditingServerNamesJSON: []byte(server.AuditingServerNames),
|
||||
AuditingServerNamesJSON: server.AuditingServerNames,
|
||||
AuditingResult: auditingResult,
|
||||
CreatedAt: int64(server.CreatedAt),
|
||||
DnsName: server.DnsName,
|
||||
@@ -782,7 +782,7 @@ func (this *ServerService) FindEnabledServer(ctx context.Context, req *pb.FindEn
|
||||
pbGroups := []*pb.ServerGroup{}
|
||||
if len(server.GroupIds) > 0 {
|
||||
groupIds := []int64{}
|
||||
err = json.Unmarshal([]byte(server.GroupIds), &groupIds)
|
||||
err = json.Unmarshal(server.GroupIds, &groupIds)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -838,18 +838,18 @@ func (this *ServerService) FindEnabledServer(ctx context.Context, req *pb.FindEn
|
||||
UserPlanId: int64(server.UserPlanId),
|
||||
|
||||
Config: configJSON,
|
||||
ServerNamesJSON: []byte(server.ServerNames),
|
||||
HttpJSON: []byte(server.Http),
|
||||
HttpsJSON: []byte(server.Https),
|
||||
TcpJSON: []byte(server.Tcp),
|
||||
TlsJSON: []byte(server.Tls),
|
||||
UnixJSON: []byte(server.Unix),
|
||||
UdpJSON: []byte(server.Udp),
|
||||
ServerNamesJSON: server.ServerNames,
|
||||
HttpJSON: server.Http,
|
||||
HttpsJSON: server.Https,
|
||||
TcpJSON: server.Tcp,
|
||||
TlsJSON: server.Tls,
|
||||
UnixJSON: server.Unix,
|
||||
UdpJSON: server.Udp,
|
||||
WebId: int64(server.WebId),
|
||||
ReverseProxyJSON: []byte(server.ReverseProxy),
|
||||
ReverseProxyJSON: server.ReverseProxy,
|
||||
|
||||
IncludeNodes: []byte(server.IncludeNodes),
|
||||
ExcludeNodes: []byte(server.ExcludeNodes),
|
||||
IncludeNodes: server.IncludeNodes,
|
||||
ExcludeNodes: server.ExcludeNodes,
|
||||
CreatedAt: int64(server.CreatedAt),
|
||||
NodeCluster: &pb.NodeCluster{
|
||||
Id: int64(server.ClusterId),
|
||||
@@ -1260,9 +1260,9 @@ func (this *ServerService) FindAllEnabledServerNamesWithUserId(ctx context.Conte
|
||||
}
|
||||
serverNames := []string{}
|
||||
for _, server := range servers {
|
||||
if len(server.ServerNames) > 0 && server.ServerNames != "null" {
|
||||
if models.IsNotNull(server.ServerNames) {
|
||||
serverNameConfigs := []*serverconfigs.ServerNameConfig{}
|
||||
err = json.Unmarshal([]byte(server.ServerNames), &serverNameConfigs)
|
||||
err = json.Unmarshal(server.ServerNames, &serverNameConfigs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user