fix: 修复UpdateAttributes删除gatewayId的问题,保留非参数属性
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user