bi_dashboard_detail.go 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package bi_dashboard
  2. import (
  3. "eta_gn/eta_api/global"
  4. "time"
  5. )
  6. type BiDashboardDetail struct {
  7. BiDashboardDetailId int `gorm:"primaryKey;autoIncrement;column:bi_dashboard_detail_id" ` // 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. func GetBiDashboardDetailById(id int) (list []*BiDashboardDetail, err error) {
  20. err = global.DEFAULT_DmSQL.Table("bi_dashboard_detail").Where("bi_dashboard_id IN ?", id).Find(&list).Error
  21. return
  22. }
  23. // multiAdd
  24. func AddBiDashboardDetailMulti(items []*BiDashboardDetail) (err error) {
  25. return global.DEFAULT_DmSQL.CreateInBatches(items, 100).Error
  26. }
  27. // del
  28. func DeleteBiDashboardDetail(id int) (err error) {
  29. return global.DEFAULT_DmSQL.Where("bi_dashboard_id = ?", id).Delete(&BiDashboardDetail{}).Error
  30. }
  31. type MoveDashboardDetailReq struct {
  32. BiDashboardId int `description:"看板id"`
  33. BiDashboardDetailId int `description:"看板详情id"`
  34. Sort int `description:"排序"`
  35. OtherDetailId int `description:"交换的详情id"`
  36. OtherSort int `description:"交换的排序"`
  37. }
  38. // update
  39. func EditBiDashboardDetail(item *BiDashboardDetail) (err error) {
  40. return global.DEFAULT_DmSQL.Model(item).Where("bi_dashboard_detail_id = ?", item.BiDashboardDetailId).Updates(item).Error
  41. }
  42. type DelDashboardDetailReq struct {
  43. BiDashboardDetailId int `description:"看板详情id"`
  44. }
  45. // del
  46. func DeleteBiDashboardDetailByDetailId(id int) (err error) {
  47. return global.DEFAULT_DmSQL.Where("bi_dashboard_detail_id = ?", id).Delete(&BiDashboardDetail{}).Error
  48. }