首次提交:初始化项目代码
This commit is contained in:
@@ -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,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user