123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- <?php
- namespace App\Http\Controllers\V2_17_3\Friends;
- use App\Http\Controllers\Controller;
- use App\Http\Controllers\Core\Auth;
- use App\Managers\FriendManager;
- use App\Services\V2_17_3\Friends\ApplyService;
- use Illuminate\Http\Request;
- class ApplyController extends Controller
- {
- /**
- * 全部申请列表
- * @param Request $request
- * @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
- * @deprecated Friend/GetApplyAllList
- */
- public function getAllList(Request $request)
- {
- $uid = Auth::auth();
- $pages = array(
- 'limit' => 20,
- 'page' => $request->get('page', 1)
- );
- $as = new FriendManager();
- $data = $as->getApplyAllList($uid, $pages);
- return response([
- 'code' => 200,
- 'message' => 'success',
- 'data' => $data
- ]);
- }
- /**
- * 发出申请列表
- * @param Request $request
- * @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
- * @deprecated Friend/GetApplySendList
- */
- public function getSendList(Request $request)
- {
- $uid = Auth::auth();
- $pages = array(
- 'limit' => 20,
- 'page' => $request->get('page', 1)
- );
- $as = new FriendManager();
- $data = $as->getSendList($uid, $pages);
- return response([
- 'code' => 200,
- 'message' => 'success',
- 'data' => $data
- ]);
- }
- /**
- * 收到申请列表
- * @param Request $request
- * @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
- * @deprecated Friend/GetApplyReceiveList
- */
- public function getReceiveList(Request $request)
- {
- $uid = Auth::auth();
- $pages = array(
- 'limit' => 20,
- 'page' => $request->get('page', 1)
- );
- $as = new FriendManager();
- $data = $as->getReceiveList($uid, $pages);
- return response([
- 'code' => 200,
- 'message' => 'success',
- 'data' => $data
- ]);
- }
- /**
- * 发起好友申请
- * @param Request $request
- * @return array
- * @throws \App\Exceptions\AlertException
- */
- public function send(Request $request)
- {
- $uid = Auth::auth();
- $this->validate($request, [
- 'invite_uid' => 'required|integer', // 被申请用户
- 'question' => 'required' // 问答
- ]);
- $to_uid = $request->post('invite_uid');
- $question = $request->post('question', []);
- $as = new ApplyService();
- if ($as->send($uid, $to_uid, $question)) {
- return response(array(
- 'code' => 200,
- 'message' => 'success'
- ));
- } else {
- return response(array(
- 'code' => 401,
- 'message' => '发送失败'
- ));
- }
- }
- /**
- * 同意好友申请
- * @param int $apply_uid
- * @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
- * @throws \App\Exceptions\AlertException
- */
- public function agree(int $apply_uid)
- {
- $uid = Auth::auth();
- $as = new ApplyService();
- $as->agree($uid, $apply_uid);
- return response([
- 'code' => 200,
- 'message' => 'success'
- ]);
- }
- }
|