ot_alert_policy.go 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. package dto
  2. import (
  3. "go-admin/app/admin/models"
  4. "go-admin/common/dto"
  5. common "go-admin/common/models"
  6. )
  7. type OtAlertPolicyGetPageReq struct {
  8. dto.Pagination `search:"-"`
  9. AppId int64 `form:"appId" search:"type:exact;column:app_id;table:ot_alert_policy" comment:"业务ID"`
  10. RuleId int64 `form:"ruleId" search:"type:exact;column:rule_id;table:ot_alert_policy" comment:"监控规则ID"`
  11. MonitorAlias string `form:"monitorAlias" search:"type:exact;column:monitor_alias;table:ot_alert_policy" comment:"监控项别名"`
  12. Power string `form:"power" search:"type:exact;column:power;table:ot_alert_policy" comment:"是否启用"`
  13. OtAlertPolicyOrder
  14. }
  15. type OtAlertPolicyImportReq struct {
  16. AppId int64 `json:"appId" search:"type:or;column:app_id;table:ot_alert_policy" comment:"业务ID"`
  17. // OtAlertPolicyOrder
  18. }
  19. type OtAlertPolicyOrder struct {
  20. Id string `form:"idOrder" search:"type:order;column:id;table:ot_alert_policy"`
  21. AppId string `form:"appIdOrder" search:"type:order;column:app_id;table:ot_alert_policy"`
  22. RuleId string `form:"ruleIdOrder" search:"type:order;column:rule_id;table:ot_alert_policy"`
  23. MonitorAlias string `form:"monitorAliasOrder" search:"type:order;column:monitor_alias;table:ot_alert_policy"`
  24. Policy string `form:"policyOrder" search:"type:order;column:policy;table:ot_alert_policy"`
  25. Power string `form:"powerOrder" search:"type:order;column:power;table:ot_alert_policy"`
  26. CreatedAt string `form:"createdAtOrder" search:"type:order;column:created_at;table:ot_alert_policy"`
  27. UpdatedAt string `form:"updatedAtOrder" search:"type:order;column:updated_at;table:ot_alert_policy"`
  28. DeletedAt string `form:"deletedAtOrder" search:"type:order;column:deleted_at;table:ot_alert_policy"`
  29. CreateBy string `form:"createByOrder" search:"type:order;column:create_by;table:ot_alert_policy"`
  30. UpdateBy string `form:"updateByOrder" search:"type:order;column:update_by;table:ot_alert_policy"`
  31. }
  32. func (m *OtAlertPolicyGetPageReq) GetNeedSearch() interface{} {
  33. return *m
  34. }
  35. type OtAlertPolicyInsertReq struct {
  36. Id int `json:"-" comment:"业务应用告警规则表"` // 业务应用告警规则表
  37. AppId int64 `json:"appId" comment:"业务ID"`
  38. RuleId int64 `json:"ruleId" comment:"监控规则ID"`
  39. MonitorAlias string `json:"monitorAlias" comment:"监控项别名"`
  40. Policy string `json:"policy" comment:"告警策略"`
  41. Power int64 `json:"power" comment:"是否启用"`
  42. common.ControlBy
  43. }
  44. func (s *OtAlertPolicyInsertReq) Generate(model *models.OtAlertPolicy) {
  45. if s.Id == 0 {
  46. model.Model = common.Model{Id: s.Id}
  47. }
  48. model.AppId = s.AppId
  49. model.RuleId = s.RuleId
  50. model.MonitorAlias = s.MonitorAlias
  51. model.Policy = s.Policy
  52. model.Power = s.Power
  53. model.CreateBy = s.CreateBy // 添加这而,需要记录是被谁创建的
  54. }
  55. func (s *OtAlertPolicyInsertReq) GetId() interface{} {
  56. return s.Id
  57. }
  58. type OtAlertPolicyUpdateReq struct {
  59. Id int `uri:"id" comment:"业务应用告警规则表"` // 业务应用告警规则表
  60. AppId int64 `json:"appId" comment:"业务ID"`
  61. RuleId int64 `json:"ruleId" comment:"监控规则ID"`
  62. MonitorAlias string `json:"monitorAlias" comment:"监控项别名"`
  63. Policy string `json:"policy" comment:"告警策略"`
  64. Power int64 `json:"power" comment:"是否启用"`
  65. common.ControlBy
  66. }
  67. func (s *OtAlertPolicyUpdateReq) Generate(model *models.OtAlertPolicy) {
  68. if s.Id == 0 {
  69. model.Model = common.Model{Id: s.Id}
  70. }
  71. model.AppId = s.AppId
  72. model.RuleId = s.RuleId
  73. model.MonitorAlias = s.MonitorAlias
  74. model.Policy = s.Policy
  75. model.Power = s.Power
  76. model.UpdateBy = s.UpdateBy // 添加这而,需要记录是被谁更新的
  77. }
  78. func (s *OtAlertPolicyUpdateReq) GetId() interface{} {
  79. return s.Id
  80. }
  81. // OtAlertPolicyGetReq 功能获取请求参数
  82. type OtAlertPolicyGetReq struct {
  83. Id int `uri:"id"`
  84. }
  85. func (s *OtAlertPolicyGetReq) GetId() interface{} {
  86. return s.Id
  87. }
  88. // OtAlertPolicyDeleteReq 功能删除请求参数
  89. type OtAlertPolicyDeleteReq struct {
  90. Ids []int `json:"ids"`
  91. }
  92. func (s *OtAlertPolicyDeleteReq) GetId() interface{} {
  93. return s.Ids
  94. }