From 24cba1dfaf242e67b45d39d33cfcd0ad87e574f6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=99=88=E6=99=AF=E9=98=B3?= <1656488874@qq.com>
Date: Tue, 30 Jul 2019 16:06:35 +0800
Subject: [PATCH] =?UTF-8?q?fix=20Node=E8=8A=82=E7=82=B9=E5=88=A0=E9=99=A4?=
=?UTF-8?q?=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
backend/main.go | 1 +
backend/routes/node.go | 18 ++++++++++++++++++
frontend/src/views/node/NodeList.vue | 2 +-
3 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/backend/main.go b/backend/main.go
index a7d23c35..7feb9ffc 100644
--- a/backend/main.go
+++ b/backend/main.go
@@ -91,6 +91,7 @@ func main() {
app.POST("/nodes/:id", routes.PostNode) // 修改节点
app.GET("/nodes/:id/tasks", routes.GetNodeTaskList) // 节点任务列表
app.GET("/nodes/:id/system", routes.GetSystemInfo) // 节点任务列表
+ app.DELETE("/nodes/:id", routes.DeleteNode) // 删除节点
// 爬虫
app.GET("/spiders", routes.GetSpiderList) // 爬虫列表
app.GET("/spiders/:id", routes.GetSpider) // 爬虫详情
diff --git a/backend/routes/node.go b/backend/routes/node.go
index 756af958..f86c152d 100644
--- a/backend/routes/node.go
+++ b/backend/routes/node.go
@@ -108,3 +108,21 @@ func GetSystemInfo(c *gin.Context) {
Data: sysInfo,
})
}
+
+func DeleteNode(c *gin.Context) {
+ id := c.Param("id")
+ node, err := model.GetNode(bson.ObjectIdHex(id))
+ if err != nil {
+ HandleError(http.StatusInternalServerError, c ,err)
+ return
+ }
+ err = node.Delete()
+ if err != nil {
+ HandleError(http.StatusInternalServerError, c, err)
+ return
+ }
+ c.JSON(http.StatusOK, Response{
+ Status: "ok",
+ Message: "success",
+ })
+}
diff --git a/frontend/src/views/node/NodeList.vue b/frontend/src/views/node/NodeList.vue
index 3ec7ea18..8542d753 100644
--- a/frontend/src/views/node/NodeList.vue
+++ b/frontend/src/views/node/NodeList.vue
@@ -114,7 +114,7 @@
-
+