excel_sheet_data.go 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. package excel
  2. import (
  3. "eta_gn/eta_api/global"
  4. "eta_gn/eta_api/utils"
  5. "time"
  6. )
  7. // ExcelSheetData excel表格详情表
  8. type ExcelSheetData struct {
  9. ExcelDataId int `orm:"column(excel_data_id);pk" gorm:"primaryKey" `
  10. ExcelInfoId int `description:"数据归属的excel_info的id"`
  11. ExcelSheetId int `description:"数据归属sheet"`
  12. Sort int `description:"数据排序"`
  13. Data string `description:"数据,分页存储"`
  14. ModifyTime time.Time `description:"最近修改日期"`
  15. CreateTime time.Time `description:"创建日期"`
  16. }
  17. // Update 更新 excel表格的sheet基础信息
  18. func (ExcelSheetData *ExcelSheetData) Update(cols []string) (err error) {
  19. //o := orm.NewOrmUsingDB("data")
  20. //_, err = o.Update(ExcelSheetData, cols...)
  21. err = global.DmSQL["data"].Select(cols).Updates(ExcelSheetData).Error
  22. return
  23. }
  24. // AddExcelSheetData 新增excel表格的sheet基础信息
  25. func AddExcelSheetData(excelInfo *ExcelSheetData) (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. err = global.DmSQL["data"].Create(excelInfo).Error
  34. return
  35. }
  36. // GetSheetDataListBySheetIdListAndPage 根据sheet_id列表和页码获取所有的sheet数据详情
  37. func GetSheetDataListBySheetIdListAndPage(excelSheetIdList []int, page int) (items []*ExcelSheetData, err error) {
  38. num := len(excelSheetIdList)
  39. if num <= 0 {
  40. return
  41. }
  42. // o := orm.NewOrmUsingDB("data")
  43. // sql := ` SELECT *
  44. //FROM excel_sheet_data WHERE 1=1 AND excel_sheet_id in (` + utils.GetOrmInReplace(num) + `) AND sort = ? `
  45. // _, err = o.Raw(sql, excelSheetIdList, page).QueryRows(&items)
  46. sql := ` SELECT *
  47. FROM excel_sheet_data WHERE 1=1 AND excel_sheet_id in (` + utils.GetOrmInReplace(num) + `) AND sort = ? `
  48. err = global.DmSQL["data"].Raw(sql, excelSheetIdList, page).Find(&items).Error
  49. return
  50. }
  51. // GetAllSheetDataListByExcelInfoId 根据表格id获取所有的sheet的所有数据详情
  52. func GetAllSheetDataListByExcelInfoId(excelInfoId int) (items []*ExcelSheetData, err error) {
  53. // o := orm.NewOrmUsingDB("data")
  54. // sql := ` SELECT *
  55. //FROM excel_sheet_data WHERE 1=1 AND excel_info_id = ? ORDER BY sort ASC `
  56. // _, err = o.Raw(sql, excelInfoId).QueryRows(&items)
  57. sql := ` SELECT *
  58. FROM excel_sheet_data WHERE 1=1 AND excel_info_id = ? ORDER BY sort ASC `
  59. err = global.DmSQL["data"].Raw(sql, excelInfoId).Find(&items).Error
  60. return
  61. }