|
|
@@ -22,7 +22,7 @@ class Announcement extends Api
|
|
|
//获取大分类
|
|
|
public function gettype(AnnouncementModel $announcementModel){
|
|
|
|
|
|
- $this->success('', $announcementModel::getTypeList());
|
|
|
+ $this->success('', $announcementModel::getTypeList($this->lan));
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -30,13 +30,19 @@ class Announcement extends Api
|
|
|
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);
|
|
|
+ $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')->order('is_top desc, weigh desc')->paginate($this->pageSize);
|
|
|
|
|
|
- $paginator = $announcementType::getSubTypeById($paginator);
|
|
|
+ $paginator = $announcementType::getSubTypeById($paginator, $this->lan);
|
|
|
$this->success('', $this->buildResp($paginator->total(), $paginator->currentPage(), $paginator->items()));
|
|
|
}
|
|
|
|