action.go 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Copyright 2017 utimes.cc. All rights reserved.
  2. // Use of this source code is governed by utimes.cc.
  3. package dbmodel
  4. import (
  5. "encoding/json"
  6. "github.com/astaxie/beego/orm"
  7. )
  8. type Action struct {
  9. Id int64 `orm:"auto,column(id)"`
  10. Uid int64 `orm:"column(uid)"`
  11. Modules string `orm:"column(modules)"`
  12. Func string `orm:"column(func)"`
  13. Name string `orm:"column(name)"`
  14. Before string `orm:"column(before)"`
  15. After string `orm:"column(after)"`
  16. CreatedAt string `orm:"column(created_at)"`
  17. }
  18. func (p *Action) TableName() string {
  19. return "t_gd_admin_action_log"
  20. }
  21. func (p Action) String() string {
  22. vals, _ := json.Marshal(p)
  23. return string(vals)
  24. }
  25. func (p *Action) Create(db orm.Ormer) (int64, error) {
  26. return db.Insert(p)
  27. }
  28. func (p *Action) FetchAll(db orm.Ormer, mapFilter map[string]interface{}, cols []string) (lists []Action, err error) {
  29. qa := db.QueryTable(p.TableName())
  30. for k, v := range mapFilter {
  31. qa = qa.Filter(k, v)
  32. }
  33. _, err = qa.All(&lists, cols...)
  34. return
  35. }