author.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. package service
  2. import (
  3. "context"
  4. "encoding/json"
  5. artmdl "go-common/app/interface/openplatform/article/model"
  6. "go-common/app/job/openplatform/article/dao"
  7. "go-common/app/job/openplatform/article/model"
  8. "go-common/library/log"
  9. )
  10. func (s *Service) upAuthors(c context.Context, action string, newMsg []byte, oldMsg []byte) {
  11. log.Info("s.upAuthors action(%s) old(%s) new(%s)", action, string(oldMsg), string(newMsg))
  12. var (
  13. err error
  14. newAuthor = &model.Author{}
  15. )
  16. if err = json.Unmarshal(newMsg, newAuthor); err != nil {
  17. log.Error("json.Unmarshal(%s) error(%+v)", newMsg, err)
  18. dao.PromError("article:解析作者表databus新内容")
  19. return
  20. }
  21. s.updateAuthorCache(c, newAuthor.Mid)
  22. }
  23. // updateAuthorCache update author cache
  24. func (s *Service) updateAuthorCache(c context.Context, mid int64) (err error) {
  25. arg := &artmdl.ArgAuthor{Mid: mid}
  26. if err = s.articleRPC.UpdateAuthorCache(c, arg); err != nil {
  27. log.Error("s.articleRPC.UpdateAuthorCache(%+v) error(%+v)", arg, err)
  28. dao.PromError("article:更新作者缓存")
  29. return
  30. }
  31. log.Info("s.articleRPC.UpdateAuthorCache(%+v) success", arg)
  32. dao.PromInfo("article:更新作者缓存")
  33. return
  34. }