前端组件调整,剔除无用文件
This commit is contained in:
@@ -9,13 +9,173 @@
|
||||
namespace app\controller\admin;
|
||||
|
||||
use app\controller\Admin;
|
||||
use app\model\AdPlace;
|
||||
use app\model\Ad as AdModel;
|
||||
|
||||
class Ad extends Admin{
|
||||
|
||||
/**
|
||||
* @title 系统首页
|
||||
* @title 广告位列表
|
||||
*/
|
||||
public function index(){
|
||||
|
||||
public function index(AdPlace $adp){
|
||||
if ($this->request->isAjax()) {
|
||||
$res = $adp->paginate(25, false, array(
|
||||
'query' => $this->request->param()
|
||||
));
|
||||
$data = $res->toArray();
|
||||
$this->data['data'] = $data;
|
||||
return $this->data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 添加广告位
|
||||
*/
|
||||
public function add(AdPlace $adp){
|
||||
if ($this->request->isPost()) {
|
||||
$data = $this->request->post();
|
||||
$result = $adp->save($data);
|
||||
if (false !== $result) {
|
||||
return $this->success('成功添加', url('/admin/ad/index'));
|
||||
}else{
|
||||
return $this->error($this->model->getError());
|
||||
}
|
||||
}else{
|
||||
$info['appid'] = rand_string(10, 1); //八位数字appid
|
||||
$info['appsecret'] = rand_string(32); //32位数字加字母秘钥
|
||||
$this->data['data'] = array(
|
||||
'info' => $info
|
||||
);
|
||||
|
||||
return $this->data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 编辑广告位
|
||||
*/
|
||||
public function edit(AdPlace $adp){
|
||||
if ($this->request->isPost()) {
|
||||
$data = $this->request->post();
|
||||
if (!isset($data['id']) || !$data['id']) {
|
||||
return $this->error('非法操作!');
|
||||
}
|
||||
|
||||
$result = $adp->exists(true)->save($data);
|
||||
if (false !== $result) {
|
||||
return $this->success('修改成功', url('/admin/ad/index'));
|
||||
}else{
|
||||
return $this->error($this->model->getError());
|
||||
}
|
||||
}else{
|
||||
$info = $adp->where('id', $this->request->param('id'))->find();
|
||||
$this->data['template'] = "add";
|
||||
$this->data['data'] = array(
|
||||
'info' => $info
|
||||
);
|
||||
return $this->data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 删除广告位
|
||||
*/
|
||||
public function del(AdPlace $adp){
|
||||
$ids = $this->request->param('ids', 0);
|
||||
if(!$ids){
|
||||
return $this->error('非法操作!');
|
||||
}else{
|
||||
$ids = \explode(",", $ids);
|
||||
}
|
||||
$result = $adp->where('id', 'IN', $ids)->delete();
|
||||
|
||||
if(false !== $result){
|
||||
return $this->success('删除成功!');
|
||||
}else{
|
||||
return $this->error('删除失败!');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 广告列表
|
||||
*/
|
||||
public function lists(AdModel $ad){
|
||||
if ($this->request->isAjax()) {
|
||||
$res = $ad->paginate(25, false, array(
|
||||
'query' => $this->request->param()
|
||||
));
|
||||
$data = $res->toArray();
|
||||
$this->data['data'] = $data;
|
||||
return $this->data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 添加广告
|
||||
*/
|
||||
public function addad(AdModel $ad){
|
||||
if ($this->request->isPost()) {
|
||||
$data = $this->request->post();
|
||||
$result = $ad->save($data);
|
||||
if (false !== $result) {
|
||||
return $this->success('成功添加', url('/admin/ad/index'));
|
||||
}else{
|
||||
return $this->error($this->model->getError());
|
||||
}
|
||||
}else{
|
||||
$info['appid'] = rand_string(10, 1); //八位数字appid
|
||||
$info['appsecret'] = rand_string(32); //32位数字加字母秘钥
|
||||
$this->data['data'] = array(
|
||||
'info' => $info
|
||||
);
|
||||
|
||||
return $this->data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 编辑广告
|
||||
*/
|
||||
public function editad(AdModel $ad){
|
||||
if ($this->request->isPost()) {
|
||||
$data = $this->request->post();
|
||||
if (!isset($data['id']) || !$data['id']) {
|
||||
return $this->error('非法操作!');
|
||||
}
|
||||
|
||||
$result = $ad->exists(true)->save($data);
|
||||
if (false !== $result) {
|
||||
return $this->success('修改成功', url('/admin/ad/index'));
|
||||
}else{
|
||||
return $this->error($this->model->getError());
|
||||
}
|
||||
}else{
|
||||
$info = $ad->where('id', $this->request->param('id'))->find();
|
||||
$this->data['template'] = "addad";
|
||||
$this->data['data'] = array(
|
||||
'info' => $info
|
||||
);
|
||||
return $this->data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 删除广告
|
||||
*/
|
||||
public function delad(AdModel $ad){
|
||||
$ids = $this->request->param('ids', 0);
|
||||
if(!$ids){
|
||||
return $this->error('非法操作!');
|
||||
}else{
|
||||
$ids = \explode(",", $ids);
|
||||
}
|
||||
$result = $ad->where('id', 'IN', $ids)->delete();
|
||||
|
||||
if(false !== $result){
|
||||
return $this->success('删除成功!');
|
||||
}else{
|
||||
return $this->error('删除失败!');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user