LandTempService.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. namespace App\Module\Game\Services;
  3. use App\Module\Game\Dtos\LandChangeTempDto;
  4. use App\Module\Game\Dtos\LandStatusTempDto;
  5. use App\Module\Game\Logics\LandTemp;
  6. /**
  7. * 土地临时数据服务类
  8. *
  9. * 提供土地临时数据相关的服务方法,用于外部调用
  10. */
  11. class LandTempService
  12. {
  13. /**
  14. * 获取用户的土地变更临时数据
  15. *
  16. * @param int $userId 用户ID
  17. * @return array 用户的土地变更数据,键为土地ID,值为LandChangeTempDto对象
  18. */
  19. public static function getUserLandChanges(int $userId): array
  20. {
  21. return LandTemp::getUserLandChanges($userId);
  22. }
  23. /**
  24. * 获取用户特定土地的变更临时数据
  25. *
  26. * @param int $userId 用户ID
  27. * @param int $landId 土地ID
  28. * @return LandChangeTempDto|null 土地变更数据,不存在时返回null
  29. */
  30. public static function getUserLandChange(int $userId, int $landId): ?LandChangeTempDto
  31. {
  32. return LandTemp::getUserLandChange($userId, $landId);
  33. }
  34. /**
  35. * 获取用户的土地状态变更临时数据
  36. *
  37. * @param int $userId 用户ID
  38. * @return array 用户的土地状态变更数据,键为土地ID,值为LandStatusTempDto对象
  39. */
  40. public static function getUserLandStatusChanges(int $userId): array
  41. {
  42. return LandTemp::getUserLandStatusChanges($userId);
  43. }
  44. /**
  45. * 获取用户特定土地的状态变更临时数据
  46. *
  47. * @param int $userId 用户ID
  48. * @param int $landId 土地ID
  49. * @return LandStatusTempDto|null 土地状态变更数据,不存在时返回null
  50. */
  51. public static function getUserLandStatusChange(int $userId, int $landId): ?LandStatusTempDto
  52. {
  53. return LandTemp::getUserLandStatusChange($userId, $landId);
  54. }
  55. /**
  56. * 清除用户的土地变更临时数据
  57. *
  58. * @param int $userId 用户ID
  59. * @return void
  60. */
  61. public static function clearUserLandChanges(int $userId): void
  62. {
  63. LandTemp::clearUserLandChanges($userId);
  64. }
  65. /**
  66. * 清除用户的土地状态变更临时数据
  67. *
  68. * @param int $userId 用户ID
  69. * @return void
  70. */
  71. public static function clearUserLandStatusChanges(int $userId): void
  72. {
  73. LandTemp::clearUserLandStatusChanges($userId);
  74. }
  75. /**
  76. * 清除用户的所有土地临时数据
  77. *
  78. * @param int $userId 用户ID
  79. * @return void
  80. */
  81. public static function clearUserAllLandTemp(int $userId): void
  82. {
  83. LandTemp::clearUserAllLandTemp($userId);
  84. }
  85. }