model

package
v0.0.0-...-4aebee4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 23, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PasswordCount password encryption difficulty
	PasswordCount = 12
	// super admin
	StatusSuperAdmin = "super_admin"
	// admin User
	StatusAdmin = "common_admin"
	// active User
	StatusActiveUser = "active"
	// inactive User
	StatusInactiveUser = "inactive"
	// Suspend User
	StatusSuspendUser = "suspend"
)

Variables

View Source
var DB *gorm.DB

Functions

func CreateBaseFileFolder

func CreateBaseFileFolder(ownerId string, fileStoreId string) (string, error)

CreateBaseFileFolder create a user fileFolder with fileStoreId and ownerId, and return it uuid or err

func CreateFileStore

func CreateFileStore(userId string) (string, error)

CreateFileStore create new fileStore by userId, and return it uuid or err

func Database

func Database()

Database init mysql connect

func GetFileInfoFromRedis

func GetFileInfoFromRedis(md5 string) string

GetFileInfoFromRedis get file upload path form redis

Types

type File

type File struct {
	Uuid           string `gorm:"primarykey"`
	Owner          string // file owner if File deleted the owner is null,
	FileName       string // real filename
	FilePostfix    string
	FileUuid       string // file used md5 as name in cloud
	FilePath       string // file's filefolder in cloud, used for save share file
	ParentFolderId string
	Size           int64 // file size
}

func (*File) BeforeCreate

func (file *File) BeforeCreate(tx *gorm.DB) (err error)

BeforeCreate create uuid before insert database

func (*File) SaveFileUploadInfoToRedis

func (file *File) SaveFileUploadInfoToRedis()

SaveFileUploadInfoToRedis save file path to redis

type FileFolder

type FileFolder struct {
	Uuid           string `gorm:"primarykey"`
	FileFolderName string
	ParentFolderID string
	FileStoreID    string
	OwnerID        string
	Size           int64
}

func (*FileFolder) AddFileFolderSize

func (fileFolder *FileFolder) AddFileFolderSize(t *gorm.DB, appendSize int64) (err error)

AddFileFolderSize add filefolder size and add size for parent filefolder

func (*FileFolder) BeforeCreate

func (fileFolder *FileFolder) BeforeCreate(tx *gorm.DB) (err error)

BeforeCreate create uuid before insert database

func (*FileFolder) SubFileFolderSize

func (fileFolder *FileFolder) SubFileFolderSize(t *gorm.DB, size int64) (err error)

SubFileFolderSize sub filefolder size and sub size for parent filefolder

func (*FileFolder) SubSize

func (fileFolder *FileFolder) SubSize(size int64) error

SubSize sub filefolder size

type FileStore

type FileStore struct {
	Uuid        string `gorm:"primarykey"`
	OwnerID     string
	CurrentSize int64
	MaxSize     int64
}

func (*FileStore) AddCurrentSize

func (fileStore *FileStore) AddCurrentSize(size int64) (err error)

AddCurrentSize add size to currentsize

func (*FileStore) BeforeCreate

func (fileStore *FileStore) BeforeCreate(tx *gorm.DB) (err error)

BeforeCreate create uuid before insert database

func (*FileStore) SubCurrentSize

func (fileStore *FileStore) SubCurrentSize(size int64) (err error)

SubCurrentSize sub size to cueerentsize

type Share

type Share struct {
	Uuid        string `gorm:"primarykey"`
	Owner       string
	FileId      string // file uuid of share file
	FileName    string
	Title       string
	Size        int64
	SharingTime string
}

func (*Share) AddViewCount

func (share *Share) AddViewCount()

AddViewCount add share view in redis

func (*Share) BeforeCreate

func (file *Share) BeforeCreate(tx *gorm.DB) (err error)

BeforeCreate create uuid before insert database

func (*Share) CheckRedisExistsShare

func (share *Share) CheckRedisExistsShare() bool

CheckRedisExistsShare use title info to check, because title surely exsits when the share info store to redis

func (*Share) DailyViewCount

func (share *Share) DailyViewCount() float64

DailyViewCount get daily view count by share uuid

func (*Share) DeleteShareInfoInRedis

func (share *Share) DeleteShareInfoInRedis()

DeleteShareInfoInRedis delete share info that in redis

func (*Share) DownloadURL

func (share *Share) DownloadURL() (string, error)

DownloadURL get share download url

func (*Share) GetShareInfoFromRedis

func (share *Share) GetShareInfoFromRedis() string

GetShareInfoFromRedis get share info from redis and return downloadurl

func (*Share) SaveShareInfoToRedis

func (share *Share) SaveShareInfoToRedis(downloadUrl string) error

SaveShareInRedis save share info to redis

func (*Share) SetEmptyShare

func (share *Share) SetEmptyShare()

SetEmptyShare set a empty share

func (*Share) ViewCount

func (share *Share) ViewCount() (num int64)

ViewCount get share view from redis

type User

type User struct {
	Uuid                 string `gorm:"primarykey"`
	UserName             string
	PasswordDigest       string
	NickName             string
	Status               string
	Avatar               string `gorm:"size:1000"`
	UserFileStoreID      string
	UserMainFileFolderID string
}

func (*User) CheckPassword

func (user *User) CheckPassword(password string) bool

CheckPassword check user password

func (*User) CreateUser

func (user *User) CreateUser() error

CreateUser create user in database, and bind a userstore for user

func (*User) SetPassword

func (user *User) SetPassword(password string) error

SetPassword encrypt user password to save data

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL