SystemConfigLogic.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | saiadmin [ saiadmin快速开发框架 ]
  4. // +----------------------------------------------------------------------
  5. // | Author: sai <1430792918@qq.com>
  6. // +----------------------------------------------------------------------
  7. namespace plugin\saiadmin\app\logic\system;
  8. use plugin\saiadmin\basic\BaseLogic;
  9. use plugin\saiadmin\exception\ApiException;
  10. use plugin\saiadmin\app\model\system\SystemConfig;
  11. use plugin\saiadmin\app\model\system\SystemConfigGroup;
  12. use support\Cache;
  13. use plugin\saiadmin\utils\Helper;
  14. /**
  15. * 参数配置逻辑层
  16. */
  17. class SystemConfigLogic extends BaseLogic
  18. {
  19. /**
  20. * 构造函数
  21. */
  22. public function __construct()
  23. {
  24. $this->model = new SystemConfig();
  25. }
  26. /**
  27. * 获取配置组
  28. */
  29. public function getGroup($config)
  30. {
  31. $prefix = 'cfg_';
  32. $data = Cache::get($prefix . $config);
  33. if (!is_null($data)) {
  34. return $data;
  35. }
  36. $group = SystemConfigGroup::where('code', $config)->findOrEmpty();
  37. if ($group->isEmpty()) {
  38. throw new ApiException('配置组不存在');
  39. }
  40. $info = $this->model->where('group_id', $group->id)->select();
  41. Cache::set($prefix . $config, $info->toArray());
  42. return $info;
  43. }
  44. }