<?php

namespace App\Rpc\v1;

use App\Model\AppNews;
use App\Model\AppWebsiteConfig;
use App\Rpc\BaseService;
use Hyperf\RpcServer\Annotation\RpcService;

#[RpcService(name: "website", server: "jsonrpc-http", protocol: "jsonrpc-http")]
class WebsiteService extends BaseService
{
    /**
     * 查看单个新闻详情
     * @url /news/view
     * @param $id
     * @return array
     */
    public function config($host): array
    {
        $query = AppWebsiteConfig::query()->where('app_domain', 'like' , "%$host%")->where('is_delete', 0)->first()?->toArray();

        if (!$query) {
            return $this->getResponse()->setCode(404)->send();
        }

        return $this->getResponse()->setData($query)->setCode(0)->send();
    }
}