| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
- namespace app\api\controller\service;
- use app\common\controller\Api;
- /**
- * 首页接口
- */
- class Notice extends Api
- {
- protected $noNeedLogin = ['*'];
- protected $noNeedRight = ['*'];
- /**
- * 平台公告
- * @return void
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- */
- public function getList()
- {
- if (!$this->request->isPost()) {
- $this->error('请求方式异常');
- }
- $type = input('type/d',0);
- $page = input('page/d',1);
- $limit = 10;
- $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();
- $this->success('列表返回成功',$list);
- }
- public function detail()
- {
- if (!$this->request->isPost()) {
- $this->error('请求方式异常');
- }
- $id = input('id/d','');
- $info = model('app\api\model\service\Notice')->where(['id'=>$id,'state'=>1])->find();
- !$info && $this->error('信息异常');
- $info['content'] = htmlspecialchars_decode($info['content']);
- $this->success('信息返回成功',$info);
- }
- }
|