*/ namespace app\manage\model; use app\BaseModel; use think\facade\Cache; class Config extends BaseModel { protected $json = ['val']; protected $jsonAssoc = true; public static function changeList($list) { foreach($list as &$item) { $item['name'] = $item['field']; $item['value'] = $item['val']; } return $list; } // 获取系统配置信息 public static function getSystemInfo($update=false){ $name='systemInfo'; // $auth=request()->header('Authorization'); $nameFields=['sysInfo','fileUpload','chatInfo','compass']; // 如果是登录状态才会返回chatINfo // if($auth){ // $name='all'.$name; // $nameFields[]="chatInfo"; // } if(Cache::has($name) && !$update){ $systemInfo=Cache::get($name); }else{ $systemInfo=[]; $conf=Config::where([['field','in',$nameFields]])->select()->toArray(); foreach($conf as $v){ $value=[]; if($v['field']=='fileUpload'){ $value['size'] = $v['val']['size']; $value['preview'] = $v['val']['preview']; $value['fileExt'] = $v['val']['fileExt']; }else{ $value=$v['val']; } $systemInfo[$v['field']]=$value; } Cache::set($name,$systemInfo,7*86400); } return $systemInfo; } }