edb_refresh_config.go 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. package edb_refresh
  2. import (
  3. "errors"
  4. "github.com/beego/beego/v2/client/orm"
  5. "time"
  6. )
  7. // EdbRefreshConfig
  8. // @Description: 指标的刷新时间配置表
  9. type EdbRefreshConfig struct {
  10. EdbRefreshConfigId int `orm:"column(edb_refresh_config_id);pk"`
  11. RefreshFrequency string `description:"刷新频率"`
  12. RefreshFrequencyDay int `description:"具体刷新的日期"`
  13. RefreshTime string `description:"刷新时间"`
  14. RefreshAllData int `description:"是否刷新所有数据,0:否,1:刷新所有数据"`
  15. RefreshDataNum int `description:"刷新单元格数"`
  16. ModifyTime time.Time `description:"最晚一次的更新时间"`
  17. CreateTime time.Time `description:"添加时间"`
  18. }
  19. // Add
  20. // @Description: 添加
  21. // @author: Roc
  22. // @receiver m
  23. // @datetime 2023-12-14 16:11:10
  24. // @param cols []string
  25. // @return err error
  26. func (m *EdbRefreshConfig) Add() (err error) {
  27. if m.EdbRefreshConfigId > 0 {
  28. err = errors.New("该配置已存在")
  29. return
  30. }
  31. o := orm.NewOrmUsingDB("data")
  32. lastId, err := o.Insert(m)
  33. if err != nil {
  34. return
  35. }
  36. m.EdbRefreshConfigId = int(lastId)
  37. return
  38. }
  39. // Update
  40. // @Description: 更新
  41. // @author: Roc
  42. // @receiver m
  43. // @datetime 2023-12-14 16:11:10
  44. // @param cols []string
  45. // @return err error
  46. func (m *EdbRefreshConfig) Update(cols []string) (err error) {
  47. o := orm.NewOrmUsingDB("data")
  48. _, err = o.Update(m, cols...)
  49. return
  50. }
  51. // Delete
  52. // @Description: 删除
  53. // @author: Roc
  54. // @receiver m
  55. // @datetime 2023-12-14 16:11:10
  56. // @return err error
  57. func (m *EdbRefreshConfig) Delete() (err error) {
  58. o := orm.NewOrmUsingDB("data")
  59. _, err = o.Delete(m)
  60. return
  61. }
  62. // GetEdbRefreshConfigListByCondition
  63. // @Description: 根据条条件获取刷新配置列表
  64. // @author: Roc
  65. // @datetime 2024-01-09 13:28:49
  66. // @param condition string
  67. // @param pars []interface{}
  68. // @return list []*EdbRefreshDefaultConfig
  69. // @return err error
  70. func GetEdbRefreshConfigListByCondition(condition string, pars []interface{}) (list []*EdbRefreshConfig, err error) {
  71. o := orm.NewOrmUsingDB("data")
  72. sql := `SELECT * FROM edb_refresh_config
  73. WHERE 1 = 1 `
  74. if condition != "" {
  75. sql += condition
  76. }
  77. sql += ` ORDER BY edb_refresh_config_id ASC `
  78. _, err = o.Raw(sql, pars).QueryRows(&list)
  79. return
  80. }