功能更新

This commit is contained in:
2020-03-30 21:16:28 +08:00
parent b16e4ab920
commit f31f3b99fa
23 changed files with 464 additions and 230 deletions

View File

@@ -40,19 +40,17 @@ class Seo extends Base {
public function add() {
if ($this->request->isPost()) {
$data = $this->request->post();
$result = $this->seo->save($data);
$result = SeoRule::create($data);
if ($result) {
return $this->success("添加成功!");
} else {
return $this->error("添加失败!");
}
} else {
$data = array(
'keyList' => $this->seo->keyList,
$this->data = array(
'keyList' => SeoRule::$keyList,
);
$this->assign($data);
$this->setMeta("添加规则");
return $this->fetch('public/edit');
return $this->fetch('admin/public/edit');
}
}
@@ -62,22 +60,24 @@ class Seo extends Base {
public function edit($id = null) {
if ($this->request->isPost()) {
$data = $this->request->post();
$result = $this->seo->save($data, array('id' => $data['id']));
$result = SeoRule::update($data, array('id' => $data['id']));
if (false !== $result) {
return $this->success("修改成功!");
} else {
return $this->error("修改失败!");
}
} else {
$id = input('id', '', 'trim,intval');
$info = $this->seo->where(array('id' => $id))->find();
$data = array(
$id = $this->request->param('id', 0);
if (!$id) {
return $this->error("非法操作!");
}
$info = SeoRule::find($id);
$this->data = array(
'info' => $info,
'keyList' => $this->seo->keyList,
'keyList' => SeoRule::$keyList,
);
$this->assign($data);
$this->setMeta("编辑规则");
return $this->fetch('public/edit');
return $this->fetch('admin/public/edit');
}
}
@@ -85,11 +85,20 @@ class Seo extends Base {
* @title 删除SEO
*/
public function del() {
$id = $this->getArrayParam('id');
$id = $this->request->param('id');
if (empty($id)) {
return $this->error("非法操作!");
}
$result = $this->seo->where(array('id' => array('IN', $id)))->delete();
if (is_array($id)) {
$map[] = ['id', 'IN', $id];
}else{
$map[] = ['id', '=', $id];
}
$result = SeoRule::where($map)->delete();
if ($result) {
return $this->success("删除成功!");
} else {
@@ -117,19 +126,19 @@ class Seo extends Base {
*/
public function addrewrite() {
if ($this->request->isPost()) {
$result = model('Rewrite')->change();
$data = $this->request->param();
$result = Rewrite::create($data);
if (false != $result) {
return $this->success("添加成功!", url('admin/seo/rewrite'));
return $this->success("添加成功!", url('/admin/seo/rewrite'));
} else {
return $this->error(model('Rewrite')->getError());
return $this->error('添加失败!');
}
} else {
$data = array(
'keyList' => $this->rewrite->keyList,
$this->data = array(
'keyList' => Rewrite::$keyList,
);
$this->assign($data);
$this->setMeta("添加路由规则");
return $this->fetch('public/edit');
return $this->fetch('admin/public/edit');
}
}
@@ -138,22 +147,22 @@ class Seo extends Base {
*/
public function editrewrite() {
if ($this->request->isPost()) {
$result = model('Rewrite')->change();
$data = $this->request->param();
$result = Rewrite::update($data, ['id' => $data['id']]);
if (false != $result) {
return $this->success("更新成功!", url('admin/seo/rewrite'));
return $this->success("更新成功!", url('/admin/seo/rewrite'));
} else {
return $this->error(model('Rewrite')->getError());
return $this->error('更新失败!');
}
} else {
$id = input('id', '', 'trim,intval');
$info = db('Rewrite')->where(array('id' => $id))->find();
$data = array(
$id = $this->request->param('id');
$info = Rewrite::find($id);
$this->data = array(
'info' => $info,
'keyList' => $this->rewrite->keyList,
'keyList' => Rewrite::$keyList,
);
$this->assign($data);
$this->setMeta("编辑路由规则");
return $this->fetch('public/edit');
return $this->fetch('admin/public/edit');
}
}
@@ -161,11 +170,20 @@ class Seo extends Base {
* @title 删除静态规则
*/
public function delrewrite() {
$id = $this->getArrayParam('id');
$id = $this->request->param('id');
if (empty($id)) {
return $this->error("非法操作!");
}
$result = db('Rewrite')->where(array('id' => array('IN', $id)))->delete();
if (is_array($id)) {
$map[] = ['id', 'IN', $id];
}else{
$map[] = ['id', '=', $id];
}
$result = Rewrite::where($map)->delete();
if ($result) {
return $this->success("删除成功!");
} else {