1234567891011121314151617181920212223242526272829303132333435 |
- <?php
- namespace App\JsonRpc;
- use App\Model\Ad;
- use App\Tools\Result;
- use Hyperf\RpcServer\Annotation\RpcService;
- #[RpcService(name: "OrderService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
- class OrderService implements OrderServiceInterface
- {
- /**
- * @param array $data
- * @return array
- */
- public function getAD(array $data): array
- {
- $where = [];
- $id = $data['id'];
- if ($id) {
- $where[] = ['id', '=', $id];
- }
- $rep = AD::where($where)->limit(10)->orderBy("id", "asc")->get();
- $count = AD::where($where)->count();
- $data = [
- 'rows' => $rep->toArray(),
- 'count' => $count,
- ];
- if (empty($rep->toArray())) {
- return Result::error("没有广告数据");
- }
- return Result::success($data);
- }
- }
|