|
|
|
@@ -44,12 +44,16 @@ func (cp *ChannelPricing) Insert() error { |
|
|
|
now := common.GetTimestamp() |
|
|
|
cp.CreatedTime = now |
|
|
|
cp.UpdatedTime = now |
|
|
|
return DB.Create(cp).Error |
|
|
|
err := DB.Create(cp).Error |
|
|
|
if err == nil { |
|
|
|
InvalidateChannelPricingCache() |
|
|
|
} |
|
|
|
return err |
|
|
|
} |
|
|
|
|
|
|
|
func (cp *ChannelPricing) Update() error { |
|
|
|
cp.UpdatedTime = common.GetTimestamp() |
|
|
|
return DB.Model(&ChannelPricing{}).Where("id = ?", cp.Id).Updates(map[string]interface{}{ |
|
|
|
err := DB.Model(&ChannelPricing{}).Where("id = ?", cp.Id).Updates(map[string]interface{}{ |
|
|
|
"quota_type": cp.QuotaType, |
|
|
|
"model_ratio": cp.ModelRatio, |
|
|
|
"completion_ratio": cp.CompletionRatio, |
|
|
|
@@ -57,10 +61,18 @@ func (cp *ChannelPricing) Update() error { |
|
|
|
"tag_ids": cp.TagIds, |
|
|
|
"updated_time": cp.UpdatedTime, |
|
|
|
}).Error |
|
|
|
if err == nil { |
|
|
|
InvalidateChannelPricingCache() |
|
|
|
} |
|
|
|
return err |
|
|
|
} |
|
|
|
|
|
|
|
func (cp *ChannelPricing) Delete() error { |
|
|
|
return DB.Delete(cp).Error |
|
|
|
err := DB.Delete(cp).Error |
|
|
|
if err == nil { |
|
|
|
InvalidateChannelPricingCache() |
|
|
|
} |
|
|
|
return err |
|
|
|
} |
|
|
|
|
|
|
|
// GetChannelPricing 获取指定模型在指定渠道的定价 |
|
|
|
|