bi_dashboard_home_page.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package bi_dashboard
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type BiDashboardHomePage struct {
  7. BiDashboardHomePageId int `orm:"column(bi_dashboard_home_page_id);pk"`
  8. BiDashboardId int `gorm:"type:int(10);default:null;comment:'看板id'"`
  9. AdminId int `gorm:"type:int(10);default:null;"`
  10. CreateTime time.Time `gorm:"type:datetime;comment:'创建时间'"`
  11. ModifyTime time.Time `gorm:"type:datetime;comment:'更新时间'"`
  12. FromType int `gorm:"type:int(10);default:null;comment:'来源,前端跳转用 1我的 2共享 3公共"`
  13. }
  14. // tableName
  15. func (m *BiDashboardHomePage) TableName() string {
  16. return "bi_dashboard_home_page"
  17. }
  18. // get
  19. func GetBiDashboardHomePageById(id int) (item *BiDashboardHomePage, err error) {
  20. sql := ` SELECT a.* FROM bi_dashboard_home_page AS a INNER JOIN bi_dashboard AS b
  21. ON a.bi_dashboard_id = b.bi_dashboard_id WHERE a.admin_id = ? `
  22. o := orm.NewOrm()
  23. err = o.Raw(sql, id).QueryRow(&item)
  24. return
  25. }
  26. // save
  27. func SaveBiDashboardHomePage(item *BiDashboardHomePage) (err error) {
  28. //return global.DEFAULT_DmSQL.Save(item).Error
  29. o := orm.NewOrm()
  30. if item.BiDashboardHomePageId > 0 {
  31. _, err = o.Raw("UPDATE bi_dashboard_home_page SET bi_dashboard_id=?,modify_time=? WHERE bi_dashboard_home_page_id=?", item.BiDashboardId, item.ModifyTime, item.BiDashboardHomePageId).Exec()
  32. } else {
  33. _, err = o.Insert(item)
  34. }
  35. return
  36. }
  37. type SaveHomePageReq struct {
  38. BiDashboardId int `description:"看板id"`
  39. FromType int `description:"来源,前端跳转用 1我的 2共享 3公共"`
  40. }