| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- /**
- * raingad IM [ThinkPHP6]
- * @author xiekunyu <raingad@foxmail.com>
- */
- namespace app\manage\model;
- use app\BaseModel;
- use think\facade\Cache;
- class Config extends BaseModel
- {
- protected $json = ['val'];
- protected $jsonAssoc = true;
-
- public static function autoTask(){
- $autoTask=Config::where(['field'=>'autoTask'])->value('val');
- if($autoTask){
- return $autoTask;
- }else{
- $autoTask=[
- 'group_id'=>0, //群聊ID
- 'group_num'=>1, //群聊序号
- 'user_id'=>0, //上一次的客服ID
- ];
- Config::create(['field'=>'autoTask','val'=>$autoTask]);
- return $autoTask;
- }
- }
- 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;
- }
- }
|