liuxiaolong
2019-08-22 d279022520262b8fb8fc985df3bb19df19192a2f
add cluster updateName and leave
2个文件已修改
41 ■■■■■ 已修改文件
controllers/cluster.go 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/router.go 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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,"退出失败")
    }
}
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)
    }
    // 文件 上传