table_info.go 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. package data_manage
  2. import (
  3. "github.com/rdlucklib/rdluck_tools/orm"
  4. "time"
  5. )
  6. type TableInfo struct {
  7. TableInfoId int `orm:"column(table_info_id);pk"`
  8. TableName string `description:"表格名称"`
  9. UniqueCode string `description:"表格唯一编码"`
  10. TableClassifyId int `description:"表格分类id"`
  11. SysUserId int `description:"操作人id"`
  12. SysUserRealName string `description:"操作人真实姓名"`
  13. StartDate time.Time `description:"开始日期"`
  14. EdbInfoIds string `description:"指标id"`
  15. TableType int `description:"表格类型,1:指标+日期"`
  16. TableImage string `description:"图表图片"`
  17. Sort int `description:"排序字段,数字越小越排前面"`
  18. EdbEndDate time.Time `description:"指标最后更新日期"`
  19. ModifyTime time.Time
  20. CreateTime time.Time
  21. }
  22. type TableInfoItem struct {
  23. TableInfoId int `description:"图表id"`
  24. TableName string `description:"图表名称"`
  25. TableClassifyId int `description:"图表分类"`
  26. }
  27. //图表检索数据
  28. type TableInfoSearch struct {
  29. EdbCode string `description:"图表编码"`
  30. StartDate string `description:"起始日期"`
  31. EndDate string `description:"终止日期"`
  32. DataList []*EdbInfoSearchData
  33. }
  34. // GetTableInfoById 根据id获取表格详情
  35. func GetTableInfoById(tableInfoId int) (item *TableInfo, err error) {
  36. o := orm.NewOrm()
  37. o.Using("data")
  38. sql := ` SELECT * FROM table_info WHERE table_info_id=? `
  39. err = o.Raw(sql, tableInfoId).QueryRow(&item)
  40. return
  41. }
  42. // GetAllTableInfoList 获取所有的 ETA表格信息
  43. func GetAllTableInfoList() (items []*TableInfo, err error) {
  44. o := orm.NewOrm()
  45. o.Using("data")
  46. sql := ` select * from table_info order by table_info_id desc`
  47. _, err = o.Raw(sql).QueryRows(&items)
  48. return
  49. }
  50. func GetTableInfoByCondition(condition string, pars []interface{}) (item *TableInfo, err error) {
  51. o := orm.NewOrm()
  52. o.Using("data")
  53. sql := ` SELECT * FROM table_info WHERE 1=1 `
  54. if condition != "" {
  55. sql += condition
  56. }
  57. err = o.Raw(sql, pars).QueryRow(&item)
  58. return
  59. }
  60. func ModifyTableInfoModifyTime(tableInfoId int64) (err error) {
  61. o := orm.NewOrm()
  62. o.Using("data")
  63. sql := ` UPDATE table_info SET modify_time = NOW() WHERE table_info_id = ? `
  64. _, err = o.Raw(sql, tableInfoId).Exec()
  65. return
  66. }
  67. // TableDataList 表格数据
  68. type TableDataList struct {
  69. Date string `description:"指标日期"`
  70. DataCol1 string `description:"第1个表格的数据"`
  71. DataCol2 string `description:"第2个表格的数据"`
  72. DataCol3 string `description:"第3个表格的数据"`
  73. DataCol4 string `description:"第4个表格的数据"`
  74. DataCol5 string `description:"第5个表格的数据"`
  75. DataCol6 string `description:"第6个表格的数据"`
  76. DataCol7 string `description:"第7个表格的数据"`
  77. DataCol8 string `description:"第8个表格的数据"`
  78. DataCol9 string `description:"第9个表格的数据"`
  79. DataCol10 string `description:"第10个表格的数据"`
  80. DataType int8 `description:"数据类型,默认的区间数据是 1;插入数据是 2"`
  81. Sort int `description:"排序字段,越小越靠前"`
  82. }
  83. // Update 更新图表基础信息
  84. func (tableInfo *TableInfo) Update(cols []string) (err error) {
  85. o := orm.NewOrm()
  86. o.Using("data")
  87. _, err = o.Update(tableInfo, cols...)
  88. return
  89. }
  90. // GetTableInfoByClassifyIdAndName 根据分类id和图表名获取图表信息
  91. func GetTableInfoByClassifyIdAndName(classifyId int, tableName string) (item *TableInfo, err error) {
  92. o := orm.NewOrm()
  93. o.Using("data")
  94. sql := ` SELECT * FROM table_info WHERE table_classify_id = ? and table_name=? `
  95. err = o.Raw(sql, classifyId, tableName).QueryRow(&item)
  96. return
  97. }