客户剩余接口次数查询接口增加总次数和已用次数

This commit is contained in:
majintao
2024-08-12 15:17:51 +08:00
parent e318980b48
commit 156e09d4df
2 changed files with 30 additions and 9 deletions
@@ -149,17 +149,21 @@ public class UsersController {
// 改成遍历用户有的uri // 改成遍历用户有的uri
for (OpenResource openResource : userResources) { for (OpenResource openResource : userResources) {
String uri = openResource.getUri(); String uri = openResource.getUri();
ApiMonitorInfo info = new ApiMonitorInfo();
info.setApiUri(uri);
info.setApiName(openResource.getName());
info.setUserId((int) id);
info.setUsername(user.getUserName());
if (null != countMap.get(uri) && countMap.get(uri) > 0) { if (null != countMap.get(uri) && countMap.get(uri) > 0) {
ApiMonitorInfo info = new ApiMonitorInfo();
info.setApiUri(uri);
info.setApiName(openResource.getName());
info.setUserId((int) id);
info.setUsername(user.getUserName());
long curVistedCount = apiVisitCountService.findApiVisitCountByDay(id, uri, DateUtil.truncateDay(new Date())); long curVistedCount = apiVisitCountService.findApiVisitCountByDay(id, uri, DateUtil.truncateDay(new Date()));
long total = apiVisitCountService.findApiVisitAllCount(id, uri, DateUtil.truncateDay(new Date())); long historyCount = apiVisitCountService.findApiVisitAllCount(id, uri, DateUtil.truncateDay(new Date()));
info.setSurplusCallCount(countMap.get(uri) - curVistedCount - total); Integer totalCount = countMap.get(uri);
list.add(info); info.setTotalCallCount(Long.valueOf(totalCount));
long usedCount = curVistedCount + historyCount;
info.setSurplusCallCount(totalCount - usedCount);
info.setUsedCallCount(usedCount);
} }
list.add(info);
} }
} }
@@ -10,6 +10,8 @@ public class ApiMonitorInfo {
private String apiUri; private String apiUri;
private String apiName; private String apiName;
private Long surplusCallCount; private Long surplusCallCount;
private Long totalCallCount;
private Long usedCallCount;
private Date endTime; private Date endTime;
public Long getSurplusCallCount() { public Long getSurplusCallCount() {
@@ -61,4 +63,19 @@ public class ApiMonitorInfo {
this.apiName = apiName; this.apiName = apiName;
} }
public Long getTotalCallCount() {
return totalCallCount;
}
public void setTotalCallCount(Long totalCallCount) {
this.totalCallCount = totalCallCount;
}
public Long getUsedCallCount() {
return usedCallCount;
}
public void setUsedCallCount(Long usedCallCount) {
this.usedCallCount = usedCallCount;
}
} }