excel_sheet.go 2.0 KB

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