zhangzengfei
2023-10-24 c5654846d3b8b002284dee57aa50e95d67649f0e
system-service/controllers/cluster.go
@@ -75,7 +75,7 @@
         return &bhomeclient.Reply{Success: true, Data: map[string]interface{}{
            "clusterId":   arr[0].ClusterId,
            "clusterName": arr[0].ClusterName,
            "password":    arr[0].Password,
            //"password":    arr[0].Password,
            "nodes":       nodes,
            "virtualIp":   arr[0].VirtualIp,
            "localId":     config.Server.AnalyServerId,
@@ -252,6 +252,7 @@
type LeaveArg struct {
   IsDel bool `json:"isDel"` //是否删除数据
   Pwd   string `json:"password"` //是否删除数据
}
// @Summary 退出集群
@@ -264,6 +265,21 @@
func (cc ClusterController) Leave(h *bhomeclient.WrapperHandler, c *bhomeclient.Request) *bhomeclient.Reply {
   var reqBody LeaveArg
   c.BindJSON(&reqBody)
   var clusterE models.Cluster
   arr, err := clusterE.FindAll()
   if err != nil {
      return &bhomeclient.Reply{Success: false, Msg: "集群查询失败"}
   }
   if arr != nil && len(arr) > 0 {
      if config.ClusterSet.PwdPre+reqBody.Pwd != arr[0].Password {
         return &bhomeclient.Reply{Success: false, Msg: "密码错误"}
      }
   } else {
      return &bhomeclient.Reply{Success: false, Msg: "集群查询失败"}
   }
   sv := service.NewClusterService(h.Bk)
   if b, err := sv.Leave(reqBody.IsDel); b {
      return &bhomeclient.Reply{Success: true, Msg: "退出成功"}