保存文件
Showing
2 changed files
with
63 additions
and
8 deletions
... | @@ -247,10 +247,10 @@ class PropertyTrackService extends Service | ... | @@ -247,10 +247,10 @@ class PropertyTrackService extends Service |
247 | } | 247 | } |
248 | 248 | ||
249 | /** | 249 | /** |
250 | * 歌曲文件存储 | 250 | * 歌曲文件存储 (分享页面) |
251 | * @return \Illuminate\Http\JsonResponse|mixed | 251 | * @return \Illuminate\Http\JsonResponse|mixed |
252 | */ | 252 | */ |
253 | public function fileSave() | 253 | public function shareFileSave() |
254 | { | 254 | { |
255 | try { | 255 | try { |
256 | 256 | ||
... | @@ -258,12 +258,7 @@ class PropertyTrackService extends Service | ... | @@ -258,12 +258,7 @@ class PropertyTrackService extends Service |
258 | 258 | ||
259 | DB::transaction(function () use ($fileTypes){ | 259 | DB::transaction(function () use ($fileTypes){ |
260 | 260 | ||
261 | $upload_user = ''; | ||
262 | if ($this->request->input('from') == 1) { | ||
263 | $upload_user = $this->request->get('identifier') ? $this->request->get('identifier')->user_id : ''; | ||
264 | } elseif ($this->request->input('from') == 2) { | ||
265 | $upload_user = PropertyShare::query()->where(['id'=>$this->request->get('id')])->pluck('phone')->first(); | 261 | $upload_user = PropertyShare::query()->where(['id'=>$this->request->get('id')])->pluck('phone')->first(); |
266 | } | ||
267 | 262 | ||
268 | //property_track_files | 263 | //property_track_files |
269 | $res = PropertyTrackFile::query()->create([ | 264 | $res = PropertyTrackFile::query()->create([ |
... | @@ -311,6 +306,65 @@ class PropertyTrackService extends Service | ... | @@ -311,6 +306,65 @@ class PropertyTrackService extends Service |
311 | } | 306 | } |
312 | 307 | ||
313 | /** | 308 | /** |
309 | * 歌曲文件存储 | ||
310 | * @return \Illuminate\Http\JsonResponse|mixed | ||
311 | */ | ||
312 | public function fileSave() | ||
313 | { | ||
314 | try { | ||
315 | |||
316 | $fileTypes = $this->request->input('file_types'); | ||
317 | |||
318 | DB::transaction(function () use ($fileTypes){ | ||
319 | |||
320 | $upload_user = $this->request->get('identifier') ? $this->request->get('identifier')->user_id : ''; | ||
321 | |||
322 | //property_track_files | ||
323 | $res = PropertyTrackFile::query()->create([ | ||
324 | 'pt_id' => $this->request->get('track_id'), | ||
325 | 'name' => $this->request->input('name'), | ||
326 | 'size_byte' => $this->request->input('size'), | ||
327 | 'upload_user' => $upload_user, | ||
328 | 'upload_ip' => $this->request->input('upload_ip'), //上传客户端ip | ||
329 | 'from' => $this->request->input('from'), // 0:版权 1:分贝登录用户 2:通过分享 | ||
330 | ]); | ||
331 | |||
332 | $data = []; | ||
333 | foreach ($fileTypes as $tpye_id) { | ||
334 | $data[] = [ | ||
335 | 'pt_id' => $this->request->input('track_id'), | ||
336 | 'p_file_id' => $res->id, | ||
337 | 'p_type_id' => $tpye_id, | ||
338 | 'created_at'=> $this->now, | ||
339 | ]; | ||
340 | } | ||
341 | |||
342 | //property_track_file_types | ||
343 | PropertyTrackFileType::query()->insert($data); | ||
344 | |||
345 | //file_maps | ||
346 | FileMap::query()->create([ | ||
347 | 'user_id' => $this->request->get('identifier')->user_id, | ||
348 | 'company_id' => $this->request->get('identifier')->company_id, | ||
349 | 'name' => $this->request->input('name'), | ||
350 | 'path' => $this->request->input('dir'), | ||
351 | 'location' => $this->request->input('location'), | ||
352 | 'key' => $this->request->input('url'), | ||
353 | 'mime' => $this->request->input('mime'), | ||
354 | 'size' => $this->request->input('size'), | ||
355 | 'link' => 'property', | ||
356 | 'link_id' => $res->id, | ||
357 | ]); | ||
358 | }); | ||
359 | |||
360 | return Response::success(); | ||
361 | } catch (\Throwable $throwable) { | ||
362 | Log::info(__METHOD__, ['msg'=>$throwable->getMessage()]); | ||
363 | return Response::error(); | ||
364 | } | ||
365 | } | ||
366 | |||
367 | /** | ||
314 | * @return \Illuminate\Http\JsonResponse|mixed | 368 | * @return \Illuminate\Http\JsonResponse|mixed |
315 | */ | 369 | */ |
316 | public function getCosToken() | 370 | public function getCosToken() | ... | ... |
... | @@ -19,6 +19,7 @@ Route::group(["prefix"=>"property", "middleware"=>['auth.identifier']], function | ... | @@ -19,6 +19,7 @@ Route::group(["prefix"=>"property", "middleware"=>['auth.identifier']], function |
19 | Route::get('/track/pending', 'PropertyTrackController@pending'); | 19 | Route::get('/track/pending', 'PropertyTrackController@pending'); |
20 | Route::get('/track/file', 'PropertyTrackController@file'); | 20 | Route::get('/track/file', 'PropertyTrackController@file'); |
21 | Route::post('/track/shareCreate', 'PropertyTrackController@shareCreate'); | 21 | Route::post('/track/shareCreate', 'PropertyTrackController@shareCreate'); |
22 | Route::post('/track/fileSave', 'PropertyTrackController@fileSave'); | ||
22 | }); | 23 | }); |
23 | 24 | ||
24 | Route::group(["prefix"=>"property"], function (){ | 25 | Route::group(["prefix"=>"property"], function (){ |
... | @@ -33,7 +34,7 @@ Route::group(["prefix"=>"property", "middleware"=>['auth.share']], function (){ | ... | @@ -33,7 +34,7 @@ Route::group(["prefix"=>"property", "middleware"=>['auth.share']], function (){ |
33 | Route::get('/track/shareShow', 'PropertyTrackController@shareShow'); | 34 | Route::get('/track/shareShow', 'PropertyTrackController@shareShow'); |
34 | Route::get('/track/shareFile', 'PropertyTrackController@shareFile'); | 35 | Route::get('/track/shareFile', 'PropertyTrackController@shareFile'); |
35 | Route::post('/track/getCosToken', 'PropertyTrackController@getCosToken'); | 36 | Route::post('/track/getCosToken', 'PropertyTrackController@getCosToken'); |
36 | Route::post('/track/fileSave', 'PropertyTrackController@fileSave'); | 37 | Route::post('/track/shareFileSave', 'PropertyTrackController@shareFileSave'); |
37 | }); | 38 | }); |
38 | 39 | ||
39 | 40 | ... | ... |
-
Please register or sign in to post a comment