mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
Feat: create folder / Modify: add index to some column
This commit is contained in:
@@ -11,10 +11,10 @@ type File struct {
|
||||
gorm.Model
|
||||
Name string
|
||||
SourceName string
|
||||
UserID uint
|
||||
UserID uint `gorm:"index:user_id"`
|
||||
Size uint64
|
||||
PicInfo string
|
||||
FolderID uint
|
||||
FolderID uint `gorm:"index:folder_id"`
|
||||
PolicyID uint
|
||||
Dir string `gorm:"size:65536"`
|
||||
}
|
||||
|
||||
@@ -1,19 +1,28 @@
|
||||
package model
|
||||
|
||||
import "github.com/jinzhu/gorm"
|
||||
import (
|
||||
"github.com/HFO4/cloudreve/pkg/util"
|
||||
"github.com/jinzhu/gorm"
|
||||
)
|
||||
|
||||
// Folder 目录
|
||||
type Folder struct {
|
||||
// 表字段
|
||||
gorm.Model
|
||||
Name string
|
||||
ParentID uint
|
||||
ParentID uint `gorm:"index:parent_id"`
|
||||
Position string `gorm:"size:65536"`
|
||||
OwnerID uint
|
||||
OwnerID uint `gorm:"index:owner_id"`
|
||||
PositionAbsolute string `gorm:"size:65536"`
|
||||
}
|
||||
|
||||
// 关联模型
|
||||
OptionsSerialized PolicyOption `gorm:"-"`
|
||||
// Create 创建目录
|
||||
func (folder *Folder) Create() (uint, error) {
|
||||
if err := DB.Create(folder).Error; err != nil {
|
||||
util.Log().Warning("无法插入目录记录, %s", err)
|
||||
return 0, err
|
||||
}
|
||||
return folder.ID, nil
|
||||
}
|
||||
|
||||
// GetFolderByPath 根据绝对路径和UID查找目录
|
||||
|
||||
Reference in New Issue
Block a user