excel_sheet.go 3.3 KB

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