客户剩余接口次数查询接口增加总次数和已用次数
This commit is contained in:
+12
-8
@@ -149,17 +149,21 @@ public class UsersController {
|
||||
// 改成遍历用户有的uri
|
||||
for (OpenResource openResource : userResources) {
|
||||
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) {
|
||||
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 total = apiVisitCountService.findApiVisitAllCount(id, uri, DateUtil.truncateDay(new Date()));
|
||||
info.setSurplusCallCount(countMap.get(uri) - curVistedCount - total);
|
||||
list.add(info);
|
||||
long historyCount = apiVisitCountService.findApiVisitAllCount(id, uri, DateUtil.truncateDay(new Date()));
|
||||
Integer totalCount = countMap.get(uri);
|
||||
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 apiName;
|
||||
private Long surplusCallCount;
|
||||
private Long totalCallCount;
|
||||
private Long usedCallCount;
|
||||
private Date endTime;
|
||||
|
||||
public Long getSurplusCallCount() {
|
||||
@@ -60,5 +62,20 @@ public class ApiMonitorInfo {
|
||||
public void setApiName(String 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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user