edb_refresh_mapping.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. package edb_refresh
  2. import (
  3. "errors"
  4. "github.com/beego/beego/v2/client/orm"
  5. "time"
  6. )
  7. // EdbRefreshMapping
  8. // @Description: 指标刷新时间配置关系表
  9. type EdbRefreshMapping struct {
  10. EdbRefreshMappingId int `orm:"column(edb_refresh_mapping_id);pk"`
  11. Source int `description:"来源"`
  12. SubSource int `description:"来源名称"`
  13. EdbInfoId int `description:"指标id,如果是数据源(钢联、有色)的,那么就是数据源里面的id"`
  14. EdbRefreshConfigId int `description:"刷新配置id"`
  15. SysUserId int `description:"操作人id"`
  16. SysUserRealName string `description:"操作人真实姓名"`
  17. ModifyTime time.Time `description:"最晚一次的更新时间"`
  18. CreateTime time.Time `description:"添加时间"`
  19. }
  20. // Add
  21. // @Description: 添加
  22. // @author: Roc
  23. // @receiver m
  24. // @datetime 2023-12-14 16:11:10
  25. // @param cols []string
  26. // @return err error
  27. func (m *EdbRefreshMapping) Add() (err error) {
  28. if m.EdbRefreshMappingId > 0 {
  29. err = errors.New("该配置已存在")
  30. return
  31. }
  32. o := orm.NewOrmUsingDB("data")
  33. lastId, err := o.Insert(m)
  34. if err != nil {
  35. return
  36. }
  37. m.EdbRefreshMappingId = int(lastId)
  38. return
  39. }
  40. // Update
  41. // @Description: 更新
  42. // @author: Roc
  43. // @receiver m
  44. // @datetime 2023-12-14 16:11:10
  45. // @param cols []string
  46. // @return err error
  47. func (m *EdbRefreshMapping) Update(cols []string) (err error) {
  48. o := orm.NewOrmUsingDB("data")
  49. _, err = o.Update(m, cols...)
  50. return
  51. }
  52. // Delete
  53. // @Description: 删除
  54. // @author: Roc
  55. // @receiver m
  56. // @datetime 2023-12-14 16:11:10
  57. // @return err error
  58. func (m *EdbRefreshMapping) Delete() (err error) {
  59. o := orm.NewOrmUsingDB("data")
  60. _, err = o.Delete(m)
  61. return
  62. }