excel_edb_mapping.go 1.4 KB

123456789101112131415161718192021222324252627282930313233
  1. package excel
  2. import (
  3. "eta/eta_task/global"
  4. "eta/eta_task/utils"
  5. "time"
  6. )
  7. // ExcelEdbMapping excel与指标的关系表
  8. type ExcelEdbMapping struct {
  9. ExcelEdbMappingId int `gorm:"column:excel_edb_mapping_id;primaryKey;autoIncrement"`
  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 := global.DbMap[utils.DbNameIndex]
  19. sql := ` SELECT count(*) FROM excel_edb_mapping WHERE source in (` + utils.GetOrmInReplace(len(sources)) + `)`
  20. err = o.Raw(sql, sources).Scan(&total).Error
  21. return
  22. }
  23. // GetExcelEdbMappingListBySource 根据表格类型获取列表
  24. func GetExcelEdbMappingListBySource(sources []int, pageIndex, pageSize int) (items []*ExcelEdbMapping, err error) {
  25. o := global.DbMap[utils.DbNameIndex]
  26. sql := ` SELECT * FROM excel_edb_mapping WHERE source in (` + utils.GetOrmInReplace(len(sources)) + `) Limit ?,? `
  27. err = o.Raw(sql, sources, pageIndex, pageSize).Find(&items).Error
  28. return
  29. }