excel_sheet.go 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. Frozen string `description:"冻结行"`
  19. }
  20. // Update 更新 excel表格的sheet基础信息
  21. func (excelSheet *ExcelSheet) Update(cols []string) (err error) {
  22. o := orm.NewOrmUsingDB("data")
  23. _, err = o.Update(excelSheet, cols...)
  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. return
  36. }
  37. // GetAllSheetList 根据excel_id获取所有的sheet
  38. func GetAllSheetList(excelInfoId int) (item []*ExcelSheet, err error) {
  39. o := orm.NewOrmUsingDB("data")
  40. sql := ` SELECT *
  41. FROM excel_sheet WHERE 1=1 AND excel_info_id = ? `
  42. sql += " ORDER BY sort asc "
  43. _, err = o.Raw(sql, excelInfoId).QueryRows(&item)
  44. return
  45. }
  46. // SheetItem excel表格详情表
  47. type SheetItem struct {
  48. ExcelSheetId int `orm:"column(excel_sheet_id);pk" json:"-"`
  49. ExcelInfoId int `description:"excel的id" json:"-"`
  50. SheetName string `description:"sheet名称"`
  51. PageNum int `description:"数据总页码数"`
  52. Index string `description:"excel数据中的index"`
  53. Sort int `description:"排序"`
  54. Config string `description:"sheet配置"`
  55. CalcChain string `description:"计算公式"`
  56. ModifyTime time.Time `description:"最近修改日期" json:"-"`
  57. CreateTime time.Time `description:"创建日期"`
  58. Data *ExcelSheetData `description:"excel的数据"`
  59. Frozen string `description:"冻结行"`
  60. }
  61. // GetAllSheetItemList 根据excel_id获取所有的sheet详情
  62. func GetAllSheetItemList(excelInfoId int) (item []*SheetItem, err error) {
  63. o := orm.NewOrmUsingDB("data")
  64. sql := ` SELECT *
  65. FROM excel_sheet WHERE 1=1 AND excel_info_id = ? `
  66. sql += " ORDER BY sort asc "
  67. _, err = o.Raw(sql, excelInfoId).QueryRows(&item)
  68. return
  69. }
  70. // GetAllNoConfigSheetItemList 根据excel_id获取所有的sheet详情
  71. func GetAllNoConfigSheetItemList(excelInfoId int) (item []*SheetItem, err error) {
  72. o := orm.NewOrmUsingDB("data")
  73. sql := ` SELECT excel_sheet_id,excel_info_id,sheet_name,sort,page_num,create_time
  74. FROM excel_sheet WHERE 1=1 AND excel_info_id = ? `
  75. sql += " ORDER BY sort asc "
  76. _, err = o.Raw(sql, excelInfoId).QueryRows(&item)
  77. return
  78. }
  79. // AddExcelSheetParams excel表格详情表
  80. type AddExcelSheetParams struct {
  81. ExcelSheetId int `orm:"column(excel_sheet_id);pk"`
  82. ExcelInfoId int `description:"excel的id"`
  83. SheetName string `description:"sheet名称"`
  84. Index string `description:"excel数据中的index"`
  85. Sort int `description:"排序"`
  86. Config string `description:"配置信息"`
  87. CalcChain string `description:"计算公式"`
  88. DataList []*ExcelSheetData `description:"excel的数据"`
  89. Frozen string `description:"冻结行"`
  90. }