dyjh 6 vuotta sitten
vanhempi
commit
73f2ff20a5

+ 3 - 55
app/Http/Controllers/Admin/Album/AgentController.php

xqd xqd
@@ -121,29 +121,11 @@ class AgentController extends Controller
             return $this->_updateSave();
         }
         $data = $this->repository->find($request->get('id'));
-        $banner = AgentBannerModel::where([['agent_id',$data['id']],['type',0]])->get();
-        $imgs = array();
-        foreach($banner as $key=>$val){
-            $imgs[] = $val['url'];
-        }
-        $data->agent_banner = $imgs;
-        $video = AgentBannerModel::where([['agent_id',$request->get('id')],['type',1]])->first();
-        return view('admin.album.agent.edit',compact('data','video'));
-    }
 
-    public function videoDel(Request $request)
-    {
-        $check = AgentBannerModel::find($request->get('id'));
-        if($check) $osskey = $check->oss_key;
-        if(!$check) return  $this->showWarning("操作失败");
-        $bool = AgentBannerModel::where('id',$request->get('id'))->delete();
-        if($bool) {
-            OSS::publicDeleteObject(config('alioss.BucketName'),$osskey);
-            return  $this->showMessage('操作成功');
-        }else{
-            return  $this->showWarning("操作失败");
-        }
+        return view('admin.album.agent.edit',compact('data'));
     }
+
+
     /**
      * 保存修改
      */
@@ -222,39 +204,5 @@ class AgentController extends Controller
     }
 
 
-    public function uploadVideo(Request $request)
-    {
-        $video = $request->file('video');
-// 判断图片有效性
-        if (!$video) {
-            return back()->withErrors('上传视频无效..');
-        }
-        $agentid = $request->input('agent_id');
-        $check = AgentBannerModel::where([['agent_id',$agentid],['type',1]])->first();
-        if($check) OSS::publicDeleteObject(config('alioss.BucketName'),$check->oss_key);
-// 获取图片在临时文件中的地址
-        $videoPath = $video->getRealPath();
-
-// 制作文件名
-        $ex = $video->getClientOriginalExtension();
-        $key = time() . rand(10000, 99999999) . '.' . $ex;
-
-//阿里 OSS 文件上传
-        $result = OSS::publicUpload(config('alioss.BucketName'),$key, $videoPath);
-        if ($result) {
-            $data['name'] = $video->getClientOriginalName();
-            $data['type'] = 1;
-            $data['agent_id'] = $agentid;
-            $data['oss_key'] =  $key;
-            $data['url'] = config('alioss.FileUrl').$key;
-            $video = AgentBannerModel::create($data);
-            if(!$video){
-                return back()->withErrors('上传视频失败..');
-            }
-            return  $this->showMessage('上传成功');
 
-        } else {
-            return back()->withErrors('上传视频失败..');
-        }
-    }
 }

+ 59 - 0
app/Http/Controllers/Admin/Album/ManufacturerController.php

xqd xqd xqd xqd
@@ -8,8 +8,10 @@
  */
 namespace App\Http\Controllers\Admin\Album;
 use App\Http\Controllers\Admin\Controller;
+use App\Models\AgentBannerModel;
 use App\Models\AlbumManufacturerModel;
 use App\Models\AlbumUserModel;
+use App\Services\OSS;
 use Illuminate\Http\Request;
 use App\Repositories\Base\Criteria\OrderBy;
 use App\Repositories\Album\Criteria\MultiWhere;
@@ -49,6 +51,13 @@ class ManufacturerController extends Controller
         if ($data) {
             $data['banner'] = json_decode($data['banner'], true);
         }
+        $banner = AgentBannerModel::where([['store_id',$this->getStoreId()],['type',0]])->get();
+        $imgs = array();
+        foreach($banner as $key=>$val){
+            $imgs[] = $val['url'];
+        }
+        $data->agent_banner = $imgs;
+        $video = AgentBannerModel::where([['agent_id',$request->get('id')],['type',1]])->first();
         return view('admin.album.manufacturer.edit',compact('data'));
     }
 
@@ -57,6 +66,7 @@ class ManufacturerController extends Controller
         if ($request->method() == 'POST') {
             return $this->_createSave();
         }
+
         return view('admin.album.manufacturer.edit');
     }
 
@@ -178,4 +188,53 @@ class ManufacturerController extends Controller
             return  $this->showWarning("操作失败");
         }
     }
