Feat: insert file record to database

This commit is contained in:
HFO4
2019-11-20 15:24:26 +08:00
parent e835dafc88
commit e09294d388
4 changed files with 35 additions and 4 deletions

View File

@@ -16,6 +16,14 @@ type File struct {
Dir string `gorm:"size:65536"`
}
// Create 创建文件记录
func (file *File) Create() (uint, error) {
if err := DB.Create(file).Error; err != nil {
return 0, err
}
return file.ID, nil
}
// GetFileByPathAndName 给定路径、文件名、用户ID查找文件
func GetFileByPathAndName(path string, name string, uid uint) (File, error) {
var file File