diff --git a/backend/model/node.go b/backend/model/node.go index 63461ced..4c51e41d 100644 --- a/backend/model/node.go +++ b/backend/model/node.go @@ -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"` } diff --git a/backend/routes/node.go b/backend/routes/node.go index e9233b76..756af958 100644 --- a/backend/routes/node.go +++ b/backend/routes/node.go @@ -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, }) }