| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- <?php
- namespace App\Http\Controllers\Api\v1;
- use App\Http\Controllers\Api\BaseController;
- use App\Services\MusicCollectService;
- use App\Services\MusicPlayedService;
- use App\Services\MusicService;
- use App\Services\MusicSheetsService;
- use Illuminate\Http\Request;
- /**
- * 佛音控制器类
- * @author wesmiler
- * @since 2020/11/10
- * Class MusicController
- * @package App\Http\Controllers
- */
- class MusicController extends BaseController
- {
- /**
- * 构造函数
- * @author wesmiler
- * @since 2020/11/11
- * MusicController constructor.
- */
- public function __construct()
- {
- parent::__construct();
- $this->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);
- }
- }
|