service = MaterialService::getInstance(); // 只放行素材名与文件夹:对象键、体积、哈希都是同步结果,不接受手工改 $this->updateField = ['id', 'name', 'folder_id']; $this->notRequest = ['name', 'folder_id']; } /** * 素材概览统计 * * @Method GET * @throws Exception */ public function stat(): JsonResponse { return jok($this->service->stat(), '统计获取成功'); } /** * 从 OSS 增量同步对象 * * @Method POST * @throws Exception */ public function syncFromOss(): JsonResponse { $this->insertField = ['oss_config_id']; $this->notRequest = ['prefix', 'marker', 'limit']; $params = $this->checkRequiredFields(request()->post()); return jok($this->service->syncFromOss($params), '同步完成'); } /** * 全库引用扫描 * * @Method POST * @throws Exception */ public function scanReferences(): JsonResponse { // 表多、正文长时会跑几十秒,先把执行时限和内存放开 cc_set_time_limit(); return jok($this->service->scanReferences(request()->post()), '扫描完成'); } /** * 无引用素材清单 * * @Method GET * @throws Exception */ public function unusedList(): JsonResponse { return jok($this->service->unusedList(request()->query()), '列表获取成功'); } /** * 回收:删远端对象并软删记录 * * @Method POST * @throws Exception */ public function reclaim(): JsonResponse { $ids = request()->post('ids'); if (empty($ids) || !is_array($ids)) { UtilsService::getInstance()->notFound('参数错误'); } return jok($this->service->reclaim($ids), '回收完成'); } /** * 批量移动到文件夹 * * @Method POST * @throws Exception */ public function moveToFolder(): JsonResponse { $ids = request()->post('ids'); if (empty($ids) || !is_array($ids)) { UtilsService::getInstance()->notFound('参数错误'); } return jok( $this->service->moveToFolder($ids, (int) request()->post('folder_id', 0)), '移动成功' ); } }