request = $request; $this->flowPoolService = $flowPoolService; } /** * RD流量池列表 * * @return void */ public function real() { $list = $this->flowPoolService->real(); return res($list, 'RD流量池列表', 201); } /** * 列表. * * @return \Illuminate\Http\Response */ public function index() { $conditions = $this->request->all(); $flowPools = $this->flowPoolService->index($conditions); return res($flowPools, '流量池列表', 201); } /** * 详情. * * @return \Illuminate\Http\Response */ public function show() { $conditions = $this->request->all(); $res = $this->flowPoolService->show($conditions); return res($res, '流量池详情', 201); } /** * 创建. * * @return \Illuminate\Http\Response */ public function create() { $attributes = $this->request->all(); $flowPool = $this->flowPoolService->store($attributes); return res($flowPool, '创建成功'); } /** * 编辑. * * @return \Illuminate\Http\Response */ public function update($id) { $attributes = $this->request->all(); $attributes['id'] = $id; $flowPool = $this->flowPoolService->store($attributes); return res($flowPool, '修改成功'); } /** * 删除. * * @return \Illuminate\Http\Response */ public function destroy() { $ids = $this->request->ids(); $this->flowPoolService->destroy($ids); return res(true, '删除成功'); } /** * 添加卡. * * @return \Illuminate\Http\Response */ public function addCards() { if (!$this->request->file('file')) { throw new InvalidArgumentException('上传的文件错误'); } $cards = (new FlowCardImport)->toArray($this->request->file('file')); if (empty($cards)) { throw new InvalidArgumentException('上传的文件错误'); } $sheet = $cards[0]; $simArray = []; foreach ($sheet as $row) { if (is_numeric($row[0])) { $simArray[] = $row[0]; } } $simArray = array_unique($simArray); if (empty($simArray)) { throw new InvalidArgumentException('流量卡张数为空'); } $pool_id = $this->request->get('pool_id', 0); $this->flowPoolService->addCards($pool_id, $simArray); return res(true, '添加成功'); } /** * 编辑. * * @return \Illuminate\Http\Response */ public function setting() { $attributes = $this->request->all(); $setting = $this->flowPoolService->setting($attributes); return res($setting, $attributes['id'] ? '修改成功' : '添加成功'); } }