From 42d16cde8f2ceb85db2fdb5e022054ae2cc01188 Mon Sep 17 00:00:00 2001 From: majintao Date: Mon, 2 Sep 2024 14:08:27 +0800 Subject: [PATCH] =?UTF-8?q?api=E6=AC=A1=E6=95=B0=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E5=A2=9E=E5=8A=A0=E5=AE=A2=E6=88=B7=E6=98=B5?= =?UTF-8?q?=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bkoff/controllers/ApiUserController.java | 31 +++++++++++-------- .../src/main/webapp/apiCountLog/list.ftl | 2 ++ .../src/main/webapp/apiUser/auth.ftl | 4 +-- .../fangjia/dal/mongo/model/ApiCountLog.java | 11 +++++++ 4 files changed, 33 insertions(+), 15 deletions(-) diff --git a/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/ApiUserController.java b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/ApiUserController.java index 2acac8e27..3f67b111c 100644 --- a/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/ApiUserController.java +++ b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/ApiUserController.java @@ -98,16 +98,16 @@ public class ApiUserController { ArrayList queryParams = new ArrayList(); if (model.getStatus() != null) { queryParams.add(new QueryParam("status", model.getStatus())); - }else { - queryParams.add(new QueryParam("status",0)); + } else { + queryParams.add(new QueryParam("status", 0)); } - if (model.getIsTest()!=null){ - queryParams.add(new QueryParam("isTest",model.getIsTest())); - }else { - queryParams.add(new QueryParam("isTest",0)); + if (model.getIsTest() != null) { + queryParams.add(new QueryParam("isTest", model.getIsTest())); + } else { + queryParams.add(new QueryParam("isTest", 0)); } - if (model.getPurpose()!=null){ - queryParams.add(new QueryParam("purpose",model.getPurpose())); + if (model.getPurpose() != null) { + queryParams.add(new QueryParam("purpose", model.getPurpose())); } List apiUsers = this.apiUserService.findApiUsersByParamsSortDate(queryParams); List apiUserBoList = new ArrayList(); @@ -738,22 +738,27 @@ public class ApiUserController { ApiCountLog apiCountLog = new ApiCountLog(); if (countMap != null && countMap.containsKey(model.getUri())) { String bkoffUserId = (String) ThreadLocalData.getInstance().get(ThreadLocalKey.UserId); + User user = userService.findById(userId); BkoffUsers bkoffUser = bkoffUsersService.findBkoffUsersById(bkoffUserId); apiCountLog.setUserId(userId); + apiCountLog.setUserName(user.getDisplayName()); apiCountLog.setUri(model.getUri()); apiCountLog.setUriName(apiMap.get(model.getUri())); apiCountLog.setOperator(bkoffUser.getRealName()); Integer oldCount = countMap.get(model.getUri()); apiCountLog.setOldCount(oldCount); apiCountLog.setNewCount(count); - if (count >= oldCount){ - apiCountLog.setOperate("增加"+(count-oldCount)+"次"); - }else if (oldCount > count){ - apiCountLog.setOperate("减少"+(oldCount-count)+"次"); + if (count > oldCount) { + apiCountLog.setOperate("增加" + (count - oldCount) + "次"); + } else if (oldCount > count) { + apiCountLog.setOperate("减少" + (oldCount - count) + "次"); } apiCountLog.setOperateTime(new Date()); - apiCountLogService.save(apiCountLog); + // 次数改变了再记录 + if (!count.equals(oldCount)) { + apiCountLogService.save(apiCountLog); + } } totalCountMap.put(model.getUri(), count); authority.setTotalCountMap(totalCountMap); diff --git a/projects/fangjia-bkoff/src/main/webapp/apiCountLog/list.ftl b/projects/fangjia-bkoff/src/main/webapp/apiCountLog/list.ftl index 5c5f75cfa..06fbad4d6 100644 --- a/projects/fangjia-bkoff/src/main/webapp/apiCountLog/list.ftl +++ b/projects/fangjia-bkoff/src/main/webapp/apiCountLog/list.ftl @@ -30,6 +30,7 @@ + @@ -41,6 +42,7 @@ <#list apiCountLogList as it> + diff --git a/projects/fangjia-bkoff/src/main/webapp/apiUser/auth.ftl b/projects/fangjia-bkoff/src/main/webapp/apiUser/auth.ftl index 0a4f1da6f..100afe5b8 100644 --- a/projects/fangjia-bkoff/src/main/webapp/apiUser/auth.ftl +++ b/projects/fangjia-bkoff/src/main/webapp/apiUser/auth.ftl @@ -106,9 +106,9 @@   / <#if bo.totalCountMap?? && bo.totalCountMap[bo.uri!]??> - + <#else> - + diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/ApiCountLog.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/ApiCountLog.java index 32a112ff3..00b512da9 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/ApiCountLog.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/ApiCountLog.java @@ -16,6 +16,8 @@ public class ApiCountLog implements MongoEntity { private Long userId; + private String userName; + private String uri; private String uriName; @@ -113,4 +115,13 @@ public class ApiCountLog implements MongoEntity { public void setNewCount(Integer newCount) { this.newCount = newCount; } + + @Column(name = "user_name") + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } }
鐢ㄦ埛ID鐢ㄦ埛鏄电О uri API鍚嶇О 鎿嶄綔
${it.userId!}${it.userName!} ${it.uri!} ${it.uriName!} ${it.operate!}