|
|
|
@@ -3,8 +3,11 @@ package adapters |
|
|
|
import ( |
|
|
|
"context" |
|
|
|
"github.com/pkg/errors" |
|
|
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" |
|
|
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" |
|
|
|
"gorm.io/gorm" |
|
|
|
"gorm.io/gorm/clause" |
|
|
|
"strconv" |
|
|
|
|
|
|
|
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" |
|
|
|
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" |
|
|
|
@@ -40,5 +43,24 @@ func (l *UpdateClusterLogic) UpdateCluster(req *types.ClusterCreateReq) (resp *t |
|
|
|
} |
|
|
|
cluster.Location = location |
|
|
|
l.svcCtx.DbEngin.Table("t_cluster").Model(&cluster).Updates(&cluster) |
|
|
|
// 更新资源价格表 |
|
|
|
clusterId, err := strconv.ParseInt(req.Id, 10, 64) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
resourceCost := &types.ResourceCost{ |
|
|
|
ResourceID: clusterId, |
|
|
|
Price: req.Price, |
|
|
|
ResourceType: constants.CLUSTER, |
|
|
|
CostType: req.CostType, |
|
|
|
} |
|
|
|
dbResult := l.svcCtx.DbEngin.Clauses(clause.OnConflict{ |
|
|
|
Columns: []clause.Column{{Name: "resource_id"}}, |
|
|
|
DoUpdates: clause.AssignmentColumns([]string{"price", "cost_type"}), |
|
|
|
}).Create(&resourceCost) |
|
|
|
|
|
|
|
if dbResult.Error != nil { |
|
|
|
panic(dbResult.Error) |
|
|
|
} |
|
|
|
return |
|
|
|
} |