excel_sheet.go 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. package excel
  2. import (
  3. "eta_gn/eta_api/global"
  4. "time"
  5. )
  6. // ExcelSheet excel表格详情表
  7. type ExcelSheet struct {
  8. ExcelSheetId int `orm:"column(excel_sheet_id);pk" gorm:"primaryKey" `
  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. err = global.DmSQL["data"].Select(cols).Updates(excelSheet).Error
  22. return
  23. }
  24. // GetAllSheetList 根据excel_id获取所有的sheet
  25. func GetAllSheetList(excelInfoId int) (item []*ExcelSheet, err error) {
  26. sql := ` SELECT *
  27. FROM excel_sheet WHERE 1=1 AND excel_info_id = ? `
  28. sql += " ORDER BY sort asc "
  29. err = global.DmSQL["data"].Raw(sql, excelInfoId).Find(&item).Error
  30. return
  31. }
  32. // SheetItem excel表格详情表
  33. type SheetItem struct {
  34. ExcelSheetId int `orm:"column(excel_sheet_id);pk" gorm:"primaryKey" json:"-"`
  35. ExcelInfoId int `description:"excel的id" json:"-"`
  36. SheetName string `description:"sheet名称"`
  37. PageNum int `description:"数据总页码数"`
  38. Index string `description:"excel数据中的index"`
  39. Sort int `description:"排序"`
  40. Config string `description:"sheet配置"`
  41. CalcChain string `description:"计算公式"`
  42. ModifyTime time.Time `description:"最近修改日期" json:"-"`
  43. CreateTime time.Time `description:"创建日期"`
  44. Data *ExcelSheetData `gorm:"-" description:"excel的数据"`
  45. }
  46. // GetAllSheetItemList 根据excel_id获取所有的sheet详情
  47. func GetAllSheetItemList(excelInfoId int) (item []*SheetItem, err error) {
  48. sql := ` SELECT *
  49. FROM excel_sheet WHERE 1=1 AND excel_info_id = ? `
  50. sql += " ORDER BY sort asc "
  51. err = global.DmSQL["data"].Raw(sql, excelInfoId).Find(&item).Error
  52. return
  53. }
  54. // GetAllNoConfigSheetItemList 根据excel_id获取所有的sheet详情
  55. func GetAllNoConfigSheetItemList(excelInfoId int) (item []*SheetItem, err error) {
  56. sql := ` SELECT excel_sheet_id,excel_info_id,sheet_name,sort,page_num,create_time
  57. FROM excel_sheet WHERE 1=1 AND excel_info_id = ? `
  58. sql += " ORDER BY sort asc "
  59. err = global.DmSQL["data"].Raw(sql, excelInfoId).Find(&item).Error
  60. return
  61. }
  62. // AddExcelSheetParams excel表格详情表
  63. type AddExcelSheetParams struct {
  64. ExcelSheetId int `orm:"column(excel_sheet_id);pk" gorm:"primaryKey" `
  65. ExcelInfoId int `description:"excel的id"`
  66. SheetName string `description:"sheet名称"`
  67. Index string `description:"excel数据中的index"`
  68. Sort int `description:"排序"`
  69. Config string `description:"配置信息"`
  70. CalcChain string `description:"计算公式"`
  71. DataList []*ExcelSheetData `description:"excel的数据"`
  72. }