优化代码

This commit is contained in:
GoEdgeLab
2022-07-22 15:05:30 +08:00
parent 95e849c998
commit 7f64c98d88
72 changed files with 675 additions and 628 deletions

View File

@@ -20,7 +20,7 @@ func (this *APINodeService) CreateAPINode(ctx context.Context, req *pb.CreateAPI
return nil, err
}
tx := this.NullTx()
var tx = this.NullTx()
nodeId, err := models.SharedAPINodeDAO.CreateAPINode(tx, req.Name, req.Description, req.HttpJSON, req.HttpsJSON, req.RestIsOn, req.RestHTTPJSON, req.RestHTTPSJSON, req.AccessAddrsJSON, req.IsOn)
if err != nil {
@@ -37,7 +37,7 @@ func (this *APINodeService) UpdateAPINode(ctx context.Context, req *pb.UpdateAPI
return nil, err
}
tx := this.NullTx()
var tx = this.NullTx()
err = models.SharedAPINodeDAO.UpdateAPINode(tx, req.ApiNodeId, req.Name, req.Description, req.HttpJSON, req.HttpsJSON, req.RestIsOn, req.RestHTTPJSON, req.RestHTTPSJSON, req.AccessAddrsJSON, req.IsOn, req.IsPrimary)
if err != nil {
@@ -54,7 +54,7 @@ func (this *APINodeService) DeleteAPINode(ctx context.Context, req *pb.DeleteAPI
return nil, err
}
tx := this.NullTx()
var tx = this.NullTx()
err = models.SharedAPINodeDAO.DisableAPINode(tx, req.ApiNodeId)
if err != nil {
@@ -71,7 +71,7 @@ func (this *APINodeService) FindAllEnabledAPINodes(ctx context.Context, req *pb.
return nil, err
}
tx := this.NullTx()
var tx = this.NullTx()
nodes, err := models.SharedAPINodeDAO.FindAllEnabledAPINodes(tx)
if err != nil {
@@ -111,7 +111,7 @@ func (this *APINodeService) CountAllEnabledAPINodes(ctx context.Context, req *pb
return nil, err
}
tx := this.NullTx()
var tx = this.NullTx()
count, err := models.SharedAPINodeDAO.CountAllEnabledAPINodes(tx)
if err != nil {
@@ -128,7 +128,7 @@ func (this *APINodeService) CountAllEnabledAndOnAPINodes(ctx context.Context, re
return nil, err
}
tx := this.NullTx()
var tx = this.NullTx()
count, err := models.SharedAPINodeDAO.CountAllEnabledAndOnAPINodes(tx)
if err != nil {
@@ -145,7 +145,7 @@ func (this *APINodeService) ListEnabledAPINodes(ctx context.Context, req *pb.Lis
return nil, err
}
tx := this.NullTx()
var tx = this.NullTx()
nodes, err := models.SharedAPINodeDAO.ListEnabledAPINodes(tx, req.Offset, req.Size)
if err != nil {
@@ -184,12 +184,12 @@ func (this *APINodeService) ListEnabledAPINodes(ctx context.Context, req *pb.Lis
// FindEnabledAPINode 根据ID查找节点
func (this *APINodeService) FindEnabledAPINode(ctx context.Context, req *pb.FindEnabledAPINodeRequest) (*pb.FindEnabledAPINodeResponse, error) {
_, _, err := this.ValidateAdminAndUser(ctx, 0, 0)
_, _, err := this.ValidateAdminAndUser(ctx)
if err != nil {
return nil, err
}
tx := this.NullTx()
var tx = this.NullTx()
node, err := models.SharedAPINodeDAO.FindEnabledAPINode(tx, req.ApiNodeId, nil)
if err != nil {