feat(admin): 系统渠道 - 增加复制渠道

This commit is contained in:
esncy committed 2026-09-14 09:31:03 +08:00
1 parent 4b0e9d8965
commit 73439aac23
9 files changed
+254 -3

No files matched your search

+19
View File
@@ -84,6 +84,25 @@ func (r *Repository) ChannelModels(channelID string, includeDisabled bool) ([]mo
return items, r.attachChannelModelPriceTiers(pointers)
}
func (r *Repository) CreateDuplicatedSystemChannel(channel *model.ModelChannel, channelModels []model.ChannelModel, priceTiers []model.ChannelModelPriceTier) error {
return r.db.Transaction(func(tx *gorm.DB) error {
if err := tx.Create(channel).Error; err != nil {
return err
}
if len(channelModels) > 0 {
if err := tx.Create(&channelModels).Error; err != nil {
return err
}
}
if len(priceTiers) > 0 {
if err := tx.Create(&priceTiers).Error; err != nil {
return err
}
}
return nil
})
}
func (r *Repository) ChannelModelByID(channelID string, id string) (*model.ChannelModel, error) {
var item model.ChannelModel
if err := r.db.First(&item, "id = ? AND channel_id = ?", id, channelID).Error; err != nil {