package cloud

import (
	"context"
	"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
	"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
	"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"

	"github.com/zeromicro/go-zero/core/logx"
)

type DeleteClusterLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewDeleteClusterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteClusterLogic {
	return &DeleteClusterLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *DeleteClusterLogic) DeleteCluster(req *types.DeleteClusterReq) (*types.CloudResp, error) {
	// 删除集群信息
	var resp types.CloudResp
	tx := l.svcCtx.DbEngin.Where("name = ?", req.Name).Delete(&models.ScParticipantPhyInfo{})
	if tx.Error != nil {
		return nil, tx.Error
	}
	resp.Code = string(200)
	resp.Msg = "success"
	resp.Data = ""
	return &resp, nil
}
