114 lines
3.0 KiB
PHP
114 lines
3.0 KiB
PHP
<?php
|
||
// +------------------------------------------------+
|
||
// |http://www.cjango.com |
|
||
// +------------------------------------------------+
|
||
// | 修复BUG不是一朝一夕的事情,等我喝醉了再说吧! |
|
||
// +------------------------------------------------+
|
||
// | Author: 小陈叔叔 <Jason.Chen> |
|
||
// +------------------------------------------------+
|
||
namespace app\system\controller;
|
||
|
||
use app\common\model\Advert as AdvertModel;
|
||
use app\common\model\AdvertDetail as AdvertDetailModel;
|
||
use app\common\service\Advert as AdvertService;
|
||
use app\common\service\AdvertDetail as AdvertDetailService;
|
||
|
||
class Banner extends _Init
|
||
{
|
||
|
||
public function index($title = '')
|
||
{
|
||
$map['status'] = ['egt', 0];
|
||
if ($title) {
|
||
$map['title'] = ['like', "%{$title}%"];
|
||
}
|
||
$this->list = AdvertModel::where($map)->paginate();
|
||
return $this->fetch();
|
||
}
|
||
|
||
public function add()
|
||
{
|
||
if (IS_POST) {
|
||
$data = $this->request->post();
|
||
$res = AdvertService::add($data);
|
||
return $this->back($res);
|
||
} else {
|
||
return $this->fetch();
|
||
}
|
||
}
|
||
|
||
public function edit($id)
|
||
{
|
||
if (IS_POST) {
|
||
$data = $this->request->post();
|
||
$res = AdvertService::edit($data);
|
||
return $this->back($res);
|
||
} else {
|
||
$this->assign('info', AdvertModel::get($id));
|
||
return $this->fetch('add');
|
||
}
|
||
}
|
||
|
||
public function del($id)
|
||
{
|
||
$res = AdvertService::del($id);
|
||
return $this->back($res);
|
||
}
|
||
|
||
/**
|
||
* 修改状态
|
||
* @param [type] $id [description]
|
||
* @param [type] $status [description]
|
||
* @param [type] $type [description]
|
||
*/
|
||
public function status($id, $status, $type)
|
||
{
|
||
$res = AdvertService::status($id, $status, $type);
|
||
return $this->back($res);
|
||
}
|
||
|
||
public function detail($advert_id)
|
||
{
|
||
$this->info = AdvertModel::get($advert_id);
|
||
return $this->fetch();
|
||
}
|
||
|
||
public function banadd($advert_id)
|
||
{
|
||
if (IS_POST) {
|
||
$data = $this->request->post();
|
||
$data['advert_id'] = $advert_id;
|
||
unset($data['image']);
|
||
$res = AdvertDetailService::add($data);
|
||
return $this->back($res);
|
||
} else {
|
||
return $this->fetch();
|
||
}
|
||
}
|
||
|
||
public function banedit($id)
|
||
{
|
||
if (IS_POST) {
|
||
$data = $this->request->post();
|
||
unset($data['image']);
|
||
$res = AdvertDetailService::edit($data);
|
||
return $this->back($res);
|
||
} else {
|
||
$this->assign('info', AdvertDetailModel::get($id));
|
||
return $this->fetch('banadd');
|
||
}
|
||
}
|
||
|
||
public function bandel($id)
|
||
{
|
||
$res = AdvertDetailService::del($id);
|
||
return $this->back($res);
|
||
}
|
||
|
||
public function banstatus($id, $status, $type)
|
||
{
|
||
$res = AdvertDetailService::status($id, $status, $type);
|
||
return $this->back($res);
|
||
}
|
||
}
|