update
This commit is contained in:
@ -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();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user