all(),[ 'corpid' => 'required|string', 'type' => ['required', Rule::in([1, 2, 3, 4])], 'need_media_id' => ['nullable', Rule::in([0, 1])], ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $file = $request->file('material_file'); $corpid = $request->input('corpid'); $type = $request->input('type'); $needMediaId = $request->input('need_media_id'); $uploadToOss = $request->input('upload_to_oss', 1); $data = []; $errno = MaterialService::uploadMaterial($corpid, $type, $file, $needMediaId, $uploadToOss, $data); return self::returnValue($data, $errno); } /** * 导入excel * @param Request $request * @return mixed */ public function importExcel(Request $request) { $validator = \Validator::make($request->all(),[ 'corpid' => 'required|string', 'file' => 'required|file', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $file = $request->file('file'); $corpid = $request->input('corpid'); $importType = $request->input('import_type', 1); list($res, $code) = ImportService::importExcel($file, $corpid, $importType); return self::returnValue($res, $code); } public function uploadFileToOss(Request $request) { $validator = \Validator::make($request->all(),[ 'type' => ['required', Rule::in([1, 2, 3, 4])], ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $file = $request->file('file'); $corpid = $request->input('corpid'); $type = $request->input('type'); $isMaterial = $request->input('is_material', 1); $data = []; $errno = MaterialService::uploadFileToOss($corpid, $type, $file, $isMaterial, $data); return self::returnValue($data, $errno); } public function uploadFileByUrl(Request $request) { $validator = \Validator::make($request->all(),[ 'corpid' => 'required|string', 'img_url' => 'required|string', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $corpid = $request->input('corpid'); $imgUrl = $request->input('img_url'); $ossUrl = ''; $errno = MaterialService::uploadFileByUrl($corpid, $imgUrl, $ossUrl); return self::returnValue(['oss_url' => $ossUrl], $errno); } }