后台内容模块功能完善
This commit is contained in:
@@ -36,27 +36,23 @@ class Link extends Base {
|
||||
* @title 添加链接
|
||||
*/
|
||||
public function add() {
|
||||
$link = model('Link');
|
||||
if ($this->request->isPost()) {
|
||||
$data = input('post.');
|
||||
$data = $this->request->post();
|
||||
if ($data) {
|
||||
unset($data['id']);
|
||||
$result = $link->save($data);
|
||||
$result = LinkM::create($data);
|
||||
if ($result) {
|
||||
return $this->success("添加成功!", url('Link/index'));
|
||||
return $this->success("添加成功!", url('/admin/link/index'));
|
||||
} else {
|
||||
return $this->error($link->getError());
|
||||
return $this->error('添加失败!');
|
||||
}
|
||||
} else {
|
||||
return $this->error($link->getError());
|
||||
return $this->error('未提交数据');
|
||||
}
|
||||
} else {
|
||||
$data = array(
|
||||
'keyList' => $link->keyList,
|
||||
$this->data = array(
|
||||
'keyList' => LinkM::$keyList,
|
||||
);
|
||||
$this->assign($data);
|
||||
$this->setMeta("添加友链");
|
||||
return $this->fetch('public/edit');
|
||||
return $this->fetch('admin/public/edit');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,31 +60,27 @@ class Link extends Base {
|
||||
* @title 修改链接
|
||||
*/
|
||||
public function edit() {
|
||||
$link = model('Link');
|
||||
$id = input('id', '', 'trim,intval');
|
||||
$id = $this->request->param('id');
|
||||
if ($this->request->isPost()) {
|
||||
$data = input('post.');
|
||||
$data = $this->request->post();
|
||||
if ($data) {
|
||||
$result = $link->save($data, array('id' => $data['id']));
|
||||
if ($result) {
|
||||
return $this->success("修改成功!", url('Link/index'));
|
||||
$result = LinkM::update($data, array('id' => $data['id']));
|
||||
if (false !== $result) {
|
||||
return $this->success("修改成功!", url('/admin/link/index'));
|
||||
} else {
|
||||
return $this->error("修改失败!");
|
||||
}
|
||||
} else {
|
||||
return $this->error($link->getError());
|
||||
return $this->error('未提交数据');
|
||||
}
|
||||
} else {
|
||||
$map = array('id' => $id);
|
||||
$info = db('Link')->where($map)->find();
|
||||
$info = LinkM::find($id);
|
||||
|
||||
$data = array(
|
||||
'keyList' => $link->keyList,
|
||||
$this->data = array(
|
||||
'keyList' => LinkM::$keyList,
|
||||
'info' => $info,
|
||||
);
|
||||
$this->assign($data);
|
||||
$this->setMeta("编辑友链");
|
||||
return $this->fetch('public/edit');
|
||||
return $this->fetch('admin/public/edit');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,18 +88,23 @@ class Link extends Base {
|
||||
* @title 删除链接
|
||||
*/
|
||||
public function delete() {
|
||||
$id = $this->getArrayParam('id');
|
||||
if (empty($id)) {
|
||||
return $this->error('非法操作!');
|
||||
}
|
||||
$link = db('Link');
|
||||
$id = $this->request->param('id', '');
|
||||
|
||||
$map = array('id' => array('IN', $id));
|
||||
$result = $link->where($map)->delete();
|
||||
if ($result) {
|
||||
return $this->success("删除成功!");
|
||||
$map = [];
|
||||
if (!$id) {
|
||||
return $this->error('请选择要操作的数据!');
|
||||
}
|
||||
if (is_array($id)) {
|
||||
$map[] = ['id', 'IN', $id];
|
||||
}else{
|
||||
$map[] = ['id', '=', $id];
|
||||
}
|
||||
|
||||
$result = LinkM::where($map)->delete();
|
||||
if (false !== $result) {
|
||||
return $this->success('删除成功');
|
||||
} else {
|
||||
return $this->error("删除失败!");
|
||||
return $this->error('删除失败!');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user