| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <?php
- namespace App\Module\Game\Services;
- use App\Module\Game\Dtos\GodChangeTempDto;
- use App\Module\Game\Logics\GodTemp;
- use Illuminate\Support\Facades\Log;
- /**
- * 神像临时数据服务类
- *
- * 提供神像临时数据相关的服务方法,用于外部调用
- */
- class GodTempService
- {
- /**
- * 获取用户的神像变更临时数据
- *
- * @param int $userId 用户ID
- * @return GodChangeTempDto[] 用户的神像变更数据
- */
- public static function getUserGodChanges(int $userId): array
- {
- try {
- return GodTemp::getUserGodChanges($userId);
- } catch (\Exception $e) {
- Log::error('获取用户神像变更临时数据失败', [
- 'error' => $e->getMessage(),
- 'user_id' => $userId,
- ]);
- return [];
- }
- }
- /**
- * 获取用户特定神像类型的变更临时数据
- *
- * @param int $userId 用户ID
- * @param int $godType 神像类型
- * @return GodChangeTempDto|null 神像变更数据,不存在时返回null
- */
- public static function getUserGodChange(int $userId, int $godType): ?GodChangeTempDto
- {
- try {
- return GodTemp::getUserGodChange($userId, $godType);
- } catch (\Exception $e) {
- Log::error('获取用户特定神像变更临时数据失败', [
- 'error' => $e->getMessage(),
- 'user_id' => $userId,
- 'god_type' => $godType,
- ]);
- return null;
- }
- }
- /**
- * 清除用户的神像变更临时数据
- *
- * @param int $userId 用户ID
- * @return void
- */
- public static function clearUserGodChanges(int $userId): void
- {
- try {
- GodTemp::clearUserGodChanges($userId);
- } catch (\Exception $e) {
- Log::error('清除用户神像变更临时数据失败', [
- 'error' => $e->getMessage(),
- 'user_id' => $userId,
- ]);
- }
- }
- /**
- * 清除用户特定神像类型的变更临时数据
- *
- * @param int $userId 用户ID
- * @param int $godType 神像类型
- * @return void
- */
- public static function clearUserGodChange(int $userId, int $godType): void
- {
- try {
- GodTemp::clearUserGodChange($userId, $godType);
- } catch (\Exception $e) {
- Log::error('清除用户特定神像变更临时数据失败', [
- 'error' => $e->getMessage(),
- 'user_id' => $userId,
- 'god_type' => $godType,
- ]);
- }
- }
- }
|