Re-struct pkg/api, pkg/database

This commit is contained in:
2021-12-07 00:19:05 +08:00
parent 546385a484
commit 83f2b76cbc
25 changed files with 1350 additions and 1192 deletions

30
pkg/database/struct.go Normal file
View File

@@ -0,0 +1,30 @@
package database
import (
"path/filepath"
)
type File struct {
Db *Database `json:"-"`
ID int64 `json:"id"`
Folder_id int64 `json:"folder_id"`
Foldername string `json:"foldername"`
Filename string `json:"filename"`
Filesize int64 `json:"filesize"`
}
type Folder struct {
Db *Database `json:"-"`
ID int64 `json:"id"`
Folder string `json:"-"`
Foldername string `json:"foldername"`
}
func (f *File) Path() (string, error) {
folder, err := f.Db.GetFolder(f.Folder_id)
if err != nil {
return "", err
}
return filepath.Join(folder.Folder, f.Filename), nil
}