| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <?php
- // +----------------------------------------------------------------------
- // | EasyAdmin
- // +----------------------------------------------------------------------
- // | PHP交流群: 763822524
- // +----------------------------------------------------------------------
- // | 开源协议 https://mit-license.org
- // +----------------------------------------------------------------------
- // | github开源项目:https://github.com/zhongshaofa/EasyAdmin
- // +----------------------------------------------------------------------
- namespace app\common\service;
- use app\common\model\LevelSettingModel;
- use utils\RedisCache;
- /**
- * 用户等级配置服务 by wes
- * Class LevelSettingService
- * @package app\common\service
- */
- class LevelSettingService
- {
- protected static $instance = null;
- protected $model = null;
- public function __construct()
- {
- $this->model = new LevelSettingModel();
- }
- /**
- * 静态化入口
- * @return static|null
- */
- public static function make()
- {
- if(!self::$instance){
- self::$instance = new static();
- }
- return self::$instance;
- }
- /**
- * 按类型获取列表
- * @param $groupKey 分组
- * @return array|mixed
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function getListData($display=0)
- {
- $cacheKey = "caches:levels:list_{$display}";
- $data = RedisCache::get($cacheKey);
- if($data){
- return $data;
- }
- $where = [];
- if($display){
- $where['display'] = $display;
- }
- $data = $this->model->where($where)->select();
- $data = $data? $data->toArray():[];
- if($data){
- RedisCache::set($cacheKey, $data, rand(5,10));
- }
- return $data;
- }
- }
|