首次提交:初始化项目代码
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type DeletedFile struct {
|
||||
ID uint `json:"id" gorm:"primaryKey;comment:删除记录ID"`
|
||||
UserID uint `json:"user_id" gorm:"comment:用户ID"`
|
||||
UserCode string `json:"user_code" gorm:"index;size:8;comment:用户码"`
|
||||
FileKey string `json:"file_key" gorm:"size:500;comment:文件存储键"`
|
||||
FileName string `json:"file_name" gorm:"size:255;comment:文件名"`
|
||||
Size int64 `json:"size" gorm:"comment:文件大小(字节)"`
|
||||
DeletedAt time.Time `json:"deleted_at" gorm:"comment:删除时间"`
|
||||
RemovedAt gorm.DeletedAt `json:"-" gorm:"comment:物理删除时间"`
|
||||
}
|
||||
|
||||
func (DeletedFile) TableName() string {
|
||||
return "deleted_files"
|
||||
}
|
||||
|
||||
func (DeletedFile) TableComment() string {
|
||||
return "回收站文件表"
|
||||
}
|
||||
|
||||
func NewDeletedFile(userID uint, userCode, fileKey, fileName string, size int64) *DeletedFile {
|
||||
return &DeletedFile{
|
||||
UserID: userID,
|
||||
UserCode: userCode,
|
||||
FileKey: fileKey,
|
||||
FileName: fileName,
|
||||
Size: size,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type Favorite struct {
|
||||
ID uint `json:"id" gorm:"primaryKey;comment:收藏ID"`
|
||||
UserID uint `json:"user_id" gorm:"comment:用户ID"`
|
||||
UserCode string `json:"user_code" gorm:"index;size:8;comment:用户码"`
|
||||
FileKey string `json:"file_key" gorm:"size:500;comment:文件存储键"`
|
||||
Size int64 `json:"size" gorm:"default:0;comment:文件大小(字节)"`
|
||||
CreatedAt time.Time `json:"created_at" gorm:"comment:收藏时间"`
|
||||
DeletedAt gorm.DeletedAt `json:"-" gorm:"comment:删除时间"`
|
||||
}
|
||||
|
||||
func (Favorite) TableName() string {
|
||||
return "favorites"
|
||||
}
|
||||
|
||||
func (Favorite) TableComment() string {
|
||||
return "用户收藏表"
|
||||
}
|
||||
|
||||
func NewFavorite(userID uint, userCode, fileKey string, size int64) *Favorite {
|
||||
return &Favorite{
|
||||
UserID: userID,
|
||||
UserCode: userCode,
|
||||
FileKey: fileKey,
|
||||
Size: size,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package entity
|
||||
|
||||
// FileMeta contains metadata about a file stored in the object storage.
|
||||
// FileMeta 包含存储在对象存储中的文件元数据。
|
||||
//
|
||||
// Fields:
|
||||
// - Key: The unique key/path of the file in the storage.
|
||||
// - Size: The size of the file in bytes.
|
||||
//
|
||||
// 字段:
|
||||
// - Key: 文件在存储中的唯一键/路径。
|
||||
// - Size: 文件大小(字节)。
|
||||
type FileMeta struct {
|
||||
Key string `json:"key"`
|
||||
Size int64 `json:"size"`
|
||||
}
|
||||
|
||||
// UploadRequest contains the necessary information to upload a file.
|
||||
// UploadRequest 包含上传文件所需的必要信息。
|
||||
//
|
||||
// Fields:
|
||||
// - Filename: The original filename.
|
||||
// - Content: The file content as bytes.
|
||||
// - ContentType: The MIME type of the file.
|
||||
//
|
||||
// 字段:
|
||||
// - Filename: 原始文件名。
|
||||
// - Content: 文件内容(字节)。
|
||||
// - ContentType: 文件的 MIME 类型。
|
||||
type UploadRequest struct {
|
||||
Filename string
|
||||
Content []byte
|
||||
ContentType string
|
||||
}
|
||||
Reference in New Issue
Block a user