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
b0bf964e
Commit
b0bf964e
authored
Dec 12, 2017
by
mengyixi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
文件类型统计
parent
d3a8f3e3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
4 deletions
+29
-4
FileServiceContract.php
app/Contracts/FileServiceContract.php
+1
-0
FileController.php
app/Http/Controllers/FileController.php
+7
-0
FileService.php
app/Services/FileService.php
+20
-0
web.php
routes/web.php
+1
-4
No files found.
app/Contracts/FileServiceContract.php
View file @
b0bf964e
...
...
@@ -17,4 +17,5 @@ interface FileServiceContract
public
function
delete
(
$file_id
);
public
function
groupSpace
(
$group_id
);
public
function
ossSpace
(
$group_id
);
public
function
countFile
(
$group_id
);
}
\ No newline at end of file
app/Http/Controllers/FileController.php
View file @
b0bf964e
...
...
@@ -52,4 +52,11 @@ class FileController extends Controller
$finalspace
=
json_encode
(
$finalspace
);
return
$finalspace
;
}
public
function
countFile
(
Request
$request
)
{
$group_id
=
$request
->
group_id
;
$result
=
$this
->
mFile
->
countFile
(
$group_id
);
return
json_encode
(
$result
);
}
}
app/Services/FileService.php
View file @
b0bf964e
...
...
@@ -86,4 +86,24 @@ class FileService implements FileServiceContract
}
return
$space
;
}
public
function
countFile
(
$group_id
)
{
$files
=
File
::
where
([
"group_id"
=>
$group_id
])
->
get
();
$count
=
$files
->
count
();
$files
=
$files
->
groupBy
(
"file_type"
);
$files
=
$files
->
toArray
();
$files_keys
=
array_keys
(
$files
);
$result
=
array
();
$i
=
0
;
foreach
(
$files
as
$type
){
$files_keys
[
$i
]
=
count
(
$type
);
$per
=
$files_keys
[
$i
]
/
$count
;
$per
=
floor
(
$per
*
100
)
.
"%"
;
$keyValue
=
array
(
"value"
=>
$per
,
"name"
=>
$files_keys
[
$i
]);
array_push
(
$result
,
$keyValue
);
$i
++
;
}
return
$result
;
}
}
\ No newline at end of file
routes/web.php
View file @
b0bf964e
...
...
@@ -116,11 +116,8 @@ Route::get('/',function (){return view('login');})->name('admin.login');
Route
::
get
(
'get_all'
,
'FileController@getAll'
)
->
name
(
'file.getAll'
);
Route
::
delete
(
'delete_file'
,
'FileController@delete'
)
->
name
(
'file.delete'
);
Route
::
get
(
'group_space'
,
'FileController@groupSpace'
)
->
name
(
'file.groupSpace'
);
<<<<<<<
HEAD
Route
::
get
(
'oss_space'
,
'FileController@ossSpace'
)
->
name
(
'file.ossSpace'
);
=======
Route
::
get
(
'oss_space'
,
'FileController@ossSpace'
)
->
name
(
'file.ossspace'
);
>>>>>>>
b17167244102ea0cfb09e3d1f3cb459cddf1c995
Route
::
get
(
'count_file'
,
'FileController@countFile'
)
->
name
(
'file.countFile'
);
});
...
...
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