game.go 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package service
  2. import (
  3. "context"
  4. "go-common/app/interface/main/space/model"
  5. )
  6. var (
  7. _emptyGameList = make([]*model.Game, 0)
  8. _emptyAppGameList = make([]*model.AppGame, 0)
  9. )
  10. // LastPlayGame get last play game by mid
  11. func (s *Service) LastPlayGame(c context.Context, mid, vmid int64) (data []*model.Game, err error) {
  12. if mid != vmid {
  13. if err = s.privacyCheck(c, vmid, model.PcyGame); err != nil {
  14. return
  15. }
  16. }
  17. if data, err = s.dao.LastPlayGame(c, vmid); err != nil {
  18. err = nil
  19. data = _emptyGameList
  20. return
  21. }
  22. if len(data) == 0 {
  23. data = _emptyGameList
  24. }
  25. return
  26. }
  27. // AppPlayedGame get app played games.
  28. func (s *Service) AppPlayedGame(c context.Context, mid, vmid int64, platform string, pn, ps int) (data []*model.AppGame, count int, err error) {
  29. if mid != vmid {
  30. if err = s.privacyCheck(c, vmid, model.PcyGame); err != nil {
  31. return
  32. }
  33. }
  34. if data, count, err = s.dao.AppPlayedGame(c, vmid, platform, pn, ps); err != nil {
  35. err = nil
  36. data = _emptyAppGameList
  37. return
  38. }
  39. if len(data) == 0 {
  40. data = _emptyAppGameList
  41. }
  42. return
  43. }