From 263c7b18ce7f18f1222318f6e0e499e907895a52 Mon Sep 17 00:00:00 2001
From: liuxiaolong <736321739@qq.com>
Date: 星期三, 13 十一月 2019 19:33:39 +0800
Subject: [PATCH] fix

---
 controllers/cluster.go |   85 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 84 insertions(+), 1 deletions(-)

diff --git a/controllers/cluster.go b/controllers/cluster.go
index 873901e..5a780a9 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,21 @@
 	NodeIps []string `json:"nodeIps"`
 }
 
+type ClusterDb struct {
+	ClusterId   string `json:"clusterId"`
+	ClusterName string `json:"clusterName"`
+	Nodes []NodeDb     `json:"nodes"`
+}
+type NodeDb struct {
+	Id string `json:"id"`
+	ClusterId string `json:"cluster_id"`
+	NodeName string `json:"node_name"`
+	NodeId string `json:"node_id"`
+	NodeIp string `json:"node_ip"`
+	CreateTime string `json:"create_time"`
+	IsDelete bool `json:"isDelete"`
+}
+
 
 func (cc ClusterController) Create(c *gin.Context) {
 	var clusterVo ClusterCreateVo
@@ -62,7 +78,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 {
@@ -76,6 +92,25 @@
 	util.ResponseFormat(c,code.Success,pwd)
 }
 
+/*
+// @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/findCluster [get]
+*/
+func (cc ClusterController) FindCluster(c *gin.Context) {
+	var clusterApi dbapi.ClusterApi
+	b, d := clusterApi.FindCluster()
+	if b {
+		util.ResponseFormat(c,code.Success, d)
+	} else {
+		util.ResponseFormat(c,code.ComError,"闆嗙兢鏌ヨ澶辫触")
+	}
+}
 
 func (cc ClusterController) Search(c *gin.Context) {
 	var csv ClusterSearchVo
@@ -137,3 +172,51 @@
 		util.ResponseFormat(c,code.ComError,"鍔犲叆澶辫触")
 	}
 }
+
+/*
+// @Security ApiKeyAuth
+// @Summary 淇濆瓨闆嗙兢鍚嶇О
+// @Description 淇濆瓨闆嗙兢鍚嶇О
+// @Accept x-www-form-urlencoded
+// @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