forked from JointCloud/pcm-coordinator
36 lines
919 B
Go
36 lines
919 B
Go
package core
|
|
|
|
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 GetClusterByIdLogic struct {
|
|
logx.Logger
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
}
|
|
|
|
func NewGetClusterByIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetClusterByIdLogic {
|
|
return &GetClusterByIdLogic{
|
|
Logger: logx.WithContext(ctx),
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
}
|
|
}
|
|
|
|
func (l *GetClusterByIdLogic) GetClusterById(req *types.GetClusterByIdReq) (resp *types.GetClusterByIdResp, err error) {
|
|
resp = &types.GetClusterByIdResp{}
|
|
tx := l.svcCtx.DbEngin.Raw("select * from t_cluster where id = ?", req.ClusterId).Scan(&resp.ClusterInfo)
|
|
if tx.Error != nil {
|
|
logx.Errorf(tx.Error.Error())
|
|
return nil, errors.New("cluster create failed")
|
|
}
|
|
return resp, nil
|
|
}
|