search_web_card.go 1.5 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. // SearchWebCardAdd add search web card
  9. func (d *Dao) SearchWebCardAdd(param *show.SearchWebCardAP) (err error) {
  10. if err = d.DB.Create(param).Error; err != nil {
  11. log.Error("dao.show.SearchWebCardAdd error(%v)", err)
  12. return
  13. }
  14. return
  15. }
  16. // SearchWebCardUpdate search update web card
  17. func (d *Dao) SearchWebCardUpdate(param *show.SearchWebCardUP) (err error) {
  18. if err = d.DB.Model(&show.SearchWebCardUP{}).Update(param).Error; err != nil {
  19. log.Error("dao.show.SearchWebCardUpdate error(%v)", err)
  20. return
  21. }
  22. return
  23. }
  24. // SearchWebCardDelete search delete cweb card
  25. func (d *Dao) SearchWebCardDelete(id int64) (err error) {
  26. up := map[string]interface{}{
  27. "deleted": common.Deleted,
  28. }
  29. if err = d.DB.Model(&show.SearchWebCard{}).Where("id = ?", id).Update(up).Error; err != nil {
  30. log.Error("dao.show.SearchWebCardDelete error(%v)", err)
  31. return
  32. }
  33. return
  34. }
  35. // SWBFindByID search web card table find by id
  36. func (d *Dao) SWBFindByID(id int64) (card *show.SearchWebCard, err error) {
  37. card = &show.SearchWebCard{}
  38. w := map[string]interface{}{
  39. "deleted": common.NotDeleted,
  40. }
  41. if err = d.DB.Model(&show.SearchWebCard{}).Where("id = ?", id).Where(w).First(card).Error; err != nil {
  42. if err == gorm.ErrRecordNotFound {
  43. card = nil
  44. err = nil
  45. } else {
  46. log.Error("dao.ormshow.event_topic.findByID error(%v)", err)
  47. }
  48. }
  49. return
  50. }