table_data.go 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package models
  2. import (
  3. "eta_gn/eta_chart_lib/global"
  4. "time"
  5. )
  6. type TableData struct {
  7. TableDataId int `orm:"column(table_data_id);pk" gorm:"column:table_data_id;primary_key"`
  8. TableInfoId int `description:"表格id" gorm:"column:table_info_id"`
  9. Date time.Time `description:"指标时间" gorm:"column:date"`
  10. DataCol1 string `orm:"column(data_col_1);" description:"第1个表格的数据" gorm:"column:data_col_1"`
  11. DataCol2 string `orm:"column(data_col_2);" description:"第2个表格的数据" gorm:"column:data_col_2"`
  12. DataCol3 string `orm:"column(data_col_3);" description:"第3个表格的数据" gorm:"column:data_col_3"`
  13. DataCol4 string `orm:"column(data_col_4);" description:"第4个表格的数据" gorm:"column:data_col_4"`
  14. DataCol5 string `orm:"column(data_col_5);" description:"第5个表格的数据" gorm:"column:data_col_5"`
  15. DataCol6 string `orm:"column(data_col_6);" description:"第6个表格的数据" gorm:"column:data_col_6"`
  16. DataCol7 string `orm:"column(data_col_7);" description:"第7个表格的数据" gorm:"column:data_col_7"`
  17. DataCol8 string `orm:"column(data_col_8);" description:"第8个表格的数据" gorm:"column:data_col_8"`
  18. DataCol9 string `orm:"column(data_col_9);" description:"第9个表格的数据" gorm:"column:data_col_9"`
  19. DataCol10 string `orm:"column(data_col_10);" description:"第10个表格的数据" gorm:"column:data_col_10"`
  20. DataType int8 `description:"数据类型,默认的区间数据是 1;插入数据是 2" gorm:"column:data_type"`
  21. Sort int `description:"排序字段,越小越靠前" gorm:"column:sort"`
  22. AfterTableDataId int `description:"在某个表格数据id后面" gorm:"column:after_table_data_id"`
  23. BeforeTableDataId int `description:"在某个表格数据id前面" gorm:"column:before_table_data_id"`
  24. ModifyTime time.Time `description:"修改时间" gorm:"column:modify_time"`
  25. CreateTime time.Time `description:"创建时间" gorm:"column:create_time"`
  26. }
  27. // GetTableDataListByTableInfoId 根据表格id获取数据列表
  28. func GetTableDataListByTableInfoId(tableInfoId int) (items []*TableData, err error) {
  29. o := global.DmSQL["data"]
  30. sql := ` SELECT * FROM table_data WHERE table_info_id = ? order by sort asc `
  31. err = o.Raw(sql, tableInfoId).Scan(&items).Error
  32. return
  33. }
  34. // func GetTableDataListByTableInfoId(tableInfoId int) (items []*TableData, err error) {
  35. // o := orm.NewOrmUsingDB("data")
  36. // pars := make([]interface{}, 0)
  37. // pars = append(pars, tableInfoId)
  38. // sql := ` SELECT * FROM table_data WHERE table_info_id = ? order by sort asc `
  39. // _, err = o.Raw(sql, tableInfoId).QueryRows(&items)
  40. // return
  41. // }