tmp
This commit is contained in:
parent
bfec6255bc
commit
2f0b38a3fb
@ -14,7 +14,7 @@ type Key string
|
|||||||
type Value interface {
|
type Value interface {
|
||||||
Int() int
|
Int() int
|
||||||
String() string
|
String() string
|
||||||
Float() float32
|
Float() float64
|
||||||
Duration() time.Duration
|
Duration() time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,10 +22,10 @@ type DurationValue time.Duration
|
|||||||
|
|
||||||
type FloatValue struct {
|
type FloatValue struct {
|
||||||
EmptyValue
|
EmptyValue
|
||||||
Val float32
|
Val float64
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v FloatValue) Float() float32 {
|
func (v FloatValue) Float() float64 {
|
||||||
return v.Val
|
return v.Val
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,8 +47,8 @@ func (v IntValue) Int() int {
|
|||||||
return v.Val
|
return v.Val
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v IntValue) Float() float32 {
|
func (v IntValue) Float() float64 {
|
||||||
return float32(v.Val)
|
return float64(v.Val)
|
||||||
}
|
}
|
||||||
|
|
||||||
type EmptyValue struct{}
|
type EmptyValue struct{}
|
||||||
@ -61,7 +61,7 @@ func (v EmptyValue) String() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v EmptyValue) Float() float32 {
|
func (v EmptyValue) Float() float64 {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ func (p *staticProvider) GetValue(ctx context.Context, key config.Key) config.Va
|
|||||||
return config.StringValue{
|
return config.StringValue{
|
||||||
Val: val,
|
Val: val,
|
||||||
}
|
}
|
||||||
case float32:
|
case float64:
|
||||||
return config.FloatValue{
|
return config.FloatValue{
|
||||||
Val: val,
|
Val: val,
|
||||||
}
|
}
|
||||||
|
24
internal/domain/fs_link.go
Normal file
24
internal/domain/fs_link.go
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
package domain
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
type StorageType int
|
||||||
|
|
||||||
|
const (
|
||||||
|
StorageTypeFS StorageType = iota
|
||||||
|
StorageTypeS3
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
fslinkTemplate = "fs:///%s"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetFSConverter(storageType StorageType) func(fslink string) string {
|
||||||
|
switch storageType {
|
||||||
|
default:
|
||||||
|
// TODO s3 converter
|
||||||
|
return func(fslink string) string {
|
||||||
|
return fmt.Sprintf(fslinkTemplate, fslink)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -6,6 +6,7 @@ import (
|
|||||||
|
|
||||||
"git.optclblast.xyz/draincloud/draincloud-core/internal/storage"
|
"git.optclblast.xyz/draincloud/draincloud-core/internal/storage"
|
||||||
"git.optclblast.xyz/draincloud/draincloud-core/internal/storage/models/files"
|
"git.optclblast.xyz/draincloud/draincloud-core/internal/storage/models/files"
|
||||||
|
// "git.optclblast.xyz/draincloud/draincloud-core/internal/storage/models/files"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -26,7 +27,7 @@ func NewFilesEngine(
|
|||||||
|
|
||||||
type File struct {
|
type File struct {
|
||||||
Name string
|
Name string
|
||||||
UserID uuid.UUID
|
UserID int64
|
||||||
Ext string
|
Ext string
|
||||||
Type string
|
Type string
|
||||||
Size int64
|
Size int64
|
||||||
@ -38,7 +39,13 @@ func (e *FilesEngine) SaveFile(
|
|||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
file File,
|
file File,
|
||||||
) (uuid.UUID, error) {
|
) (uuid.UUID, error) {
|
||||||
fileID, err := e.metaStorage.SaveMetadata(ctx, files.FileMetadata{})
|
fileID, err := e.metaStorage.SaveMetadata(ctx, files.FileMetadata{
|
||||||
|
Name: file.Name,
|
||||||
|
UserID: file.UserID,
|
||||||
|
Ext: file.Ext,
|
||||||
|
Type: file.Type,
|
||||||
|
// FSLink: f,
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return uuid.Nil, fmt.Errorf("failed to create new file metadata: %w", err)
|
return uuid.Nil, fmt.Errorf("failed to create new file metadata: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -36,4 +36,5 @@ type BlobStorage interface {
|
|||||||
GetFile(ctx context.Context, id uuid.UUID) (*os.File, error)
|
GetFile(ctx context.Context, id uuid.UUID) (*os.File, error)
|
||||||
SaveBlob(ctx context.Context, id uuid.UUID, data []byte) error
|
SaveBlob(ctx context.Context, id uuid.UUID, data []byte) error
|
||||||
DeleteFile(ctx context.Context, id uuid.UUID) error
|
DeleteFile(ctx context.Context, id uuid.UUID) error
|
||||||
|
GetFSLink(ctx context.Context, fileID uuid.UUID) (string, error)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user