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