From d279022520262b8fb8fc985df3bb19df19192a2f Mon Sep 17 00:00:00 2001
From: liuxiaolong <736321739@qq.com>
Date: 星期四, 22 八月 2019 19:57:07 +0800
Subject: [PATCH] add cluster updateName and leave
---
controllers/cluster.go | 39 +++++++++++++++++++++++++++++++++++++++
router/router.go | 2 ++
2 files changed, 41 insertions(+), 0 deletions(-)
diff --git a/controllers/cluster.go b/controllers/cluster.go
index e9b77b5..7ac903d 100644
--- a/controllers/cluster.go
+++ b/controllers/cluster.go
@@ -199,3 +199,42 @@
util.ResponseFormat(c,code.ComError,"鍔犲叆澶辫触")
}
}
+
+// @Summary 淇濆瓨闆嗙兢鍚嶇О
+// @Description 淇濆瓨闆嗙兢鍚嶇О
+// @Produce json
+// @Tags cluster
+// @Param clusterName query string true "闆嗙兢鍚嶇О"
+// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
+// @Failure 500 {string} json "{"code":500, success:false, msg:"",data:""}"
+// @Router /data/api-v/cluster/updateClusterName [post]
+func (cc ClusterController) UpdateClusterName(c *gin.Context) {
+ clusterName := c.PostForm("clusterName")
+ if clusterName == "" {
+ util.ResponseFormat(c,code.RequestParamError, "鍙傛暟鏈夎")
+ return
+ }
+ var api dbapi.ClusterApi
+ b,_ := api.UpdateClusterName(clusterName)
+ if b {
+ util.ResponseFormat(c,code.UpdateSuccess,"鏇存柊鎴愬姛")
+ } else {
+ util.ResponseFormat(c,code.ComError, "鏇存柊澶辫触")
+ }
+}
+
+// @Summary 閫�鍑洪泦缇�
+// @Description 閫�鍑洪泦缇�
+// @Produce json
+// @Tags cluster
+// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
+// @Failure 500 {string} json "{"code":500, success:false, msg:"",data:""}"
+// @Router /data/api-v/cluster/leave [post]
+func (cc ClusterController) Leave(c *gin.Context) {
+ var api dbapi.ClusterApi
+ if b,_:= api.Leave();b {
+ util.ResponseFormat(c,code.Success,"閫�鍑烘垚鍔�")
+ } else {
+ util.ResponseFormat(c,code.ComError,"閫�鍑哄け璐�")
+ }
+}
\ No newline at end of file
diff --git a/router/router.go b/router/router.go
index b10b63c..7680086 100644
--- a/router/router.go
+++ b/router/router.go
@@ -233,6 +233,8 @@
clusterApi.POST("/stopSearching", clusterController.StopSearching)
clusterApi.GET("/getSearchNodes", clusterController.GetSearchNodes)
clusterApi.POST("/joinCluster", clusterController.JoinCluster)
+ clusterApi.POST("/updateClusterName", clusterController.UpdateClusterName)
+ clusterApi.POST("/leave", clusterController.Leave)
}
// 鏂囦欢 涓婁紶
--
Gitblit v1.8.0