fix(admin): 渠道模型 - 删除后支持重新拉取并友好提示重名

This commit is contained in:
ddCat committed 2026-07-31 09:47:46 +08:00
1 parent ffd222c6a6
commit a8b3727c38
3 files changed
+102 -8

No files matched your search

+8 -6
View File
@@ -73,12 +73,6 @@ func (r *Repository) ChannelModels(channelID string, includeDisabled bool) ([]mo
return items, query.Find(&items).Error
}
func (r *Repository) ChannelModelsIncludingDeleted(channelID string) ([]model.ChannelModel, error) {
var items []model.ChannelModel
err := r.db.Unscoped().Where("channel_id = ?", channelID).Order("created_at asc").Find(&items).Error
return items, err
}
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 {
@@ -95,6 +89,14 @@ func (r *Repository) ChannelModelByKey(channelID string, modelKey string) (*mode
return &item, nil
}
func (r *Repository) ChannelModelByKeyIncludingDisabled(channelID string, modelKey string) (*model.ChannelModel, error) {
var item model.ChannelModel
if err := r.db.First(&item, "channel_id = ? AND model_key = ?", channelID, modelKey).Error; err != nil {
return nil, err
}
return &item, nil
}
func (r *Repository) SaveChannelModel(item *model.ChannelModel) error {
return r.db.Save(item).Error
}