excel_sheet.go 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. package excel
  2. import (
  3. "eta/eta_chart_lib/global"
  4. "eta/eta_chart_lib/utils"
  5. "time"
  6. )
  7. // ExcelSheet excel表格详情表
  8. type ExcelSheet struct {
  9. //ExcelSheetId int `orm:"column(excel_sheet_id);pk"`
  10. ExcelSheetId int `gorm:"column:excel_sheet_id;primaryKey"`
  11. ExcelInfoId int `description:"excel的id"`
  12. SheetName string `description:"sheet名称"`
  13. PageNum int `description:"总页码数"`
  14. Index string `description:"excel数据中的index"`
  15. Sort int `description:"排序"`
  16. Config string `description:"配置信息"`
  17. CalcChain string `description:"计算公式"`
  18. ModifyTime time.Time `description:"最近修改日期"`
  19. CreateTime time.Time `description:"创建日期"`
  20. }
  21. // Update 更新 excel表格的sheet基础信息
  22. func (excelSheet *ExcelSheet) Update(cols []string) (err error) {
  23. //o := orm.NewOrmUsingDB("data")
  24. //_, err = o.Update(excelSheet, cols...)
  25. err = global.DbMap[utils.DbNameIndex].Model(&excelSheet).Select(cols).Updates(&excelSheet).Error
  26. return
  27. }
  28. // AddExcelSheet 新增excel表格的sheet基础信息
  29. func AddExcelSheet(excelInfo *ExcelSheet) (err error) {
  30. //o := orm.NewOrmUsingDB("data")
  31. // 表格信息入库
  32. //lastId, err := o.Insert(excelInfo)
  33. err = global.DbMap[utils.DbNameIndex].Create(&excelInfo).Error
  34. if err != nil {
  35. return
  36. }
  37. //excelInfo.ExcelInfoId = int(lastId)
  38. return
  39. }
  40. // GetAllSheetList 根据excel_id获取所有的sheet
  41. func GetAllSheetList(excelInfoId int) (item []*ExcelSheet, err error) {
  42. //o := orm.NewOrmUsingDB("data")
  43. sql := ` SELECT *
  44. FROM excel_sheet WHERE 1=1 AND excel_info_id = ? `
  45. sql += " ORDER BY sort asc "
  46. //_, err = o.Raw(sql, excelInfoId).QueryRows(&item)
  47. err = global.DbMap[utils.DbNameIndex].Raw(sql, excelInfoId).Find(&item).Error
  48. return
  49. }
  50. // SheetItem excel表格详情表
  51. type SheetItem struct {
  52. //ExcelSheetId int `orm:"column(excel_sheet_id);pk" json:"-"`
  53. ExcelSheetId int `gorm:"column:excel_sheet_id;primaryKey" json:"-"`
  54. ExcelInfoId int `description:"excel的id" json:"-"`
  55. SheetName string `description:"sheet名称"`
  56. PageNum int `description:"数据总页码数"`
  57. Index string `description:"excel数据中的index"`
  58. Sort int `description:"排序"`
  59. Config string `description:"sheet配置"`
  60. CalcChain string `description:"计算公式"`
  61. ModifyTime time.Time `description:"最近修改日期" json:"-"`
  62. CreateTime time.Time `description:"创建日期"`
  63. Data *ExcelSheetData `description:"excel的数据"`
  64. }
  65. // GetAllSheetItemList 根据excel_id获取所有的sheet详情
  66. func GetAllSheetItemList(excelInfoId int) (item []*SheetItem, err error) {
  67. //o := orm.NewOrmUsingDB("data")
  68. sql := ` SELECT *
  69. FROM excel_sheet WHERE 1=1 AND excel_info_id = ? `
  70. sql += " ORDER BY sort asc "
  71. //_, err = o.Raw(sql, excelInfoId).QueryRows(&item)
  72. err = global.DbMap[utils.DbNameIndex].Raw(sql, excelInfoId).Find(&item).Error
  73. return
  74. }
  75. // GetAllNoConfigSheetItemList 根据excel_id获取所有的sheet详情
  76. func GetAllNoConfigSheetItemList(excelInfoId int) (item []*SheetItem, err error) {
  77. //o := orm.NewOrmUsingDB("data")
  78. sql := ` SELECT excel_sheet_id,excel_info_id,sheet_name,sort,page_num,create_time
  79. FROM excel_sheet WHERE 1=1 AND excel_info_id = ? `
  80. sql += " ORDER BY sort asc "
  81. //_, err = o.Raw(sql, excelInfoId).QueryRows(&item)
  82. err = global.DbMap[utils.DbNameIndex].Raw(sql, excelInfoId).Find(&item).Error
  83. return
  84. }
  85. // AddExcelSheetParams excel表格详情表
  86. type AddExcelSheetParams struct {
  87. //ExcelSheetId int `orm:"column(excel_sheet_id);pk"`
  88. ExcelSheetId int `gorm:"column:excel_sheet_id;primaryKey"`
  89. ExcelInfoId int `description:"excel的id"`
  90. SheetName string `description:"sheet名称"`
  91. Index string `description:"excel数据中的index"`
  92. Sort int `description:"排序"`
  93. Config string `description:"配置信息"`
  94. CalcChain string `description:"计算公式"`
  95. DataList []*ExcelSheetData `description:"excel的数据"`
  96. }