mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
Add: model/folder
This commit is contained in:
@@ -107,6 +107,19 @@ func (user *User) BeforeSave() (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
// AfterCreate 创建用户后的钩子
|
||||
func (user *User) AfterCreate(tx *gorm.DB) (err error) {
|
||||
// 创建用户的默认根目录
|
||||
defaultFolder := &Folder{
|
||||
Name: "根目录",
|
||||
Position: ".",
|
||||
OwnerID: user.ID,
|
||||
PositionAbsolute: "/",
|
||||
}
|
||||
tx.Create(defaultFolder)
|
||||
return err
|
||||
}
|
||||
|
||||
//SerializeOptions 将序列后的Option写入到数据库字段
|
||||
func (user *User) SerializeOptions() (err error) {
|
||||
optionsValue, err := json.Marshal(&user.OptionsSerialized)
|
||||
|
||||
Reference in New Issue
Block a user