FriendService.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <?php
  2. namespace App\Http\Services\V1;
  3. use App\Generated\V1\Messages\Friend\GetApplyAllListMessage;
  4. use App\Generated\V1\Messages\Friend\GetApplyReceiveListMessage;
  5. use App\Generated\V1\Messages\Friend\GetApplySendListMessage;
  6. use App\Generated\V1\Messages\Friend\GetEachLikeListMessage;
  7. use App\Generated\V1\Messages\Friend\GetStarListMessage;
  8. use App\Generated\V1\Messages\Friend\GetChatHistoryMessage;
  9. use App\Generated\V1\Messages\Friend\GetUnreadCountMessage;
  10. use App\Generated\V1\Messages\Friend\AgreeApplyMessage;
  11. use App\Generated\V1\Messages\Friend\GetAllListMessage;
  12. use App\Http\Controllers\Core\Auth;
  13. use App\Managers\FriendManager;
  14. use App\Services\V2_17_3\Friends\ApplyService;
  15. class FriendService
  16. {
  17. protected $friendManager;
  18. public function __construct(FriendManager $friendManager)
  19. {
  20. $this->friendManager = $friendManager;
  21. }
  22. public function getAllList(GetAllListMessage $message)
  23. {
  24. $page = $message->getPage();
  25. $uid = Auth::auth();
  26. $data = $this->friendManager->getAllList($uid, [
  27. 'limit' => 20,
  28. 'page' => $page,
  29. ]);
  30. $message->setResponse($data);
  31. }
  32. public function getApplyAllList(GetApplyAllListMessage $message)
  33. {
  34. $page = $message->getPage() ?: 1;
  35. $uid = Auth::auth();
  36. $pages = array(
  37. 'limit' => 20,
  38. 'page' => $page,
  39. );
  40. $data = $this->friendManager->getApplyAllList($uid, $pages);
  41. $message->setResponse($data);
  42. }
  43. public function getApplyReceiveList(GetApplyReceiveListMessage $message)
  44. {
  45. $page = $message->getPage() ?: 1;
  46. $uid = Auth::auth();
  47. $pages = array(
  48. 'limit' => 20,
  49. 'page' => $page
  50. );
  51. $data = $this->friendManager->getReceiveList($uid, $pages);
  52. $message->setResponse($data);
  53. }
  54. public function getApplySendList(GetApplySendListMessage $message)
  55. {
  56. $page = $message->getPage() ?: 1;
  57. $uid = Auth::auth();
  58. $pages = array(
  59. 'limit' => 20,
  60. 'page' => $page
  61. );
  62. $data = $this->friendManager->getSendList($uid, $pages);
  63. $message->setResponse($data);
  64. }
  65. public function getEachLikeList(GetEachLikeListMessage $message)
  66. {
  67. $page = $message->getPage() ?: 1;
  68. $uid = Auth::auth();
  69. $pages = array(
  70. 'limit' => 20,
  71. 'page' => $page
  72. );
  73. $data = $this->friendManager->getEachLikeList($uid, $pages);
  74. $message->setResponse($data);
  75. }
  76. public function getStarList(GetStarListMessage $message)
  77. {
  78. $page = $message->getPage() ?: 1;
  79. $uid = Auth::auth();
  80. $pages = array(
  81. 'limit' => 20,
  82. 'page' => $page
  83. );
  84. $data = $this->friendManager->getStarList($uid, $pages);
  85. $message->setResponse($data);
  86. }
  87. public function getChatHistory(GetChatHistoryMessage $message)
  88. {
  89. $page = $message->getPage() ?: 1;
  90. $friendUid = $message->getFriendUid();
  91. $uid = Auth::auth();
  92. $pages = array(
  93. 'limit' => 20,
  94. 'page' => $page
  95. );
  96. $data = $this->friendManager->getHistory($uid, $friendUid, $pages);
  97. $message->setResponse($data);
  98. }
  99. public function getUnreadCount(GetUnreadCountMessage $message)
  100. {
  101. $uid = Auth::auth();
  102. $data = $this->friendManager->getUnreadCount($uid);
  103. $message->setResponse($data);
  104. }
  105. public function agreeApply(AgreeApplyMessage $message)
  106. {
  107. $uid = Auth::auth();
  108. $applyUid = $message->getApplyUid();
  109. $as = new ApplyService();
  110. $as->agree($uid, $applyUid);
  111. }
  112. }