renderSuccess('', compact('accessList')); } /** * 新增get数据 */ public function addInfo() { $menu = (new AccessModel())->getList(); return $this->renderSuccess('', compact('menu')); } /** * 添加到分类 */ public function add() { if($this->request->isGet()){ //查找所有插件 $accessList = ApplicationModel::getAllPlus(); return $this->renderSuccess('', compact('accessList')); } $model = new ApplicationModel; // 新增记录 if ($model->addApplication($this->postData())) { return $this->renderSuccess('添加成功'); } return $this->renderError('添加失败'); } /** * 添加类别 */ public function addcategory() { $data = $this->postData(); $model = new ModelApplication_category; if(isset($data['id'])){ $model = $model->detail($data['id']); // 编辑记录 if ($model->edit(['category_name'=>$data['category_name']])) { return $this->renderSuccess('编辑成功'); } }else{ // 新增记录 if ($model->add($data)) { return $this->renderSuccess('添加成功'); } } return $this->renderError('添加失败'); } /** * 添加应用 */ public function addapplication() { if($this->request->isGet()){ return $this->addInfo(); } $data = json_decode($this->postData()['params'], true); $model = new ApplicationModel; // 新增记录 if ($model->add($data)) { return $this->renderSuccess('添加成功'); } return $this->renderError('添加失败'); } /** * 编辑 */ public function edit($id) { if($this->request->isGet()){ return $this->editInfo($id); } $data = json_decode($this->postData()['params'], true); if (isset($data['access_id']) && count($data['access_id']) == 0) { return $this->renderError('请选择权限'); } $model = ApplicationModel::detail($data['id']); // 更新记录 if ($model->edit($data)) { return $this->renderSuccess('更新成功'); } return $this->renderError('更新失败'); } /** * 修改get数据 */ public function editInfo($id) { $menu = (new AccessModel())->getList(); $model = ApplicationModel::detail($id); $select_menu = array_column($model->toArray()['access'], 'access_id'); $model['access_id']=$select_menu; return $this->renderSuccess('', compact('model', 'menu', 'select_menu')); } /** * 删除 */ public function delete($id) { // 删除--软 $model = ApplicationModel::detail($id); if (!$model->setDelete()) { return $this->renderError('操作失败'); } return $this->renderSuccess('操作成功'); } /** * 删除---分类 */ public function del_category() { $data = $this->postData(); $model = ModelApplication_category::detail($data['id']); // 删除--软 if ($model->setDelete()) { return $this->renderSuccess('删除成功'); } return $this->renderError('删除失败'); } //清空应用分类 public function deleteplugs_category(){ $data = $this->postData(); $model = ApplicationModel::detail($data['id']); // 删除--软 if ($model->delete_category()) { return $this->renderSuccess('删除成功'); } return $this->renderError('删除失败'); } }