account.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package service
  2. import (
  3. "context"
  4. "time"
  5. "go-common/app/job/main/figure/model"
  6. "go-common/library/log"
  7. )
  8. // AccountExp handle user exp chenage message
  9. func (s *Service) AccountExp(c context.Context, mid, exp int64) (err error) {
  10. s.figureDao.UpdateAccountExp(c, mid, exp)
  11. return
  12. }
  13. // AccountReg handle user register message, init user figure info
  14. func (s *Service) AccountReg(c context.Context, mid int64) (err error) {
  15. var id int64
  16. if id, err = s.figureDao.ExistFigure(c, mid); err != nil || id != 0 {
  17. log.Info("user(%d) already init", mid)
  18. return
  19. }
  20. f := &model.Figure{
  21. Mid: mid,
  22. LawfulScore: s.c.Figure.Lawful,
  23. WideScore: s.c.Figure.Wide,
  24. FriendlyScore: s.c.Figure.Friendly,
  25. BountyScore: s.c.Figure.Bounty,
  26. CreativityScore: s.c.Figure.Creativity,
  27. Ver: 1,
  28. Ctime: time.Now(),
  29. Mtime: time.Now(),
  30. }
  31. if _, err = s.figureDao.SaveFigure(c, f); err != nil {
  32. return
  33. }
  34. s.figureDao.AddFigureInfoCache(c, f)
  35. return
  36. }
  37. // AccountViewVideo handle user view video message
  38. func (s *Service) AccountViewVideo(c context.Context, mid int64) (err error) {
  39. s.figureDao.IncArchiveViews(c, mid)
  40. return
  41. }