feat: basic structure
This commit is contained in:
32
internal/driver/driver.go
Normal file
32
internal/driver/driver.go
Normal file
@ -0,0 +1,32 @@
|
||||
package driver
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
type Driver interface {
|
||||
Reader
|
||||
Writer
|
||||
Other
|
||||
}
|
||||
|
||||
type Reader interface {
|
||||
File(ctx context.Context, path string) (*FileInfo, error)
|
||||
List(ctx context.Context, path string) ([]FileInfo, error)
|
||||
Link(ctx context.Context, args LinkArgs) (*Link, error)
|
||||
}
|
||||
|
||||
type Writer interface {
|
||||
MakeDir(ctx context.Context, path string) error
|
||||
Move(ctx context.Context, src, dst string) error
|
||||
Rename(ctx context.Context, src, dst string) error
|
||||
Copy(ctx context.Context, src, dst string) error
|
||||
Remove(ctx context.Context, path string) error
|
||||
Put(ctx context.Context, stream FileStream, parent string) error
|
||||
}
|
||||
|
||||
type Other interface {
|
||||
Init(ctx context.Context) error
|
||||
Update(ctx context.Context) error
|
||||
Drop(ctx context.Context) error
|
||||
}
|
8
internal/driver/error.go
Normal file
8
internal/driver/error.go
Normal file
@ -0,0 +1,8 @@
|
||||
package driver
|
||||
|
||||
import "errors"
|
||||
|
||||
var (
|
||||
ErrorDirNotFound = errors.New("directory not found")
|
||||
ErrorObjectNotFound = errors.New("object not found")
|
||||
)
|
18
internal/driver/file.go
Normal file
18
internal/driver/file.go
Normal file
@ -0,0 +1,18 @@
|
||||
package driver
|
||||
|
||||
import (
|
||||
"io"
|
||||
"time"
|
||||
)
|
||||
|
||||
type FileInfo interface {
|
||||
GetName() string
|
||||
GetModTime() time.Time
|
||||
GetSize() int64
|
||||
}
|
||||
|
||||
type FileStream interface {
|
||||
io.ReadCloser
|
||||
FileInfo
|
||||
GetMimetype() string
|
||||
}
|
20
internal/driver/link.go
Normal file
20
internal/driver/link.go
Normal file
@ -0,0 +1,20 @@
|
||||
package driver
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type LinkArgs struct {
|
||||
Path string
|
||||
IP string
|
||||
Header http.Header
|
||||
}
|
||||
|
||||
type Link struct {
|
||||
URL string
|
||||
Header http.Header
|
||||
Data io.ReadCloser
|
||||
Status int
|
||||
FilePath string
|
||||
}
|
9
internal/model/account.go
Normal file
9
internal/model/account.go
Normal file
@ -0,0 +1,9 @@
|
||||
package model
|
||||
|
||||
type Account struct {
|
||||
ID uint `json:"id" gorm:"primaryKey"`
|
||||
VirtualPath string `json:"virtual_path"`
|
||||
Index int `json:"index"`
|
||||
Type string `json:"type"`
|
||||
Status string `json:"status"`
|
||||
}
|
0
internal/server/README.md
Normal file
0
internal/server/README.md
Normal file
11
internal/store/account.go
Normal file
11
internal/store/account.go
Normal file
@ -0,0 +1,11 @@
|
||||
package store
|
||||
|
||||
import "github.com/alist-org/alist/v3/internal/model"
|
||||
|
||||
type Account interface {
|
||||
Create(account model.Account) error
|
||||
Update(account model.Account) error
|
||||
Delete(id uint) error
|
||||
GetByID(id uint) (*model.Account, error)
|
||||
List() ([]model.Account, error)
|
||||
}
|
Reference in New Issue
Block a user