diff --git a/app/adminapi/controller/UploadController.php b/app/adminapi/controller/UploadController.php index 1bee7dd3..0d6722bb 100644 --- a/app/adminapi/controller/UploadController.php +++ b/app/adminapi/controller/UploadController.php @@ -36,7 +36,7 @@ class UploadController extends BaseAdminController { try { $cid = $this->request->post('cid', 0); - $result = UploadService::image($cid); + $result = UploadService::image($cid, $this->adminInfo['user_id']); return $this->success('上传成功', $result); } catch (Exception $e) { return $this->fail($e->getMessage()); @@ -53,7 +53,7 @@ class UploadController extends BaseAdminController { try { $cid = $this->request->post('cid', 0); - $result = UploadService::video($cid); + $result = UploadService::video($cid, $this->adminInfo['user_id']); return $this->success('上传成功', $result); } catch (Exception $e) { return $this->fail($e->getMessage()); diff --git a/app/adminapi/lists/file/FileLists.php b/app/adminapi/lists/file/FileLists.php index 31d0c969..e88671a0 100644 --- a/app/adminapi/lists/file/FileLists.php +++ b/app/adminapi/lists/file/FileLists.php @@ -42,6 +42,19 @@ class FileLists extends BaseAdminDataLists implements ListsSearchInterface ]; } + public function userSearch(): array + { + $userWhere['source_id'] = 0; + // 超级管理员数据 + if ($this->adminInfo['root'] && !$this->adminInfo['user_id']) { + unset($userWhere['source_id']); + } + // 普通用户数据 + if (!$this->adminInfo['root'] && $this->adminInfo['user_id']) { + $userWhere['source_id'] = $this->adminInfo['user_id']; + } + return $userWhere; + } /** * @notes 获取文件列表 @@ -57,7 +70,8 @@ class FileLists extends BaseAdminDataLists implements ListsSearchInterface $lists = (new File())->field(['id,cid,type,name,uri,create_time']) ->order('id', 'desc') ->where($this->searchWhere) - ->where('source', FileEnum::SOURCE_ADMIN) + ->where($this->userSearch()) + // ->where('source', FileEnum::SOURCE_ADMIN) ->limit($this->limitOffset, $this->limitLength) ->select() ->toArray(); @@ -79,8 +93,8 @@ class FileLists extends BaseAdminDataLists implements ListsSearchInterface */ public function count(): int { - return (new File())->where($this->searchWhere) - ->where('source', FileEnum::SOURCE_ADMIN) + return (new File())->where($this->searchWhere)->where($this->userSearch()) + // ->where('source', FileEnum::SOURCE_ADMIN) ->count(); } } \ No newline at end of file