From db13ccd4e0fda491183db680776c45779ac90f0c Mon Sep 17 00:00:00 2001 From: admin Date: Thu, 23 Apr 2026 08:38:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DUpdateAttributes?= =?UTF-8?q?=E5=88=A0=E9=99=A4gatewayId=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=8C?= =?UTF-8?q?=E4=BF=9D=E7=95=99=E9=9D=9E=E5=8F=82=E6=95=B0=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/repository/asset.go | 2 +- server/service/asset.go | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/server/repository/asset.go b/server/repository/asset.go index f0c847864..2d8107d22 100644 --- a/server/repository/asset.go +++ b/server/repository/asset.go @@ -212,7 +212,7 @@ func (r assetRepository) UpdateAttributes(c context.Context, assetId, protocol s } } - err := r.GetDB(c).Where("asset_id = ?", assetId).Delete(&model.AssetAttribute{}).Error + err := r.GetDB(c).Where("asset_id = ? AND name IN ?", assetId, parameterNames).Delete(&model.AssetAttribute{}).Error if err != nil { return err } diff --git a/server/service/asset.go b/server/service/asset.go index 33378d4d6..b1ccbd443 100644 --- a/server/service/asset.go +++ b/server/service/asset.go @@ -313,7 +313,11 @@ func (s assetService) UpdateById(id string, m maps.Map) error { } if item.AccessGatewayId == "" { - item.AccessGatewayId = "-" + if gatewayId, ok := m["gatewayId"]; ok && gatewayId != "" && gatewayId != "-" { + item.AccessGatewayId = gatewayId.(string) + } else { + item.AccessGatewayId = "-" + } } return s.Transaction(context.Background(), func(ctx context.Context) error {