节点状态中增加时间戳字段

This commit is contained in:
刘祥超
2022-06-06 19:39:08 +08:00
parent a2f98d2f25
commit 3c4b7ca57b
9 changed files with 108 additions and 31 deletions

View File

@@ -18,6 +18,7 @@ import (
stringutil "github.com/iwind/TeaGo/utils/string"
"io"
"path/filepath"
"time"
)
// NSNodeService 域名服务器节点服务
@@ -398,9 +399,18 @@ func (this *NSNodeService) UpdateNSNodeStatus(ctx context.Context, req *pb.Updat
return nil, errors.New("'nodeId' should be greater than 0")
}
tx := this.NullTx()
var tx = this.NullTx()
err = models.SharedNSNodeDAO.UpdateNodeStatus(tx, nodeId, req.StatusJSON)
// 修改时间戳
var nodeStatus = &nodeconfigs.NodeStatus{}
err = json.Unmarshal(req.StatusJSON, nodeStatus)
if err != nil {
return nil, errors.New("decode node status json failed: " + err.Error())
}
nodeStatus.UpdatedAt = time.Now().Unix()
// 保存
err = models.SharedNSNodeDAO.UpdateNodeStatus(tx, nodeId, nodeStatus)
if err != nil {
return nil, err
}