Announcement.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace app\admin\controller\general;
  3. use app\common\controller\Backend;
  4. /**
  5. * 文件管理
  6. *
  7. * @icon fa fa-circle-o
  8. */
  9. class Announcement extends Backend
  10. {
  11. /**
  12. * Banner模型对象 茶说、公告、合成公告、轮播图
  13. * @var \app\admin\model\Banner
  14. */
  15. protected $model = null;
  16. protected $multiFields = 'status,is_show' ;
  17. public function _initialize()
  18. {
  19. parent::_initialize();
  20. $this->model = new \app\common\model\AnnouncementModel;
  21. $this->view->assign("typeList", $this->model ::getTypeList());
  22. }
  23. /**
  24. * 查
  25. * @return string|Json
  26. * @throws \think\Exception
  27. * @throws DbException
  28. */
  29. public function index()
  30. {
  31. //设置过滤方法
  32. $this->request->filter(['strip_tags', 'trim']);
  33. if (false === $this->request->isAjax()) {
  34. return $this->view->fetch();
  35. }
  36. //如果发送的来源是 Selectpage,则转发到 Selectpage
  37. if ($this->request->request('keyField')) {
  38. return $this->selectpage();
  39. }
  40. [$where, $sort, $order, $offset, $limit] = $this->buildparams();
  41. $map = [];
  42. $type = $this->request->param('type_id/d');
  43. if($type > 0) $map['type_id'] = $type;
  44. $list = $this->model
  45. ->where($where)->where($map)
  46. ->order($sort, $order)
  47. ->paginate($limit);
  48. $result = ['total' => $list->total(), 'rows' => $list->items()];
  49. return json($result);
  50. }
  51. }