Notice.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace app\common\controller;
  3. use app\BaseController;
  4. use app\common\middleware\Auth;
  5. use app\admin\model\Notice as NoticeModel;
  6. /**
  7. * Description of Notice
  8. *
  9. * @author sgq
  10. */
  11. class Notice extends BaseController {
  12. protected $middleware = [Auth::class];
  13. /**
  14. * 通知列表
  15. * @return type
  16. */
  17. public function index() {
  18. $total = NoticeModel::count();
  19. return view("", ["total" => $total]);
  20. }
  21. /**
  22. * 显示通知详情
  23. */
  24. public function view() {
  25. $id = $this->request->param("id");
  26. $row = \app\common\api\NoticeApi::getOne($id);
  27. $creater = \app\admin\api\UserApi::getOne($row["creater"]);
  28. return view("", ["row" => $row, "creater" => $creater]);
  29. }
  30. public function list() {
  31. if ($this->request->isAjax()) {
  32. $pageSize = $this->request->param("pageSize") ?: 6;
  33. $page = $this->request->param("page") ?: 1;
  34. $list = NoticeModel::where('batch', 'null')->whereOr('batch', "")->order(["isTop", "topTime" => "desc", "createTime" => "desc"])->page($page, $pageSize)->select();
  35. return json($list);
  36. }
  37. }
  38. }