SystemConfigService.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. *
  4. * @author: xaboy<365615158@qq.com>
  5. * @day: 2017/11/23
  6. */
  7. namespace crmeb\services;
  8. use app\admin\model\system\SystemConfig;
  9. /** 获取系统配置服务类
  10. * Class SystemConfigService
  11. * @package service
  12. */
  13. class SystemConfigService
  14. {
  15. protected static $configList = null;
  16. public static $ProtectedKey = [
  17. 'wechat_appid', 'wechat_appsecret', 'wechat_token', 'wechat_encodingaeskey', 'wechat_encode',
  18. 'pay_weixin_mchid', 'pay_weixin_client_cert', 'pay_weixin_client_key', 'pay_weixin_key', 'pay_weixin_open',
  19. 'routine_appId', 'routine_appsecret',
  20. 'pay_routine_mchid', 'pay_routine_key', 'pay_routine_client_cert', 'pay_routine_client_key', 'pay_weixin_open'
  21. ];
  22. /**获取系统配置
  23. * @param $key
  24. * @return mixed|null
  25. */
  26. public static function config($key)
  27. {
  28. if (self::$configList === null) self::$configList = self::getAll();
  29. return isset(self::$configList[$key]) ? self::$configList[$key] : null;
  30. }
  31. /**获取单个配置效率更高
  32. * @param $key
  33. * @return bool|mixed
  34. */
  35. public static function get($key)
  36. {
  37. return SystemConfig::getConfigValue($key);
  38. }
  39. /** 获取多个配置
  40. * @param $keys ',' 隔开
  41. * @return array
  42. */
  43. public static function more($keys)
  44. {
  45. return SystemConfig::getMore($keys);
  46. }
  47. /**获取全部配置
  48. * @return array
  49. */
  50. public static function getAll()
  51. {
  52. return SystemConfig::getAllConfig() ?: [];
  53. }
  54. }