This commit is contained in:
toom1996
2025-07-30 18:53:12 +08:00
parent 7299dcb272
commit c8ca10660d
3 changed files with 26 additions and 30 deletions

View File

@ -6,6 +6,7 @@ use App\Model\AppNews;
use App\Model\AppNewsColumn;
use App\Model\AppNewsSecondColumn;
use App\Rpc\BaseService;
use Hyperf\DbConnection\Db;
use Hyperf\RpcServer\Annotation\RpcService;
#[RpcService(name: "news", server: "jsonrpc-http", protocol: "jsonrpc-http")]
@ -113,14 +114,25 @@ class NewsService extends BaseService
}
}
// 热门文章
$hot = AppNews::formatQuery(['created_at'])
->where('platform', $id)
->where('is_delete', 0)
->select(['title', 'id', 'cover', 'created_at'])
->limit(5)
->orderBy('id', 'desc')
->orderBy(Db::raw('RAND()'))
->get()
->toArray();
return $this->getResponse()->setExtra('hot', $hot)->setExtra('total', ceil($total / $limit))->setData($value)->setCode(0)->send();
// 猜你喜欢
$guess = AppNews::formatQuery(['created_at'])
->where('platform', $id)
->where('is_delete', 0)
->select(['title', 'id', 'cover', 'created_at'])
->limit(10)
->orderBy(Db::raw('RAND()'))
->get()
->toArray();
return $this->getResponse()->setExtra('guess', $guess)->setExtra('hot', $hot)->setExtra('total', ceil($total / $limit))->setData($value)->setCode(0)->send();
}
}