bi_dashboard_detail.go 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. package bi_dashboard
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type BiDashboardDetail struct {
  7. BiDashboardDetailId int `orm:"column(bi_dashboard_detail_id);pk" ` // bi看板id
  8. BiDashboardId int `gorm:"column:bi_dashboard_id" ` // 看板id
  9. Type int `gorm:"column:type" ` // 1图表 2表格
  10. UniqueCode string `gorm:"column:unique_code;size:32;not null" ` // 报告唯一编码
  11. Sort int `gorm:"column:sort" ` // 排序字段
  12. CreateTime time.Time `gorm:"column:create_time" ` // 创建时间
  13. ModifyTime time.Time `gorm:"column:modify_time" ` // 更新时间
  14. }
  15. // tableName
  16. func (m *BiDashboardDetail) TableName() string {
  17. return "bi_dashboard_detail"
  18. }
  19. // add
  20. //func AddBiDashboardDetail(item *BiDashboardDetail) (err error) {
  21. //err = global.DEFAULT_DmSQL.Create(item).Error
  22. //return
  23. //}
  24. func GetBiDashboardDetailById(id int) (list []*BiDashboardDetail, err error) {
  25. //err = global.DEFAULT_DmSQL.Table("bi_dashboard_detail").Where("bi_dashboard_id IN ?", id).Find(&list).Error
  26. o := orm.NewOrm()
  27. _, err = o.Raw("SELECT * FROM bi_dashboard_detail where bi_dashboard_id = ?", id).QueryRows(&list)
  28. return
  29. }
  30. // multiAdd
  31. func AddBiDashboardDetailMulti(items []*BiDashboardDetail) (err error) {
  32. o := orm.NewOrm()
  33. _, err = o.InsertMulti(len(items), items)
  34. return
  35. }
  36. // del
  37. func DeleteBiDashboardDetail(id int) (err error) {
  38. o := orm.NewOrm()
  39. _, err = o.Raw("DELETE from bi_dashboard_detail where bi_dashboard_id=?", id).Exec()
  40. return
  41. }
  42. type MoveDashboardDetailReq struct {
  43. BiDashboardId int `description:"看板id"`
  44. BiDashboardDetailId int `description:"看板详情id"`
  45. Sort int `description:"排序"`
  46. OtherDetailId int `description:"交换的详情id"`
  47. OtherSort int `description:"交换的排序"`
  48. }
  49. // update
  50. func EditBiDashboardDetail(item *BiDashboardDetail) (err error) {
  51. //return global.DEFAULT_DmSQL.Model(item).Where("bi_dashboard_detail_id = ?", item.BiDashboardDetailId).Updates(item).Error
  52. o := orm.NewOrm()
  53. _, err = o.Raw("UPDATE bi_dashboard_detail SET bi_dashboard_id=?,type=?,unique_code=?,sort=?,modify_time=? WHERE bi_dashboard_detail_id=?", item.BiDashboardId, item.Type, item.UniqueCode, item.Sort, item.ModifyTime, item.BiDashboardDetailId).Exec()
  54. return
  55. }
  56. type DelDashboardDetailReq struct {
  57. BiDashboardDetailId int `description:"看板详情id"`
  58. }
  59. // del
  60. func DeleteBiDashboardDetailByDetailId(id int) (err error) {
  61. //return global.DEFAULT_DmSQL.Where("bi_dashboard_detail_id = ?", id).Delete(&BiDashboardDetail{}).Error
  62. o := orm.NewOrm()
  63. _, err = o.Raw("DELETE from bi_dashboard_detail where bi_dashboard_detail_id=?", id).Exec()
  64. return
  65. }