excel_sheet_data.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package excel
  2. import (
  3. "eta_gn/eta_api/global"
  4. "eta_gn/eta_api/utils"
  5. "time"
  6. )
  7. type ExcelSheetData struct {
  8. ExcelDataId int `orm:"column(excel_data_id);pk" gorm:"primaryKey" `
  9. ExcelInfoId int `description:"数据归属的excel_info的id"`
  10. ExcelSheetId int `description:"数据归属sheet"`
  11. Sort int `description:"数据排序"`
  12. Data string `description:"数据,分页存储"`
  13. ModifyTime time.Time `description:"最近修改日期"`
  14. CreateTime time.Time `description:"创建日期"`
  15. }
  16. func (ExcelSheetData *ExcelSheetData) Update(cols []string) (err error) {
  17. err = global.DmSQL["data"].Select(cols).Updates(ExcelSheetData).Error
  18. return
  19. }
  20. func GetSheetDataListBySheetIdListAndPage(excelSheetIdList []int, page int) (items []*ExcelSheetData, err error) {
  21. num := len(excelSheetIdList)
  22. if num <= 0 {
  23. return
  24. }
  25. sql := ` SELECT *
  26. FROM excel_sheet_data WHERE 1=1 AND excel_sheet_id in (` + utils.GetOrmInReplace(num) + `) AND sort = ? `
  27. err = global.DmSQL["data"].Raw(sql, excelSheetIdList, page).Find(&items).Error
  28. return
  29. }
  30. func GetAllSheetDataListByExcelInfoId(excelInfoId int) (items []*ExcelSheetData, err error) {
  31. sql := ` SELECT *
  32. FROM excel_sheet_data WHERE 1=1 AND excel_info_id = ? ORDER BY sort ASC `
  33. err = global.DmSQL["data"].Raw(sql, excelInfoId).Find(&items).Error
  34. return
  35. }