Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
workbiu-admin
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gxx
workbiu-admin
Commits
ecb006a8
Commit
ecb006a8
authored
Dec 12, 2017
by
mengyixi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
countspace
parent
9d437dfd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
6 deletions
+46
-6
FileServiceContract.php
app/Contracts/FileServiceContract.php
+2
-0
FileController.php
app/Http/Controllers/FileController.php
+18
-6
FileService.php
app/Services/FileService.php
+24
-0
web.php
routes/web.php
+2
-0
No files found.
app/Contracts/FileServiceContract.php
View file @
ecb006a8
...
@@ -15,4 +15,6 @@ interface FileServiceContract
...
@@ -15,4 +15,6 @@ interface FileServiceContract
public
function
getAll
(
$group_id
);
public
function
getAll
(
$group_id
);
public
function
get
(
$id
);
public
function
get
(
$id
);
public
function
delete
(
$file_id
);
public
function
delete
(
$file_id
);
public
function
groupSpace
(
$group_id
);
public
function
ossSpace
(
$group_id
);
}
}
\ No newline at end of file
app/Http/Controllers/FileController.php
View file @
ecb006a8
...
@@ -30,12 +30,24 @@ class FileController extends Controller
...
@@ -30,12 +30,24 @@ class FileController extends Controller
}
}
}
}
public
function
deleteFormOss
(
Request
$request
)
public
function
groupSpace
(
Request
$request
)
{
{
$file_id
=
$request
;
$group_id
=
$request
->
group_id
;
$result
=
$this
->
mFile
->
delete
(
$file_id
);
$result
=
$this
->
mFile
->
groupSpace
(
$group_id
);
if
(
$result
){
$mbyte
=
$result
/
1048576
;
return
view
(
route
(
'500'
));
$finalspace
=
array
(
"space"
=>
10485760
,
"usespace"
=>
$mbyte
);
}
$finalspace
=
json_encode
(
$finalspace
);
return
$finalspace
;
}
public
function
ossSpace
(
Request
$request
)
{
$group_id
=
$request
->
group_id
;
$result
=
$this
->
mFile
->
groupSpace
(
$group_id
);
$mbyte
=
$result
/
1048576
;
$finalspace
=
array
(
"space"
=>
10485760
,
"usespace"
=>
$mbyte
);
$finalspace
=
json_encode
(
$finalspace
);
return
$finalspace
;
}
}
}
}
app/Services/FileService.php
View file @
ecb006a8
...
@@ -59,4 +59,28 @@ class FileService implements FileServiceContract
...
@@ -59,4 +59,28 @@ class FileService implements FileServiceContract
// }
// }
return
$result
;
return
$result
;
}
}
public
function
groupSpace
(
$group_id
)
{
$files
=
File
::
where
([
"group"
=>
$group_id
])
->
get
();
$space
=
0
;
foreach
(
$files
as
$file
)
{
$size
=
$file
->
size
;
$space
=
$space
+
$size
;
}
return
$space
;
}
public
function
ossSpace
(
$group_id
)
{
$files
=
File
::
where
([
"group"
=>
$group_id
])
->
get
()
->
unique
(
"pointer"
);
$space
=
0
;
foreach
(
$files
as
$file
)
{
$size
=
$file
->
size
;
$space
=
$space
+
$size
;
}
return
$space
;
}
}
}
\ No newline at end of file
routes/web.php
View file @
ecb006a8
...
@@ -115,6 +115,8 @@ Route::get('/',function (){return view('login');})->name('admin.login');
...
@@ -115,6 +115,8 @@ Route::get('/',function (){return view('login');})->name('admin.login');
Route
::
group
([
'prefix'
=>
'file'
],
function
(){
Route
::
group
([
'prefix'
=>
'file'
],
function
(){
Route
::
get
(
'get_all'
,
'FileController@getAll'
)
->
name
(
'file.getAll'
);
Route
::
get
(
'get_all'
,
'FileController@getAll'
)
->
name
(
'file.getAll'
);
Route
::
delete
(
'delete_file'
,
'FileController@delete'
)
->
name
(
'file.delete'
);
Route
::
delete
(
'delete_file'
,
'FileController@delete'
)
->
name
(
'file.delete'
);
Route
::
get
(
'group_space'
,
'FileController@groupSpace'
)
->
name
(
'file.groupspace'
);
Route
::
get
(
'oss_space'
,
'FileController@ossSpace'
)
->
name
(
'file.ossspace'
);
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment