excel_edb_mapping.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. package excel
  2. import (
  3. "eta_gn/eta_task/global"
  4. "eta_gn/eta_task/utils"
  5. "time"
  6. )
  7. // ExcelEdbMapping excel与指标的关系表
  8. type ExcelEdbMapping struct {
  9. ExcelEdbMappingId int `gorm:"column:excel_edb_mapping_id;primaryKey"` // `orm:"column(excel_edb_mapping_id);pk"`
  10. ExcelInfoId int `description:"excel的id"`
  11. Source int `description:"表格来源,1:excel插件的表格,2:自定义表格,3:混合表格,4:自定义分析,默认:1"`
  12. EdbInfoId int `description:"计算指标id"`
  13. CreateTime time.Time `description:"创建时间"`
  14. ModifyTime time.Time `description:"修改时间"`
  15. }
  16. // GetExcelEdbMappingTotalBySource 根据表格类型获取总数
  17. func GetExcelEdbMappingTotalBySource(sources []int) (total int, err error) {
  18. //o := orm.NewOrmUsingDB("data")
  19. sql := ` SELECT count(*) FROM excel_edb_mapping WHERE source in (` + utils.GetOrmInReplace(len(sources)) + `)`
  20. //err = o.Raw(sql, sources).QueryRow(&total)
  21. err = global.DmSQL["data"].Raw(sql, sources).Scan(total).Error
  22. return
  23. }
  24. // GetExcelEdbMappingListBySource 根据表格类型获取列表
  25. func GetExcelEdbMappingListBySource(sources []int, pageIndex, pageSize int) (items []*ExcelEdbMapping, err error) {
  26. //o := orm.NewOrmUsingDB("data")
  27. sql := ` SELECT * FROM excel_edb_mapping WHERE source in (` + utils.GetOrmInReplace(len(sources)) + `) Limit ?,? `
  28. //_, err = o.Raw(sql, sources, pageIndex, pageSize).QueryRows(&items)
  29. err = global.DmSQL["data"].Raw(sql, sources, pageIndex, pageSize).Find(&items).Error
  30. return
  31. }