<?php

namespace App\Rpc\v1;

use App\FormModel\rpc\v1\RpcIndexModel;
use App\Model\AppArticle;
use App\Rpc\BaseService;
use Hyperf\RpcServer\Annotation\RpcService;

// #[RpcService(name: "shows", server: "jsonrpc-http", protocol: "jsonrpc-http", publishTo: 'nacos')]
class ShowsService extends BaseService
{
    public function view($aid): array
    {
        $data = AppArticle::formatQuery(['images', 'title', 'cover', 'brand_name'])
            ->select(['brand', 'aid', 'title', 'cover', 'brand as brand_name', 'images', 'description'])
            ->where('aid', $aid)
            ->first()
            ->toArray();

        $data['more'] = AppArticle::formatQuery(['images', 'title', 'cover', 'brand_name'])
            ->where('brand', '=', $data['brand'])
            ->orderBy('published_at', 'DESC')
            ->limit(25);
        return $this->getResponse()->setPageModule($data)->send();
    }
}