|
|
|
@@ -2,8 +2,10 @@ package participantservicelogic |
|
|
|
|
|
|
|
import ( |
|
|
|
"context" |
|
|
|
"github.com/pkg/errors" |
|
|
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/model" |
|
|
|
"gitlink.org.cn/jcce-pcm/utils/tool" |
|
|
|
"gorm.io/gorm" |
|
|
|
"time" |
|
|
|
|
|
|
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/rpc/internal/svc" |
|
|
|
@@ -60,7 +62,9 @@ func (l *RegisterParticipantLogic) RegisterParticipant(in *pcmCore.ParticipantPh |
|
|
|
tool.Convert(info, nodeInfo) |
|
|
|
nodeInfo.CreatedTime = time.Now() |
|
|
|
nodeInfo.ParticipantId = participantInfo.Id |
|
|
|
if nodeInfo.Id == 0 { |
|
|
|
//查询节点name与ParticipantId是否存在 |
|
|
|
nodeErr := db.Where(&model.ScNodePhyInfo{NodeName: nodeInfo.NodeName, ParticipantId: in.ParticipantId}).Take(nodeInfo) |
|
|
|
if errors.Is(nodeErr.Error, gorm.ErrRecordNotFound) { |
|
|
|
nodeInfo.Id = tool.GenSnowflakeID() |
|
|
|
} |
|
|
|
nodeList = append(nodeList, nodeInfo) |
|
|
|
@@ -73,7 +77,9 @@ func (l *RegisterParticipantLogic) RegisterParticipant(in *pcmCore.ParticipantPh |
|
|
|
tool.Convert(label, labelInfo) |
|
|
|
labelInfo.CreatedTime = time.Now() |
|
|
|
labelInfo.ParticipantId = participantInfo.Id |
|
|
|
if labelInfo.Id == 0 { |
|
|
|
//查询标签key value与ParticipantId是否存在 |
|
|
|
labelErr := db.Where(&model.ScParticipantLabelInfo{Key: labelInfo.Key, Value: labelInfo.Value, ParticipantId: in.ParticipantId}).Take(labelInfo) |
|
|
|
if errors.Is(labelErr.Error, gorm.ErrRecordNotFound) { |
|
|
|
labelInfo.Id = tool.GenSnowflakeID() |
|
|
|
} |
|
|
|
labelList = append(labelList, labelInfo) |
|
|
|
|