FriendController.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <?php
  2. namespace App\Http\Controllers\Deed;
  3. use App\Http\Controllers\Controller;
  4. use App\Http\Controllers\Core\Auth;
  5. use App\Managers\DeedFriendManager;
  6. use App\Services\Deed\FriendService;
  7. use Illuminate\Http\Request;
  8. class FriendController extends Controller
  9. {
  10. public function overview()
  11. {
  12. $uid = Auth::auth();
  13. $fs = new FriendService();
  14. $data = $fs->overview($uid);
  15. return array(
  16. 'code' => 200,
  17. 'message' => 'success',
  18. 'data' => $data
  19. );
  20. }
  21. /**
  22. * 好友列表未读概览
  23. */
  24. public function getListCnt()
  25. {
  26. $uid = Auth::auth();
  27. $fs = new FriendService();
  28. $data = $fs->getListCnt($uid);
  29. return array(
  30. 'code' => 200,
  31. 'message' => 'success',
  32. 'data' => $data
  33. );
  34. }
  35. /**
  36. * 全部好友列表
  37. * @param Request $request
  38. * @return array
  39. */
  40. public function getAllList(Request $request)
  41. {
  42. $uid = Auth::auth();
  43. $pages = array(
  44. 'limit' => 20,
  45. 'page' => $request->get('page', 1)
  46. );
  47. $fs = new FriendService();
  48. $data = $fs->getAllList($uid, $pages);
  49. return array(
  50. 'code' => 200,
  51. 'message' => 'success',
  52. 'data' => $data
  53. );
  54. }
  55. /**
  56. * 相互喜欢列表
  57. * @param Request $request
  58. * @return array
  59. */
  60. public function getEachLikeList(Request $request)
  61. {
  62. $uid = Auth::auth();
  63. $pages = array(
  64. 'limit' => 20,
  65. 'page' => $request->get('page', 1)
  66. );
  67. $fs = new FriendService();
  68. $data = $fs->getEachLikeList($uid, $pages);
  69. return array(
  70. 'code' => 200,
  71. 'message' => 'success',
  72. 'data' => $data
  73. );
  74. }
  75. /**
  76. * 星标好友列表
  77. * @param Request $request
  78. * @return array
  79. */
  80. public function getStarList(Request $request)
  81. {
  82. $uid = Auth::auth();
  83. $pages = array(
  84. 'limit' => 20,
  85. 'page' => $request->get('page', 1)
  86. );
  87. $fs = new FriendService();
  88. $data = $fs->getStarList($uid, $pages);
  89. return array(
  90. 'code' => 200,
  91. 'message' => 'success',
  92. 'data' => $data
  93. );
  94. }
  95. /**
  96. * 星标某个好友
  97. * @param int $friend_uid
  98. * @return array
  99. * @deprecated DeedFriend/StarFriend
  100. */
  101. public function starFriend(int $friend_uid)
  102. {
  103. $uid = Auth::auth();
  104. $fs = new DeedFriendManager();
  105. $fs->starFriend($uid, $friend_uid);
  106. return array(
  107. 'code' => 200,
  108. 'message' => 'success'
  109. );
  110. }
  111. /**
  112. * 隐藏某个好友
  113. * @param int $friend_uid
  114. * @return array
  115. * @deprecated DeedFriend/HideFriend
  116. */
  117. public function hideFriend(int $friend_uid)
  118. {
  119. $uid = Auth::auth();
  120. $fs = new DeedFriendManager();
  121. $fs->hideFriend($uid, $friend_uid);
  122. return array(
  123. 'code' => 200,
  124. 'message' => 'success'
  125. );
  126. }
  127. /**
  128. * 聊天历史
  129. * @param $friend_uid
  130. * @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
  131. */
  132. public function history($friend_uid)
  133. {
  134. $uid = Auth::auth();
  135. $friend_service = new FriendService();
  136. $data = $friend_service->history($uid, $friend_uid);
  137. return response([
  138. 'code' => 200,
  139. 'message' => 'OK',
  140. 'data' => $data,
  141. ]);
  142. }
  143. }