added network diagram

This commit is contained in:
Marvin Zhang
2019-07-24 21:03:30 +08:00
parent 41f5f8b989
commit 2fda41d9ee
2 changed files with 10 additions and 2 deletions

View File

@@ -18,6 +18,9 @@ type Node struct {
Mac string `json:"mac" bson:"mac"`
Description string `json:"description" bson:"description"`
// 前端展示
IsMaster bool `json:"is_master"`
UpdateTs time.Time `json:"update_ts" bson:"update_ts"`
CreateTs time.Time `json:"create_ts" bson:"create_ts"`
}

View File

@@ -9,15 +9,20 @@ import (
)
func GetNodeList(c *gin.Context) {
results, err := model.GetNodeList(nil)
nodes, err := model.GetNodeList(nil)
if err != nil {
HandleError(http.StatusInternalServerError, c, err)
return
}
for i, node := range nodes {
nodes[i].IsMaster = services.IsMasterNode(node.Id.Hex())
}
c.JSON(http.StatusOK, Response{
Status: "ok",
Message: "success",
Data: results,
Data: nodes,
})
}