<?php
/*
 本代码由 口号帮 创建
 创建时间 2019-05-06 16:50:44
 技术支持 口号帮
 严禁反编译、逆向等任何形式的侵权行为，违者将追究法律责任
*/

namespace App\Http\Controllers\Api\V1;use App\Http\Controllers\BaseController;use Illuminate\Http\Request;use Illuminate\Support\Facades\Redis;use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;class WhiteListController extends BaseController{public function setWhite(Request $request){$phone=$request->phones;$channel=$request->channels;$type=$request->type;$O280=(bool)empty($phone);if($O280)goto O28Bodyx5;goto O28Nextx5;O28Bodyx5:$O280=(bool)empty($channel);goto O28x4;O28Nextx5:O28x4:$O281=(bool)$O280;if($O281)goto O28Bodyx3;goto O28Nextx3;O28Bodyx3:$O281=(bool)empty($type);goto O28x2;O28Nextx3:O28x2:if($O281)goto O28Bodyx6;goto O28Nextx6;O28Bodyx6:$this->set('type',$this->badRequest);$this->set('info','请传入请求参数:phones/channels/type');goto O28x1;O28Nextx6:$O280=!empty($phone);if($O280)goto O28Bodyx8;goto O28Nextx8;O28Bodyx8:$redis_key='phone_white_list';$redis_value=$phone;$info='电话';goto O28x7;O28Nextx8:$redis_key='channel_white_list';$redis_value=$channel;$info='渠道';O28x7:$redis_value_arr=array_unique(explode(',',$redis_value));$exists=json_decode(Redis::get($redis_key),true);if(Redis::exists($redis_key))goto O28Bodyxa;goto O28Nextxa;O28Bodyxa:$O280=$type=='set';if($O280)goto O28Bodyxc;goto O28Nextxc;O28Bodyxc:foreach($redis_value_arr as $k=>$item){$A_A___A_A="in_array";$O28AC0=$A_A___A_A($item,$exists);if($O28AC0)goto O28Bodyxe;goto O28Nextxe;O28Bodyxe:unset($redis_value_arr[$k]);goto O28xd;O28Nextxe:O28xd:}foreach($redis_value_arr as $item){array_push($exists,$item);Redis::set($redis_key,json_encode($exists));}$this->set('info',"插入".$info."白名单成功");$this->set('data',json_decode(Redis::get($redis_key)));goto O28xb;O28Nextxc:$O280=$type=='reduce';if($O280)goto O28Bodyxf;goto O28Nextxf;O28Bodyxf:foreach($redis_value_arr as $value){$A_A___AA_="in_array";$O28AC0=$A_A___AA_($value,$exists);if($O28AC0)goto O28Bodyxh;goto O28Nextxh;O28Bodyxh:foreach($exists as $k=>$exist){$O280=$exists[$k]==$value;if($O280)goto O28Bodyxj;goto O28Nextxj;O28Bodyxj:unset($exists[$k]);Redis::set($redis_key,json_encode(explode(',',implode(',',$exists))));goto O28xi;O28Nextxj:O28xi:}goto O28xg;O28Nextxh:$O280=new BadRequestHttpException($info."不存在于白名单中");throw $O280;O28xg:}$this->set('info',"减少".$info."白名单成功");$this->set('data',json_decode(Redis::get($redis_key)));goto O28xb;O28Nextxf:$O280=$type=='del';if($O280)goto O28Bodyxk;goto O28Nextxk;O28Bodyxk:Redis::del($redis_key);$this->set('info',"清空".$info."白名单成功");$this->set('data',json_decode(Redis::get($redis_key)));goto O28xb;O28Nextxk:$redis_values=json_decode(Redis::get($redis_key));foreach($redis_value_arr as $v){$A_A___AAA="in_array";$O28AC0=$A_A___AAA($v,$redis_values);$O280=!$O28AC0;if($O280)goto O28Bodyxm;goto O28Nextxm;O28Bodyxm:$this->set('info',$v."不存在".$info."白名单中");$this->set('data',json_decode(Redis::get($redis_key)));goto O28xl;O28Nextxm:$this->set('info',$v."存在".$info."白名单中");$this->set('data',json_decode(Redis::get($redis_key)));O28xl:}O28xb:goto O28x9;O28Nextxa:$O280=$type!='set';if($O280)goto O28Bodyxo;goto O28Nextxo;O28Bodyxo:$this->set('info',"redis键不存在,请先添加");goto O28xn;O28Nextxo:Redis::set($redis_key,json_encode($redis_value_arr));$this->set('info',"添加成功");$this->set('data',json_decode(Redis::get($redis_key)));O28xn:O28x9:O28x1:return $this->jsonResponse();}}
?>