Browse Source

feat: invalidate cache on channel pricing changes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
feat/alipay-payment
fengsilin 1 month ago
parent
commit
ba21a870cd
1 changed files with 15 additions and 3 deletions
  1. +15
    -3
      model/channel_pricing.go

+ 15
- 3
model/channel_pricing.go View File

@@ -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 获取指定模型在指定渠道的定价


Loading…
Cancel
Save