123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259 |
- <?php
- namespace app\admin\controller;
- use think\Db;
- use cmf\controller\AdminBaseController;
- use app\admin\model\SlideItemModel;
- class SlideItemController extends AdminBaseController
- {
-
- public function index()
- {
- $content = hook_one('admin_slide_item_index_view');
- if (!empty($content)) {
- return $content;
- }
- $id = $this->request->param('slide_id', 0, 'intval');
- $slideId = !empty($id) ? $id : 1;
- $result = Db::name('slideItem')->where('slide_id', $slideId)->select();
- $this->assign('slide_id', $id);
- $this->assign('result', $result);
- return $this->fetch();
- }
-
- public function add()
- {
- $content = hook_one('admin_slide_item_add_view');
- if (!empty($content)) {
- return $content;
- }
- $slideId = $this->request->param('slide_id');
- $this->assign('slide_id', $slideId);
- return $this->fetch();
- }
-
- public function addPost()
- {
- $data = $this->request->param();
- Db::name('slideItem')->insert($data['post']);
- $this->success("添加成功!", url("slideItem/index", ['slide_id' => $data['post']['slide_id']]));
- }
-
- public function edit()
- {
- $content = hook_one('admin_slide_item_edit_view');
- if (!empty($content)) {
- return $content;
- }
- $id = $this->request->param('id', 0, 'intval');
- $result = Db::name('slideItem')->where('id', $id)->find();
- $this->assign('result', $result);
- $this->assign('slide_id', $result['slide_id']);
- return $this->fetch();
- }
-
- public function editPost()
- {
- $data = $this->request->param();
- $data['post']['image'] = cmf_asset_relative_url($data['post']['image']);
- Db::name('slideItem')->update($data['post']);
- $this->success("保存成功!", url("SlideItem/index", ['slide_id' => $data['post']['slide_id']]));
- }
-
- public function delete()
- {
- $id = $this->request->param('id', 0, 'intval');
- $slideItem = Db::name('slideItem')->find($id);
- $result = Db::name('slideItem')->delete($id);
- if ($result) {
-
- $this->success("删除成功!", url("SlideItem/index", ["slide_id" => $slideItem['slide_id']]));
- } else {
- $this->error('删除失败!');
- }
- }
-
- public function ban()
- {
- $id = $this->request->param('id', 0, 'intval');
- if ($id) {
- $rst = Db::name('slideItem')->where('id', $id)->update(['status' => 0]);
- if ($rst) {
- $this->success("幻灯片隐藏成功!");
- } else {
- $this->error('幻灯片隐藏失败!');
- }
- } else {
- $this->error('数据传入失败!');
- }
- }
-
- public function cancelBan()
- {
- $id = $this->request->param('id', 0, 'intval');
- if ($id) {
- $result = Db::name('slideItem')->where('id', $id)->update(['status' => 1]);
- if ($result) {
- $this->success("幻灯片启用成功!");
- } else {
- $this->error('幻灯片启用失败!');
- }
- } else {
- $this->error('数据传入失败!');
- }
- }
-
- public function listOrder()
- {
- $slideItemModel = new SlideItemModel();
- parent::listOrders($slideItemModel);
- $this->success("排序更新成功!");
- }
- }
|