Notice.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace app\api\controller\service;
  3. use app\common\controller\Api;
  4. /**
  5. * 首页接口
  6. */
  7. class Notice extends Api
  8. {
  9. protected $noNeedLogin = ['*'];
  10. protected $noNeedRight = ['*'];
  11. /**
  12. * 平台公告
  13. * @return void
  14. * @throws \think\db\exception\DataNotFoundException
  15. * @throws \think\db\exception\ModelNotFoundException
  16. * @throws \think\exception\DbException
  17. */
  18. public function getList()
  19. {
  20. if (!$this->request->isPost()) {
  21. $this->error('请求方式异常');
  22. }
  23. $type = input('type/d',0);
  24. $page = input('page/d',1);
  25. $limit = 10;
  26. $list = model('app\api\model\service\Notice')->where(['type'=>$type,'state'=>1])->field('id,title,image,createtime')->order('weigh desc,id desc')->page($page)->limit($limit)->select();
  27. $this->success('列表返回成功',$list);
  28. }
  29. public function detail()
  30. {
  31. if (!$this->request->isPost()) {
  32. $this->error('请求方式异常');
  33. }
  34. $id = input('id/d','');
  35. $info = model('app\api\model\service\Notice')->where(['id'=>$id,'state'=>1])->find();
  36. !$info && $this->error('信息异常');
  37. $info['content'] = htmlspecialchars_decode($info['content']);
  38. $this->success('信息返回成功',$info);
  39. }
  40. }