<?php

namespace App\Http\Services\V1;

use App\Generated\V1\Messages\UserNotice\SysnoticeListMessage;
use App\Generated\V1\Messages\UserNotice\SysnoticeDescMessage;
use App\Http\Controllers\Controller;
use App\Http\Controllers\Core\Auth;
use App\Managers\UserNoticeManager;
use App\Models\QQ\FormIdModel;
use App\Models\User\AuthKey;
use App\Models\User\Openid;
use App\Services\User\NoticeService;
use App\Services\Vendor\GeTui\ApiService;
use Illuminate\Http\Request;

class UserNoticeService
{
    protected $userNoticeManager;

    public function __construct(UserNoticeManager $userNoticeManager)
    {
        $this->userNoticeManager = $userNoticeManager;
    }

    public function sysnoticeList(SysnoticeListMessage $message)
    {
        $page = $message->getPage() ?: 1;
        $unread = $message->getUnread() ?: 0;

        $uid = Auth::auth();
        $pages = array(
            'page' => $page,
            'limit' => 20
        );


        $data = $this->userNoticeManager->systemList($uid, $pages, $unread);

        if ($pages['page'] == 1) {
            $likemeOverView = $this->userNoticeManager->likeMeOverView($uid);
            $inviteOverView = $this->userNoticeManager->inviteOverView($uid);
        }


        $message->setResponse([
            'likeme_overview' => $likemeOverView ?? null,
            'invite_overview' => $inviteOverView ?? null,
            'system' => $data
        ]);
    }

    public function sysnoticeDesc(SysnoticeDescMessage $message)
    {
        $uid = Auth::auth();

        $data = $this->userNoticeManager->systemListDesc($uid);

        $message->setResponse($data);
    }
}
