Cloudreve/models/folder.go

25 lines
592 B
Go
Raw Normal View History

2019-11-15 16:32:43 +08:00
package model
import "github.com/jinzhu/gorm"
// Folder 目录
type Folder struct {
// 表字段
gorm.Model
Name string
ParentID uint
Position string `gorm:"size:65536"`
OwnerID uint
PositionAbsolute string `gorm:"size:65536"`
// 关联模型
OptionsSerialized PolicyOption `gorm:"-"`
}
2019-11-18 19:09:56 +08:00
// GetFolderByPath 根据绝对路径和UID查找目录
func GetFolderByPath(path string, uid uint) (Folder, error) {
var folder Folder
2019-11-18 19:32:06 +08:00
result := DB.Where("owner_id = ? AND position_absolute = ?", uid, path).Find(&folder)
2019-11-18 19:09:56 +08:00
return folder, result.Error
}