service = new DynamicService(); $this->commentService = new DynamicCommentService(); } /** * 列表 * @return array */ public function index(){ $params = request()->all(); $type = isset($params['type'])? $params['type'] : 0; if($type==1){ $params['user_id'] = $this->userId; return $this->service->getCollectList($params); }else{ return $this->service->getDataList($params); } } /** * 动态评论 * @return mixed */ public function commentList(){ $params = request()->all(); return $this->commentService->getDataList($params); } /** * 发布动态评论 * @param Request $request * @param DynamicValidator $validate * @return array */ public function comment(Request $request, DynamicValidator $validate){ $params = $validate->check($request->all(),'publish'); if(!is_array($params)){ return message($params, false); } return $this->commentService->comment($this->userId); } /** * 我的动态 * @return array */ public function myList(){ $params = request()->all(); $params['user_id'] = $this->userId; return $this->service->getDataList($params); } /** * 详情 * @return array|mixed */ public function info(){ $id = request()->get('id',0); if($id<=0){ return message(1006, false); } $info = $this->service->getDetail($id, $this->userId); return message(1005, true, $info); } /** * 发布动态 * @param Request $request * @param DynamicValidator $validate * @return array */ public function publish(Request $request, DynamicValidator $validate){ $params = $validate->check($request->all(),'publish'); if(!is_array($params)){ return message($params, false); } return $this->service->publish($this->userId); } /** * 动态通知 * @return mixed */ public function notice(){ return $this->service->notice($this->userId); } }