Merge branch 'dev' into 'master'

后台优化

See merge request !795
This commit is contained in:
2024-01-24 14:09:05 +08:00
4 changed files with 1705 additions and 1613 deletions
@@ -63,7 +63,6 @@ public class ApiUserController {
private ApiCountCityService apiCountCityService; private ApiCountCityService apiCountCityService;
/** /**
* 所有api用户的信息展示 * 所有api用户的信息展示
* *
@@ -186,6 +185,9 @@ public class ApiUserController {
apiUser.setManager(model.getManager()); apiUser.setManager(model.getManager());
apiUser.setIsMonitor(model.getIsMonitor()); apiUser.setIsMonitor(model.getIsMonitor());
this.apiUserService.save(apiUser); this.apiUserService.save(apiUser);
// 新增用户,默认挂牌价改为默认评估价
model.setPriceType("evaluate");
modifyUserCfg(id, ApiUserCfg.ApiUserCfgKey.PRICE_TYPE, model.getPriceType());
if (model.getEvaluateRate() != null && model.getEvaluateRate() != 0) { if (model.getEvaluateRate() != null && model.getEvaluateRate() != 0) {
ApiUserCfg apiUserCfg = new ApiUserCfg(); ApiUserCfg apiUserCfg = new ApiUserCfg();
apiUserCfg.setUserId(apiUser.getId()); apiUserCfg.setUserId(apiUser.getId());
@@ -552,10 +554,31 @@ public class ApiUserController {
User user = this.userService.findById(model.getUserId()); User user = this.userService.findById(model.getUserId());
model.setDisplayName(user.getDisplayName() == null ? "" : user.getDisplayName()); model.setDisplayName(user.getDisplayName() == null ? "" : user.getDisplayName());
Map<String, Integer> urisMap = authority.getOpenResourseUrisMap(); Map<String, Integer> urisMap = authority.getOpenResourseUrisMap();
// 用户有的uri
String flag = model.getMsg();
List<OpenResource> userResources = new ArrayList<OpenResource>();
if ("0".equals(flag)) {
for (OpenResource openResource : openResourceList) { for (OpenResource openResource : openResourceList) {
if (!authority.getOpenResourseUris().contains(openResource.getUri())) {
userResources.add(openResource);
}
}
} else {
for (OpenResource openResource : openResourceList) {
if (authority.getOpenResourseUris().contains(openResource.getUri())) {
userResources.add(openResource);
}
}
}
// 改成遍历用户有的uri
for (OpenResource openResource : userResources) {
AuthorityBo bo = new AuthorityBo(); AuthorityBo bo = new AuthorityBo();
BeanUtils.copyProperties(openResource, bo); BeanUtils.copyProperties(openResource, bo);
if (authority != null) { if (authority != null) {
bo.setHasAuth(authority.getOpenResourseUris().contains(bo.getUri()));
bo.setHasAuth(authority.getOpenResourseUris().contains(bo.getUri())); bo.setHasAuth(authority.getOpenResourseUris().contains(bo.getUri()));
model.setSupportLatLng(authority.isSupportLatLng()); model.setSupportLatLng(authority.isSupportLatLng());
bo.setLimitCountMap(authority.getLimitCountMap()); bo.setLimitCountMap(authority.getLimitCountMap());
@@ -986,8 +1009,7 @@ public class ApiUserController {
if (model.getWay() != 3) { if (model.getWay() != 3) {
model.setStatAnalyBoList(sortStatAnaly(bos)); model.setStatAnalyBoList(sortStatAnaly(bos));
model.setChartSeries(toChartString(bos)); model.setChartSeries(toChartString(bos));
} } else {
else {
model.setChartSeries(toChartString(bos)); model.setChartSeries(toChartString(bos));
model.setEachCityBoList(eachCityBos); model.setEachCityBoList(eachCityBos);
} }
@@ -1030,7 +1052,8 @@ public class ApiUserController {
if (model.getQuery().equals("uri")) { if (model.getQuery().equals("uri")) {
bos = createAnalyBosByLink(analys); bos = createAnalyBosByLink(analys);
model.setChartSeries(toChartString(bos)); model.setChartSeries(toChartString(bos));
}if(model.getQuery().equals("day")){ }
if (model.getQuery().equals("day")) {
bos = createAnalyByCity(analys, "day"); bos = createAnalyByCity(analys, "day");
List<Date> list = new ArrayList<Date>(); List<Date> list = new ArrayList<Date>();
@@ -1214,6 +1237,7 @@ public class ApiUserController {
return bos; return bos;
} }
private List<StatAnalyBo> sortStatAnaly(List<StatAnalyBo> bos) { private List<StatAnalyBo> sortStatAnaly(List<StatAnalyBo> bos) {
Collections.sort(bos, new Comparator<StatAnalyBo>() { Collections.sort(bos, new Comparator<StatAnalyBo>() {
@Override @Override
@@ -1229,6 +1253,7 @@ public class ApiUserController {
return bos; return bos;
} }
private Map<String, String> converMapData(List<OpenResource> resources) { private Map<String, String> converMapData(List<OpenResource> resources) {
Map<String, String> map = new HashMap<String, String>(); Map<String, String> map = new HashMap<String, String>();
for (OpenResource resource : resources) { for (OpenResource resource : resources) {
@@ -1318,8 +1343,7 @@ public class ApiUserController {
list1.add(list2.get(0) + apiCountCity.getSuccess()); list1.add(list2.get(0) + apiCountCity.getSuccess());
list1.add(list2.get(1) + apiCountCity.getFail()); list1.add(list2.get(1) + apiCountCity.getFail());
map.put(apiCountCity.getCity(), list1); map.put(apiCountCity.getCity(), list1);
} } else {
else {
List<Integer> list1 = new ArrayList<Integer>(); List<Integer> list1 = new ArrayList<Integer>();
list1.add(apiCountCity.getSuccess()); list1.add(apiCountCity.getSuccess());
list1.add(apiCountCity.getFail()); list1.add(apiCountCity.getFail());
@@ -1576,7 +1600,8 @@ public class ApiUserController {
if (successInvalidCount != null) { if (successInvalidCount != null) {
successInvalidCount = successInvalidCount + apiInvokeStatistical.getSuccessInvalidTime(); successInvalidCount = successInvalidCount + apiInvokeStatistical.getSuccessInvalidTime();
} else { } else {
successInvalidCount = apiInvokeStatistical.getSuccessInvalidTime();; successInvalidCount = apiInvokeStatistical.getSuccessInvalidTime();
;
} }
if (defeatCount != null) { if (defeatCount != null) {
defeatCount = defeatCount + apiInvokeStatistical.getDefeatTime(); defeatCount = defeatCount + apiInvokeStatistical.getDefeatTime();
@@ -1591,6 +1616,7 @@ public class ApiUserController {
return resultMap; return resultMap;
} }
public void setApiUserService(ApiUserService apiUserService) { public void setApiUserService(ApiUserService apiUserService) {
this.apiUserService = apiUserService; this.apiUserService = apiUserService;
} }
@@ -1646,16 +1672,13 @@ public class ApiUserController {
this.apiCountCityService = apiCountCityService; this.apiCountCityService = apiCountCityService;
} }
public Map<String,Integer> string2map(String str) public Map<String, Integer> string2map(String str) {
{
Map<String, Integer> map = new HashMap<String, Integer>(); Map<String, Integer> map = new HashMap<String, Integer>();
String[] a = str.split(","); String[] a = str.split(",");
for (String i : a) for (String i : a) {
{
String[] b = i.split(":"); String[] b = i.split(":");
if (b.length > 1) if (b.length > 1) {
{
map.put(b[0], Integer.parseInt(b[1])); map.put(b[0], Integer.parseInt(b[1]));
} }
} }
@@ -11,6 +11,26 @@
<script type="text/javascript"> <script type="text/javascript">
</script> </script>
<#-- 将表头固定-->
<style>
table {
width: 100%;
border-collapse: collapse;
table-layout: fixed;
}
th, td {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}
th {
position: sticky;
top: 0;
background-color: #f2f2f2;
}
</style>
</head> </head>
<body> <body>
@@ -31,12 +51,13 @@
<div class="list"> <div class="list">
<table width="50%"> <table width="50%">
<thead> <thead>
<tr>Ap <tr>
API数量:&nbsp<b>${authorityBoList?size}</b>个
<th align="center" width="15%"> <th align="center" width="15%">
uri uri
</th> </th>
<th align="center" width="15%"> <th align="center" width="15%">
描述 API名称
</th> </th>
<th align="center" width="10%"> <th align="center" width="10%">
是否有权限<input type="checkbox" id="auth" >全选</input> 是否有权限<input type="checkbox" id="auth" >全选</input>
@@ -63,7 +84,7 @@
${bo.uri!} ${bo.uri!}
</td> </td>
<td align="center"> <td align="center">
${bo.description!} ${bo.name!}
</td> </td>
<td align="center"> <td align="center">
<input type="checkbox" <#if bo.hasAuth>checked </#if> id="auth_${bo_index + 1}" ></input> <input type="checkbox" <#if bo.hasAuth>checked </#if> id="auth_${bo_index + 1}" ></input>
@@ -1,12 +1,39 @@
<#ftl attributes={"content_type":"text/html; charset=UTF-8"}> <#ftl attributes={"content_type":"text/html; charset=UTF-8"}>
<#compress> <#compress>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>api用户列表</title> <title>api用户列表</title>
<link rel="stylesheet" type="text/css" href="../style/main.css?v=${version}"/> <link rel="stylesheet" type="text/css" href="../style/main.css?v=${version}"/>
<#include "/common_js.ftl" /> <#include "/common_js.ftl" />
<#-- 将表头固定-->
<style>
table {
width: 100%;
border-collapse: collapse;
table-layout: fixed;
}
th, td {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}
th {
position: sticky;
top: 0;
background-color: #f2f2f2;
}
.resizable-td {
resize: horizontal; /* 允许水平调整大小 */
overflow: auto; /* 显示滚动条以便查看超出部分 */
min-width: 50px; /* 设置最小宽度,防止过于缩小 */
}
</style>
</head> </head>
<body> <body>
<#include "/layout/header.ftl" /> <#include "/layout/header.ftl" />
@@ -44,7 +71,7 @@
<th align="center" width="100px"> <th align="center" width="100px">
公司 公司
</th> </th>
<th align="center" width="550px"> <th align="center" width="150px">
appKey appKey
</th> </th>
<th align="center" width="60px"> <th align="center" width="60px">
@@ -98,7 +125,7 @@
<td align="center"> <td align="center">
${bo.company!} ${bo.company!}
</td> </td>
<td align="center"> <td align="center" class="resizable-td">
${bo.appKey!} ${bo.appKey!}
</td> </td>
<td align="center"> <td align="center">
@@ -130,13 +157,15 @@
</#if> </#if>
</td> </td>
<td align="center"> <td align="center">
<a href="../apiUser/auth?userId=${bo.userId!}">权限控制</a> <a href="../apiUser/auth?userId=${bo.userId!}">API权限控制</a>
<a href="../apiUser/auth?userId=${bo.userId!}&msg=0">新增API</a>
<a href="../apiUser/city?userId=${bo.userId!}">城市管理</a> <a href="../apiUser/city?userId=${bo.userId!}">城市管理</a>
<a href="../apiUser/priceRating?userId=${bo.userId!}">价格评级</a> <a href="../apiUser/priceRating?userId=${bo.userId!}">价格评级</a>
<#if bo.status==0> <#if bo.status==0>
<a href="javascript:if(confirm('确认禁用?')){location.href='../apiUser/status?userId=${bo.userId!}&status=1'}">禁用</a> <a href="javascript:if(confirm('确认禁用?')){location.href='../apiUser/status?userId=${bo.userId!}&status=1'}">禁用</a>
<#else> <#else>
<a href="javascript:if(confirm('确认再次启用?')){location.href='../apiUser/status?userId=${bo.userId!}&status=0'}"><font style="color:#198B3D;">再启用</font></a> <a href="javascript:if(confirm('确认再次启用?')){location.href='../apiUser/status?userId=${bo.userId!}&status=0'}"><font
style="color:#198B3D;">再启用</font></a>
</#if> </#if>
</td> </td>
</tr> </tr>
@@ -8,6 +8,25 @@
.up {color: green;} .up {color: green;}
#spinner{width:500px;height:100px;margin:30px 0 0 100px;text-align:center;padding-top:50px;border:2px solid #CCC;} #spinner{width:500px;height:100px;margin:30px 0 0 100px;text-align:center;padding-top:50px;border:2px solid #CCC;}
#checkMsg{width:500px;margin:30px 0 0 100px;padding:10px 0 10px 50px;text-align:left;border:2px solid #CCC;} #checkMsg{width:500px;margin:30px 0 0 100px;padding:10px 0 10px 50px;text-align:left;border:2px solid #CCC;}
<#-- 将表头固定-->
table {
width: 100%;
border-collapse: collapse;
table-layout: fixed;
}
th, td {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}
th {
position: sticky;
top: 0;
background-color: #f2f2f2;
}
</style> </style>
</head> </head>
<body> <body>