Documentation ¶
Index ¶
- Constants
- Variables
- func CountFileSize() (int64, error)
- func CountModel(m interface{}) (count int64, err error)
- func CountUser() (int64, error)
- func CreateAuthToken(t *AuthToken) error
- func CreateFile(f *File) error
- func CreateMessage(msg *Message) error
- func CreateOAuth2Application(app *OAuth2Application) error
- func CreateOAuth2Token(t *OAuth2Token) error
- func CreateUser(u *User) error
- func DeleteAuthTokenByID(id, userID uint) error
- func DeleteAuthTokenByUserID(userID uint) error
- func DeleteFile(f *File) error
- func DeleteOAuth2Application(app *OAuth2Application) error
- func DeleteOAuth2TokenByAccessToken(accessToken string) error
- func DeleteOAuth2TokenByCode(code string) error
- func DeleteOAuth2TokenByRefreshToken(refreshToken string) error
- func DeleteUser(u *User) error
- func GetNicknamesByID(uids []uint) (map[uint]string, error)
- func IsEmailUsed(email string) (bool, error)
- func IsErrAuthTokenEmpty(err error) bool
- func IsErrAuthTokenNotExist(err error) bool
- func IsErrEmailAlreadyUsed(err error) bool
- func IsErrFileAlreadyExist(err error) bool
- func IsErrFileLocked(err error) bool
- func IsErrFileMaxSizeLimit(err error) bool
- func IsErrFileNotDirectory(err error) bool
- func IsErrFileNotExist(err error) bool
- func IsErrFileParentNotDirectory(err error) bool
- func IsErrMessageReceiverNotExist(err error) bool
- func IsErrMessageSendNotExist(err error) bool
- func IsErrModifyRootFile(err error) bool
- func IsErrOAuth2ApplicationNotExist(err error) bool
- func IsErrOAuth2TokenNotExist(err error) bool
- func IsErrUserNotExist(err error) bool
- func IsErrUsernameAlreadyUsed(err error) bool
- func IsFileUnlockFailed(err error) bool
- func IsUserExists(uid int64) (bool, error)
- func IsUsernameUsed(username string) (bool, error)
- func LockUserFile(ctx context.Context, uid uint) (id string, err error)
- func LoginTypeToString(t LoginType) string
- func MoveFile(f *File, dir *File) error
- func NewEngine(ctx context.Context, migrateFunc func(*gorm.DB) error) error
- func RenameFile(f *File) error
- func SaveUser(u *User) error
- func UnlockUserFile(ctx context.Context, uid uint, id string) error
- func UpdateAuthToken(t *AuthToken) error
- type AuthToken
- type ErrAuthTokenEmpty
- type ErrAuthTokenNotExist
- type ErrEmailAlreadyUsed
- type ErrFileAlreadyExist
- type ErrFileLocked
- type ErrFileNotDirectory
- type ErrFileNotExist
- type ErrFileParentNotDirectory
- type ErrFileUnlockFailed
- type ErrMessageReceiverNotExist
- type ErrMessageSenderNotExist
- type ErrModifyRootFile
- type ErrOAuth2ApplicationNotExist
- type ErrOAuth2TokenNotExist
- type ErrUserMaxFileCapacityLimit
- type ErrUserNotExist
- type ErrUsernameAlreadyUsed
- type File
- func CreateDirectory(parent *File, dirName string) (*File, error)
- func CreateUserRootFile(u *User) *File
- func GetFileByID(id uint, uid uint) (*File, error)
- func GetUserRootFile(uid uint) (*File, error)
- func SearchFile(opts *SearchFileOptions) (files []*File, _ int64, _ error)
- func TryUploadFile(u *User, p *File, header *multipart.FileHeader) (*File, error)
- type FileType
- type FindUserMessageOption
- type ListOptions
- type LoginType
- type Message
- type MessageRoleType
- type OAuth2Application
- type OAuth2Token
- func (t *OAuth2Token) GetAccess() string
- func (t *OAuth2Token) GetAccessCreateAt() time.Time
- func (t *OAuth2Token) GetAccessExpiresIn() time.Duration
- func (t *OAuth2Token) GetClientID() string
- func (t *OAuth2Token) GetCode() string
- func (t *OAuth2Token) GetCodeCreateAt() time.Time
- func (t *OAuth2Token) GetCodeExpiresIn() time.Duration
- func (t *OAuth2Token) GetRedirectURI() string
- func (t *OAuth2Token) GetRefresh() string
- func (t *OAuth2Token) GetRefreshCreateAt() time.Time
- func (t *OAuth2Token) GetRefreshExpiresIn() time.Duration
- func (t *OAuth2Token) GetScope() string
- func (t *OAuth2Token) GetUserID() string
- func (t *OAuth2Token) Invalid() error
- func (t *OAuth2Token) InvalidAccessToken() error
- func (t *OAuth2Token) InvalidCode() error
- func (t *OAuth2Token) InvalidRefreshToken() error
- func (t *OAuth2Token) New() oauth2.TokenInfo
- func (t *OAuth2Token) SetAccess(token string)
- func (t *OAuth2Token) SetAccessCreateAt(createAt time.Time)
- func (t *OAuth2Token) SetAccessExpiresIn(d time.Duration)
- func (t *OAuth2Token) SetClientID(id string)
- func (t *OAuth2Token) SetCode(code string)
- func (t *OAuth2Token) SetCodeCreateAt(createAt time.Time)
- func (t *OAuth2Token) SetCodeExpiresIn(d time.Duration)
- func (t *OAuth2Token) SetRedirectURI(uri string)
- func (t *OAuth2Token) SetRefresh(token string)
- func (t *OAuth2Token) SetRefreshCreateAt(createAt time.Time)
- func (t *OAuth2Token) SetRefreshExpiresIn(d time.Duration)
- func (t *OAuth2Token) SetScope(scope string)
- func (t *OAuth2Token) SetUserID(id string)
- type ReadDirOption
- type SearchFileOptions
- type SearchOrderBy
- type SearchUserOptions
- type Statistic
- type TimestampOrientation
- type User
- func (u *User) AvatarLink() string
- func (u *User) AvatarPath() string
- func (u *User) CanIUploadFile(size int64) bool
- func (u *User) DeleteAvatar() error
- func (u *User) GetRootDir() ([]*File, error)
- func (u *User) HashPassword(pwd string)
- func (u *User) IsOAuth2() bool
- func (u *User) IsPasswordSet() bool
- func (u *User) IsPlain() bool
- func (u *User) RemainingFileSize() int64
- func (u *User) UploadAvatar(data []byte) error
- func (u *User) ValidatePassword(pwd string) bool
- type UserMessage
- type UserMessageStatus
- type UserType
Constants ¶
View Source
const ( SearchOrderByID = "id ASC" SearchOrderByIDReverse = "id DESC" SearchOrderByOldest = "created_at ASC" SearchOrderByNewest = "created_at DESC" SearchOrderByLeastUpdated = "updated_at ASC" SearchOrderByRecentUpdated = "updated_at DESC" SearchOrderByAlphabetically = "nickname ASC" SearchOrderByAlphabeticallyReverse = "nickname DESC" SearchOrderByMaxFileCapacity = "max_file_capacity ASC" SearchOrderByMaxFileCapacityReverse = "max_file_capacity DESC" SearchOrderByUsedFileCapacity = "used_file_capacity ASC" SearchOrderByUsedFileCapacityReverse = "used_file_capacity DESC" )
View Source
const (
MaxUserMessageCount = 32
)
Variables ¶
View Source
var (
CacheUserKey = "user_%d"
)
Functions ¶
func CountFileSize ¶
func CountModel ¶
func CreateAuthToken ¶
func CreateFile ¶
func CreateMessage ¶
func CreateOAuth2Application ¶
func CreateOAuth2Application(app *OAuth2Application) error
func CreateOAuth2Token ¶
func CreateOAuth2Token(t *OAuth2Token) error
func CreateUser ¶
func DeleteAuthTokenByID ¶
func DeleteAuthTokenByUserID ¶
func DeleteFile ¶
func DeleteOAuth2Application ¶
func DeleteOAuth2Application(app *OAuth2Application) error
func DeleteOAuth2TokenByCode ¶
func DeleteUser ¶
func IsEmailUsed ¶
func IsErrAuthTokenEmpty ¶
func IsErrAuthTokenNotExist ¶
func IsErrEmailAlreadyUsed ¶
func IsErrFileAlreadyExist ¶
func IsErrFileLocked ¶
func IsErrFileMaxSizeLimit ¶
func IsErrFileNotDirectory ¶
func IsErrFileNotExist ¶
func IsErrModifyRootFile ¶
func IsErrUserNotExist ¶
func IsFileUnlockFailed ¶
func IsUserExists ¶
func IsUsernameUsed ¶
func LoginTypeToString ¶
func RenameFile ¶
func UpdateAuthToken ¶
Types ¶
type AuthToken ¶
type AuthToken struct { ID uint `gorm:"primary_key"` CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time `sql:"index"` Code string `gorm:"unique_index;not null"` UserID uint `gorm:"index"` User *User `gorm:"-"` HasRecentActivity bool `gorm:"-"` }
func GetAuthTokenByCode ¶
func ListAuthTokens ¶
func ListAuthTokens(uid uint, listOpts ListOptions) ([]*AuthToken, error)
type ErrAuthTokenEmpty ¶
type ErrAuthTokenEmpty struct { }
func (ErrAuthTokenEmpty) Error ¶
func (e ErrAuthTokenEmpty) Error() string
type ErrAuthTokenNotExist ¶
func (ErrAuthTokenNotExist) Error ¶
func (e ErrAuthTokenNotExist) Error() string
type ErrEmailAlreadyUsed ¶
type ErrEmailAlreadyUsed struct {
Email string
}
func (ErrEmailAlreadyUsed) Error ¶
func (err ErrEmailAlreadyUsed) Error() string
type ErrFileAlreadyExist ¶
func (ErrFileAlreadyExist) Error ¶
func (err ErrFileAlreadyExist) Error() string
type ErrFileLocked ¶
type ErrFileLocked struct {
ID uint
}
func (ErrFileLocked) Error ¶
func (err ErrFileLocked) Error() string
type ErrFileNotDirectory ¶
func (ErrFileNotDirectory) Error ¶
func (err ErrFileNotDirectory) Error() string
type ErrFileNotExist ¶
func (ErrFileNotExist) Error ¶
func (err ErrFileNotExist) Error() string
type ErrFileParentNotDirectory ¶
func (ErrFileParentNotDirectory) Error ¶
func (err ErrFileParentNotDirectory) Error() string
type ErrFileUnlockFailed ¶
func (ErrFileUnlockFailed) Error ¶
func (err ErrFileUnlockFailed) Error() string
type ErrMessageReceiverNotExist ¶
type ErrMessageReceiverNotExist struct { ID uint Role MessageRoleType }
func (ErrMessageReceiverNotExist) Error ¶
func (e ErrMessageReceiverNotExist) Error() string
type ErrMessageSenderNotExist ¶
type ErrMessageSenderNotExist struct { ID uint Role MessageRoleType }
func (ErrMessageSenderNotExist) Error ¶
func (e ErrMessageSenderNotExist) Error() string
type ErrModifyRootFile ¶
func (ErrModifyRootFile) Error ¶
func (err ErrModifyRootFile) Error() string
type ErrOAuth2ApplicationNotExist ¶
func (ErrOAuth2ApplicationNotExist) Error ¶
func (e ErrOAuth2ApplicationNotExist) Error() string
type ErrOAuth2TokenNotExist ¶
func (ErrOAuth2TokenNotExist) Error ¶
func (e ErrOAuth2TokenNotExist) Error() string
type ErrUserMaxFileCapacityLimit ¶
type ErrUserMaxFileCapacityLimit struct {
UserID uint
}
func (ErrUserMaxFileCapacityLimit) Error ¶
func (err ErrUserMaxFileCapacityLimit) Error() string
type ErrUserNotExist ¶
func (ErrUserNotExist) Error ¶
func (err ErrUserNotExist) Error() string
type ErrUsernameAlreadyUsed ¶
type ErrUsernameAlreadyUsed struct {
Username string
}
func (ErrUsernameAlreadyUsed) Error ¶
func (err ErrUsernameAlreadyUsed) Error() string
type File ¶
type File struct { ID uint `gorm:"primary_key"` CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time `sql:"index"` FileID string `gorm:"unique_index"` FileDir string FileName string FileType FileType FileSize int64 Owner uint ParentID uint }
func CreateUserRootFile ¶
func GetUserRootFile ¶
func SearchFile ¶
func SearchFile(opts *SearchFileOptions) (files []*File, _ int64, _ error)
func TryUploadFile ¶
type FindUserMessageOption ¶
type FindUserMessageOption struct { UserID uint Status UserMessageStatus Orientation TimestampOrientation Timestamp time.Time Count uint }
type ListOptions ¶
func (ListOptions) SetDefaultOptions ¶
func (opts ListOptions) SetDefaultOptions()
func (ListOptions) SetEnginePagination ¶
func (opts ListOptions) SetEnginePagination(e *gorm.DB) *gorm.DB
type Message ¶
type Message struct { ID uint `gorm:"primary_key"` CreatedAt time.Time `sql:"index"` SenderID uint `sql:"index"` SenderType MessageRoleType ReceiverID uint `sql:"index"` ReceiverType MessageRoleType ContentType string Content []byte `gorm:"varchar(512)"` }
type MessageRoleType ¶
type MessageRoleType int
const ( MessageRoleSystem MessageRoleType = iota MessageRoleUser MessageRoleGroup )
type OAuth2Application ¶
type OAuth2Application struct { ID uint `gorm:"primary_key"` CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time `sql:"index"` UID uint `gorm:"index"` User *User `gorm:"-"` Name string ClientID string `gorm:"unique_index"` ClientSecret string Domain string }
func GetOAuth2ApplicationByClientID ¶
func GetOAuth2ApplicationByClientID(clientID string) (*OAuth2Application, error)
func GetOAuth2ApplicationByUserID ¶
func GetOAuth2ApplicationByUserID(userID uint) ([]*OAuth2Application, error)
func (*OAuth2Application) LoadUser ¶
func (app *OAuth2Application) LoadUser() (err error)
type OAuth2Token ¶
type OAuth2Token struct { ID uint `gorm:"primary_key"` ClientID string `gorm:"index"` UserID string `gorm:"index"` RedirectURI string Scope string Code string `gorm:"index"` CodeExpiredAt time.Time CodeExpiresIn time.Duration Access string `gorm:"index"` AccessExpiredAt time.Time AccessExpiresIn time.Duration Refresh string `gorm:"index"` RefreshExpiredAt time.Time RefreshExpiresIn time.Duration }
func GetOAuth2TokenByAccessToken ¶
func GetOAuth2TokenByAccessToken(token string) (*OAuth2Token, error)
func GetOAuth2TokenByCode ¶
func GetOAuth2TokenByCode(code string) (*OAuth2Token, error)
func GetOAuth2TokenByRefreshToken ¶
func GetOAuth2TokenByRefreshToken(token string) (*OAuth2Token, error)
func (*OAuth2Token) GetAccess ¶
func (t *OAuth2Token) GetAccess() string
func (*OAuth2Token) GetAccessCreateAt ¶
func (t *OAuth2Token) GetAccessCreateAt() time.Time
func (*OAuth2Token) GetAccessExpiresIn ¶
func (t *OAuth2Token) GetAccessExpiresIn() time.Duration
func (*OAuth2Token) GetClientID ¶
func (t *OAuth2Token) GetClientID() string
func (*OAuth2Token) GetCode ¶
func (t *OAuth2Token) GetCode() string
func (*OAuth2Token) GetCodeCreateAt ¶
func (t *OAuth2Token) GetCodeCreateAt() time.Time
func (*OAuth2Token) GetCodeExpiresIn ¶
func (t *OAuth2Token) GetCodeExpiresIn() time.Duration
func (*OAuth2Token) GetRedirectURI ¶
func (t *OAuth2Token) GetRedirectURI() string
func (*OAuth2Token) GetRefresh ¶
func (t *OAuth2Token) GetRefresh() string
func (*OAuth2Token) GetRefreshCreateAt ¶
func (t *OAuth2Token) GetRefreshCreateAt() time.Time
func (*OAuth2Token) GetRefreshExpiresIn ¶
func (t *OAuth2Token) GetRefreshExpiresIn() time.Duration
func (*OAuth2Token) GetScope ¶
func (t *OAuth2Token) GetScope() string
func (*OAuth2Token) GetUserID ¶
func (t *OAuth2Token) GetUserID() string
func (*OAuth2Token) Invalid ¶
func (t *OAuth2Token) Invalid() error
func (*OAuth2Token) InvalidAccessToken ¶
func (t *OAuth2Token) InvalidAccessToken() error
func (*OAuth2Token) InvalidCode ¶
func (t *OAuth2Token) InvalidCode() error
func (*OAuth2Token) InvalidRefreshToken ¶
func (t *OAuth2Token) InvalidRefreshToken() error
func (*OAuth2Token) New ¶
func (t *OAuth2Token) New() oauth2.TokenInfo
func (*OAuth2Token) SetAccess ¶
func (t *OAuth2Token) SetAccess(token string)
func (*OAuth2Token) SetAccessCreateAt ¶
func (t *OAuth2Token) SetAccessCreateAt(createAt time.Time)
func (*OAuth2Token) SetAccessExpiresIn ¶
func (t *OAuth2Token) SetAccessExpiresIn(d time.Duration)
func (*OAuth2Token) SetClientID ¶
func (t *OAuth2Token) SetClientID(id string)
func (*OAuth2Token) SetCode ¶
func (t *OAuth2Token) SetCode(code string)
func (*OAuth2Token) SetCodeCreateAt ¶
func (t *OAuth2Token) SetCodeCreateAt(createAt time.Time)
func (*OAuth2Token) SetCodeExpiresIn ¶
func (t *OAuth2Token) SetCodeExpiresIn(d time.Duration)
func (*OAuth2Token) SetRedirectURI ¶
func (t *OAuth2Token) SetRedirectURI(uri string)
func (*OAuth2Token) SetRefresh ¶
func (t *OAuth2Token) SetRefresh(token string)
func (*OAuth2Token) SetRefreshCreateAt ¶
func (t *OAuth2Token) SetRefreshCreateAt(createAt time.Time)
func (*OAuth2Token) SetRefreshExpiresIn ¶
func (t *OAuth2Token) SetRefreshExpiresIn(d time.Duration)
func (*OAuth2Token) SetScope ¶
func (t *OAuth2Token) SetScope(scope string)
func (*OAuth2Token) SetUserID ¶
func (t *OAuth2Token) SetUserID(id string)
type ReadDirOption ¶
type ReadDirOption struct {
OnlyDir bool
}
type SearchFileOptions ¶
type SearchFileOptions struct { ListOptions Keyword string Type FileType FID uint Owner uint OrderBy SearchOrderBy Actor *File }
type SearchOrderBy ¶
type SearchOrderBy string
func (SearchOrderBy) String ¶
func (s SearchOrderBy) String() string
type SearchUserOptions ¶
type SearchUserOptions struct { ListOptions Keyword string Type UserType UID uint IsActive sql.NullBool SearchByEmail bool OrderBy SearchOrderBy Actor *User }
type Statistic ¶
type Statistic struct { Counter struct { User, File, TotalFileSize int64 } }
func GetStatistic ¶
func GetStatistic() (stats Statistic)
type TimestampOrientation ¶
type TimestampOrientation int
const ( TimestampOrientationForward TimestampOrientation = iota // 向后查询 TimestampOrientationBack // 向前查询 )
type User ¶
type User struct { ID uint `gorm:"primary_key"` CreatedAt time.Time `sql:"index"` UpdatedAt time.Time `sql:"index"` DeletedAt *time.Time `sql:"index"` LastLoginAt time.Time `sql:"index"` Nickname string `gorm:"not null"` Username string `gorm:"unique_index,not null"` Email string `gorm:"unique_index,not null"` Password string `gorm:"not null" json:"-"` MustChangePassword bool `gorm:"not null,default:false"` IsActive bool `sql:"index"` IsAdmin bool LoginType LoginType Type UserType Avatar string `gorm:"varchar(2048)"` UsedFileCapacity int64 MaxFileCapacity int64 }
func GetUserByEmail ¶
func GetUserByID ¶
func GetUserByUsername ¶
func SearchUser ¶
func SearchUser(opts *SearchUserOptions) (users []*User, _ int64, _ error)
func (*User) AvatarLink ¶
func (*User) AvatarPath ¶
func (*User) CanIUploadFile ¶
func (*User) DeleteAvatar ¶
func (*User) GetRootDir ¶
func (*User) HashPassword ¶
func (*User) IsPasswordSet ¶
func (*User) RemainingFileSize ¶
func (*User) UploadAvatar ¶
func (*User) ValidatePassword ¶
type UserMessage ¶
type UserMessage struct { ID uint `gorm:"primary_key"` CreatedAt time.Time `gorm:"index"` UpdatedAt time.Time DeletedAt *time.Time `sql:"index"` UserID uint `gorm:"index"` MessageID uint Status UserMessageStatus }
func FindUserMessages ¶
func FindUserMessages(opts FindUserMessageOption) ([]*UserMessage, error)
type UserMessageStatus ¶
type UserMessageStatus int
const ( UserMessageStatusNone UserMessageStatus = iota UserMessageStatusRead UserMessageStatusUnread UserMessageStatusUndo )
Click to show internal directories.
Click to hide internal directories.