|
|
@@ -7,6 +7,9 @@ use Illuminate\Http\Request;
|
|
|
use Illuminate\Support\Str;
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
use App\Http\Api\AuthApi;
|
|
|
+use App\Http\Api\StudioApi;
|
|
|
+use App\Http\Api\ShareApi;
|
|
|
+
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
require_once __DIR__.'/../../../public/app/ucenter/function.php';
|
|
|
@@ -35,17 +38,28 @@ class CollectionController extends Controller
|
|
|
# code...
|
|
|
//$table = Collection::select($indexCol)->where('owner', $_COOKIE["user_uid"]);
|
|
|
# 获取studio内所有channel
|
|
|
- $user = \App\Http\Api\AuthApi::current($request);
|
|
|
- if($user){
|
|
|
- //判断当前用户是否有指定的studio的权限
|
|
|
- if($user['user_uid'] === \App\Http\Api\StudioApi::getIdByName($request->get('name'))){
|
|
|
- $table = Collection::select($indexCol)->where('owner', $user["user_uid"]);
|
|
|
- }else{
|
|
|
- return $this->error(__('auth.failed'));
|
|
|
- }
|
|
|
- }else{
|
|
|
+ $user = AuthApi::current($request);
|
|
|
+ if(!$user){
|
|
|
return $this->error(__('auth.failed'));
|
|
|
}
|
|
|
+ $studioId = StudioApi::getIdByName($request->get('name'));
|
|
|
+ //判断当前用户是否有指定的studio的权限
|
|
|
+ if($user['user_uid'] !== $studioId){
|
|
|
+ return $this->error(__('auth.failed'));
|
|
|
+ }
|
|
|
+ $table = Collection::select($indexCol);
|
|
|
+ if($request->get('view2','my')==='my'){
|
|
|
+ $table = $table->where('owner', $studioId);
|
|
|
+ }else{
|
|
|
+ //协作
|
|
|
+ $resList = ShareApi::getResList($studioId,4);
|
|
|
+ $resId=[];
|
|
|
+ foreach ($resList as $res) {
|
|
|
+ $resId[] = $res['res_id'];
|
|
|
+ }
|
|
|
+ $table = $table->whereIn('uid', $resId)->where('owner','<>', $studioId);
|
|
|
+ }
|
|
|
+
|
|
|
break;
|
|
|
case 'public':
|
|
|
$table = Collection::select($indexCol)->where('status', 30);
|
|
|
@@ -115,6 +129,34 @@ class CollectionController extends Controller
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Display a listing of the resource.
|
|
|
+ *
|
|
|
+ * @return \Illuminate\Http\Response
|
|
|
+ */
|
|
|
+ public function showMyNumber(Request $request){
|
|
|
+ $user = AuthApi::current($request);
|
|
|
+ if(!$user){
|
|
|
+ return $this->error(__('auth.failed'));
|
|
|
+ }
|
|
|
+ //判断当前用户是否有指定的studio的权限
|
|
|
+ $studioId = StudioApi::getIdByName($request->get('studio'));
|
|
|
+ if($user['user_uid'] !== $studioId){
|
|
|
+ return $this->error(__('auth.failed'));
|
|
|
+ }
|
|
|
+ //我的
|
|
|
+ $my = Collection::where('owner', $studioId)->count();
|
|
|
+ //协作
|
|
|
+ $resList = ShareApi::getResList($studioId,4);
|
|
|
+ $resId=[];
|
|
|
+ foreach ($resList as $res) {
|
|
|
+ $resId[] = $res['res_id'];
|
|
|
+ }
|
|
|
+ $collaboration = Collection::whereIn('uid', $resId)->where('owner','<>', $studioId)->count();
|
|
|
+
|
|
|
+ return $this->ok(['my'=>$my,'collaboration'=>$collaboration]);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Store a newly created resource in storage.
|
|
|
*
|