excel_sheet_data.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. err = global.DmSQL["data"].Select(cols).Updates(ExcelSheetData).Error
  20. return
  21. }
  22. // GetSheetDataListBySheetIdListAndPage 根据sheet_id列表和页码获取所有的sheet数据详情
  23. func GetSheetDataListBySheetIdListAndPage(excelSheetIdList []int, page int) (items []*ExcelSheetData, err error) {
  24. num := len(excelSheetIdList)
  25. if num <= 0 {
  26. return
  27. }
  28. sql := ` SELECT *
  29. FROM excel_sheet_data WHERE 1=1 AND excel_sheet_id in (` + utils.GetOrmInReplace(num) + `) AND sort = ? `
  30. err = global.DmSQL["data"].Raw(sql, excelSheetIdList, page).Find(&items).Error
  31. return
  32. }
  33. // GetAllSheetDataListByExcelInfoId 根据表格id获取所有的sheet的所有数据详情
  34. func GetAllSheetDataListByExcelInfoId(excelInfoId int) (items []*ExcelSheetData, err error) {
  35. sql := ` SELECT *
  36. FROM excel_sheet_data WHERE 1=1 AND excel_info_id = ? ORDER BY sort ASC `
  37. err = global.DmSQL["data"].Raw(sql, excelInfoId).Find(&items).Error
  38. return
  39. }