|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
|
|
namespace app\admin\controller\system;
|
|
namespace app\admin\controller\system;
|
|
|
|
|
|
|
|
|
|
+use app\admin\logic\SystemBannerLogic;
|
|
|
use app\common\controller\AdminController;
|
|
use app\common\controller\AdminController;
|
|
|
use app\common\model\SystemBannerModel;
|
|
use app\common\model\SystemBannerModel;
|
|
|
use think\App;
|
|
use think\App;
|
|
@@ -15,7 +16,7 @@ class Banner extends AdminController
|
|
|
|
|
|
|
|
use \app\admin\traits\Curd;
|
|
use \app\admin\traits\Curd;
|
|
|
|
|
|
|
|
- public function __construct (App $app)
|
|
|
|
|
|
|
+ public function __construct(App $app)
|
|
|
{
|
|
{
|
|
|
parent::__construct($app);
|
|
parent::__construct($app);
|
|
|
|
|
|
|
@@ -23,32 +24,21 @@ class Banner extends AdminController
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function index ()
|
|
|
|
|
|
|
+ public function index()
|
|
|
{
|
|
{
|
|
|
if ($this->request->isAjax()) {
|
|
if ($this->request->isAjax()) {
|
|
|
if (input('selectFields')) {
|
|
if (input('selectFields')) {
|
|
|
return $this->selectList();
|
|
return $this->selectList();
|
|
|
}
|
|
}
|
|
|
list($page, $limit, $where) = $this->buildTableParames();
|
|
list($page, $limit, $where) = $this->buildTableParames();
|
|
|
- $count = $this->model
|
|
|
|
|
- ->where($where)
|
|
|
|
|
- ->count();
|
|
|
|
|
-// return 11;
|
|
|
|
|
-
|
|
|
|
|
-// return json_decode('[{"price":10, "fee":1},{"price":50, "fee":0.5},{"price":100, "fee":0}]');
|
|
|
|
|
- $list = $this->model
|
|
|
|
|
- ->where($where)
|
|
|
|
|
- ->withAttr('img_pic', function ($val, $data){
|
|
|
|
|
- return __HTTPGETIMGADMIN($val);
|
|
|
|
|
- })
|
|
|
|
|
- ->page($page, $limit)
|
|
|
|
|
- ->order($this->sort)
|
|
|
|
|
- ->select();
|
|
|
|
|
|
|
+
|
|
|
|
|
+ list($count, $list) = SystemBannerLogic::getList($page, $limit, $where, $this->sort);
|
|
|
|
|
+
|
|
|
$data = [
|
|
$data = [
|
|
|
- 'code' => 0,
|
|
|
|
|
- 'msg' => '',
|
|
|
|
|
|
|
+ 'code' => 0,
|
|
|
|
|
+ 'msg' => '',
|
|
|
'count' => $count,
|
|
'count' => $count,
|
|
|
- 'data' => $list,
|
|
|
|
|
|
|
+ 'data' => $list,
|
|
|
];
|
|
];
|
|
|
return json($data);
|
|
return json($data);
|
|
|
}
|
|
}
|
|
@@ -60,7 +50,7 @@ class Banner extends AdminController
|
|
|
/**
|
|
/**
|
|
|
* @NodeAnotation(title="修改")
|
|
* @NodeAnotation(title="修改")
|
|
|
*/
|
|
*/
|
|
|
- public function edit ($id)
|
|
|
|
|
|
|
+ public function edit($id)
|
|
|
{
|
|
{
|
|
|
$row = $this->model->find($id);
|
|
$row = $this->model->find($id);
|
|
|
empty($row) && $this->error('数据不存在');
|
|
empty($row) && $this->error('数据不存在');
|
|
@@ -68,15 +58,8 @@ class Banner extends AdminController
|
|
|
$post = $this->request->post();
|
|
$post = $this->request->post();
|
|
|
$rule = [];
|
|
$rule = [];
|
|
|
$this->validate($post, $rule);
|
|
$this->validate($post, $rule);
|
|
|
- try {
|
|
|
|
|
- $post['banner_desc'] = htmlspecialchars_decode($post['banner_desc']);
|
|
|
|
|
- $post['img_pic'] = __HTTPSAVEIMGADMIN($post['img_pic']);
|
|
|
|
|
- $save = $row->save($post);
|
|
|
|
|
- RedisCache::clear('getAppBanner'.$row['type']);
|
|
|
|
|
- } catch (\Exception $e) {
|
|
|
|
|
- $this->error('保存失败');
|
|
|
|
|
- }
|
|
|
|
|
- $save ? $this->success('保存成功') : $this->error('保存失败');
|
|
|
|
|
|
|
+ $save = SystemBannerLogic::edit($post);
|
|
|
|
|
+ $save === true ? $this->success('保存成功') : $this->error('保存失败');
|
|
|
}
|
|
}
|
|
|
$row['img_pic'] = __HTTPGETIMGADMIN($row['img_pic']);
|
|
$row['img_pic'] = __HTTPGETIMGADMIN($row['img_pic']);
|
|
|
$this->assign('row', $row);
|
|
$this->assign('row', $row);
|
|
@@ -88,21 +71,14 @@ class Banner extends AdminController
|
|
|
*/
|
|
*/
|
|
|
public function add()
|
|
public function add()
|
|
|
{
|
|
{
|
|
|
- if ($this->request->isAjax()){
|
|
|
|
|
- $row = request()->post();
|
|
|
|
|
- $row['img_pic'] = __HTTPSAVEIMGADMIN($row['img_pic']);
|
|
|
|
|
- $row['banner_desc'] = htmlspecialchars_decode($row['banner_desc']);
|
|
|
|
|
- $row['create_time'] = sr_getcurtime(time());
|
|
|
|
|
- unset($row['file']);
|
|
|
|
|
- $save = $this->model->insert($row);
|
|
|
|
|
- RedisCache::clear('getAppBanner'.$row['type']);
|
|
|
|
|
- $save?$this->success('添加成功'):$this->error('添加失败');
|
|
|
|
|
-
|
|
|
|
|
|
|
+ if ($this->request->isAjax()) {
|
|
|
|
|
+ $row = request()->post();
|
|
|
|
|
+ $save = SystemBannerLogic::add($row);
|
|
|
|
|
+ $save === true ? $this->success('添加成功') : $this->error('添加失败');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return $this->fetch();
|
|
return $this->fetch();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|