新增APICode
This commit is contained in:
+2
-1
@@ -623,7 +623,8 @@ public class ApiUserController {
|
||||
* @param AuthorityBo
|
||||
* :用户的appKey username、等资料
|
||||
*/
|
||||
List<OpenResource> openResourceList = openResourceService.findAll();
|
||||
List<QueryParam> queryParams = Arrays.asList(new QueryParam("pubStatus", 1));
|
||||
List<OpenResource> openResourceList = openResourceService.findOpenResource(queryParams);
|
||||
List<AuthorityBo> authorityBoList = new ArrayList<AuthorityBo>();
|
||||
ApiUserAuthority authority = apiUserAuthorityService.findByUserId(model.getUserId());
|
||||
if (authority == null) {
|
||||
|
||||
+17
-5
@@ -2,10 +2,7 @@ package com.fangjia.bkoff.controllers;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
import com.fangjia.bkoff.model.JsonModel;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@@ -42,6 +39,15 @@ public class OpenResourceController {
|
||||
}
|
||||
|
||||
public Object doAddAction(OpenResourceModel model) {
|
||||
List<OpenResource> openResource = this.openResourceService.findOpenResource(null);
|
||||
HashSet<Integer> apiCodeSet = new HashSet<Integer>();
|
||||
for (OpenResource resource : openResource) {
|
||||
apiCodeSet.add(resource.getApiCode());
|
||||
}
|
||||
if (model.getApiCode() != 0 && apiCodeSet.contains(model.getApiCode())){
|
||||
model.setMsg("APICode已存在");
|
||||
return model;
|
||||
}
|
||||
if (!"doAdd".equals(model.getMethod())) {
|
||||
return model;
|
||||
}
|
||||
@@ -70,7 +76,9 @@ public class OpenResourceController {
|
||||
OpenResource r = new OpenResource();
|
||||
r.setUri(uri);
|
||||
r.setName(name);
|
||||
r.setApiCode(model.getApiCode());
|
||||
r.setSaveResult(model.getSave_result());
|
||||
r.setPubStatus(model.getPubStatus() ? 1 : 0);
|
||||
r.setDescription(model.getDescription());
|
||||
this.openResourceService.save(r);
|
||||
model.setMsg("添加成功!");
|
||||
@@ -80,6 +88,7 @@ public class OpenResourceController {
|
||||
public Object doChangeAction(OpenResourceModel model){
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
data.put("saveResult",model.getSave_result());
|
||||
data.put("pubStatus",model.getPubStatus() ? 1 : 0);
|
||||
this.openResourceService.update(data,model.getId());
|
||||
model.setMsg("保存成功");
|
||||
JsonModel model1 = new JsonModel();
|
||||
@@ -105,6 +114,9 @@ public class OpenResourceController {
|
||||
if (StringUtils.isNotBlank(model.getDescription())) {
|
||||
data.put("description", model.getDescription());
|
||||
}
|
||||
if (0 != model.getApiCode()){
|
||||
data.put("apiCode",model.getApiCode());
|
||||
}
|
||||
List<QueryParam> params = new ArrayList<QueryParam>();
|
||||
params.add(new QueryParam("uri", uri));
|
||||
params.add(new QueryParam("name", name));
|
||||
@@ -141,7 +153,7 @@ public class OpenResourceController {
|
||||
|
||||
/**
|
||||
* 格式化URI
|
||||
*
|
||||
*
|
||||
* @param uri
|
||||
* @return
|
||||
*/
|
||||
|
||||
@@ -28,6 +28,9 @@ public class OpenResourceModel extends BaseModel {
|
||||
private Boolean save_result;
|
||||
|
||||
private OpenResource or;
|
||||
private Boolean pubStatus;
|
||||
|
||||
private int apiCode;
|
||||
|
||||
public String getExceptId() {
|
||||
return exceptId;
|
||||
@@ -116,4 +119,20 @@ public class OpenResourceModel extends BaseModel {
|
||||
public void setSave_result(Boolean save_result) {
|
||||
this.save_result = save_result;
|
||||
}
|
||||
|
||||
public Boolean getPubStatus() {
|
||||
return pubStatus;
|
||||
}
|
||||
|
||||
public void setPubStatus(Boolean pubStatus) {
|
||||
this.pubStatus = pubStatus;
|
||||
}
|
||||
|
||||
public int getApiCode() {
|
||||
return apiCode;
|
||||
}
|
||||
|
||||
public void setApiCode(int apiCode) {
|
||||
this.apiCode = apiCode;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,11 @@
|
||||
top: 0;
|
||||
background-color: #f2f2f2;
|
||||
}
|
||||
.resizable-td {
|
||||
resize: horizontal; /* 允许水平调整大小 */
|
||||
overflow: auto; /* 显示滚动条以便查看超出部分 */
|
||||
min-width: 50px; /* 设置最小宽度,防止过于缩小 */
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
@@ -58,28 +63,33 @@
|
||||
<thead>
|
||||
<tr>
|
||||
API数量: <b>${authorityBoList?size}</b>个
|
||||
<th align="center" width="15%">
|
||||
<th align="center" width="50px">
|
||||
APICode
|
||||
</th>
|
||||
<th align="center" width="100px">
|
||||
uri
|
||||
</th>
|
||||
<th align="center" width="15%">
|
||||
<th align="center" width="100px">
|
||||
API名称
|
||||
</th>
|
||||
<th align="center" width="10%">
|
||||
是否有权限<input type="checkbox" id="auth" >全选</input>
|
||||
<th align="center" width="60px">
|
||||
是否有权限</br>
|
||||
<input type="checkbox" id="auth" >全选</input>
|
||||
</th>
|
||||
<th align="center" width="30%">
|
||||
<th align="center" width="100px">
|
||||
访问最大次数(每天)/(总数)
|
||||
</th>
|
||||
<th align="center" width="15%">
|
||||
<th align="center" width="60px">
|
||||
访问次数修改
|
||||
</th>
|
||||
<th align="center" width="10%">
|
||||
是否按查得计费<input type="checkbox" id="isCheckCount" >全选</input>
|
||||
<th align="center" width="70px">
|
||||
是否按查得计费</br>
|
||||
<input type="checkbox" id="isCheckCount" >全选</input>
|
||||
</th>
|
||||
<th align="center" width="10%">
|
||||
<th align="center" width="70px">
|
||||
计费次数(当天)/(历史)
|
||||
</th>
|
||||
<th align="center" width="15%">
|
||||
<th align="center" width="150px">
|
||||
操作
|
||||
</th>
|
||||
</tr>
|
||||
@@ -88,10 +98,13 @@
|
||||
<#list authorityBoList as bo>
|
||||
<tr>
|
||||
<td align="center">
|
||||
${bo.apiCode!}
|
||||
</td>
|
||||
<td align="center" class="resizable-td">
|
||||
<input type="hidden" id="uri_${bo_index + 1}" value="${bo.uri!}"></input>
|
||||
${bo.uri!}
|
||||
</td>
|
||||
<td align="center">
|
||||
<td align="center" class="resizable-td">
|
||||
${bo.name!}
|
||||
</td>
|
||||
<td align="center">
|
||||
@@ -99,16 +112,15 @@
|
||||
</td>
|
||||
<td align="center">
|
||||
<#if bo.limitCountMap?? && bo.limitCountMap[bo.uri!]??>
|
||||
<input type="text" value="${bo.limitCountMap[bo.uri!]}" name="limit" id="limit_${bo_index + 1}" style="width:80px;" ></input>
|
||||
<input type="text" value="${bo.limitCountMap[bo.uri!]}" name="limit" id="limit_${bo_index + 1}" style="width:40px;" readonly></input>
|
||||
<#else>
|
||||
<input type="text" value="" name="limit" id="limit_${bo_index + 1}" style="width:80px;" ></input>
|
||||
<input type="text" value="" name="limit" id="limit_${bo_index + 1}" style="width:60px;" readonly></input>
|
||||
</#if>
|
||||
|
||||
/
|
||||
/
|
||||
<#if bo.totalCountMap?? && bo.totalCountMap[bo.uri!]??>
|
||||
<input type="text" value="${bo.totalCountMap[bo.uri!]}" name="sum" id="sum_${bo_index + 1}" style="width:80px;" readonly ></input>
|
||||
<input type="text" value="${bo.totalCountMap[bo.uri!]}" name="sum" id="sum_${bo_index + 1}" style="width:40px;" readonly ></input>
|
||||
<#else>
|
||||
<input type="text" value="" name="sum" id="sum_${bo_index + 1}" style="width:80px;" readonly></input>
|
||||
<input type="text" value="" name="sum" id="sum_${bo_index + 1}" style="width:60px;" readonly></input>
|
||||
</#if>
|
||||
|
||||
</td>
|
||||
|
||||
@@ -23,6 +23,7 @@ table{text-align: left;}
|
||||
<form id="_form" action="doAdd" method="post">
|
||||
<input name="method" value="doAdd" type="hidden"/>
|
||||
<table style = "border:0px;">
|
||||
<tr><td width="20%"><strong>APICode</strong></td><td width="30%"><input size="35" id="apiCode" name="apiCode" value="${apiCode!}"/></td><td width="50%"><font color="red" id="_apiCode_error"></font></td></tr>
|
||||
<tr><td width="20%"><strong>名称</strong></td><td width="30%"><input size="35" id="name" name="name" value="${name!}"/></td><td width="50%"><font color="red" id="_name_error"></font></td></tr>
|
||||
<tr><td><strong>URI</strong></td><td><input size="35" id="uri" name="uri" value="${uri!}"/></td><td><font color="red" id="_uri_error"></font></td></tr>
|
||||
<tr><td><strong>说明</strong></td><td colspan="2"><input size="40" id="description" name="description" value="${description!}"/></td></tr>
|
||||
@@ -32,6 +33,12 @@ table{text-align: left;}
|
||||
<label><input name="save_result" type="radio" value="true" checked/>监控 </label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td><strong>是否对外</strong></td>
|
||||
<td colspan="2">
|
||||
<label><input name="pubStatus" type="radio" value="true" />不对外 </label>
|
||||
<label><input name="pubStatus" type="radio" value="true" checked/>对外 </label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td clospan="2"><input type="button" id="_sub" value="创建"/></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
@@ -24,6 +24,11 @@ table{text-align: left;}
|
||||
<input type="hidden" name="id" value="${or.id}"/>
|
||||
<input name="method" value="doUpdate" type="hidden"/>
|
||||
<table style = "border:0px;">
|
||||
<tr><td width="20%"><strong>APICode</strong></td><td width="30%"><#if apiCode != 0>
|
||||
<input size="35" id="apiCode" name="apiCode" value="${apiCode}"/>
|
||||
<#else>
|
||||
<input size="35" id="apiCode" name="apiCode" value="${or.apiCode}"/>
|
||||
</#if></td><td width="50%"><font color="red" id="_apiCode_error"></font></td></tr>
|
||||
<tr><td width="20%"><strong>名称</strong></td><td width="30%"><input size="35" id="name" name="name" value="${name!or.name}"/></td><td width="50%"><font color="red" id="_name_error"></font></td></tr>
|
||||
<tr><td><strong>URI</strong></td><td><input size="35" id="uri" name="uri" value="${uri!or.uri}"/></td><td><font color="red" id="_uri_error"></font></td></tr>
|
||||
<tr><td><strong>说明</strong></td><td colspan="2"><input size="40" id="description" name="description" value="${description!or.description}"/></td></tr>
|
||||
|
||||
@@ -47,8 +47,8 @@
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th align="center" width="15%">
|
||||
ID
|
||||
<th align="center" width="50px">
|
||||
APICode
|
||||
</th>
|
||||
<th align="center" width="15%">
|
||||
名称
|
||||
@@ -56,15 +56,18 @@
|
||||
<th align="center" width="15%">
|
||||
URI
|
||||
</th>
|
||||
<th align="center" width="10%">
|
||||
<th align="center" width="100px">
|
||||
监控返回结果
|
||||
</th>
|
||||
<th align="center" width="100px">
|
||||
是否对外
|
||||
</th>
|
||||
<th align="center" width="20%">
|
||||
说明
|
||||
</th>
|
||||
<th align="center" width="10%">
|
||||
是否有字权限
|
||||
</th>
|
||||
<#-- <th align="center" width="10%">-->
|
||||
<#-- 是否有字权限-->
|
||||
<#-- </th>-->
|
||||
<th>
|
||||
操作
|
||||
</th>
|
||||
@@ -74,7 +77,7 @@
|
||||
<#list ors as or>
|
||||
<tr>
|
||||
<td align="center">
|
||||
${or.id}
|
||||
${or.apiCode!}
|
||||
</td>
|
||||
<td align="center">
|
||||
${or.name!}
|
||||
@@ -86,17 +89,20 @@
|
||||
<input type="checkbox" value="false" <#if or.saveResult??&&or.saveResult==true>checked </#if> id="jk_${or.id}"
|
||||
</td>
|
||||
<td align="center">
|
||||
${or.description!}
|
||||
<input type="checkbox" value="false" <#if or.pubStatus??&&or.pubStatus==1>checked </#if> id="pub_${or.id}"
|
||||
</td>
|
||||
<td align="center">
|
||||
<#if or.hasSubResource>
|
||||
有
|
||||
<#else>
|
||||
无
|
||||
</#if>
|
||||
${or.description!}
|
||||
</td>
|
||||
<#-- <td align="center">-->
|
||||
<#-- <#if or.hasSubResource>-->
|
||||
<#-- 有-->
|
||||
<#-- <#else>-->
|
||||
<#-- 无-->
|
||||
<#-- </#if>-->
|
||||
<#-- </td>-->
|
||||
<td>
|
||||
<a onclick="return confirm('您确定要删除这条信息吗?');" href="../openResource/doDelete?id=${or.id}">删除</a>
|
||||
<a onclick="return confirm('您确定要删除这条信息吗?');" href="../openResource/doDelete?id=${or.id}">删除</a>
|
||||
<a href="../openResource/doUpdate?id=${or.id}">编辑</a>
|
||||
<a href="#" onclick="saveSingle(this)" value="${or.id}">保存</a>
|
||||
</td>
|
||||
@@ -118,18 +124,27 @@
|
||||
var a = $(e);
|
||||
var id = a.attr("value");
|
||||
var eck = $('#jk_'+id).attr("checked");
|
||||
var eck2 = $('#pub_'+id).attr("checked");
|
||||
var flag = false;
|
||||
var flag2 = false;
|
||||
if (eck == "checked") {
|
||||
flag = true;
|
||||
}
|
||||
else{
|
||||
flag= false;
|
||||
}
|
||||
if (eck2 == "checked") {
|
||||
flag2 = true;
|
||||
}
|
||||
else{
|
||||
flag2 = false;
|
||||
}
|
||||
|
||||
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "../openResource/doChange",
|
||||
data: "id="+id+"&save_result="+flag,
|
||||
data: "id="+id+"&save_result="+flag+"&pubStatus="+flag2,
|
||||
dataType: "json",
|
||||
success: function (data)
|
||||
{
|
||||
|
||||
@@ -32,6 +32,10 @@ public class AuthorityBo implements Serializable {
|
||||
private long curVisitedCount;
|
||||
private long totalVisitedCount;
|
||||
private Integer isCheckCount;//是否按查得计费 1:是 ,0:否
|
||||
|
||||
private int pubStatus;
|
||||
|
||||
private int apiCode;
|
||||
|
||||
public Map<String, BasicDBObject> getResourceAuthorityMap() {
|
||||
return resourceAuthorityMap;
|
||||
@@ -158,7 +162,19 @@ public class AuthorityBo implements Serializable {
|
||||
this.totalVisitedCount = totalVisitedCount;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public int getPubStatus() {
|
||||
return pubStatus;
|
||||
}
|
||||
|
||||
public void setPubStatus(int pubStatus) {
|
||||
this.pubStatus = pubStatus;
|
||||
}
|
||||
|
||||
public int getApiCode() {
|
||||
return apiCode;
|
||||
}
|
||||
|
||||
public void setApiCode(int apiCode) {
|
||||
this.apiCode = apiCode;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user