You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
949 B
Go

5 months ago
package models
import (
"time"
"github.com/astaxie/beego/orm"
)
func init() {
orm.RegisterModelWithPrefix("cm_", new(File))
}
type File struct {
Id string `orm:"pk" json:"id"`
Downloadcount int64 `json:"downloadcount"`
Name string `json:"fileName"`
LastDownloadtime time.Time `json:"last_downloadtime"`
}
func FindFileById(id string) (*File, error) {
fileModel := new(File)
err := orm.NewOrm().QueryTable(new(File)).Filter("id", id).One(fileModel)
if err != nil {
return nil, err
}
return fileModel, nil
}
func FindFileByFileName(name string) (*File, error) {
fileModel := new(File)
err := orm.NewOrm().QueryTable(new(File)).Filter("name", name).One(fileModel)
if err != nil {
return nil, err
}
return fileModel, nil
}
func UpdateFile(file *File) (int64, error) {
return orm.NewOrm().Update(file)
}
func InsertFile(file *File) (int64, error) {
return orm.NewOrm().Insert(file)
}