models

package
v0.0.0-...-0e219ad Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const SecretType_Private = 2
View Source
const SecretType_Public = 1

Variables

This section is empty.

Functions

func AuditShareFile

func AuditShareFile(username, filehash string) bool

AuditShareFile: 审核文件

func CancelAuditShareFile

func CancelAuditShareFile(username, filehash string) bool

CancelAuditShareFile: 取消审核文件

func CancelShareFile

func CancelShareFile(username, filehash string) bool

CancelShareFile: 取消共享文件

func CheckFileExist

func CheckFileExist(filehash string) bool

CheckFileExist : 检查全局文件表中文件元信息是否存在

func CheckUserFileExist

func CheckUserFileExist(username, filename, filehash string) bool

CheckFileExist : 检查全局文件表中文件元信息是否存在

func CloseDB

func CloseDB()

CloseDB closes database connection (unnecessary)

func CommitFileInfo

func CommitFileInfo(file File) (int, error)

func CreateInviteCode

func CreateInviteCode(code string) error

func DeleteFile

func DeleteFile(filehash, filename string) error

DeleteFile : 删除文件

func DeleteUser

func DeleteUser(username string) error

DeleteUser : 删除用户

func DeleteUserFile

func DeleteUserFile(username, filehash, filename string) error

DeleteUserFile : 删除文件

func DeleteUserFileByUsername

func DeleteUserFileByUsername(username string) error

func FileTransaction

func FileTransaction(uid int, toUid int, transactionFileId int, privateKey string) (bool, error)

func IsValid

func IsValid(code string) (bool, error)

func LikeFile

func LikeFile(uid, fileID, likeNum int) (int, string)

func OnFileUploadFinished

func OnFileUploadFinished(filehash string, filename string,
	filesize int64, fileaddr string) error

OnFileUploadFinished : 文件上传完成,保存meta

func OnUserFileUploadFinished

func OnUserFileUploadFinished(username, filehash, filename string, filesize int64) error

OnUserFileUploadFinished : 更新用户文件表

func PublicFile

func PublicFile(uid, fileID int) error

func RenameFileName

func RenameFileName(filehash, oldfilename, filename string) bool

RenameFileName : 文件重命名

func RenameUserFileName

func RenameUserFileName(username, filehash, oldfilename, filename string) bool

RenameUserFileName : 文件重命名

func Setup

func Setup()

func ShareFile

func ShareFile(username, filehash string) bool

ShareFile: 共享文件

func UpdateUserPassword

func UpdateUserPassword(username string, passwd string) (bool, error)

UpdateUserPassword : 修改用户密码

func UserExist

func UserExist(username string) (bool, error)

UserExist : 查询用户是否存在

func UserSignin

func UserSignin(username string, encpwd string) bool

UserSignin : 判断密码是否一致

func UserSignup

func UserSignup(
	username string, passwd string, inviteCode string,
	phone string, avatarUrl string,
) bool

UserSignup : 通过用户名及密码完成user表的注册操作

Types

type File

type File struct {
	ID            int    `gorm:"primary_key" json:"file_id"`
	FileSHA1      string `gorm:"column:file_sha1;not null" json:"file_sha1,omitempty"`
	FileName      string `gorm:"column:file_name;not null" json:"file_name"`
	FileSize      int64  `gorm:"column:file_size;not null" json:"file_size,omitempty"`
	FileAddr      string `gorm:"column:file_addr;not null" json:"file_addr"`
	ImgAddr       string `gorm:"column:img_addr;not null" json:"img_addr"`
	OwnerUID      int    `gorm:"column:owner_uid;not null" json:"owner_uid,omitempty"`
	CreatorUID    int    `gorm:"column:creator_uid;not null" json:"creator_uid,omitempty"`
	CreateAt      string `gorm:"column:create_at;" json:"create_at,omitempty"`
	UpdateAt      string `gorm:"column:update_at;" json:"update_at,omitempty"`
	Status        int64  `gorm:"column:status;" json:"status,omitempty"`
	TransactionId string `gorm:"column:transaction_id;" json:"TransactionId"`
}

File : 文件表结构体

func GetFileMeta

func GetFileMeta(filehash, filename string) (*File, error)

GetFileMeta : 从mysql获取文件元信息

func GetFileMetaList

func GetFileMetaList(limit int) ([]File, error)

GetFileMetaList : 从mysql批量获取文件元信息

type FileRead

type FileRead struct {
	ID            int    `gorm:"primary_key" json:"file_id"`
	FileSHA1      string `gorm:"column:file_sha1;not null" json:"file_sha1,omitempty"`
	FileName      string `gorm:"column:file_name;not null" json:"file_name"`
	FileSize      int64  `gorm:"column:file_size;not null" json:"file_size,omitempty"`
	FileAddr      string `gorm:"column:file_addr;not null" json:"file_addr"`
	ImgAddr       string `gorm:"column:img_addr;not null" json:"img_addr"`
	OwnerUID      int    `gorm:"column:owner_uid;not null" json:"owner_uid,omitempty"`
	CreatorUID    int    `gorm:"column:creator_uid;not null" json:"creator_uid,omitempty"`
	Username      string `gorm:"column:username;not null" json:"username,omitempty"`
	AvatarUrl     string `gorm:"column:avatar_url;" json:"avatar_url,omitempty"`
	LikeCnt       int    `gorm:"column:like_cnt;not null" json:"like_cnt"`
	ArTag         bool   `gorm:"column:ar_tag;not null" json:"ar_tag"`
	CreateAt      string `gorm:"column:create_at;" json:"create_at,omitempty"`
	UpdateAt      string `gorm:"column:update_at;" json:"update_at,omitempty"`
	Status        int64  `gorm:"column:status;" json:"status,omitempty"`
	TransactionId string `gorm:"column:transaction_id;" json:"TransactionId"`
}

