playService = $playService; $this->playValidate = $playValidate; } /** * 视频列表 function * * @author dotdotdot <6383846@qq.com> * @date 2022-08-15 * @param Request $request * @return array */ public function list(Request $request) { $params = [ 'uid' => getDecodeTokenData()['uid'], 'sid' => $request->param('sid'), 'page' => $request->param('page', 1), 'limit' => $request->param('limit', 20) ]; if (!$this->playValidate->scene('list')->check($params)) { throw new ApiException((string)$this->playValidate->getError(), EnumCode::ValidateError); } $data = $this->playService->list($params); return json(['code' => EnumCode::Success, 'msg' => 'ok', 'data' => $data]); } /** * 视频解锁单集或全集 function * * @author dotdotdot <6383846@qq.com> * @date 2022-08-16 * @param Request $request * @return array */ public function videoUnlock(Request $request) { $params = [ 'uid' => getDecodeTokenData()['uid'], 'id' => $request->param('id'), 'sid' => $request->param('sid') ]; if (!$this->playValidate->scene('videoUnlock')->check($params)) { throw new ApiException((string)$this->playValidate->getError(), EnumCode::ValidateError); } $this->playService->videoUnlock($params); return json(['code' => EnumCode::Success, 'msg' => 'ok']); } /** * 播放 function * * @author dotdotdot <6383846@qq.com> * @date 2022-08-22 * @param Request $request * @return array */ public function videoPlay(Request $request) { $params = [ 'uid' => getDecodeTokenData()['uid'], 'sid' => $request->param('sid'), 'id' => $request->param('id') ]; if (!$this->playValidate->scene('videoPlay')->check($params)) { throw new ApiException((string)$this->playValidate->getError(), EnumCode::ValidateError); } $data = $this->playService->videoPlay($params); return json(['code' => EnumCode::Success, 'msg' => 'ok', 'data' => [$data]]); } /** * 追剧 function * * @author dotdotdot <6383846@qq.com> * @date 2022-08-22 * @param Request $request * @return array */ public function bingeWatching(Request $request) { $actionAllowed = ['method' => 'binge_watching_', 'key' => getDecodeTokenData()['uid'], 'period' => 1]; Hook::listen('action_allowed', $actionAllowed); $params = [ 'uid' => getDecodeTokenData()['uid'], 'sid' => $request->param('sid') ]; if (!$this->playValidate->scene('bingeWatching')->check($params)) { throw new ApiException((string)$this->playValidate->getError(), EnumCode::ValidateError); } $this->playService->bingeWatching($params); return json(['code' => EnumCode::Success, 'msg' => 'ok']); } }