OrderService.php 859 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace App\JsonRpc;
  3. use App\Model\Ad;
  4. use App\Tools\Result;
  5. use Hyperf\RpcServer\Annotation\RpcService;
  6. #[RpcService(name: "OrderService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
  7. class OrderService implements OrderServiceInterface
  8. {
  9. /**
  10. * @param array $data
  11. * @return array
  12. */
  13. public function getAD(array $data): array
  14. {
  15. $where = [];
  16. $id = $data['id'];
  17. if ($id) {
  18. $where[] = ['id', '=', $id];
  19. }
  20. $rep = AD::where($where)->limit(10)->orderBy("id", "asc")->get();
  21. $count = AD::where($where)->count();
  22. $data = [
  23. 'rows' => $rep->toArray(),
  24. 'count' => $count,
  25. ];
  26. if (empty($rep->toArray())) {
  27. return Result::error("没有广告数据");
  28. }
  29. return Result::success($data);
  30. }
  31. }