feat: upload

This commit is contained in:
Rogee
2025-01-15 10:43:16 +08:00
parent 9bfdf0e0ea
commit ab827715fb
16 changed files with 378 additions and 161 deletions

View File

@@ -10,7 +10,7 @@ type Storage struct {
}
type CreateStorageReq struct {
Name string `json:"name"`
Config string `json:"config"`
Type fields.StorageType `json:"type"`
Name string `json:"name"`
Config fields.StorageConfig `json:"config"`
Type fields.StorageType `json:"type"`
}

View File

@@ -122,3 +122,19 @@ func (svc *Service) SetDefault(ctx context.Context, id int64) error {
// Commit transaction
return tx.Commit()
}
// GetDefault
func (svc *Service) GetDefault(ctx context.Context) (*model.Storages, error) {
_, span := otel.Start(ctx, "storages.service.GetDefault")
defer span.End()
tbl := table.Storages
stmt := tbl.SELECT(tbl.AllColumns).WHERE(tbl.IsDefault.EQ(Bool(true)))
span.SetAttributes(semconv.DBStatementKey.String(stmt.DebugSql()))
var storage model.Storages
if err := stmt.QueryContext(ctx, svc.db, &storage); err != nil {
return nil, err
}
return &storage, nil
}