excel_sheet.go 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. Sort int `description:"排序"`
  52. Config string `description:"sheet配置"`
  53. CalcChain string `description:"计算公式"`
  54. ModifyTime time.Time `description:"最近修改日期" json:"-"`
  55. CreateTime time.Time `description:"创建日期"`
  56. Data *ExcelSheetData `description:"excel的数据"`
  57. }
  58. // GetAllSheetItemList 根据excel_id获取所有的sheet详情
  59. func GetAllSheetItemList(excelInfoId int) (item []*SheetItem, err error) {
  60. o := orm.NewOrmUsingDB("data")
  61. sql := ` SELECT *
  62. FROM excel_sheet WHERE 1=1 AND excel_info_id = ? `
  63. sql += " ORDER BY sort asc "
  64. _, err = o.Raw(sql, excelInfoId).QueryRows(&item)
  65. return
  66. }
  67. // GetAllNoConfigSheetItemList 根据excel_id获取所有的sheet详情
  68. func GetAllNoConfigSheetItemList(excelInfoId int) (item []*SheetItem, err error) {
  69. o := orm.NewOrmUsingDB("data")
  70. sql := ` SELECT excel_sheet_id,excel_info_id,sheet_name,sort,page_num,create_time
  71. FROM excel_sheet WHERE 1=1 AND excel_info_id = ? `
  72. sql += " ORDER BY sort asc "
  73. _, err = o.Raw(sql, excelInfoId).QueryRows(&item)
  74. return
  75. }
  76. // AddExcelSheetParams excel表格详情表
  77. type AddExcelSheetParams struct {
  78. ExcelSheetId int `orm:"column(excel_sheet_id);pk"`
  79. ExcelInfoId int `description:"excel的id"`
  80. SheetName string `description:"sheet名称"`
  81. Index string `description:"excel数据中的index"`
  82. Sort int `description:"排序"`
  83. Config string `description:"配置信息"`
  84. CalcChain string `description:"计算公式"`
  85. DataList []*ExcelSheetData `description:"excel的数据"`
  86. }