| | |
| | | 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, |
| | |
| | | |
| | | type LeaveArg struct { |
| | | IsDel bool `json:"isDel"` //是否删除数据 |
| | | Pwd string `json:"password"` //是否删除数据 |
| | | } |
| | | |
| | | // @Summary 退出集群 |
| | |
| | | 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: "退出成功"} |