mirror of
https://github.com/wgh136/nysoure.git
synced 2025-12-16 15:51:14 +00:00
feat: Add tag field to file and uploading file models, and update related functions
This commit is contained in:
@@ -19,6 +19,7 @@ type File struct {
|
||||
User User `gorm:"foreignKey:UserID"`
|
||||
Size int64
|
||||
Hash string `gorm:"default:null"`
|
||||
Tag string `gorm:"type:text;default:null"`
|
||||
}
|
||||
|
||||
type FileView struct {
|
||||
@@ -32,6 +33,7 @@ type FileView struct {
|
||||
Hash string `json:"hash,omitempty"`
|
||||
StorageName string `json:"storage_name,omitempty"`
|
||||
CreatedAt int64 `json:"created_at,omitempty"`
|
||||
Tag string `json:"tag,omitempty"`
|
||||
}
|
||||
|
||||
func (f *File) ToView() *FileView {
|
||||
@@ -45,6 +47,7 @@ func (f *File) ToView() *FileView {
|
||||
Hash: f.Hash,
|
||||
StorageName: f.Storage.Name,
|
||||
CreatedAt: f.CreatedAt.Unix(),
|
||||
Tag: f.Tag,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,5 +67,6 @@ func (f *File) ToViewWithResource() *FileView {
|
||||
User: f.User.ToView(),
|
||||
Resource: resource,
|
||||
Hash: f.Hash,
|
||||
Tag: f.Tag,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ type UploadingFile struct {
|
||||
TempPath string
|
||||
Resource Resource `gorm:"foreignKey:TargetResourceID"`
|
||||
Storage Storage `gorm:"foreignKey:TargetStorageID"`
|
||||
Tag string `gorm:"type:text;default:null"`
|
||||
}
|
||||
|
||||
func (uf *UploadingFile) BlocksCount() int {
|
||||
|
||||
Reference in New Issue
Block a user