mysql_url_event.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package dao
  2. import (
  3. "go-common/app/admin/ep/tapd/model"
  4. "go-common/library/ecode"
  5. )
  6. // AddURLEvent Add URL Event.
  7. func (d *Dao) AddURLEvent(urlEvent *model.UrlEvent) error {
  8. return d.db.Create(urlEvent).Error
  9. }
  10. // QueryURLEventByUrlAndEvent Query URL Event By Url And Event.
  11. func (d *Dao) QueryURLEventByUrlAndEvent(urlID int64, eventType string) (urlEvents []*model.UrlEvent, err error) {
  12. err = d.db.Model(&model.HookUrl{}).Where("url_id = ? and event = ?", urlID, eventType).Find(&urlEvents).Error
  13. if err == ecode.NothingFound {
  14. err = nil
  15. }
  16. return
  17. }
  18. // QueryURLEventByUrl Query URL Event By Url.
  19. func (d *Dao) QueryURLEventByUrl(urlID int64) (urlEvents []*model.UrlEvent, err error) {
  20. err = d.db.Model(&model.HookUrl{}).Where("url_id = ?", urlID).Find(&urlEvents).Error
  21. if err == ecode.NothingFound {
  22. err = nil
  23. }
  24. return
  25. }
  26. // QueryURLEventByEventAndStatus Query URL Event By Event and status.
  27. func (d *Dao) QueryURLEventByEventAndStatus(event string, status int) (urlEvents []*model.UrlEvent, err error) {
  28. err = d.db.Model(&model.HookUrl{}).Where("event = ? and status = ?", event, status).Find(&urlEvents).Error
  29. if err == ecode.NothingFound {
  30. err = nil
  31. }
  32. return
  33. }
  34. // QueryURLEventByStatus Query URL Event By Status.
  35. func (d *Dao) QueryURLEventByStatus(status int) (urlEvents []*model.UrlEvent, err error) {
  36. err = d.db.Model(&model.HookUrl{}).Where("status = ?", status).Find(&urlEvents).Error
  37. if err == ecode.NothingFound {
  38. err = nil
  39. }
  40. return
  41. }
  42. // UpdateURLEventStatus Update URL Event status.
  43. func (d *Dao) UpdateURLEventStatus(id int64, status int) error {
  44. return d.db.Model(&model.UrlEvent{}).Where("id=?", id).Update("status", status).Error
  45. }