feat(copilot): complete runtime provider configuration

This commit is contained in:
2026-07-13 14:57:28 +08:00
parent 6b42853c0b
commit 0a69d80f7c
17 changed files with 1163 additions and 319 deletions
@@ -77,6 +77,26 @@ func (r *InstallationConfigRepo) UpsertByName(ctx context.Context, name, value s
return r.db.WithContext(ctx).Create(&model.InstallationConfig{Name: name, Value: value}).Error
}
// UpsertValues atomically updates a set of stable installation config keys.
func (r *InstallationConfigRepo) UpsertValues(ctx context.Context, values map[string]string) error {
return r.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error {
for name, value := range values {
result := tx.Model(&model.InstallationConfig{}).
Where("name = ?", name).
Update("value", value)
if result.Error != nil {
return result.Error
}
if result.RowsAffected == 0 {
if err := tx.Create(&model.InstallationConfig{Name: name, Value: value}).Error; err != nil {
return err
}
}
}
return nil
})
}
// Delete removes an InstallationConfig record by primary key (soft-delete via Base.DeletedAt).
func (r *InstallationConfigRepo) Delete(ctx context.Context, id uint) error {
return r.db.WithContext(ctx).Delete(&model.InstallationConfig{}, id).Error