Documentation ¶
Index ¶
- Constants
- Variables
- func CreateBaseFileFolder(ownerId string, fileStoreId string) (string, error)
- func CreateFileStore(userId string) (string, error)
- func Database()
- func GetFileInfoFromRedis(md5 string) string
- type File
- type FileFolder
- type FileStore
- type Share
- func (share *Share) AddViewCount()
- func (file *Share) BeforeCreate(tx *gorm.DB) (err error)
- func (share *Share) CheckRedisExistsShare() bool
- func (share *Share) DailyViewCount() float64
- func (share *Share) DeleteShareInfoInRedis()
- func (share *Share) DownloadURL() (string, error)
- func (share *Share) GetShareInfoFromRedis() string
- func (share *Share) SaveShareInfoToRedis(downloadUrl string) error
- func (share *Share) SetEmptyShare()
- func (share *Share) ViewCount() (num int64)
- type User
Constants ¶
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 ¶
var DB *gorm.DB
Functions ¶
func CreateBaseFileFolder ¶
CreateBaseFileFolder create a user fileFolder with fileStoreId and ownerId, and return it uuid or err
func CreateFileStore ¶
CreateFileStore create new fileStore by userId, and return it uuid or err
func GetFileInfoFromRedis ¶
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 ¶
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 ¶
AddCurrentSize add size to currentsize
func (*FileStore) BeforeCreate ¶
BeforeCreate create uuid before insert database
func (*FileStore) SubCurrentSize ¶
SubCurrentSize sub size to cueerentsize
type Share ¶
type Share struct {}
func (*Share) AddViewCount ¶
func (share *Share) AddViewCount()
AddViewCount add share view in redis
func (*Share) BeforeCreate ¶
BeforeCreate create uuid before insert database
func (*Share) CheckRedisExistsShare ¶
CheckRedisExistsShare use title info to check, because title surely exsits when the share info store to redis
func (*Share) DailyViewCount ¶
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 ¶
DownloadURL get share download url
func (*Share) GetShareInfoFromRedis ¶
GetShareInfoFromRedis get share info from redis and return downloadurl
func (*Share) SaveShareInfoToRedis ¶
SaveShareInRedis save share info to 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 ¶
CheckPassword check user password
func (*User) CreateUser ¶
CreateUser create user in database, and bind a userstore for user
func (*User) SetPassword ¶
SetPassword encrypt user password to save data