UserService.php 759 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace App\Module\AppGame;
  3. use App\Module\AppGame\SessionApp;
  4. class UserService
  5. {
  6. public function getToken()
  7. {
  8. return SessionApp::$session_id;
  9. }
  10. public function __construct(protected int $user_id)
  11. {
  12. }
  13. /**
  14. * @return static
  15. */
  16. static public function newBySession()
  17. {
  18. return new static(SessionApp::getUserId());
  19. }
  20. /**
  21. * 传入数据处理
  22. * @param $data
  23. * @return array|int[]
  24. */
  25. public function callData($data)
  26. {
  27. $page = $data['page'] ?? 1;
  28. $limit = $data['limit'] ?? 10;
  29. unset($data['page']);
  30. unset($data['limit']);
  31. $where = $data;
  32. return [
  33. $page, $limit, $where,
  34. ];
  35. }
  36. }