<?php

namespace App\Controller;

use App\Request\MessageNoticeRequest;
use App\Services\MessageNoticeService;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Psr\Http\Message\ResponseInterface;

/**
 * 通知消息
 * 不区分各端
 */
class MessageNoticeController extends AbstractController
{
    /**
     * 获取医生服务消息列表-分页
     * @return ResponseInterface
     */
    public function getDoctorMessageService(): ResponseInterface
    {
        $MessageNoticeService = new MessageNoticeService();
        $data = $MessageNoticeService->getDoctorMessageService();
        return $this->response->json($data);
    }

    /**
     * 获取医生系统公告列表-分页
     * @return ResponseInterface
     */
    public function getDoctorMessageSystem(): ResponseInterface
    {
        $MessageNoticeService = new MessageNoticeService();
        $data = $MessageNoticeService->getDoctorMessageSystem();
        return $this->response->json($data);
    }

    /**
     * 获取医生系统公告详情
     * @return ResponseInterface
     */
    public function getDoctorMessageSystemInfo(): ResponseInterface
    {
        $MessageNoticeService = new MessageNoticeService();
        $data = $MessageNoticeService->getDoctorMessageSystemInfo();
        return $this->response->json($data);
    }

    /**
     * 消息已读
     * @return ResponseInterface
     */
    public function putMessageReadId(): ResponseInterface
    {
        $MessageNoticeService = new MessageNoticeService();
        $data = $MessageNoticeService->putMessageReadId();
        return $this->response->json($data);
    }

    /**
     * 一键消息已读
     * @return ResponseInterface
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    public function putMessageRead(): ResponseInterface
    {
        $request = $this->container->get(MessageNoticeRequest::class);
        $request->scene('putMessageRead')->validateResolved();

        $MessageNoticeService = new MessageNoticeService();
        $data = $MessageNoticeService->putMessageRead();
        return $this->response->json($data);
    }

    /**
     * 获取患者系统消息通知最后一条消息列表
     * @return ResponseInterface
     */
    public function getPatientMessageServiceLast(): ResponseInterface
    {
        $MessageNoticeService = new MessageNoticeService();
        $data = $MessageNoticeService->getPatientMessageServiceLast();
        return $this->response->json($data);
    }

    /**
     * 获取患者服务、福利、退款、物流消息通知列表-分页
     * @return ResponseInterface
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    public function getPatientMessageSystem(): ResponseInterface
    {
        $request = $this->container->get(MessageNoticeRequest::class);
        $request->scene('getPatientMessageSystem')->validateResolved();

        $MessageNoticeService = new MessageNoticeService();
        $data = $MessageNoticeService->getPatientMessageSystem();
        return $this->response->json($data);
    }
}