fix Node节点删除问题

This commit is contained in:
陈景阳
2019-07-30 16:06:35 +08:00
parent 1c48298269
commit 24cba1dfaf
3 changed files with 20 additions and 1 deletions

View File

@@ -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) // 爬虫详情

View File

@@ -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",
})
}