edb_refresh_config.go 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. package edb_refresh
  2. import (
  3. "errors"
  4. "eta_gn/eta_index_lib/global"
  5. "time"
  6. )
  7. // EdbRefreshConfig
  8. // @Description: 指标的刷新时间配置表
  9. type EdbRefreshConfig struct {
  10. EdbRefreshConfigId int `gorm:"primaryKey;autoIncrement;column:edb_refresh_config_id"`
  11. RefreshFrequency string `gorm:"column:refresh_frequency" description:"刷新频率"`
  12. RefreshFrequencyDay int `gorm:"column:refresh_frequency_day" description:"具体刷新的日期"`
  13. RefreshTime string `gorm:"column:refresh_time" description:"刷新时间"`
  14. RefreshAllData int `gorm:"column:refresh_all_data" description:"是否刷新所有数据,0:否,1:刷新所有数据"`
  15. RefreshDataNum int `gorm:"column:refresh_data_num" description:"刷新单元格数"`
  16. ModifyTime time.Time `gorm:"column:modify_time" description:"最晚一次的更新时间"`
  17. CreateTime time.Time `gorm:"column:create_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. err = global.DEFAULT_DmSQL.Create(m).Error
  32. return
  33. }
  34. // Update
  35. // @Description: 更新
  36. // @author: Roc
  37. // @receiver m
  38. // @datetime 2023-12-14 16:11:10
  39. // @param cols []string
  40. // @return err error
  41. func (m *EdbRefreshConfig) Update(cols []string) (err error) {
  42. err = global.DEFAULT_DmSQL.Model(m).Select(cols).Updates(m).Error
  43. return
  44. }
  45. // Delete
  46. // @Description: 删除
  47. // @author: Roc
  48. // @receiver m
  49. // @datetime 2023-12-14 16:11:10
  50. // @return err error
  51. func (m *EdbRefreshConfig) Delete() (err error) {
  52. //todo 删除前判断
  53. err = global.DEFAULT_DmSQL.Delete(m).Error
  54. return
  55. }
  56. // GetEdbRefreshConfigListByCondition
  57. // @Description: 根据条条件获取刷新配置列表
  58. // @author: Roc
  59. // @datetime 2024-01-09 13:28:49
  60. // @param condition string
  61. // @param pars []interface{}
  62. // @return list []*EdbRefreshDefaultConfig
  63. // @return err error
  64. func GetEdbRefreshConfigListByCondition(condition string, pars []interface{}) (list []*EdbRefreshConfig, err error) {
  65. sql := `SELECT * FROM edb_refresh_config
  66. WHERE 1 = 1 `
  67. if condition != "" {
  68. sql += condition
  69. }
  70. sql += ` ORDER BY edb_refresh_config_id ASC `
  71. err = global.DEFAULT_DmSQL.Raw(sql, pars...).Scan(&list).Error
  72. return
  73. }