event_topic.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package show
  2. import (
  3. "go-common/app/admin/main/feed/model/common"
  4. "go-common/app/admin/main/feed/model/show"
  5. "go-common/library/log"
  6. "github.com/jinzhu/gorm"
  7. )
  8. // EventTopicAdd add event topic
  9. func (d *Dao) EventTopicAdd(param *show.EventTopicAP) (err error) {
  10. if err = d.DB.Create(param).Error; err != nil {
  11. log.Error("dao.show.EventTopicAdd error(%v)", err)
  12. return
  13. }
  14. return
  15. }
  16. // EventTopicUpdate update event topic
  17. func (d *Dao) EventTopicUpdate(param *show.EventTopicUP) (err error) {
  18. if err = d.DB.Model(&show.EventTopicUP{}).Update(param).Error; err != nil {
  19. log.Error("dao.show.EventTopicUpdate error(%v)", err)
  20. return
  21. }
  22. return
  23. }
  24. // EventTopicDelete delete cevent topic
  25. func (d *Dao) EventTopicDelete(id int64) (err error) {
  26. up := map[string]interface{}{
  27. "deleted": common.Deleted,
  28. }
  29. if err = d.DB.Model(&show.EventTopic{}).Where("id = ?", id).Update(up).Error; err != nil {
  30. log.Error("dao.show.EventTopicDelete error(%v)", err)
  31. return
  32. }
  33. return
  34. }
  35. // ETFindByID event topic table find by id
  36. func (d *Dao) ETFindByID(id int64) (topic *show.EventTopic, err error) {
  37. topic = &show.EventTopic{}
  38. w := map[string]interface{}{
  39. "deleted": common.NotDeleted,
  40. }
  41. if err = d.DB.Model(&show.EventTopic{}).Where("id = ?", id).Where(w).First(topic).Error; err != nil {
  42. if err == gorm.ErrRecordNotFound {
  43. topic = nil
  44. err = nil
  45. } else {
  46. log.Error("dao.ormshow.event_topic.findByID error(%v)", err)
  47. }
  48. }
  49. return
  50. }