liuxiaolong
2019-09-19 2dd1fa03c93b400ff1e8e4f44e27387965e4daa7
controllers/cluster.go
@@ -90,6 +90,23 @@
   util.ResponseFormat(c,code.Success,pwd)
}
// @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,"集群查询失败")
   }
}
// @Summary 搜索集群
// @Description 搜索集群
// @Accept json
@@ -137,18 +154,12 @@
// @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 {
@@ -182,3 +193,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,"退出失败")
   }
}