|
|
|
@ -23,15 +23,13 @@ type Folder struct {
|
|
|
|
|
|
|
|
|
|
// Create 创建目录
|
|
|
|
|
func (folder *Folder) Create() (uint, error) {
|
|
|
|
|
tx := DB.Begin()
|
|
|
|
|
if err := tx.FirstOrCreate(folder, *folder).Error; err != nil {
|
|
|
|
|
tx.Rollback()
|
|
|
|
|
util.Log().Warning("无法插入目录记录, %s", err)
|
|
|
|
|
return 0, err
|
|
|
|
|
if err := DB.FirstOrCreate(folder, *folder).Error; err != nil {
|
|
|
|
|
folder.Model = gorm.Model{}
|
|
|
|
|
err2 := DB.First(folder, *folder).Error
|
|
|
|
|
return folder.ID, err2
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
err := tx.Commit().Error
|
|
|
|
|
return folder.ID, err
|
|
|
|
|
return folder.ID, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetChild 返回folder下名为name的子目录,不存在则返回错误
|
|
|
|
|