picture.go 612 B

12345678910111213141516171819202122232425262728293031323334
  1. package frontm
  2. import ("github.com/astaxie/beego/orm"
  3. "wuyebaoxiuapi/models")
  4. type Picture struct {
  5. Id int
  6. CreateTime int
  7. Path string
  8. }
  9. func NewPicture()(*Picture) {
  10. return new(Picture)
  11. }
  12. func init() {
  13. orm.RegisterModel(new(Picture))
  14. }
  15. func (a *Picture) TableName() string {
  16. return models.TableName("picture")
  17. }
  18. func (a *Picture)Add()(int64, error) {
  19. return orm.NewOrm().Insert(a)
  20. }
  21. func (a *Picture)FindPictureByPath(path string) (*Picture,error) {
  22. err := orm.NewOrm().QueryTable(models.TableName("picture")).Filter("path", path).One(a)
  23. if err != nil {
  24. return nil, err
  25. }
  26. return a, nil
  27. }