ProfileService.php 697 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace App\Services\App;
  3. use App\Exceptions\ApiException;
  4. use App\Services\Service;
  5. use Exception;
  6. use Illuminate\Support\Facades\Redis;
  7. /**
  8. * Class ProfileService
  9. * @package App\Services\App
  10. */
  11. class ProfileService extends Service
  12. {
  13. /**
  14. * 获取配置
  15. * @param string $key
  16. * @return string
  17. * @throws ApiException
  18. */
  19. public function get(string $key)
  20. {
  21. try {
  22. $public_id = config('miniprogram.public_id');
  23. $profile = Redis::hget("app:config:{$public_id}", $key);
  24. return $profile;
  25. } catch (Exception $e) {
  26. throw new ApiException($e->getMessage(), $e->getCode());
  27. }
  28. }
  29. }