feat(admin): 模型管理 - 支持从上游渠道拉取模型目录 (#36)

以 main 为基线仅补齐拉取模型能力:管理员可一键导入缺失模型(默认停用待定价),并提供登录态后端代理目录接口避免 CORS。

Co-authored-by: ddcat666 <2695092045@qq.com>
This commit is contained in:
yepandddcat666 authored and GitHub committed 2026-07-23 22:04:54 +08:00
1 parent 61d12ec3ff
commit 243c43f6c2
11 files changed
+293 -7

No files matched your search

+9
View File
@@ -93,6 +93,15 @@ func (r *Repository) SaveChannelModel(item *model.ChannelModel) error {
return r.db.Save(item).Error
}
func (r *Repository) CreateMissingChannelModels(items []model.ChannelModel) (int64, error) {
if len(items) == 0 {
return 0, nil
}
// 拉取目录可能与其他管理员操作并发,唯一键冲突时保留已有定价配置。
result := r.db.Clauses(clause.OnConflict{Columns: []clause.Column{{Name: "channel_id"}, {Name: "model_key"}}, DoNothing: true}).Create(&items)
return result.RowsAffected, result.Error
}
func (r *Repository) CreditAccount(userID string) (*model.CreditAccount, error) {
account := model.CreditAccount{UserID: userID}
if err := r.db.Clauses(clause.OnConflict{DoNothing: true}).Create(&account).Error; err != nil {