fix: 修复UpdateAttributes删除gatewayId的问题,保留非参数属性

This commit is contained in:
2026-04-23 08:38:19 +08:00
parent c0e6fb701f
commit db13ccd4e0
2 changed files with 6 additions and 2 deletions
+1 -1
View File
@@ -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
}
+5 -1
View File
@@ -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 {