+
+    public function uploadVideo(Request $request)
+    {
+        $video = $request->file('video');
+// 判断图片有效性
+        if (!$video) {
+            return back()->withErrors('上传视频无效..');
+        }
+        $agentid = $request->input('agent_id');
+        $check = AgentBannerModel::where([['agent_id',$agentid],['type',1]])->first();
+        if($check) OSS::publicDeleteObject(config('alioss.BucketName'),$check->oss_key);
+// 获取图片在临时文件中的地址
+        $videoPath = $video->getRealPath();
+
+// 制作文件名
+        $ex = $video->getClientOriginalExtension();
+        $key = time() . rand(10000, 99999999) . '.' . $ex;
+
+//阿里 OSS 文件上传
+        $result = OSS::publicUpload(config('alioss.BucketName'),$key, $videoPath);
+        if ($result) {
+            $data['name'] = $video->getClientOriginalName();
+            $data['type'] = 1;
+            $data['agent_id'] = $agentid;
+            $data['oss_key'] =  $key;
+            $data['url'] = config('alioss.FileUrl').$key;
+            $video = AgentBannerModel::create($data);
+            if(!$video){
+                return back()->withErrors('上传视频失败..');
+            }
+            return  $this->showMessage('上传成功');
+
+        } else {
+            return back()->withErrors('上传视频失败..');
+        }
+    }
+    public function videoDel(Request $request)
+    {
+        $check = AgentBannerModel::find($request->get('id'));
+        if($check) $osskey = $check->oss_key;
+        if(!$check) return  $this->showWarning("操作失败");
+        $bool = AgentBannerModel::where('id',$request->get('id'))->delete();
+        if($bool) {
+            OSS::publicDeleteObject(config('alioss.BucketName'),$osskey);
+            return  $this->showMessage('操作成功');
+        }else{
+            return  $this->showWarning("操作失败");
+        }
+    }
 }

+ 11 - 7
app/Http/Controllers/Api/V1/AlbumController.php

xqd
@@ -2092,15 +2092,19 @@ class AlbumController extends Controller
     {
         $userAuth = Auth('api')->user();
         if(!$userAuth) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '未登录!');
-        if($userAuth->up_agent_id == 0){
-            $user_agent = AlbumAgentModel::where('user_id',$userAuth->id)->first();
-            $agent_id = $user_agent['id'];
-        }else{
-            $agent_id = $userAuth->up_agent_id;
+        $validator = Validator::make($request->all(), [
+            'store_id' => 'required',
+        ],[
+            'store_id.required'=>'缺少商户参数',
+        ]);
+        if ($validator->fails()) {
+            return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
         }
+        $store_id = $request->input('store_id');
+
 
-        $banner = AgentBannerModel::where([['agent_id',$agent_id],['type',0]])->get();
-        $video = AgentBannerModel::where([['agent_id',$agent_id],['type',1]])->first();
+        $banner = AgentBannerModel::where([['store_id',$store_id],['type',0]])->get();
+        $video = AgentBannerModel::where([['store_id',$store_id],['type',1]])->first();
         return $this->api(compact('banner','video'));
     }
 

+ 33 - 0
database/migrations/2019_04_26_105614_edit_agent_to_store_at_agent_banner.php

xqd
@@ -0,0 +1,33 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class EditAgentToStoreAtAgentBanner extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('agent_banner', function (Blueprint $table) {
+            //
+            $table->renameColumn('agent_id', 'store_id');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('agent_banner', function (Blueprint $table) {
+            //
+        });
+    }
+}

+ 68 - 0
resources/views/admin/album/manufacturer/edit.blade.php

xqd
@@ -411,12 +411,80 @@
                             </div>
                             <!-- /.col-lg-10 -->
                         </div>
+                        <div class="row">
+                            <div class="col-sm-12">
+                                <div class="container kv-main">
+                                    <div class="page-header">
+                                        <h3 class="text-success">视频管理</h3>
+                                    </div>
+                                    <form enctype="multipart/form-data" method="post" action="{{ url('/admin/Album/Agent/uploadVideo') }}">
+                                        <div class="form-group">
+                                            <input id="file-0b" class="file" type="file" name="video">
+                                            <input name="agent_id" type="hidden" value="{{ $data['id'] or ''}}">
+                                        </div>
+                                        {{csrf_field()}}
+                                    </form>
+                                </div>
+                            </div>
+                        </div>
                         <!-- /.row -->
                     </div>
                 </div>
             </div>
         </div>
 
+        <div class="row">
+            <div class="col-sm-12">
+                <div class="ibox float-e-margins">
+                    <div class="ibox-title">
+                        <h5>视频列表</h5>
+                    </div>
+                    <div class="ibox-content">
+
+                        <table class="table">
+                            <thead>
+                            <tr>
+                                <th>#</th>
+                                <th>链接</th>
+                                <th>文件名</th>
+                                <th>操作</th>
+                            </tr>
+                            </thead>
+                            <tbody>
+                            @if(!empty($video))
+                                <tr>
+                                    <td>{{ $video['id'] }}</td>
+                                    <td>{{ $video['name'] }}</td>
+                                    <td>{{ $video['url'] }}</td>
+                                    <td>
+                                        <div class="btn-group">
+                                            <button data-toggle="dropdown"
+                                                    class="btn btn-warning btn-sm dropdown-toggle"
+                                                    aria-expanded="false">
+                                                操作 <span class="caret"></span>
+                                            </button>
+                                            <ul class="dropdown-menu">
+                                                <li><a href="{{ U('Album/Agent/videoDel',['id'=>$video['id']])}}" onclick="return confirm('你确定执行删除操作?');">删除</a></li>
+                                            </ul>
+                                        </div>
+
+
+                                    </td>
+                                </tr>
+                            @else
+                                <tr>
+                                    <td colspan="4">暂无文件</td>
+                                </tr>
+                            @endif
+
+                            </tbody>
+                        </table>
+
+                    </div>
+                </div>
+            </div>
+        </div>
+
         <div class="modal fade" id="myModal" tabindex="-1" role="dialog"
              aria-labelledby="myModalLabel" aria-hidden="true">
             <div class="modal-dialog" style="min-width:60%;">