<?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 Illuminate\Http\Request;

class FriendController extends Controller
{
    public function getListCnt()
    {
        $uid = Auth::auth();

        $fs = new FriendManager();
        $data = $fs->getUnreadCount($uid);

        return array(
            'code' => 200,
            'message' => 'success',
            'data' => $data
        );
    }

    public function overview()
    {
        $uid = Auth::auth();

        $data = null;

        return array(
            'code' => 200,
            'message' => 'success',
            'data' => $data
        );
    }

    /**
     * 获取好友列表
     * @param  Request  $request
     * @return array
     */
    public function getAllList(Request $request)
    {
        $uid = Auth::auth();

        $pages = array(
            'limit' => 20,
            'page' => $request->get('page', 1)
        );

        $fs = new FriendManager();
        $data = $fs->getAllList($uid, $pages);

        return array(
            'code' => 200,
            'message' => 'success',
            'data' => $data
        );
    }

    /**
     * 获取相互喜欢好友列表
     * @param  Request  $request
     * @return array
     * @deprecated Friend/GetEachLikeList
     */
    public function getEachLikeList(Request $request)
    {
        $uid = Auth::auth();

        $pages = array(
            'limit' => 20,
            'page' => $request->get('page', 1)
        );

        $fs = new FriendManager();
        $data = $fs->getEachLikeList($uid, $pages);

        return array(
            'code' => 200,
            'message' => 'success',
            'data' => $data
        );
    }

    /**
     * @param  Request  $request
     * @return array
     * @deprecated Friend/GetStarList
     */
    public function getStarList(Request $request)
    {
        $uid = Auth::auth();

        $pages = array(
            'limit' => 20,
            'page' => $request->get('page', 1)
        );

        $fs = new FriendManager();
        $data = $fs->getStarList($uid, $pages);

        return array(
            'code' => 200,
            'message' => 'success',
            'data' => $data
        );
    }

    /**
     * 好友交互历史
     * @param  int  $friend_uid
     * @param  Request  $request
     * @return array
     * @deprecated Friend/GetChatHistory
     */
    public function getHistory(int $friend_uid, Request $request)
    {
        $uid = Auth::auth();

        $pages = array(
            'limit' => 1000,
            'page' => $request->get('page', 1)
        );

        $fs = new FriendManager();
        $data = $fs->getHistory($uid, $friend_uid, $pages);

        return array(
            'code' => 200,
            'message' => 'success',
            'data' => $data
        );
    }
}
