\App\Services\ApiMyFileService

我的文件服务

职责:个人中心文件管理的数据口径——一切查询/清空强制 user_id = 本人; 文件级操作(改名/移动/复制/回收站等)先经 assertMyFile 前置校验 (他人文件 400 隐藏存在性),再复用 MaintainFileService; 预览/下载走 assertVisibleFile(本人或共享——头像等共享文件可展示)。

Summary

Methods
Properties
Constants
__construct()
paginate()
trashList()
folders()
usage()
assertMyFile()
assertVisibleFile()
assertMyFolder()
filterMyIds()
purgeTrash()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
myQuery()
$fileService
N/A

Properties

Methods

__construct()

__construct(\App\Services\Admin\MaintainFileService  $fileService) : mixed

Parameters

\App\Services\Admin\MaintainFileService $fileService

Returns

mixed —

paginate()

paginate(array  $filters = [], int  $perPage = 15) : mixed

文件列表(仅本人上传;过滤参数与文件维护页同构)。

Parameters

array $filters
int $perPage

Returns

mixed —

trashList()

trashList(array  $filters = [], int  $perPage = 15) : mixed

回收站列表(仅本人;支持关键词/类型筛选,与文件维护页同构)。

Parameters

array $filters
int $perPage

Returns

mixed —

folders()

folders() : array

目录树(仅本人维度):复用文件维护的本人树查询,公共分区与维护权 不进入个人中心(与「这里只生效我个人的文件」语义一致)。

Returns

array —

usage()

usage() : array

空间用量(复用 MaintainFileService::usage,按本人 id 统计)。

Returns

array —

assertMyFile()

assertMyFile(\App\Models\SysFile  $file) : void

文件归属校验:非本人文件一律拒绝(个人中心无越权面;基类异常映射 只区分 403/400,此处按业务错误 400 处理)。

Parameters

\App\Models\SysFile $file

Throws

\InvalidArgumentException

他人文件

assertVisibleFile()

assertVisibleFile(\App\Models\SysFile  $file) : void

可见性校验(预览/下载用):本人文件或共享文件(is_shared=1)可访问。

个人中心列表仅展示本人文件,但头像等共享文件(avatar 场景自动共享, 可能由管理员经 admin 线代传)需在本人中心展示——预览/下载按 「本人+共享」口径放行(与文件维护页 assertVisible 一致); 其余操作仍强制 assertMyFile。

Parameters

\App\Models\SysFile $file

Throws

\InvalidArgumentException

非本人且非共享

assertMyFolder()

assertMyFolder(\App\Models\SysFileFolder  $folder, int  $userId) : void

目录归属校验:非本人目录一律拒绝(与 assertMyFile 同口径隐藏存在性—— 个人中心目录操作不得暴露他人目录的存在)。

Parameters

\App\Models\SysFileFolder $folder
int $userId

当前登录用户 id(控制器解析传入)

Throws

\InvalidArgumentException

他人目录

filterMyIds()

filterMyIds(int[]  $ids) : int[]

批量 ids 仅保留本人文件(界面只显示本人的,防御性过滤防绕过)。

Parameters

int[] $ids

Returns

int[] —

purgeTrash()

purgeTrash() : int

清空本人回收站:物理文件(含缩略图变体)与 DB 记录一并清理, 口径与文件维护页 purgeTrash 同构,仅限定本人。

Returns

int —

myQuery()

myQuery(array  $filters, int  $status) : mixed

本人查询基座:状态 + `user_id = 当前登录用户` + 与文件维护页同构的过滤。

Parameters

array $filters
int $status

Returns

mixed —