ClientService.php 1016 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace App\JsonRpc;
  3. use Hyperf\RpcServer\Annotation\RpcService;
  4. use App\Tools\Result;
  5. use Hyperf\DbConnection\Db;
  6. #[RpcService(name: "ClientService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
  7. class ClientService implements ClientServiceInterface
  8. {
  9. /**
  10. * @param array $data
  11. * @return array
  12. */
  13. public function test(array $data): array
  14. {
  15. var_dump($data, '---------------');
  16. $time = date('Y-m-d H:i:s', time());
  17. $data = [
  18. 'code' => 200,
  19. 'msg' => 'success',
  20. 'data' => [
  21. 'time' => $time,
  22. 'data' => $data,
  23. ]
  24. ];
  25. //mysql直接查询连接数
  26. $activeConnections = Db::select("SHOW STATUS LIKE 'Threads_connected'");
  27. // $activeConnectionsCount = $activeConnections[0]->Value ?? 0;
  28. $users = Db::select('SELECT * FROM article;');
  29. return ['code' => 200, 'msg' => 'success', 'data' => $activeConnections];
  30. }
  31. //test git
  32. }