service = new MusicService(); $this->cateService = new MusicSheetsService(); $this->collectService = new MusicCollectService(); $this->playService = new MusicPlayedService(); } /** * 列表 * @return array */ public function index(){ $params = request()->all(); $type = request()->get('type', 1); $params['user_id'] = $this->userId; if($type ==1){ return $this->service->getDataList($params); }else if($type == 2){ return $this->playService->getDataList($params); }else if($type == 3){ return $this->collectService->getDataList($params); } return message(MESSAGE_FAILED,false, []); } /** * 详情 * @return array|mixed */ public function detail(){ $id = request()->get('id',0); if($id<=0){ return message(1006, false); } $this->service->updateVisit($this->userId); $info = $this->service->getDetail($id, $this->userId); return message(1005, true, $info); } /** * 获取分类 * @return mixed */ public function cates(){ return $this->cateService->getOptions(); } /** * 收藏 * @return mixed */ public function collect(){ return $this->collectService->save($this->userId); } /** * 播放 * @return mixed */ public function play(){ return $this->playService->save($this->userId); } /** * 播放 * @return mixed */ public function playList(){ $params = request()->all(); $params['user_id'] = $this->userId; return $this->playService->getDataList($params); } }