Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sh-ds
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李良停
sh-ds
Commits
0c1a6c5b
Commit
0c1a6c5b
authored
May 04, 2022
by
wangsong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update api
parent
ffe4ea54
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
6 deletions
+40
-6
StatisticsController.java
...den/authcenter/agent/controller/StatisticsController.java
+40
-6
No files found.
eden-authcenter-agent/src/main/java/com/chineseall/eden/authcenter/agent/controller/StatisticsController.java
View file @
0c1a6c5b
...
...
@@ -2,6 +2,7 @@ package com.chineseall.eden.authcenter.agent.controller;
import
cn.sh.chineseall.framework.api.MapMessage
;
import
cn.sh.chineseall.framework.core.util.CollectionUtils
;
import
cn.sh.chineseall.framework.core.util.MathUtils
;
import
cn.sh.chineseall.framework.core.util.StringUtils
;
import
cn.sh.chineseall.framework.lang.calendar.DateUtils
;
import
com.chineseall.eden.authcenter.agent.client.ClientItem
;
...
...
@@ -12,6 +13,7 @@ import com.chineseall.eden.authcenter.config.service.AuthSourceService;
import
com.chineseall.eden.authcenter.log.service.AuthLogService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
...
...
@@ -37,7 +39,7 @@ public class StatisticsController {
*
* @return
*/
@
Reques
tMapping
(
"auth_apps"
)
@
Ge
tMapping
(
"auth_apps"
)
@ResponseBody
public
MapMessage
authApps
()
{
...
...
@@ -47,7 +49,7 @@ public class StatisticsController {
if
(
CollectionUtils
.
isNotEmpty
(
clientList
)){
clientList
.
forEach
(
item
->
{
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"c
ode
"
,
item
.
getKey
());
data
.
put
(
"c
lientId
"
,
item
.
getKey
());
data
.
put
(
"name"
,
item
.
getName
());
result
.
add
(
data
);
});
...
...
@@ -68,7 +70,7 @@ public class StatisticsController {
* @param topN topN
* @return 指定app的认证数
*/
@
Reques
tMapping
(
"app"
)
@
Ge
tMapping
(
"app"
)
@ResponseBody
public
MapMessage
applications
(
@RequestParam
(
value
=
"clientId"
,
required
=
false
)
String
clientId
,
@RequestParam
(
value
=
"latestDays"
,
defaultValue
=
"7"
)
Integer
latestDays
,
@RequestParam
(
value
=
"topN"
,
required
=
false
)
Integer
topN
)
{
List
<
StatItem
>
dataList
=
new
ArrayList
<>();
...
...
@@ -163,7 +165,7 @@ public class StatisticsController {
*
* @return
*/
@
Reques
tMapping
(
"auth_hot_org"
)
@
Ge
tMapping
(
"auth_hot_org"
)
@ResponseBody
public
MapMessage
authHotOrgs
(
@RequestParam
(
value
=
"clientId"
,
required
=
false
)
String
clientId
,
@RequestParam
(
value
=
"latestDays"
,
defaultValue
=
"7"
)
Integer
latestDays
,
@RequestParam
(
value
=
"topN"
,
required
=
false
)
Integer
topN
)
{
Map
<
String
,
Object
>
param
=
new
HashMap
<>();
...
...
@@ -201,7 +203,7 @@ public class StatisticsController {
*
* @return
*/
@
Reques
tMapping
(
"auth_user_type"
)
@
Ge
tMapping
(
"auth_user_type"
)
@ResponseBody
public
MapMessage
authUserTypes
(
@RequestParam
(
value
=
"clientId"
,
required
=
false
)
String
clientId
,
@RequestParam
(
value
=
"latestDays"
,
defaultValue
=
"7"
)
Integer
latestDays
)
{
...
...
@@ -256,7 +258,7 @@ public class StatisticsController {
}
@
Reques
tMapping
(
"auth_user_type_sum"
)
@
Ge
tMapping
(
"auth_user_type_sum"
)
@ResponseBody
public
MapMessage
authUserTypeSum
(
@RequestParam
(
value
=
"clientId"
,
required
=
false
)
String
clientId
,
@RequestParam
(
value
=
"latestDays"
,
defaultValue
=
"7"
)
Integer
latestDays
)
{
...
...
@@ -291,4 +293,36 @@ public class StatisticsController {
}
/**
* 认证高峰时间数据统计
*
* @return
*/
@GetMapping
(
"auth_pick_times"
)
@ResponseBody
public
MapMessage
authPickTimes
(
@RequestParam
(
value
=
"clientId"
,
required
=
false
)
String
clientId
,
@RequestParam
(
value
=
"latestDays"
,
defaultValue
=
"7"
)
Integer
latestDays
)
{
Map
<
String
,
Object
>
param
=
new
HashMap
<>();
param
.
put
(
"loginSuccessFlag"
,
true
);
if
(
clientId
!=
null
){
param
.
put
(
"clientId"
,
clientId
);
}
Date
startDate
=
getStartDay
(
latestDays
);
List
<
Integer
>
hourList
=
new
ArrayList
<>();
List
<
Long
>
hourCountList
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
24
;
i
++){
param
.
put
(
"hour"
,
i
);
long
count
=
authLogService
.
count
(
param
,
startDate
);
hourList
.
add
(
i
);
hourCountList
.
add
(
Double
.
valueOf
(
MathUtils
.
doubleDivide
(
count
,
latestDays
,
0
)).
longValue
());
}
return
MapMessage
.
successMessage
().
add
(
"hourList"
,
hourList
).
add
(
"dataList"
,
hourCountList
);
}
}
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