后台内容模块功能完善
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
namespace app\controller\admin;
|
||||
|
||||
use app\model\AdPlace;
|
||||
use app\model\Ad as AdModel;
|
||||
|
||||
/**
|
||||
* @title 广告管理
|
||||
@@ -36,26 +37,19 @@ class Ad extends Base {
|
||||
* @title 广告位添加
|
||||
*/
|
||||
public function add() {
|
||||
$place = model('AdPlace');
|
||||
if ($this->request->isPost()) {
|
||||
$result = $place->change();
|
||||
if (!empty($_POST['name'])) {
|
||||
$result = $place->change();
|
||||
if ($result) {
|
||||
return $this->success("添加成功!");
|
||||
} else {
|
||||
return $this->error($place->getError());
|
||||
}
|
||||
$data = $this->request->post();
|
||||
$result = AdPlace::create($data);
|
||||
if (false !== $result) {
|
||||
return $this->success("添加成功!");
|
||||
} else {
|
||||
return $this->error("标识不能为空!");
|
||||
return $this->error('添加失败!');
|
||||
}
|
||||
} else {
|
||||
$data = array(
|
||||
'keyList' => $place->keyList,
|
||||
$this->data = array(
|
||||
'keyList' => AdPlace::$keyList,
|
||||
);
|
||||
$this->assign($data);
|
||||
$this->setMeta("添加广告位");
|
||||
return $this->fetch('public/edit');
|
||||
return $this->fetch('admin/public/edit');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,26 +57,24 @@ class Ad extends Base {
|
||||
* @title 广告位编辑
|
||||
*/
|
||||
public function edit($id = null) {
|
||||
$place = model('AdPlace');
|
||||
if ($this->request->isPost()) {
|
||||
$result = $place->change();
|
||||
$data = $this->request->post();
|
||||
$result = AdPlace::update($data, ['id' => $data['id']]);
|
||||
if ($result) {
|
||||
return $this->success("修改成功!", url('admin/ad/index'));
|
||||
return $this->success("修改成功!", url('/admin/ad/index'));
|
||||
} else {
|
||||
return $this->error($this->adplace->getError());
|
||||
return $this->error('修改失败!');
|
||||
}
|
||||
} else {
|
||||
$info = db('AdPlace')->where(array('id' => $id))->find();
|
||||
$info = AdPlace::find($id);
|
||||
if (!$info) {
|
||||
return $this->error("非法操作!");
|
||||
}
|
||||
$data = array(
|
||||
$this->data = array(
|
||||
'info' => $info,
|
||||
'keyList' => $place->keyList,
|
||||
'keyList' => AdPlace::$keyList,
|
||||
);
|
||||
$this->assign($data);
|
||||
$this->setMeta("编辑广告位");
|
||||
return $this->fetch('public/edit');
|
||||
return $this->fetch('admin/public/edit');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,19 +100,15 @@ class Ad extends Base {
|
||||
* @title 广告列表
|
||||
*/
|
||||
public function lists($id = null) {
|
||||
$map['place_id'] = $id;
|
||||
$map[] = ['place_id', '=', $id];
|
||||
$order = "id desc";
|
||||
|
||||
$list = db('Ad')->where($map)->order($order)->paginate(10, false, array(
|
||||
'query' => $this->request->param(),
|
||||
));
|
||||
$data = array(
|
||||
$list = AdModel::where($map)->order($order)->paginate($this->request->pageConfig);
|
||||
$this->data = array(
|
||||
'id' => $id,
|
||||
'list' => $list,
|
||||
'page' => $list->render(),
|
||||
);
|
||||
$this->assign($data);
|
||||
$this->setMeta("广告管理");
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
@@ -128,23 +116,22 @@ class Ad extends Base {
|
||||
* @title 添加广告
|
||||
*/
|
||||
public function addad($id) {
|
||||
$ad = model('ad');
|
||||
if ($this->request->isPost()) {
|
||||
$result = $ad->change();
|
||||
$data = $this->request->post();
|
||||
|
||||
$result = AdModel::create($data);
|
||||
if ($result) {
|
||||
return $this->success("添加成功!", url('admin/ad/lists', array('id' => $this->request->param('place_id'))));
|
||||
return $this->success("添加成功!", url('/admin/ad/lists', ['id' => $data['place_id']]));
|
||||
} else {
|
||||
return $this->error($ad->getError());
|
||||
return $this->error('添加失败!');
|
||||
}
|
||||
} else {
|
||||
$info['place_id'] = $id;
|
||||
$data = array(
|
||||
$this->data = array(
|
||||
'info' => $info,
|
||||
'keyList' => $ad->keyList,
|
||||
'keyList' => AdModel::$keyList,
|
||||
);
|
||||
$this->assign($data);
|
||||
$this->setMeta("添加广告位");
|
||||
return $this->fetch('public/edit');
|
||||
return $this->fetch('admin/public/edit');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,26 +139,25 @@ class Ad extends Base {
|
||||
* @title 编辑广告
|
||||
*/
|
||||
public function editad($id = null) {
|
||||
$ad = model('ad');
|
||||
if ($this->request->isPost()) {
|
||||
$result = $ad->change();
|
||||
$data = $this->request->post();
|
||||
|
||||
$result = AdModel::update($data, ['id' => $data['id']]);
|
||||
if ($result) {
|
||||
return $this->success("修改成功!", url('admin/ad/lists', array('id' => $this->request->param('place_id'))));
|
||||
return $this->success("修改成功!", url('/admin/ad/lists', ['id' => $data['place_id']]));
|
||||
} else {
|
||||
return $this->error($ad->getError());
|
||||
return $this->error('修改失败!');
|
||||
}
|
||||
} else {
|
||||
$info = db('ad')->where(array('id' => $id))->find();
|
||||
$info = AdModel::find($id);
|
||||
if (!$info) {
|
||||
return $this->error("非法操作!");
|
||||
}
|
||||
$data = array(
|
||||
$this->data = array(
|
||||
'info' => $info,
|
||||
'keyList' => $ad->keyList,
|
||||
'keyList' => AdModel::$keyList,
|
||||
);
|
||||
$this->assign($data);
|
||||
$this->setMeta("编辑广告位");
|
||||
return $this->fetch('public/edit');
|
||||
return $this->fetch('admin/public/edit');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user