edb_source_stat.go 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. package data_stat
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "time"
  6. )
  7. // EdbSourceStat 数据源统计表
  8. type EdbSourceStat struct {
  9. Id uint64 `orm:"column(id);pk"`
  10. SourceName string `description:"来源名称"`
  11. Source int `description:"来源id"`
  12. TerminalCode string `description:"终端编码,用于配置在机器上"`
  13. EdbNum int32 `description:"指标总数"`
  14. EdbNewNum int32 `description:"今日新增指标数"`
  15. EdbDelNum int32 `description:"今日删除指标数"`
  16. NeedRefreshNum int `description:"今日需刷新指标"`
  17. HasRefreshNum int `description:"今日发起刷新任务指标数"`
  18. UpdateSuccessNum int `description:"今日已更新成功指标数"`
  19. UpdateFailedNum int `description:"今日已更新失败指标数"`
  20. RefreshSuccessNum int `description:"今日已刷新成功指标数"`
  21. RefreshFailedNum int `description:"今日已刷新失败指标数"`
  22. CreateTime time.Time `description:"创建时间"`
  23. ModifyTime time.Time `description:"修改时间"`
  24. }
  25. type EdbInfoSourceStatItem struct {
  26. Id uint64 `orm:"column(id);pk"`
  27. SourceName string `description:"来源名称"`
  28. Source int `description:"来源id"`
  29. TerminalCode string `description:"终端编码,用于配置在机器上"`
  30. EdbNum int32 `description:"指标总数"`
  31. EdbNewNum int32 `description:"今日新增指标数"`
  32. EdbDelNum int32 `description:"今日删除指标数"`
  33. NeedRefreshNum int `description:"今日需刷新指标"`
  34. HasRefreshNum int `description:"今日发起刷新任务指标数"`
  35. UpdateSuccessNum int `description:"今日已更新成功指标数"`
  36. UpdateFailedNum int `description:"今日已更新失败指标数"`
  37. RefreshSuccessNum int `description:"今日已刷新成功指标数"`
  38. RefreshFailedNum int `description:"今日已刷新失败指标数"`
  39. }
  40. type GetEdbSourceStatResp struct {
  41. List []*EdbInfoSourceStatItem
  42. Paging *paging.PagingItem
  43. }
  44. func GetEdbSourceStatByCondition(condition string, pars []interface{}, orderStr string, pageSize, startSize int) (item []*EdbSourceStat, err error) {
  45. o := orm.NewOrmUsingDB("data")
  46. sql := ` SELECT * FROM edb_source_stat WHERE 1=1 `
  47. if condition != "" {
  48. sql += condition
  49. }
  50. if orderStr != "" {
  51. sql += orderStr
  52. } else {
  53. sql += ` ORDER BY create_time DESC, id DESC `
  54. }
  55. sql += ` LIMIT ?,? `
  56. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&item)
  57. return
  58. }
  59. // GetEdbSourceStatCount
  60. func GetEdbSourceStatCount(condition string, pars []interface{}) (count int, err error) {
  61. o := orm.NewOrmUsingDB("data")
  62. sql := ` SELECT count(*) FROM edb_source_stat WHERE 1=1 `
  63. if condition != "" {
  64. sql += condition
  65. }
  66. err = o.Raw(sql, pars).QueryRow(&count)
  67. return
  68. }