更新文件管理

This commit is contained in:
yaooo 2023-11-28 11:53:35 +08:00
parent e34fc42e86
commit 8cdc2879c0
2 changed files with 19 additions and 5 deletions

View File

@ -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());

View File

@ -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();
}
}