func GetFile

func GetFile(ownerUid int, fileId int) (*FileRead, error)

func ListOwnFileInfo

func ListOwnFileInfo(owner int, page, limit int) ([]FileRead, error)

func ListPublicFileInfo

func ListPublicFileInfo(page, limit int) ([]FileRead, error)

type InviteCode

type InviteCode struct {
	ID         int    `gorm:"primary_key" json:"-"`
	Code       string `gorm:"column:code;not null"`
	Status     int    `gorm:"column:status;not null"`
	CreateTime string `gorm:"column:create_time;not null"`
	LastUpdate string `gorm:"column:last_update;not null"`
}

func QueryInviteCode

func QueryInviteCode(code string) (*InviteCode, error)

type SecretType

type SecretType int

type User

type User struct {
	ID           int    `gorm:"primary_key" json:"id"`
	Username     string `gorm:"column:user_name;not null" json:"Username"`
	Userpwd      string `gorm:"column:user_pwd;not null" json:"-"`
	SignupAt     string `gorm:"column:signup_at;" json:"SignupAt"`
	LastActiveAt string `gorm:"column:last_active;" json:"LastActive"`
	Status       int    `gorm:"column:status;" json:"-"`
	InviteCode   string `gorm:"column:invite_code;" json:"InviteCode"`
	Phone        string `gorm:"column:phone;" json:"Phone"`
	AvatarUrl    string `gorm:"column:avatar_url;" json:"AvatarUrl"`
	Balance      int    `gorm:"column:balance;" json:"Balance"`
}

User : 用户表model

func BatchQueryUserInfoList

func BatchQueryUserInfoList(uids []int) ([]User, error)

func GetUserInfo

func GetUserInfo(username string) (User, error)

GetUserInfo : 查询用户信息

func QueryUserInfoList

func QueryUserInfoList(offset, limit int) ([]User, error)

QueryUserInfoList : 批量获取用户信息

func UpdateUserAvatar

func UpdateUserAvatar(username string, avatarUrl string) (*User, error)

UpdateUserAvatar : 修改用头像

type UserFile

type UserFile struct {
	ID         int    `gorm:"primary_key" json:"-"`
	UserName   string `gorm:"column:user_name;not null" json:"Username"`
	FileHash   string `gorm:"column:file_sha1;not null" json:"FileHash"`
	FileName   string `gorm:"column:file_name;not null" json:"FileName"`
	FileSize   int64  `gorm:"column:file_size;not null" json:"FileSize"`
	UploadAt   string `gorm:"column:upload_at;" json:"UploadAt"`
	LastUpdate string `gorm:"column:last_update;" json:"LastUpdate"`
	Status     int64  `gorm:"column:status;not null" json:"-"`
	// 共享状态(0:未共享、1:待审核、2:已共享)
	ShareStatus int64 `gorm:"column:share_status;not null" json:"ShareStatus"`
}

UserFile : 用户文件表结构体

func QueryShareFileMetas

func QueryShareFileMetas(shareStatus int, usernameFilter, filenameFilter string, reverse bool, offset, limit int) ([]UserFile, error)

文件共享部分 QueryShareFileMetas : 批量获取共享文件信息

func QueryUserFileMeta

func QueryUserFileMeta(username, filehash, filename string) (*UserFile, error)

QueryUserFileMeta : 获取用户单个文件信息

func QueryUserFileMetas

func QueryUserFileMetas(username, filenameFilter string, reverse bool, offset, limit int) ([]UserFile, error)

QueryUserFileMetas : 批量获取用户文件信息

type UserOrder

type UserOrder struct {
	ID            int    `gorm:"primary_key" json:"id"`
	Type          int    `gorm:"column:type;not null" json:"type"`
	OrderSN       string `gorm:"column:order_sn;not null" json:"order_sn"`
	Content       string `gorm:"column:content;not null" json:"content"`
	CreateTime    string `gorm:"column:create_time;not null" json:"create_time"`
	Uid           int    `gorm:"column:uid;not null" json:"uid"`
	ToId          int    `gorm:"column:to_id;not null" json:"to_id"`
	TransactionId string `gorm:"column:transaction_id;not null" json:"TransactionId"`
}

func GetOrders

func GetOrders(uid int) ([]*UserOrder, error)

type UserSecretFile

type UserSecretFile struct {
	ID         int        `gorm:"primary_key" json:"-"`
	UserName   string     `gorm:"column:user_name;not null" json:"Username"`
	FileHash   string     `gorm:"column:file_sha1;not null" json:"FileHash"`
	FileName   string     `gorm:"column:file_name;not null" json:"FileName"`
	FileSize   int64      `gorm:"column:file_size;not null" json:"FileSize"`
	CreateTime string     `gorm:"column:create_time;" json:"CreateTime"`
	LastUpdate string     `gorm:"column:last_update;" json:"LastUpdate"`
	Status     int64      `gorm:"column:status;not null" json:"status"`
	Type       SecretType `gorm:"column:type;not null" json:"type"`
	Data       string     `gorm:"column:data;not null" json:"data"`
}

UserFile : 用户文件表结构体

func GenerateUserSecretFile

func GenerateUserSecretFile(username string) ([]*UserSecretFile, error)

func QuerySecretFile

func QuerySecretFile(username string, secretType SecretType) (*UserSecretFile, error)

Jump to

Keyboard shortcuts

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