Commit 40966149 authored by mengyixi's avatar mengyixi

deleteFile

parents cb989fdc 7d1e07c0
...@@ -11,8 +11,8 @@ namespace App\Contracts; ...@@ -11,8 +11,8 @@ namespace App\Contracts;
interface FileServiceContract interface FileServiceContract
{ {
// 根据团队ID 查询当前团队所有文件
public function getAll(); public function getAll($group_id);
public function get($id); public function get($id);
public function delete($file_id); public function delete($file_id);
} }
\ No newline at end of file
...@@ -23,6 +23,9 @@ class FileController extends Controller ...@@ -23,6 +23,9 @@ class FileController extends Controller
public function delete(Request $request) public function delete(Request $request)
{ {
$file_id = $request; $file_id = $request;
$this->mFile->delete($file_id); $result = $this->mFile->delete($file_id);
if($result){
return view(route('500'));
}
} }
} }
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Contracts\FileServiceContract;
use App\Contracts\GroupServiceContract; use App\Contracts\GroupServiceContract;
use App\Contracts\UserServiceContract; use App\Contracts\UserServiceContract;
use App\Util\Message; use App\Util\Message;
...@@ -13,10 +14,11 @@ class GroupController extends Controller ...@@ -13,10 +14,11 @@ class GroupController extends Controller
public $mGroup; public $mGroup;
public function __construct(GroupServiceContract $group, UserServiceContract $user ) public function __construct(GroupServiceContract $group, UserServiceContract $user ,FileServiceContract $fileHandel)
{ {
$this->mGroup = $group; $this->mGroup = $group;
$this->mUser = $user; $this->mUser = $user;
$this->mFile = $fileHandel;
} }
...@@ -33,11 +35,12 @@ class GroupController extends Controller ...@@ -33,11 +35,12 @@ class GroupController extends Controller
{ {
$id = $request->id; $id = $request->id;
$groups = $this->mGroup->get($id); $groups = $this->mGroup->get($id);
$files = $this->mFile->getAll(120);
if ($groups){ if ($groups){
return view('admin/group/groupinformation',compact('groups')); return view('admin/group/groupinformation',compact('groups','files'));
} }
return Message::makeError('查找失败'); return Message::makeError('查找失败');
} }
......
...@@ -7,17 +7,23 @@ ...@@ -7,17 +7,23 @@
*/ */
namespace App\Services; namespace App\Services;
use App\Models\File;
use App\Models\File;
use App\Contracts\FileServiceContract; use App\Contracts\FileServiceContract;
class FileService implements FileServiceContract class FileService implements FileServiceContract
{ {
public function getAll() public function getAll($group_id)
{ {
dd(1); $files = File::where('group_id',$group_id)->get();
if($files->isEmpty()){
return null;
}
return $files;
} }
public function get($id) public function get($id)
...@@ -28,6 +34,8 @@ class FileService implements FileServiceContract ...@@ -28,6 +34,8 @@ class FileService implements FileServiceContract
public function delete($file_id) public function delete($file_id)
{ {
// TODO: Implement delete() method. // TODO: Implement delete() method.
// $file = $file =File::where(["id"=>file_id])->get();
$result = $file->delete();
return $result;
} }
} }
\ No newline at end of file
...@@ -92,90 +92,47 @@ ...@@ -92,90 +92,47 @@
<th>文件名</th> <th>文件名</th>
<th>类型</th> <th>类型</th>
<th>size</th> <th>size</th>
<th>状态</th> <th>文件夹</th>
<th>所属项目</th> <th>所属项目</th>
<th>创建者</th>
<th>操作</th> <th>操作</th>
</tr> </tr>
</thead> </thead>
{{--@if($groups == null)--}} @if($files == null)
<tbody> <tbody>
<tr> <tr>
<td colspan="8" style="text-align: center;color: red"> 数据暂无 </td> <td colspan="8" style="text-align: center;color: red"> 数据暂无 </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
{{--@else--}} @else
{{--@foreach($groups as $group)--}} @foreach($files as $file)
<tbody> <tbody>
<tr> <tr>
<td></td> <td>{{$file->id}}</td>
<td></td> <td>{{$file->name}}</td>
<td></td> <td>{{$file->file_type}}</td>
<td></td> <td>{{$file->size}}</td>
<td></td> <td>{{$file->folder_id}}</td>
<td></td> <td>{{$file->project_id}}</td>
<td></td> <td>{{$file->creator_id}}</td>
<td><a href="{{$file->id}}" class="btn btn-info" > 查看详情</a>
<a href="{{$file->id}}" class="btn bg-orange" > 删除</a>
</td>
</tr> </tr>
</tbody> </tbody>
@endforeach
@endif
</table> </table>
</div> </div>
<!-- /.tab-pane --> <!-- /.tab-pane -->
<div class="tab-pane" id="settings"> <div class="tab-pane" id="settings">
<h3> wowowo 我这里什么都没有 </h3> <h3> wowowo 我这里什么都没有 </h3>
{{--<form class="form-horizontal">--}}
{{--<div class="form-group">--}}
{{--<label for="inputName" class="col-sm-2 control-label">Name</label>--}}
{{--<div class="col-sm-10">--}}
{{--<input type="email" class="form-control" id="inputName" placeholder="Name">--}}
{{--</div>--}}
{{--</div>--}}
{{--<div class="form-group">--}}
{{--<label for="inputEmail" class="col-sm-2 control-label">Email</label>--}}
{{--<div class="col-sm-10">--}}
{{--<input type="email" class="form-control" id="inputEmail" placeholder="Email">--}}
{{--</div>--}}
{{--</div>--}}
{{--<div class="form-group">--}}
{{--<label for="inputName" class="col-sm-2 control-label">Name</label>--}}
{{--<div class="col-sm-10">--}}
{{--<input type="text" class="form-control" id="inputName" placeholder="Name">--}}
{{--</div>--}}
{{--</div>--}}
{{--<div class="form-group">--}}
{{--<label for="inputExperience" class="col-sm-2 control-label">Experience</label>--}}
{{--<div class="col-sm-10">--}}
{{--<textarea class="form-control" id="inputExperience" placeholder="Experience"></textarea>--}}
{{--</div>--}}
{{--</div>--}}
{{--<div class="form-group">--}}
{{--<label for="inputSkills" class="col-sm-2 control-label">Skills</label>--}}
{{--<div class="col-sm-10">--}}
{{--<input type="text" class="form-control" id="inputSkills" placeholder="Skills">--}}
{{--</div>--}}
{{--</div>--}}
{{--<div class="form-group">--}}
{{--<div class="col-sm-offset-2 col-sm-10">--}}
{{--<div class="checkbox">--}}
{{--<label>--}}
{{--<input type="checkbox"> I agree to the <a href="#">terms and conditions</a>--}}
{{--</label>--}}
{{--</div>--}}
{{--</div>--}}
{{--</div>--}}
{{--<div class="form-group">--}}
{{--<div class="col-sm-offset-2 col-sm-10">--}}
{{--<button type="submit" class="btn btn-danger">Submit</button>--}}
{{--</div>--}}
{{--</div>--}}
{{--</form>--}}
</div> </div>
<!-- /.tab-pane --> <!-- /.tab-pane -->
</div> </div>
...@@ -191,7 +148,6 @@ ...@@ -191,7 +148,6 @@
@endsection @endsection
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment