mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
Feat: file download in service level
This commit is contained in:
@@ -17,6 +17,9 @@ type File struct {
|
||||
FolderID uint `gorm:"index:folder_id"`
|
||||
PolicyID uint
|
||||
Dir string `gorm:"size:65536"`
|
||||
|
||||
// 关联模型
|
||||
Policy Policy `gorm:"PRELOAD:false,association_autoupdate:false"`
|
||||
}
|
||||
|
||||
// Create 创建文件记录
|
||||
@@ -41,3 +44,12 @@ func (folder *Folder) GetChildFile() ([]File, error) {
|
||||
result := DB.Where("folder_id = ?", folder.ID).Find(&files)
|
||||
return files, result.Error
|
||||
}
|
||||
|
||||
// GetPolicy 获取文件所属策略
|
||||
// TODO:test
|
||||
func (file *File) GetPolicy() *Policy {
|
||||
if file.Policy.Model.ID == 0 {
|
||||
file.Policy, _ = GetPolicyByID(file.PolicyID)
|
||||
}
|
||||
return &file.Policy
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user