request->post(); if (!empty($input['id'])) { $model = ListNav::findOne($input['id']); switch ($input['code']) { case 'del': if ($model->delete()) return ['code' => 200, 'msg' => '删除完成']; break; case 'state': $model->state = $input['val']; if ($model->save()) return ['code' => 200, 'msg' => '状态设置完成']; break; case 'sort': $model->sort = $input['val']; if ($model->save()) return ['code' => 200, 'msg' => '排序设置完成']; break; } return ['code' => 300, 'msg' => '执行失败']; } } //============================推动区域信息========================================================================== //推送给区域类型数据添加 public function addListCity() { $input = Yii::$app->request->post(); $data = []; if (isset($input['informationInfo']) && is_array($input['informationInfo'])) { $data['information'] = json_encode($input['informationInfo'], JSON_UNESCAPED_UNICODE); } if (empty($input['list_id'])) { return ['code' => 300, 'msg' => '数据错误']; } $data['list_id'] = $input['list_id']; if (ListNav::find()->where(['list_id' => $data['list_id'], 'city' => $input['city_id']])->exists()) { return ['code' => 300, 'msg' => '该区域已存在']; } $data['city'] = $input['city_id']; $model = new ListNav(); $model->load($data, ''); if ($model->validate() && $model->save()) { return ['code' => 200, 'msg' => '添加成功']; } else { return ['code' => 300, 'msg' => '添加失败']; } } //获取区域推送类型列表数据 public function getListCity() { $input = Yii::$app->request->post(); if (empty($input['list_id']) && !is_numeric($input['list_id'])) { return ['code' => 300, 'msg' => '信息错误']; } $model = new ListNav(); return $model->getListCity($input); } //============================推送资讯信息========================================================================== //获取资讯栏目列表 public function getNewsList() { $data = (new CategoryNews())->getList([], ['id', 'news_name']); return $data; } public function addListNews() { $input = Yii::$app->request->post(); $data = []; if (isset($input['informationInfo']) && is_array($input['informationInfo'])) { $data['information'] = json_encode($input['informationInfo'], JSON_UNESCAPED_UNICODE); } if (empty($input['list_id'])) { return ['code' => 300, 'msg' => '数据错误']; } $data['list_id'] = $input['list_id']; if (ListNav::find()->where(['list_id' => $data['list_id'], 'news' => $input['news']])->exists()) { return ['code' => 300, 'msg' => '该资讯已存在']; } $data['news'] = $input['news']; $model = new ListNav(); $model->load($data, ''); if ($model->validate() && $model->save()) { return ['code' => 200, 'msg' => '添加成功']; } else { return ['code' => 300, 'msg' => '添加失败']; } } public function getListNews() { $input = Yii::$app->request->post(); if (empty($input['list_id']) && !is_numeric($input['list_id'])) { return ['code' => 300, 'msg' => '信息错误']; } $model = new ListNav(); return $model->getListNews($input); } //==============================自定义推送导航类目信息==============================================================\ public function addListTitle() { $input = Yii::$app->request->post(); $data = []; if (isset($input['informationInfo']) && is_array($input['informationInfo'])) { $data['information'] = json_encode($input['informationInfo'], JSON_UNESCAPED_UNICODE); } if (empty($input['list_id'])) { return ['code' => 300, 'msg' => '数据错误']; } $data['list_id'] = $input['list_id']; if (ListNav::find()->where(['list_id' => $data['list_id'], 'title' => $input['title']])->exists()) { return ['code' => 300, 'msg' => '该资讯已存在']; } $data['title'] = $input['title']; $data['url'] = $input['url']; $model = new ListNav(); $model->load($data, ''); if ($model->validate() && $model->save()) { return ['code' => 200, 'msg' => '添加成功']; } else { return ['code' => 300, 'msg' => '添加失败']; } } public function getListTitle() { $input = Yii::$app->request->post(); if (empty($input['list_id']) && !is_numeric($input['list_id'])) { return ['code' => 300, 'msg' => '信息错误']; } $model = new ListNav(); return $model->getListTitle($input); } }