lan = $this->request->getLan(); } //获取大分类 public function gettype(AnnouncementModel $announcementModel){ $this->success('', $announcementModel::getTypeList()); } //获取子分类 public function getSubtype(AnnouncementType $announcementType){ $typeId = $this->request->param('type_id', 1, 'intval'); $this->success('', $announcementType::getSubTypeByPId($typeId)); } //列表 public function list(AnnouncementModel $announcementModel, AnnouncementType $announcementType) { $typeId = $this->request->param('type_id', 1, 'intval'); $paginator = $announcementModel->where('type_id', $typeId) ->where('status', 1)->where('to_lang', $this->lan) ->field('id,to_lang,weigh,img_url,createtime,title as title,introduction,body,is_top,sub_type_id') ->order('is_top desc, weigh desc') ->paginate($this->pageSize); $paginator = $announcementType::getSubTypeById($paginator); $this->success('', $this->buildResp($paginator->total(), $paginator->currentPage(), $paginator->items())); } public function show(int $id) { $info = (new AnnouncementModel) ->where('id', $id) //->where('status', 1) ->where('to_lang', $this->lan) ->field('id,img_url,to_lang,createtime,title,introduction,body') ->find(); if(empty($info)){ $this->error('公告信息不存'); } $this->success('', $info); } }