lan = $this->request->getLan(); } //获取大分类 public function gettype(AnnouncementModel $announcementModel){ $this->success('', $announcementModel::getTypeAllList($this->lan)); } //列表 public function list(AnnouncementModel $announcementModel, AnnouncementType $announcementType) { $typeId = $this->request->param('type_id', 1, 'intval'); $subTypeId = $this->request->param('sub_type_id', 0, 'intval'); //子分类id $title = $this->request->param('title/s', ''); //标题 $paginator = $announcementModel->where('type_id', $typeId)->where('status', 1)->where('to_lang', $this->lan); //子分类 if($subTypeId > 0) $paginator =$paginator->where('find_in_set(:id,sub_type_id)',['id'=>$subTypeId]); //标题 if(!empty($title)) $paginator =$paginator->where('title', 'LIKE', '%'.$title.'%'); $paginator =$paginator->field('id,to_lang,weigh,img_url,createtime,title as title,is_top,sub_type_id,introduction,body')->order('is_top desc, weigh desc, createtime desc')->paginate($this->pageSize); $paginator = $announcementType::getSubTypeById($paginator, $this->lan); $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); } }