From 527d64c15793eb54e29a791d457827e585a3e14d Mon Sep 17 00:00:00 2001 From: Sydonian <794346190@qq.com> Date: Fri, 28 Mar 2025 09:23:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=8D=E5=88=B6Package=E7=9A=84=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E5=A2=9E=E5=8A=A0ObjectID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/models/datamap.go | 8 +++++--- coordinator/internal/mq/package.go | 7 +++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/common/models/datamap.go b/common/models/datamap.go index 5b3b47a..2629472 100644 --- a/common/models/datamap.go +++ b/common/models/datamap.go @@ -458,9 +458,11 @@ func (b *BodyNewPackage) OnUnionSerializing() { // Package克隆的事件 type BodyPackageCloned struct { serder.Metadata `union:"PackageCloned"` - Type string `json:"type"` - SourcePackageID cdssdk.PackageID `json:"sourcePackageID"` - NewPackage cdssdk.Package `json:"newPackage"` + Type string `json:"type"` + SourcePackageID cdssdk.PackageID `json:"sourcePackageID"` + NewPackage cdssdk.Package `json:"newPackage"` + SourceObjectIDs []cdssdk.ObjectID `json:"sourceObjectIDs"` // 原本的ObjectID + NewObjectIDs []cdssdk.ObjectID `json:"newObjectIDs"` // 复制后的新ObjectID,与SourceObjectIDs一一对应 } func (b *BodyPackageCloned) GetBodyType() string { diff --git a/coordinator/internal/mq/package.go b/coordinator/internal/mq/package.go index 999234b..f285d26 100644 --- a/coordinator/internal/mq/package.go +++ b/coordinator/internal/mq/package.go @@ -160,6 +160,8 @@ func (svc *Service) DeletePackage(msg *coormq.DeletePackage) (*coormq.DeletePack func (svc *Service) ClonePackage(msg *coormq.ClonePackage) (*coormq.ClonePackageResp, *mq.CodeMessage) { var pkg cdssdk.Package + var oldObjIDs []cdssdk.ObjectID + var newObjIDs []cdssdk.ObjectID err := svc.db2.DoTx(func(tx db2.SQLContext) error { var err error @@ -198,6 +200,9 @@ func (svc *Service) ClonePackage(msg *coormq.ClonePackage) (*coormq.ClonePackage oldToNew := make(map[cdssdk.ObjectID]cdssdk.ObjectID) for i, obj := range clonedObjs { oldToNew[objs[i].ObjectID] = obj.ObjectID + + oldObjIDs = append(oldObjIDs, objs[i].ObjectID) + newObjIDs = append(newObjIDs, obj.ObjectID) } clonedBlks := make([]stgmod.ObjectBlock, len(objBlks)) @@ -224,6 +229,8 @@ func (svc *Service) ClonePackage(msg *coormq.ClonePackage) (*coormq.ClonePackage svc.evtPub.Publish(&stgmod.BodyPackageCloned{ SourcePackageID: msg.PackageID, NewPackage: pkg, + SourceObjectIDs: oldObjIDs, + NewObjectIDs: newObjIDs, }) return mq.ReplyOK(coormq.RespClonePackage(pkg))