| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- <?php
- namespace App\Http\Controllers\Api\v1;
- use App\Http\Controllers\Api\webApp;
- use App\Services\Api\VideoCollectService;
- use App\Services\Api\VideoService;
- use App\Services\RedisService;
- use Illuminate\Http\Request;
- /**
- * 短视频服务管理
- * @package App\Http\Controllers\Api
- */
- class VideoController extends webApp
- {
- /**
- * 列表
- * @return array
- */
- public function index()
- {
- try {
- $params = request()->post();
- $pageSize = request()->post('pageSize', 0);
- $params['is_recommend'] = 1;
- $datas = VideoService::make()->getIndexList($params, $pageSize,'', $this->userId);
- return showJson(1010, true, $datas);
- } catch (\Exception $exception){
- RedisService::set("caches:request:error_video_index", ['error'=>$exception->getMessage(),'trace'=>$exception->getTrace()], 7200);
- return showJson(1018, false, ['error'=>env('APP_DEBUG')? $exception->getMessage() : '']);
- }
- }
- /**
- * 列表
- * @return array
- */
- public function list()
- {
- // try {
- $params = request()->post();
- $pageSize = request()->post('pageSize', 0);
- $datas = VideoService::make()->getDataList($params, $pageSize,'', $this->userId);
- return showJson(1010, true, $datas);
- // } catch (\Exception $exception){
- // RedisService::set("caches:request:error_video_list", ['error'=>$exception->getMessage(),'trace'=>$exception->getTrace()], 7200);
- // return showJson(1018, false, ['error'=>env('APP_DEBUG')? $exception->getTrace() : '']);
- // }
- }
- /**
- * 短剧列表
- * @return array
- */
- public function shortList()
- {
- try {
- $params = request()->post();
- $pageSize = request()->post('pageSize', 0);
- $datas = VideoService::make()->getShortlist($params, $pageSize,'', $this->userId);
- return showJson(1010, true, $datas);
- } catch (\Exception $exception){
- RedisService::set("caches:request:error_video_short_list", ['error'=>$exception->getMessage(),'trace'=>$exception->getTrace()], 7200);
- return showJson(1018, false, ['error'=>env('APP_DEBUG')? $exception->getTrace() : '']);
- }
- }
- /**
- * 详情
- * @return array
- */
- public function info()
- {
- $id = request()->post('id', 0);
- $info = VideoService::make()->getInfo($id, $this->userId);
- if($info){
- return showJson(1010, true, $info);
- }else{
- return showJson(1009, false);
- }
- }
- /**
- * 详情
- * @return array
- */
- public function shortInfo()
- {
- $id = request()->post('id', 0);
- $info = VideoService::make()->getShortInfo($id, $this->userId);
- if($info){
- return showJson(1010, true, $info);
- }else{
- return showJson(1009, false);
- }
- }
- /**
- * 发布
- * @return array
- */
- public function publish(Request $request)
- {
- $params = request()->all();
- if(!$result = VideoService::make()->publish($this->userId, $params, $request)){
- return showJson(VideoService::make()->getError(), false);
- }else{
- return showJson(VideoService::make()->getError(), true, $result);
- }
- }
- /**
- * 播放与浏览
- * @return array
- */
- public function updatePlay()
- {
- $id = request()->post('id',0);
- if(!$result = VideoService::make()->updatePlay($this->userId, $id)){
- return showJson(VideoService::make()->getError(), false);
- }else{
- return showJson(VideoService::make()->getError(), true, $result);
- }
- }
- /**
- * 点赞
- * @return array|mixed
- */
- public function like()
- {
- try{
- $params = request()->post();
- if(!$result = VideoCollectService::make()->collect($this->userId, $params)){
- return showJson(VideoCollectService::make()->getError(), false);
- }else{
- return showJson(VideoCollectService::make()->getError(), true, $result);
- }
- }catch (\Exception $exception){
- return showJson(1003, false,$exception->getMessage());
- }
- }
- /**
- * 收藏
- * @return array|mixed
- */
- public function collect()
- {
- try{
- $params = request()->post();
- if(!$result = VideoCollectService::make()->collect($this->userId, $params)){
- return showJson(VideoCollectService::make()->getError(), false);
- }else{
- return showJson(VideoCollectService::make()->getError(), true, $result);
- }
- }catch (\Exception $exception){
- return showJson(1003, false,$exception->getMessage());
- }
- }
- /**
- * 状态
- * @return array|mixed
- */
- public function status()
- {
- if(!$result = VideoService::make()->status()){
- return showJson(VideoService::make()->getError(), false);
- }else{
- return showJson(VideoService::make()->getError(), true, $result);
- }
- }
- /**
- * 状态
- * @return array|mixed
- */
- public function visibleType()
- {
- if(!$result = VideoService::make()->visibleType()){
- return showJson(VideoService::make()->getError(), false);
- }else{
- return showJson(VideoService::make()->getError(), true, $result);
- }
- }
- /**
- * 删除
- * @return array|mixed
- */
- public function delete()
- {
- if(!$result = VideoService::make()->delete()){
- return showJson(VideoService::make()->getError(), false);
- }else{
- return showJson(VideoService::make()->getError(), true);
- }
- }
- }
|