$e->getMessage(), 'user_id' => $userId, ]); return []; } } /** * 获取用户特定宠物的创建临时数据 * * @param int $userId 用户ID * @param int $petId 宠物ID * @return PetStatusTempDto|null 宠物创建数据,不存在时返回null */ public function getUserPetCreatedById(int $userId, int $petId): ?PetStatusTempDto { try { return PetTemp::getUserPetCreatedById($userId, $petId); } catch (\Exception $e) { Log::error('获取用户特定宠物创建临时数据失败', [ 'error' => $e->getMessage(), 'user_id' => $userId, 'pet_id' => $petId, ]); return null; } } /** * 获取用户的宠物状态变更临时数据 * * @param int $userId 用户ID * @return PetDataSimpleTempDto[] 用户的宠物状态变更数据 */ public function getUserPetStatus(int $userId): array { try { return PetTemp::getUserPetStatus($userId); } catch (\Exception $e) { Log::error('获取用户宠物状态变更临时数据失败', [ 'error' => $e->getMessage(), 'user_id' => $userId, ]); return []; } } /** * 获取用户特定宠物的状态变更临时数据 * * @param int $userId 用户ID * @param int $petId 宠物ID * @return PetDataSimpleTempDto|null 宠物状态变更数据,不存在时返回null */ public function getUserPetStatusById(int $userId, int $petId): ?PetDataSimpleTempDto { try { return PetTemp::getUserPetStatusById($userId, $petId); } catch (\Exception $e) { Log::error('获取用户特定宠物状态变更临时数据失败', [ 'error' => $e->getMessage(), 'user_id' => $userId, 'pet_id' => $petId, ]); return null; } } /** * 获取用户的宠物更新临时数据 * * @param int $userId 用户ID * @return PetStatusTempDto[] 用户的宠物更新数据 */ public function getUserPetUpdates(int $userId): array { try { return PetTemp::getUserPetUpdates($userId); } catch (\Exception $e) { Log::error('获取用户宠物更新临时数据失败', [ 'error' => $e->getMessage(), 'user_id' => $userId, ]); return []; } } /** * 获取用户特定宠物的更新临时数据 * * @param int $userId 用户ID * @param int $petId 宠物ID * @return PetStatusTempDto|null 宠物更新数据,不存在时返回null */ public function getUserPetUpdateById(int $userId, int $petId): ?PetStatusTempDto { try { return PetTemp::getUserPetUpdateById($userId, $petId); } catch (\Exception $e) { Log::error('获取用户特定宠物更新临时数据失败', [ 'error' => $e->getMessage(), 'user_id' => $userId, 'pet_id' => $petId, ]); return null; } } /** * 清除用户的宠物创建临时数据 * * @param int $userId 用户ID * @return bool 操作是否成功 */ public function clearUserPetCreated(int $userId): bool { try { PetTemp::clearUserPetCreated($userId); return true; } catch (\Exception $e) { Log::error('清除用户宠物创建临时数据失败', [ 'error' => $e->getMessage(), 'user_id' => $userId, ]); return false; } } /** * 清除用户的宠物状态变更临时数据 * * @param int $userId 用户ID * @return bool 操作是否成功 */ public function clearUserPetStatus(int $userId): bool { try { PetTemp::clearUserPetStatus($userId); return true; } catch (\Exception $e) { Log::error('清除用户宠物状态变更临时数据失败', [ 'error' => $e->getMessage(), 'user_id' => $userId, ]); return false; } } /** * 清除用户的所有宠物临时数据 * * @param int $userId 用户ID * @return bool 操作是否成功 */ public function clearUserAllPetTemp(int $userId): bool { try { PetTemp::clearUserAllPetTemp($userId); return true; } catch (\Exception $e) { Log::error('清除用户所有宠物临时数据失败', [ 'error' => $e->getMessage(), 'user_id' => $userId, ]); return false; } } }