excel_sheet.go 4.3 KB

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