| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use app\common\model\AnnouncementModel;
- class Announcement extends Api
- {
- protected array $noNeedLogin = ['list','show'];
- protected string $lan = '';
- public function _initialize()
- {
- parent::_initialize();
- $this->lan = $this->request->getLan();
- }
- public function list()
- {
- $paginator = (new AnnouncementModel)
- ->where('type', 1)
- ->where('status', 1)
- ->order('id DESC,weigh desc')
- ->field('id,img_url,createtime,' . $this->lan.'_title as title')
- ->paginate($this->pageSize);
- $this->success('', $this->buildResp($paginator->total(), $paginator->currentPage(), $paginator->items()));
- }
- public function show(int $id)
- {
- $info = (new AnnouncementModel)
- ->where('id', $id)
- ->where('status', 1)
- ->field('id,img_url,body,createtime,' . $this->lan.'_title as title')
- ->find();
- if(empty($info)){
- $this->error('公告信息不存');
- }
- $this->success('', $info);
- }
- }
|