excel_sheet.go 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. package excel
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. // ExcelSheet excel表格详情表
  7. type ExcelSheet struct {
  8. ExcelSheetId int `orm:"column(excel_sheet_id);pk"`
  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. return
  24. }
  25. // AddExcelSheet 新增excel表格的sheet基础信息
  26. func AddExcelSheet(excelInfo *ExcelSheet) (err error) {
  27. o := orm.NewOrmUsingDB("data")
  28. // 表格信息入库
  29. lastId, err := o.Insert(excelInfo)
  30. if err != nil {
  31. return
  32. }
  33. excelInfo.ExcelInfoId = int(lastId)
  34. return
  35. }
  36. // GetAllSheetList 根据excel_id获取所有的sheet
  37. func GetAllSheetList(excelInfoId int) (item []*ExcelSheet, err error) {
  38. o := orm.NewOrmUsingDB("data")
  39. sql := ` SELECT *
  40. FROM excel_sheet WHERE 1=1 AND excel_info_id = ? `
  41. sql += " ORDER BY sort asc "
  42. _, err = o.Raw(sql, excelInfoId).QueryRows(&item)
  43. return
  44. }
  45. // SheetItem excel表格详情表
  46. type SheetItem struct {
  47. ExcelSheetId int `orm:"column(excel_sheet_id);pk" json:"-"`
  48. ExcelInfoId int `description:"excel的id" json:"-"`
  49. SheetName string `description:"sheet名称"`
  50. PageNum int `description:"数据总页码数"`
  51. Index string `description:"excel数据中的index"`
  52. Sort int `description:"排序"`
  53. Config string `description:"sheet配置"`
  54. CalcChain string `description:"计算公式"`
  55. ModifyTime time.Time `description:"最近修改日期" json:"-"`
  56. CreateTime time.Time `description:"创建日期"`
  57. Data *ExcelSheetData `description:"excel的数据"`
  58. }
  59. // GetAllSheetItemList 根据excel_id获取所有的sheet详情
  60. func GetAllSheetItemList(excelInfoId int) (item []*SheetItem, err error) {
  61. o := orm.NewOrmUsingDB("data")
  62. sql := ` SELECT *
  63. FROM excel_sheet WHERE 1=1 AND excel_info_id = ? `
  64. sql += " ORDER BY sort asc "
  65. _, err = o.Raw(sql, excelInfoId).QueryRows(&item)
  66. return
  67. }
  68. // GetAllNoConfigSheetItemList 根据excel_id获取所有的sheet详情
  69. func GetAllNoConfigSheetItemList(excelInfoId int) (item []*SheetItem, err error) {
  70. o := orm.NewOrmUsingDB("data")
  71. sql := ` SELECT excel_sheet_id,excel_info_id,sheet_name,sort,page_num,create_time
  72. FROM excel_sheet WHERE 1=1 AND excel_info_id = ? `
  73. sql += " ORDER BY sort asc "
  74. _, err = o.Raw(sql, excelInfoId).QueryRows(&item)
  75. return
  76. }
  77. // AddExcelSheetParams excel表格详情表
  78. type AddExcelSheetParams struct {
  79. ExcelSheetId int `orm:"column(excel_sheet_id);pk"`
  80. ExcelInfoId int `description:"excel的id"`
  81. SheetName string `description:"sheet名称"`
  82. Index string `description:"excel数据中的index"`
  83. Sort int `description:"排序"`
  84. Config string `description:"配置信息"`
  85. CalcChain string `description:"计算公式"`
  86. DataList []*ExcelSheetData `description:"excel的数据"`
  87. }