Commit 0c1a6c5b authored by wangsong's avatar wangsong

update api

parent ffe4ea54
...@@ -2,6 +2,7 @@ package com.chineseall.eden.authcenter.agent.controller; ...@@ -2,6 +2,7 @@ package com.chineseall.eden.authcenter.agent.controller;
import cn.sh.chineseall.framework.api.MapMessage; import cn.sh.chineseall.framework.api.MapMessage;
import cn.sh.chineseall.framework.core.util.CollectionUtils; 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.core.util.StringUtils;
import cn.sh.chineseall.framework.lang.calendar.DateUtils; import cn.sh.chineseall.framework.lang.calendar.DateUtils;
import com.chineseall.eden.authcenter.agent.client.ClientItem; import com.chineseall.eden.authcenter.agent.client.ClientItem;
...@@ -12,6 +13,7 @@ import com.chineseall.eden.authcenter.config.service.AuthSourceService; ...@@ -12,6 +13,7 @@ import com.chineseall.eden.authcenter.config.service.AuthSourceService;
import com.chineseall.eden.authcenter.log.service.AuthLogService; import com.chineseall.eden.authcenter.log.service.AuthLogService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; 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.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
...@@ -37,7 +39,7 @@ public class StatisticsController { ...@@ -37,7 +39,7 @@ public class StatisticsController {
* *
* @return * @return
*/ */
@RequestMapping("auth_apps") @GetMapping("auth_apps")
@ResponseBody @ResponseBody
public MapMessage authApps() { public MapMessage authApps() {
...@@ -47,7 +49,7 @@ public class StatisticsController { ...@@ -47,7 +49,7 @@ public class StatisticsController {
if (CollectionUtils.isNotEmpty(clientList)){ if (CollectionUtils.isNotEmpty(clientList)){
clientList.forEach(item -> { clientList.forEach(item -> {
Map<String, Object> data = new HashMap<>(); Map<String, Object> data = new HashMap<>();
data.put("code", item.getKey()); data.put("clientId", item.getKey());
data.put("name", item.getName()); data.put("name", item.getName());
result.add(data); result.add(data);
}); });
...@@ -68,7 +70,7 @@ public class StatisticsController { ...@@ -68,7 +70,7 @@ public class StatisticsController {
* @param topN topN * @param topN topN
* @return 指定app的认证数 * @return 指定app的认证数
*/ */
@RequestMapping("app") @GetMapping("app")
@ResponseBody @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) { 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<>(); List<StatItem> dataList = new ArrayList<>();
...@@ -163,7 +165,7 @@ public class StatisticsController { ...@@ -163,7 +165,7 @@ public class StatisticsController {
* *
* @return * @return
*/ */
@RequestMapping("auth_hot_org") @GetMapping("auth_hot_org")
@ResponseBody @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) { 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<>(); Map<String,Object> param = new HashMap<>();
...@@ -201,7 +203,7 @@ public class StatisticsController { ...@@ -201,7 +203,7 @@ public class StatisticsController {
* *
* @return * @return
*/ */
@RequestMapping("auth_user_type") @GetMapping("auth_user_type")
@ResponseBody @ResponseBody
public MapMessage authUserTypes(@RequestParam(value = "clientId", required = false) String clientId, @RequestParam(value = "latestDays", defaultValue = "7") Integer latestDays) { public MapMessage authUserTypes(@RequestParam(value = "clientId", required = false) String clientId, @RequestParam(value = "latestDays", defaultValue = "7") Integer latestDays) {
...@@ -256,7 +258,7 @@ public class StatisticsController { ...@@ -256,7 +258,7 @@ public class StatisticsController {
} }
@RequestMapping("auth_user_type_sum") @GetMapping("auth_user_type_sum")
@ResponseBody @ResponseBody
public MapMessage authUserTypeSum(@RequestParam(value = "clientId", required = false) String clientId, @RequestParam(value = "latestDays", defaultValue = "7") Integer latestDays) { public MapMessage authUserTypeSum(@RequestParam(value = "clientId", required = false) String clientId, @RequestParam(value = "latestDays", defaultValue = "7") Integer latestDays) {
...@@ -291,4 +293,36 @@ public class StatisticsController { ...@@ -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);
}
} }
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