pcm-coordinator/internal/logic/adapters/getclusterlogic.go

37 lines
846 B
Go

package adapters
import (
"context"
"github.com/pkg/errors"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type GetClusterLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewGetClusterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetClusterLogic {
return &GetClusterLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *GetClusterLogic) GetCluster(req *types.FId) (resp *types.ClusterInfo, err error) {
resp = &types.ClusterInfo{}
db := l.svcCtx.DbEngin.Table("t_cluster").Where("id = ?", req.Id).First(&resp)
if db.Error != nil {
logx.Errorf("err %v", db.Error.Error())
return nil, errors.New("Adapter does not exist")
}
return
}