excel_sheet.go 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. package excel
  2. import (
  3. "eta/eta_api/global"
  4. "eta/eta_api/utils"
  5. "time"
  6. )
  7. // ExcelSheet excel表格详情表
  8. type ExcelSheet struct {
  9. ExcelSheetId int `orm:"column(excel_sheet_id);pk" gorm:"primaryKey" `
  10. ExcelInfoId int `description:"excel的id"`
  11. SheetName string `description:"sheet名称"`
  12. PageNum int `description:"总页码数"`
  13. Index string `description:"excel数据中的index"`
  14. Sort int `description:"排序"`
  15. Config string `description:"配置信息"`
  16. CalcChain string `description:"计算公式"`
  17. ModifyTime time.Time `description:"最近修改日期"`
  18. CreateTime time.Time `description:"创建日期"`
  19. }
  20. // Update 更新 excel表格的sheet基础信息
  21. func (excelSheet *ExcelSheet) Update(cols []string) (err error) {
  22. err = global.DbMap[utils.DbNameIndex].Select(cols).Updates(excelSheet).Error
  23. return
  24. }
  25. // AddExcelSheet 新增excel表格的sheet基础信息
  26. func AddExcelSheet(excelInfo *ExcelSheet) (err error) {
  27. o := global.DbMap[utils.DbNameIndex]
  28. // 表格信息入库
  29. err = o.Create(excelInfo).Error
  30. return
  31. }
  32. // GetAllSheetList 根据excel_id获取所有的sheet
  33. func GetAllSheetList(excelInfoId int) (item []*ExcelSheet, err error) {
  34. sql := ` SELECT *
  35. FROM excel_sheet WHERE 1=1 AND excel_info_id = ? `
  36. sql += " ORDER BY sort asc "
  37. err = global.DbMap[utils.DbNameIndex].Raw(sql, excelInfoId).Find(&item).Error
  38. return
  39. }
  40. // SheetItem excel表格详情表
  41. type SheetItem struct {
  42. ExcelSheetId int `orm:"column(excel_sheet_id);pk" gorm:"primaryKey" json:"-"`
  43. ExcelInfoId int `description:"excel的id" json:"-"`
  44. SheetName string `description:"sheet名称"`
  45. PageNum int `description:"数据总页码数"`
  46. Index string `description:"excel数据中的index"`
  47. Sort int `description:"排序"`
  48. Config string `description:"sheet配置"`
  49. CalcChain string `description:"计算公式"`
  50. ModifyTime time.Time `description:"最近修改日期" json:"-"`
  51. CreateTime time.Time `description:"创建日期"`
  52. Data *ExcelSheetData `gorm:"-" description:"excel的数据"`
  53. }
  54. // GetAllSheetItemList 根据excel_id获取所有的sheet详情
  55. func GetAllSheetItemList(excelInfoId int) (item []*SheetItem, err error) {
  56. sql := ` SELECT *
  57. FROM excel_sheet WHERE 1=1 AND excel_info_id = ? `
  58. sql += " ORDER BY sort asc "
  59. err = global.DbMap[utils.DbNameIndex].Raw(sql, excelInfoId).Find(&item).Error
  60. return
  61. }
  62. // GetAllNoConfigSheetItemList 根据excel_id获取所有的sheet详情
  63. func GetAllNoConfigSheetItemList(excelInfoId int) (item []*SheetItem, err error) {
  64. sql := ` SELECT excel_sheet_id,excel_info_id,sheet_name,sort,page_num,create_time
  65. FROM excel_sheet WHERE 1=1 AND excel_info_id = ? `
  66. sql += " ORDER BY sort asc "
  67. err = global.DbMap[utils.DbNameIndex].Raw(sql, excelInfoId).Find(&item).Error
  68. return
  69. }
  70. // AddExcelSheetParams excel表格详情表
  71. type AddExcelSheetParams struct {
  72. ExcelSheetId int `orm:"column(excel_sheet_id);pk" gorm:"primaryKey" `
  73. ExcelInfoId int `description:"excel的id"`
  74. SheetName string `description:"sheet名称"`
  75. Index string `description:"excel数据中的index"`
  76. Sort int `description:"排序"`
  77. Config string `description:"配置信息"`
  78. CalcChain string `description:"计算公式"`
  79. DataList []*ExcelSheetData `description:"excel的数据"`
  80. }