excel_sheet.go 2.5 KB

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