Display user storage usage on the dashboard
This commit is contained in:
@ -3,18 +3,26 @@ package models
|
||||
import "github.com/google/uuid"
|
||||
|
||||
type User struct {
|
||||
UserID uuid.UUID `gorm:"primaryKey;not null;unique"`
|
||||
Username string `gorm:"unique;not null"`
|
||||
Email string `gorm:"unique;not null"`
|
||||
Password string `gorm:"not null"`
|
||||
Totp string `gorm:"not null"`
|
||||
UserID uuid.UUID `gorm:"type:uuid;primaryKey"`
|
||||
Username string `gorm:"type:varchar(255);unique;not null"`
|
||||
Email string `gorm:"type:varchar(255);unique;not null"`
|
||||
Password string `gorm:"type:text;not null"`
|
||||
Totp string `gorm:"type:varchar(255);not null"`
|
||||
}
|
||||
|
||||
type File struct {
|
||||
ID uuid.UUID `gorm:"primaryKey;not null;unique"`
|
||||
OwnerID uuid.UUID `gorm:"not null"`
|
||||
Name string `gorm:"not null"`
|
||||
ID uuid.UUID `gorm:"type:uuid;primaryKey"`
|
||||
OwnerID uuid.UUID `gorm:"type:uuid;not null"`
|
||||
Name string `gorm:"type:text;not null"`
|
||||
Size uint64 `gorm:"not null"`
|
||||
TotalChunk uint64 `gorm:"not null"`
|
||||
Downloaded uint64 `gorm:"not null;default=0"`
|
||||
Downloaded uint64 `gorm:"not null;default:0"`
|
||||
Owner *User `gorm:"foreignKey:OwnerID;constraint:OnDelete:CASCADE;"`
|
||||
}
|
||||
|
||||
type Allowance struct {
|
||||
UserID uuid.UUID `gorm:"type:uuid;primaryKey"`
|
||||
AllowanceByte uint64 `gorm:"not null"`
|
||||
AllowanceFile uint64 `gorm:"not null"`
|
||||
User *User `gorm:"foreignKey:UserID;constraint:OnDelete:CASCADE;"`
|
||||
}
|
||||
|
@ -20,10 +20,10 @@ type User struct {
|
||||
Authenticated bool
|
||||
}
|
||||
|
||||
type FileInfo struct {
|
||||
Name string `json:"name"`
|
||||
Size uint64 `json:"size"`
|
||||
Chunk uint64 `json:"chunk"`
|
||||
type Allowance struct {
|
||||
AllowanceByte string
|
||||
AllowanceUsedByte string
|
||||
AllowanceUsedPercent string
|
||||
}
|
||||
|
||||
type FileData struct {
|
||||
@ -52,6 +52,9 @@ type Database interface {
|
||||
GetAllUsers() ([]models.User, error)
|
||||
UpdateUserPassword(email string, password string) error
|
||||
|
||||
CreateAllowance(userID uuid.UUID) error
|
||||
GetAllowance(userID uuid.UUID) (*models.Allowance, error)
|
||||
|
||||
CreateFile(file *models.File) error
|
||||
GetFile(fileID string) (*models.File, error)
|
||||
GetUserFile(name string, ownerID string) (*models.File, error)
|
||||
@ -72,4 +75,5 @@ type Services interface {
|
||||
DeleteUser(email string)
|
||||
GetFile(id string) (*models.File, error)
|
||||
GetUserFile(name, ownerID string) (*FileWithDetail, error)
|
||||
GetUserStorageUsage(ownerID string) (uint64, error)
|
||||
}
|
||||
|
Reference in New Issue
Block a user