|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- package cloud
-
- import (
- "context"
- "gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/models"
- "gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils"
- "time"
-
- "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
- "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
-
- "github.com/zeromicro/go-zero/core/logx"
- )
-
- type RegisterClusterLogic struct {
- logx.Logger
- ctx context.Context
- svcCtx *svc.ServiceContext
- }
-
- func NewRegisterClusterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RegisterClusterLogic {
- return &RegisterClusterLogic{
- Logger: logx.WithContext(ctx),
- ctx: ctx,
- svcCtx: svcCtx,
- }
- }
-
- func (l *RegisterClusterLogic) RegisterCluster(req *types.RegisterClusterReq) (resp *types.CloudResp, err error) {
- // 查询出所有p端信息
- participant := models.ScParticipantPhyInfo{}
-
- participant.Token = req.Token
- participant.Name = req.Name
- participant.Address = req.Address
- participant.Type = req.Type
- participant.Id = utils.GenSnowflakeID()
- participant.MetricsUrl = req.MetricsUrl
- participant.CreatedTime = time.Now()
- participant.UpdatedTime = time.Now()
-
- tx := l.svcCtx.DbEngin.Create(&participant)
- if tx.Error != nil {
- return nil, tx.Error
- }
- return
- }
|