From 2bd2068c999cda5bda8c0787ed0dcaac6cb7afdb Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@iotlink.com>
Date: 星期四, 31 十月 2019 13:27:46 +0800
Subject: [PATCH] feat: add system reboot api

---
 controllers/cluster.go |   64 +++++++++++++++++++++++++++-----
 1 files changed, 54 insertions(+), 10 deletions(-)

diff --git a/controllers/cluster.go b/controllers/cluster.go
index e9b77b5..f81dade 100644
--- a/controllers/cluster.go
+++ b/controllers/cluster.go
@@ -40,6 +40,7 @@
 	Password string `json:"password"`
 	ClusterName string `json:"clusterName"`
 	ClusterId string `json:"clusterId"`
+	VirtualIp string `json:"virtualIp"`
 }
 
 type ClusterSearchVo struct {
@@ -53,6 +54,7 @@
 	NodeIps []string `json:"nodeIps"`
 }
 
+// @Security ApiKeyAuth
 // @Summary 鍒涘缓闆嗙兢
 // @Description 鍒涘缓闆嗙兢
 // @Accept json
@@ -70,7 +72,7 @@
 		return
 	}
 	var api dbapi.ClusterApi
-	b, d := api.Create(clusterVo.ClusterName, clusterVo.Password)
+	b, d := api.Create(clusterVo.ClusterName, clusterVo.Password, clusterVo.VirtualIp)
 	if b {
 		util.ResponseFormat(c,code.Success, d)
 	} else {
@@ -78,6 +80,7 @@
 	}
 }
 
+// @Security ApiKeyAuth
 // @Summary 鐢熸垚闆嗙兢6浣嶉殢鏈哄瘑鐮�
 // @Description 鐢熸垚闆嗙兢6浣嶉殢鏈哄瘑鐮�
 // @Produce json
@@ -90,6 +93,7 @@
 	util.ResponseFormat(c,code.Success,pwd)
 }
 
+// @Security ApiKeyAuth
 // @Summary 鏌ヨ鏈湴闆嗙兢
 // @Description 鏌ヨ鏈湴闆嗙兢
 // @Produce json
@@ -107,6 +111,7 @@
 	}
 }
 
+// @Security ApiKeyAuth
 // @Summary 鎼滅储闆嗙兢
 // @Description 鎼滅储闆嗙兢
 // @Accept json
@@ -132,6 +137,7 @@
 	}
 }
 
+// @Security ApiKeyAuth
 // @Summary 閫氳繃searchNum寮傛鑾峰彇闆嗙兢鑺傜偣淇℃伅
 // @Description 閫氳繃searchNum寮傛鑾峰彇闆嗙兢鑺傜偣淇℃伅
 // @Accept json
@@ -150,22 +156,17 @@
 	}
 }
 
+// @Security ApiKeyAuth
 // @Summary 閫氳繃searchNum鍋滄鎼滅储
 // @Description 閫氳繃searchNum鍋滄鎼滅储
 // @Produce json
 // @Tags cluster
-// @Param searchNum 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/stopSearching [post]
 func (cc ClusterController) StopSearching(c *gin.Context) {
-	searchNum := c.Query("searchNum")
-	if searchNum == "" {
-		util.ResponseFormat(c,code.RequestParamError, "鍙傛暟鏈夎")
-		return
-	}
 	var api dbapi.ClusterApi
-	b, d := api.StopSearching(searchNum)
+	b, d := api.StopSearching("")
 	if b {
 		util.ResponseFormat(c,code.Success, d)
 	} else {
@@ -173,13 +174,13 @@
 	}
 }
 
-
+// @Security ApiKeyAuth
 // @Summary 鍔犲叆闆嗙兢
 // @Description 鍔犲叆闆嗙兢
 // @Accept json
 // @Produce json
 // @Tags cluster
-// @Param  clusterArg body controllers.ClusterCreateVo true "闆嗙兢鍒涘缓鍙傛暟"
+// @Param  clusterArg body controllers.ClusterJoinVo 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/joinCluster [post]
@@ -199,3 +200,46 @@
 		util.ResponseFormat(c,code.ComError,"鍔犲叆澶辫触")
 	}
 }
+
+// @Security ApiKeyAuth
+// @Summary 淇濆瓨闆嗙兢鍚嶇О
+// @Description 淇濆瓨闆嗙兢鍚嶇О
+// @Produce json
+// @Tags cluster
+// @Param clusterName formData string true "闆嗙兢鍚嶇О"
+// @Param virtualIp formData string false "铏氭嫙ip"
+// @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
+	}
+	virtualIp := c.PostForm("virtualIp")
+	var api dbapi.ClusterApi
+	b,_ := api.UpdateClusterName(clusterName,virtualIp)
+	if b {
+		util.ResponseFormat(c,code.UpdateSuccess,"鏇存柊鎴愬姛")
+	} else {
+		util.ResponseFormat(c,code.ComError, "鏇存柊澶辫触")
+	}
+}
+
+// @Security ApiKeyAuth
+// @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

--
Gitblit v1.8.0