API接口次数管理功能优化
This commit is contained in:
+84
@@ -0,0 +1,84 @@
|
||||
package com.fangjia.bkoff.controllers;
|
||||
|
||||
import com.alibaba.excel.util.DateUtils;
|
||||
import com.fangjia.bkoff.model.ApiCountLogModel;
|
||||
import com.fangjia.bkoff.model.ApiUserModel;
|
||||
import com.fangjia.bkoff.model.JsonModel;
|
||||
import com.fangjia.core.util.*;
|
||||
import com.fangjia.dal.QueryParam;
|
||||
import com.fangjia.dal.mongo.fangjia.model.ServerArea;
|
||||
import com.fangjia.dal.mongo.model.ApiCountLog;
|
||||
import com.fangjia.dal.mongo.model.ApiInvokeStatistical;
|
||||
import com.fangjia.dal.mongo.model.ApiUserCfg;
|
||||
import com.fangjia.dal.mongo.model.bkoff.BkoffUsers;
|
||||
import com.fangjia.dal.mongo.open.model.ApiJsonViewConfig;
|
||||
import com.fangjia.dal.mongo.open.model.ApiUserAuthority;
|
||||
import com.fangjia.dal.mongo.open.model.OpenResource;
|
||||
import com.fangjia.dal.mongo.tool.model.ApiCountCity;
|
||||
import com.fangjia.dal.mongo.tool.model.ApiVisitCount;
|
||||
import com.fangjia.dal.mongo.tool.model.OpenResourceCount;
|
||||
import com.fangjia.dal.mongo.tool.model.OpenUriAnaly;
|
||||
import com.fangjia.dal.sql.model.ApiUser;
|
||||
import com.fangjia.dal.sql.model.User;
|
||||
import com.fangjia.service.api.ApiUserCfgService;
|
||||
import com.fangjia.service.mongo.bkoff.ApiInvokeStatisticalService;
|
||||
import com.fangjia.service.mongo.bkoff.BkoffUsersService;
|
||||
import com.fangjia.service.mongo.fangjia.ApiCountLogService;
|
||||
import com.fangjia.service.mongo.fangjia.ServerAreaService;
|
||||
import com.fangjia.service.open.*;
|
||||
import com.fangjia.service.sql.ApiUserService;
|
||||
import com.fangjia.service.sql.UserService;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.poi.hssf.usermodel.*;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.json.JSONArray;
|
||||
import org.sothis.core.util.CollectionUtils;
|
||||
import org.sothis.core.util.Pager;
|
||||
import org.sothis.web.mvc.ActionContext;
|
||||
import org.sothis.web.mvc.annotation.Param;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.net.URLEncoder;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
/**
|
||||
* apiÓû§¿ªÍ¨µÈ¹ÜÀícontroller
|
||||
*
|
||||
* @author
|
||||
*/
|
||||
public class ApiCountLogController {
|
||||
private BkoffUsersService bkoffUsersService;
|
||||
private ApiCountLogService apiCountLogService;
|
||||
|
||||
public Object listAction(ApiCountLogModel model) {
|
||||
Pager pager = model.getPager(30);
|
||||
if (pager.getCurrentPage() > 100) {
|
||||
pager.setCurrentPage(1);
|
||||
}
|
||||
List<ApiCountLog> apiCountLogList = apiCountLogService.findApiCountLog(model.getUserId(), model.getUri(),pager);
|
||||
model.setApiCountLogList(apiCountLogList);
|
||||
pager.setTotalRows(apiCountLogList.size());
|
||||
model.setPager(pager);
|
||||
return model;
|
||||
}
|
||||
public void setBkoffUsersService(BkoffUsersService bkoffUsersService) {
|
||||
this.bkoffUsersService = bkoffUsersService;
|
||||
}
|
||||
|
||||
public void setApiCountLogService(ApiCountLogService apiCountLogService) {
|
||||
this.apiCountLogService = apiCountLogService;
|
||||
}
|
||||
}
|
||||
+41
-1
@@ -9,8 +9,10 @@ import com.fangjia.bkoff.model.JsonModel;
|
||||
import com.fangjia.core.util.*;
|
||||
import com.fangjia.dal.QueryParam;
|
||||
import com.fangjia.dal.mongo.fangjia.model.ServerArea;
|
||||
import com.fangjia.dal.mongo.model.ApiCountLog;
|
||||
import com.fangjia.dal.mongo.model.ApiInvokeStatistical;
|
||||
import com.fangjia.dal.mongo.model.ApiUserCfg;
|
||||
import com.fangjia.dal.mongo.model.bkoff.BkoffUsers;
|
||||
import com.fangjia.dal.mongo.open.model.ApiJsonViewConfig;
|
||||
import com.fangjia.dal.mongo.open.model.ApiUserAuthority;
|
||||
import com.fangjia.dal.mongo.open.model.OpenResource;
|
||||
@@ -22,6 +24,8 @@ import com.fangjia.dal.sql.model.ApiUser;
|
||||
import com.fangjia.dal.sql.model.User;
|
||||
import com.fangjia.service.api.ApiUserCfgService;
|
||||
import com.fangjia.service.mongo.bkoff.ApiInvokeStatisticalService;
|
||||
import com.fangjia.service.mongo.bkoff.BkoffUsersService;
|
||||
import com.fangjia.service.mongo.fangjia.ApiCountLogService;
|
||||
import com.fangjia.service.mongo.fangjia.ServerAreaService;
|
||||
import com.fangjia.service.open.*;
|
||||
import com.fangjia.service.sql.ApiUserService;
|
||||
@@ -73,6 +77,8 @@ public class ApiUserController {
|
||||
private ApiInvokeStatisticalService apiInvokeStatisticalService;
|
||||
private ApiVisitCountService apiVisitCountService;
|
||||
private ApiCountCityService apiCountCityService;
|
||||
private BkoffUsersService bkoffUsersService;
|
||||
private ApiCountLogService apiCountLogService;
|
||||
|
||||
/**
|
||||
* 所有api用户的信息展示
|
||||
@@ -697,6 +703,9 @@ public class ApiUserController {
|
||||
|
||||
|
||||
public Object saveAuthAction(ApiUserModel model, HttpServletRequest request) throws IllegalAccessException {
|
||||
List<OpenResource> openResourceList = openResourceService.findAll();
|
||||
Map<String, String> apiMap = converMapData(openResourceList);
|
||||
|
||||
model.setViewType("json");
|
||||
model.setViewParam("config", null);
|
||||
Long userId = model.getUserId();
|
||||
@@ -710,6 +719,7 @@ public class ApiUserController {
|
||||
authority.setSupportLatLng(model.isSupportLatLng());
|
||||
apiUserAuthorityService.save(authority);
|
||||
} else {
|
||||
Map<String, Integer> countMap = authority.getTotalCountMap();
|
||||
if (model.getLimit() != null) {
|
||||
Map<String, Integer> limitCountMap = authority.getLimitCountMap();
|
||||
if (limitCountMap == null) {
|
||||
@@ -723,7 +733,29 @@ public class ApiUserController {
|
||||
if (totalCountMap == null) {
|
||||
totalCountMap = new HashMap<String, Integer>();
|
||||
}
|
||||
totalCountMap.put(model.getUri(), model.getSum());
|
||||
Integer count = model.getSum();
|
||||
//增加次数修改日志
|
||||
ApiCountLog apiCountLog = new ApiCountLog();
|
||||
if (countMap != null && countMap.containsKey(model.getUri())) {
|
||||
String bkoffUserId = (String) ThreadLocalData.getInstance().get(ThreadLocalKey.UserId);
|
||||
BkoffUsers bkoffUser = bkoffUsersService.findBkoffUsersById(bkoffUserId);
|
||||
apiCountLog.setUserId(userId);
|
||||
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)+"次");
|
||||
}
|
||||
|
||||
apiCountLog.setOperateTime(new Date());
|
||||
apiCountLogService.save(apiCountLog);
|
||||
}
|
||||
totalCountMap.put(model.getUri(), count);
|
||||
authority.setTotalCountMap(totalCountMap);
|
||||
}
|
||||
if (model.getIsCheckCount() != null) {
|
||||
@@ -2052,4 +2084,12 @@ public class ApiUserController {
|
||||
model.setViewParam("location", "/apiUser/list");
|
||||
return model;
|
||||
}
|
||||
|
||||
public void setBkoffUsersService(BkoffUsersService bkoffUsersService) {
|
||||
this.bkoffUsersService = bkoffUsersService;
|
||||
}
|
||||
|
||||
public void setApiCountLogService(ApiCountLogService apiCountLogService) {
|
||||
this.apiCountLogService = apiCountLogService;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
package com.fangjia.bkoff.model;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.fangjia.dal.mongo.model.ApiCountLog;
|
||||
import com.fangjia.dal.mongo.model.Township;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class ApiCountLogModel extends BaseModel {
|
||||
@JSONField(name = "id")
|
||||
private String id;
|
||||
|
||||
@JSONField(name = "user_id")
|
||||
private Long userId;
|
||||
@JSONField(name = "uri")
|
||||
private String uri;
|
||||
@JSONField(name = "user_name")
|
||||
private String uriName;
|
||||
@JSONField(name = "operate")
|
||||
private String operate;
|
||||
@JSONField(name = "operator")
|
||||
private String operator;
|
||||
|
||||
@JSONField(name = "operate_time")
|
||||
private Date operateTime;
|
||||
|
||||
// 修改次数前总次数
|
||||
@JSONField(name = "old_count")
|
||||
private Integer oldCount;
|
||||
// 修改次数后的次数
|
||||
@JSONField(name = "new_count")
|
||||
private Integer newCount;
|
||||
private List<ApiCountLog> apiCountLogList;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getUri() {
|
||||
return uri;
|
||||
}
|
||||
|
||||
public void setUri(String uri) {
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
public String getUriName() {
|
||||
return uriName;
|
||||
}
|
||||
|
||||
public void setUriName(String uriName) {
|
||||
this.uriName = uriName;
|
||||
}
|
||||
|
||||
public String getOperate() {
|
||||
return operate;
|
||||
}
|
||||
|
||||
public void setOperate(String operate) {
|
||||
this.operate = operate;
|
||||
}
|
||||
|
||||
public String getOperator() {
|
||||
return operator;
|
||||
}
|
||||
|
||||
public void setOperator(String operator) {
|
||||
this.operator = operator;
|
||||
}
|
||||
|
||||
public Date getOperateTime() {
|
||||
return operateTime;
|
||||
}
|
||||
|
||||
public void setOperateTime(Date operateTime) {
|
||||
this.operateTime = operateTime;
|
||||
}
|
||||
|
||||
public Integer getOldCount() {
|
||||
return oldCount;
|
||||
}
|
||||
|
||||
public void setOldCount(Integer oldCount) {
|
||||
this.oldCount = oldCount;
|
||||
}
|
||||
|
||||
public Integer getNewCount() {
|
||||
return newCount;
|
||||
}
|
||||
|
||||
public void setNewCount(Integer newCount) {
|
||||
this.newCount = newCount;
|
||||
}
|
||||
|
||||
public List<ApiCountLog> getApiCountLogList() {
|
||||
return apiCountLogList;
|
||||
}
|
||||
|
||||
public void setApiCountLogList(List<ApiCountLog> apiCountLogList) {
|
||||
this.apiCountLogList = apiCountLogList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
<#ftl attributes={"content_type":"text/html; charset=UTF-8"}>
|
||||
<#compress>
|
||||
<!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">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||
<title>客户API次数操作日志</title>
|
||||
<link rel="stylesheet" type="text/css" href="../style/main.css?v=${version}"/>
|
||||
<script type="text/javascript" src="../js/My97DatePicker/WdatePicker.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<#include "/common_js.ftl" />
|
||||
<#include "/layout/header.ftl" />
|
||||
<div class="main-content">
|
||||
<form action="../apiCountLog/list" id="_search_log_form">
|
||||
<div>
|
||||
<label for="userId">用户ID:</label>
|
||||
<input type="text" name="userId" id="userId" class="input-medium" style="margin-top:9px;"
|
||||
value="${userId!}"></input>
|
||||
<label for="uri">uri:</label>
|
||||
<input type="text" name="uri" id="uri" class="input-medium" style="margin-top:9px;"
|
||||
value="${uri!}"></input>
|
||||
<input id="queryBtn" class="btn btn-primary" type="submit" value="查询"/>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
<div class="list" style="margin-top:5px;">
|
||||
<span style="font-size:12px;">查询到<b style="color:red;">${pager.totalRows!}</b>条记录</span>
|
||||
<table style="float:left;" name="reginTable" class="regionTab">
|
||||
<tr>
|
||||
<th>用户ID</th>
|
||||
<th>uri</th>
|
||||
<th>API名称</th>
|
||||
<th>操作</th>
|
||||
<th>原次数</th>
|
||||
<th>现次数</th>
|
||||
<th>操作人员</th>
|
||||
<th>修改日期</th>
|
||||
</tr>
|
||||
<#list apiCountLogList as it>
|
||||
<tr>
|
||||
<td>${it.userId!}</td>
|
||||
<td>${it.uri!}</td>
|
||||
<td>${it.uriName!}</td>
|
||||
<td>${it.operate!}</td>
|
||||
<td>${it.oldCount!}</td>
|
||||
<td>${it.newCount!}</td>
|
||||
<td>${it.operator!}</td>
|
||||
<td>${it.operateTime!?string("yyyy-MM-dd HH:mm:ss")}</td>
|
||||
</tr>
|
||||
</#list>
|
||||
</table>
|
||||
<#if pager??>
|
||||
<@d_pager controller="apiCountLog" action="list" currentPage=pager.currentPage totalPages=pager.totalPages theme="full"/>
|
||||
</#if>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
</#compress>
|
||||
@@ -7,6 +7,11 @@
|
||||
<title>api用户权限控制</title>
|
||||
<link rel="stylesheet" type="text/css" href="../style/main.css?v=${version}" />
|
||||
<link rel="stylesheet" type="text/css" href="../style/theme.css?v=${version}" />
|
||||
<link rel="stylesheet" type="text/css" href="../bootstrap/css/bootstrap.min.css?v=${version}" />
|
||||
<link rel="stylesheet" type="text/css" href="../style/main_simple.css?v=${version}" />
|
||||
<script type="text/javascript" src="../js/jquery-1.9.1.js?v=${version}"></script>
|
||||
<script type="text/javascript" src="../bootstrap/js/bootstrap.min.js?v=${version}"></script>
|
||||
<script type="text/javascript" src="../js/jquery.form.js?v=${version}"></script>
|
||||
<#include "/common_js.ftl" />
|
||||
<script type="text/javascript">
|
||||
</script>
|
||||
@@ -65,6 +70,9 @@
|
||||
<th align="center" width="30%">
|
||||
访问最大次数(每天)/(总数)
|
||||
</th>
|
||||
<th align="center" width="15%">
|
||||
访问次数修改
|
||||
</th>
|
||||
<th align="center" width="10%">
|
||||
是否按查得计费<input type="checkbox" id="isCheckCount" >全选</input>
|
||||
</th>
|
||||
@@ -104,6 +112,14 @@
|
||||
</#if>
|
||||
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" data-toggle="modal" data-target="#myModal" id="add_${bo_index + 1}">
|
||||
增加
|
||||
</button>
|
||||
<button type="button" data-toggle="modal" data-target="#myModal" id="reduce_${bo_index + 1}">
|
||||
减少
|
||||
</button>
|
||||
</td>
|
||||
<td align="center">
|
||||
<input type="checkbox" <#if bo.isCheckCount==1>checked </#if> id="isCheckCount_${bo_index + 1}" ></input>
|
||||
</td>
|
||||
@@ -111,6 +127,9 @@
|
||||
<td align="center">
|
||||
<input type="button" id="save_${bo_index + 1}" value="保存">
|
||||
<input type="button" data-uri="${bo.uri!}" data-userid = "${authority.userId!}" value="编辑字段"/>
|
||||
<a href="../apiCountLog/list?userId=${userId!}&uri=${bo.uri!}">
|
||||
<button>日志查看</button>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</#list>
|
||||
@@ -130,6 +149,26 @@
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3 id="myModalLabel">修改次数</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form class="form-horizontal" id="editForm">
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="countInput">次数</label>
|
||||
<div class="controls">
|
||||
<input type="text" id="countInput" name="countInput" value="" /> 次
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-primary" id="submitCount" data-dismiss="modal" aria-hidden="true">保存</button>
|
||||
<button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="theme-popover" id = "dialog" style="width:450px;">
|
||||
<div class="theme-poptit">
|
||||
<a href="javascript:;" title="关闭" class="close">×</a>
|
||||
|
||||
@@ -112,4 +112,60 @@ $(document).ready(function() {
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
// 当点击"增加"按钮时
|
||||
$('button[data-target="#myModal"]').click(
|
||||
function () {
|
||||
|
||||
var idNum = $(this).closest('tr').index() + 1; // 获取按钮所在行的索引
|
||||
var isAdd = $(this).attr('id').startsWith('add'); // 判断是增加还是减少
|
||||
|
||||
// 动态设置模态框标题
|
||||
if (isAdd) {
|
||||
$('#myModalLabel').text('增加次数');
|
||||
} else {
|
||||
$('#myModalLabel').text('减少次数');
|
||||
}
|
||||
|
||||
// 绑定修改次数的功能
|
||||
$('#submitCount').unbind('click').click(function() {
|
||||
modifyCount(isAdd, idNum);
|
||||
});
|
||||
|
||||
|
||||
// var id_num = $(this).closest('tr').index();
|
||||
// var totalInputId = '#sum_' + (id_num + 1);
|
||||
// var totalValue = parseInt($(totalInputId).val()) || 0; // 获取当前总次数的值
|
||||
//
|
||||
// // 解除之前的绑定事件
|
||||
// $('#editSubmit').unbind('click').click(function () {
|
||||
// var addedCount = parseInt($('#cityPop').val()) || 0; // 获取用户输入的次数
|
||||
//
|
||||
// var newTotal = totalValue + addedCount; // 将输入的次数加到当前总次数上
|
||||
//
|
||||
// $(totalInputId).val(newTotal); // 更新总次数输入框的值
|
||||
//
|
||||
// $("input[id='save_"+(id_num+1)+"']").trigger('click');
|
||||
// });
|
||||
});
|
||||
|
||||
function modifyCount(isAdd, idNum) {
|
||||
var totalInputId = '#sum_' + idNum;
|
||||
var totalValue = parseInt($(totalInputId).val()) || 0; // 获取当前总次数的值
|
||||
var count = parseInt($('#countInput').val()) || 0; // 获取用户输入的次数
|
||||
|
||||
var newTotal = isAdd ? totalValue + count : totalValue - count; // 根据增加或减少计算新的总次数
|
||||
|
||||
if (newTotal < 0) {
|
||||
newTotal = 0; // 确保总次数不为负数
|
||||
}
|
||||
|
||||
$(totalInputId).val(newTotal); // 更新总次数输入框的值
|
||||
$('#countInput').val(''); // 清空输入框的值
|
||||
|
||||
|
||||
// 调用 #auth 的点击事件(根据需求)
|
||||
$("input[id='save_"+(idNum)+"']").trigger('click');
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
@@ -295,6 +295,7 @@
|
||||
<@menuitem uri='/creditRate/list' text="价格可信度与匹配率关系" />
|
||||
<@menuitem uri='/czBank/sampleLogs' text="浙商银行" />
|
||||
<@menuitem uri='/villageIdentify/importResult' text="涉农结果导入" />
|
||||
<@menuitem uri='/apiCountLog/list' text="API次数日志" />
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.fangjia.dal.mongo.dao;
|
||||
|
||||
import com.fangjia.dal.MongoDao;
|
||||
import com.fangjia.dal.mongo.model.ApiCountLog;
|
||||
import com.fangjia.dal.mongo.model.DevelopmentZone;
|
||||
|
||||
public interface ApiCountLogDao extends MongoDao<ApiCountLog> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.fangjia.dal.mongo.dao;
|
||||
|
||||
import com.fangjia.dal.MongoDaoImpl;
|
||||
import com.fangjia.dal.mongo.model.ApiCountLog;
|
||||
import com.fangjia.dal.mongo.model.DevelopmentZone;
|
||||
|
||||
public class ApiCountLogDaoImpl extends MongoDaoImpl<ApiCountLog> implements ApiCountLogDao {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package com.fangjia.dal.mongo.model;
|
||||
|
||||
import com.fangjia.dal.MongoEntity;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "business.api_count_log")
|
||||
public class ApiCountLog implements MongoEntity {
|
||||
|
||||
private String id;
|
||||
|
||||
private Long userId;
|
||||
|
||||
private String uri;
|
||||
|
||||
private String uriName;
|
||||
|
||||
private String operate;
|
||||
|
||||
private String operator;
|
||||
|
||||
private Date operateTime;
|
||||
|
||||
// 修改次数前总次数
|
||||
private Integer oldCount;
|
||||
// 修改次数后的次数
|
||||
private Integer newCount;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
@Column(name = "_id")
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Column(name = "user_id")
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
@Column(name = "uri")
|
||||
public String getUri() {
|
||||
return uri;
|
||||
}
|
||||
|
||||
public void setUri(String uri) {
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
@Column(name = "uri_name")
|
||||
public String getUriName() {
|
||||
return uriName;
|
||||
}
|
||||
|
||||
public void setUriName(String uriName) {
|
||||
this.uriName = uriName;
|
||||
}
|
||||
|
||||
@Column(name = "operate")
|
||||
public String getOperate() {
|
||||
return operate;
|
||||
}
|
||||
|
||||
public void setOperate(String operate) {
|
||||
this.operate = operate;
|
||||
}
|
||||
|
||||
@Column(name = "operator")
|
||||
public String getOperator() {
|
||||
return operator;
|
||||
}
|
||||
|
||||
public void setOperator(String operator) {
|
||||
this.operator = operator;
|
||||
}
|
||||
|
||||
@Column(name = "operate_time")
|
||||
public Date getOperateTime() {
|
||||
return operateTime;
|
||||
}
|
||||
|
||||
public void setOperateTime(Date operateTime) {
|
||||
this.operateTime = operateTime;
|
||||
}
|
||||
|
||||
@Column(name = "old_count")
|
||||
public Integer getOldCount() {
|
||||
return oldCount;
|
||||
}
|
||||
|
||||
public void setOldCount(Integer oldCount) {
|
||||
this.oldCount = oldCount;
|
||||
}
|
||||
|
||||
@Column(name = "new_count")
|
||||
public Integer getNewCount() {
|
||||
return newCount;
|
||||
}
|
||||
|
||||
public void setNewCount(Integer newCount) {
|
||||
this.newCount = newCount;
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.fangjia.service.mongo.fangjia;
|
||||
|
||||
import com.fangjia.dal.mongo.model.ApiCountLog;
|
||||
import com.fangjia.dal.mongo.model.DevelopmentZone;
|
||||
import org.sothis.core.util.Pager;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by dxy on 2015/6/8.
|
||||
*/
|
||||
public interface ApiCountLogService {
|
||||
void save(ApiCountLog apiCountLog);
|
||||
|
||||
List<ApiCountLog> findApiCountLog(Long userId,String uri,Pager pager);
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
package com.fangjia.service.mongo.fangjia;
|
||||
|
||||
import com.fangjia.dal.QueryParam;
|
||||
import com.fangjia.dal.SortParam;
|
||||
import com.fangjia.dal.mongo.dao.AdministrativeMappingDao;
|
||||
import com.fangjia.dal.mongo.dao.ApiCountLogDao;
|
||||
import com.fangjia.dal.mongo.dao.DevelopmentZoneDao;
|
||||
import com.fangjia.dal.mongo.model.AdministrativeMapping;
|
||||
import com.fangjia.dal.mongo.model.ApiCountLog;
|
||||
import com.fangjia.dal.mongo.model.DevelopmentZone;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.sothis.core.util.Pager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class ApiCountLogServiceImpl implements ApiCountLogService {
|
||||
private ApiCountLogDao apiCountLogDao;
|
||||
|
||||
@Override
|
||||
public void save(ApiCountLog apiCountLog) {
|
||||
apiCountLogDao.save(apiCountLog);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ApiCountLog> findApiCountLog(Long userId, String uri,Pager pager) {
|
||||
List<QueryParam> params = new ArrayList<QueryParam>();
|
||||
if (userId!= null) {
|
||||
params.add(new QueryParam("userId", userId));
|
||||
}
|
||||
if (StringUtils.isNotBlank(uri)) {
|
||||
Pattern pattern = Pattern.compile(".*" + uri + ".*");
|
||||
params.add(new QueryParam("uri", pattern));
|
||||
}
|
||||
List<SortParam> sortParam = Arrays.asList(new SortParam("operateTime", false));
|
||||
return apiCountLogDao.findAllByParams(params,sortParam, pager.getStartRow(), pager.getPageSize());
|
||||
}
|
||||
|
||||
public void setApiCountLogDao(ApiCountLogDao apiCountLogDao) {
|
||||
this.apiCountLogDao = apiCountLogDao;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user