Notice.php 927 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace addons\exam\controller;
  3. use addons\exam\enum\CommonStatus;
  4. use addons\exam\model\NoticeModel;
  5. /**
  6. * 公告接口
  7. */
  8. class Notice extends Base
  9. {
  10. protected $noNeedLogin = ['*'];
  11. protected $noNeedRight = ['*'];
  12. protected $user;
  13. /**
  14. * 列表
  15. */
  16. public function index()
  17. {
  18. $list = NoticeModel::where('status', CommonStatus::NORMAL)
  19. ->field('id, name, createtime')
  20. ->order('weigh desc')
  21. ->paginate(15, true);
  22. $this->success('', ['list' => $list]);
  23. }
  24. /**
  25. * 详情
  26. */
  27. public function detail()
  28. {
  29. if (!$id = input('id/d', '0')) {
  30. $this->error('缺少公告ID');
  31. }
  32. if (!$notice = NoticeModel::where('id', $id)->where('status', CommonStatus::NORMAL)->find()) {
  33. $this->error('公告信息不存在');
  34. }
  35. $this->success('', $notice);
  36. }
  37. }