1.修改日志分页
This commit is contained in:
@@ -46,6 +46,10 @@ public abstract class BaseEntity<T> implements Serializable {
|
||||
* 当前实体分页对象
|
||||
*/
|
||||
protected Page<T> page;
|
||||
/**
|
||||
* 日志分页对象
|
||||
*/
|
||||
protected PageLog<T> pageLog;
|
||||
|
||||
/**
|
||||
* 自定义SQL(SQL标识,SQL内容)
|
||||
@@ -110,6 +114,19 @@ public abstract class BaseEntity<T> implements Serializable {
|
||||
this.page = page;
|
||||
return page;
|
||||
}
|
||||
@JsonIgnore
|
||||
@XmlTransient
|
||||
public PageLog<T> getPageLog() {
|
||||
if (pageLog == null){
|
||||
pageLog = new PageLog<T>();
|
||||
}
|
||||
return pageLog;
|
||||
}
|
||||
|
||||
public PageLog<T> setPageLog(PageLog<T> pageLog) {
|
||||
this.pageLog = pageLog;
|
||||
return pageLog;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
@XmlTransient
|
||||
|
||||
637
src/main/java/com/nis/domain/PageLog.java
Normal file
637
src/main/java/com/nis/domain/PageLog.java
Normal file
@@ -0,0 +1,637 @@
|
||||
/**
|
||||
* Copyright © 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
|
||||
*/
|
||||
package com.nis.domain;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.web.servlet.support.RequestContext;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.nis.util.Configurations;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.CookieUtil;
|
||||
|
||||
/**
|
||||
* 分页类
|
||||
* @author ThinkGem
|
||||
* @version 2013-7-2
|
||||
* @param <T>
|
||||
*/
|
||||
public class PageLog<T> {
|
||||
|
||||
private int pageNo = 1; // 当前页码
|
||||
private int pageSize = Integer.valueOf(Configurations.getIntProperty("page.pageSize", 30)); // 页面大小,设置为“-1”表示不进行分页(分页无效)
|
||||
|
||||
private long count;// 总记录数,设置为“-1”表示不查询总数
|
||||
private int first;// 首页索引
|
||||
// private int last;// 尾页索引
|
||||
private int prev;// 上一页索引
|
||||
private int next;// 下一页索引
|
||||
|
||||
|
||||
private boolean firstPage;//是否是第一页
|
||||
private boolean lastPage;//是否是最后一页
|
||||
|
||||
// private int length = 8;// 显示页面长度
|
||||
// private int slider = 1;// 前后显示页面长度
|
||||
|
||||
private List<T> list = new ArrayList<T>();
|
||||
|
||||
private String orderBy = ""; // 标准查询有效, 实例: updatedate desc, name asc
|
||||
|
||||
private String fields;//制定资源的字段
|
||||
|
||||
private String where;
|
||||
private String alias;
|
||||
private String funcName = "page"; // 设置点击页码调用的js函数名称,默认为page,在一页有多个分页对象时使用。
|
||||
|
||||
private String funcParam = ""; // 函数的附加参数,第三个参数值。
|
||||
|
||||
private String message = ""; // 设置提示消息,显示在“共n条”之后
|
||||
|
||||
private RequestContext requestContext;
|
||||
|
||||
private int maxExportSize=Constants.MAX_EXPORT_SIZE;
|
||||
|
||||
public PageLog() {
|
||||
this.pageSize = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造方法
|
||||
* @param request 传递 repage 参数,来记住页码
|
||||
* @param response 用于设置 Cookie,记住页码
|
||||
*/
|
||||
public PageLog(HttpServletRequest request, HttpServletResponse response){
|
||||
this(request, response, Integer.valueOf(Configurations.getIntProperty("page.pageSize", 30)));
|
||||
}
|
||||
public PageLog(HttpServletRequest request, HttpServletResponse response,String alias){
|
||||
|
||||
this(request, response, Integer.valueOf(Configurations.getIntProperty("page.pageSize", 30)),alias);
|
||||
}
|
||||
|
||||
public PageLog(HttpServletRequest request, HttpServletResponse response, int defaultPageSize,String alias){
|
||||
this.setAlias(alias);
|
||||
this.initPage(request, response, defaultPageSize);
|
||||
}
|
||||
public PageLog(HttpServletRequest request, HttpServletResponse response, int defaultPageSize){
|
||||
this.initPage(request, response, defaultPageSize);
|
||||
}
|
||||
private void initPage(HttpServletRequest request, HttpServletResponse response, int defaultPageSize){
|
||||
try {
|
||||
|
||||
this.requestContext = new RequestContext(request);
|
||||
|
||||
// 设置页码参数(传递repage参数,来记住页码)
|
||||
String no = request.getParameter("pageNo");
|
||||
if (StringUtils.isNotBlank(no)) {
|
||||
if (StringUtils.isNumeric(no)){
|
||||
CookieUtil.addCookie(response, "pageNo", no);
|
||||
this.setPageNo(Integer.parseInt(no));
|
||||
}else if (request.getParameter("repage")!=null){
|
||||
no = CookieUtil.getValue(request, "pageNo");
|
||||
if (StringUtils.isNumeric(no)){
|
||||
this.setPageNo(Integer.parseInt(no));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 设置页面大小参数(传递repage参数,来记住页码大小)
|
||||
String size = "";
|
||||
if(defaultPageSize==-1){
|
||||
size = "-1";
|
||||
}else{
|
||||
size = request.getParameter("pageSize");
|
||||
|
||||
}
|
||||
if (StringUtils.isNotBlank(size)) {
|
||||
|
||||
if (StringUtils.isNumeric(size) || size.equals("-1")){
|
||||
CookieUtil.addCookie(response, "pageSize", size);
|
||||
this.setPageSize(Integer.parseInt(size));
|
||||
} else if (request.getParameter("repage")!=null){
|
||||
size = CookieUtil.getValue(request, "pageSize");
|
||||
if (StringUtils.isNumeric(size)){
|
||||
this.setPageSize(Integer.parseInt(size));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.pageSize = defaultPageSize;
|
||||
}
|
||||
|
||||
String fields = request.getParameter("fields");
|
||||
if (StringUtils.isNotBlank(fields)){
|
||||
this.setFields(fields);
|
||||
}
|
||||
|
||||
// 设置排序参数
|
||||
String orderBy = request.getParameter("orderBy");
|
||||
if (StringUtils.isNotBlank(orderBy)){
|
||||
this.setOrderBy(orderBy);
|
||||
}
|
||||
|
||||
this.setWhere(getWhere(request));
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @Title: getWhere
|
||||
* @Description: TODO(抽取where查询条件)
|
||||
* @param @param request
|
||||
* @param @return 入参
|
||||
* @return String 返回类型
|
||||
* @author (darnell)
|
||||
* @throws
|
||||
* @date 2016年8月17日 上午9:28:21
|
||||
* @version V1.0
|
||||
* wx:日期格式的数据用日期格式化函数格式化,带空格的数据加上引号
|
||||
*/
|
||||
private String getWhere(HttpServletRequest request) {
|
||||
String format=Constants.SEARCH_DATEFORMAT;
|
||||
SimpleDateFormat sdf=new SimpleDateFormat(format);
|
||||
Map<String, String[]> requestMap = request.getParameterMap();
|
||||
StringBuilder whereBuilder = new StringBuilder(512);
|
||||
for(String paramName : request.getParameterMap().keySet()) {
|
||||
if (requestMap.get(paramName)!=null&¶mName.startsWith("search_")&&StringUtils.isNotBlank(requestMap.get(paramName)[0])) {
|
||||
String clomn=paramName.substring("search_".length());
|
||||
String value=requestMap.get(paramName)[0].trim();
|
||||
boolean isDate=false;
|
||||
try {
|
||||
sdf.parse(value);
|
||||
isDate=true;
|
||||
} catch (ParseException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
if(clomn.endsWith("_start")){
|
||||
clomn=clomn.substring(0,clomn.lastIndexOf("_start"));
|
||||
if(StringUtils.isNotBlank(alias)) whereBuilder.append(alias.trim()+".");
|
||||
whereBuilder.append(clomn).append(">=");
|
||||
if(isDate){
|
||||
whereBuilder.append("date_format('")
|
||||
.append(value).append("','%Y-%m-%d %H:%i:%S')");
|
||||
}else if(value.indexOf(" ")>-1){
|
||||
whereBuilder.append("'").append(requestMap.get(paramName)[0]).append("'");
|
||||
}else{
|
||||
whereBuilder.append(requestMap.get(paramName)[0]);
|
||||
}
|
||||
whereBuilder.append(" and ");
|
||||
}else if(clomn.endsWith("_end")){
|
||||
clomn=clomn.substring(0,clomn.lastIndexOf("_end"));
|
||||
if(StringUtils.isNotBlank(alias)) whereBuilder.append(alias.trim()+".");
|
||||
whereBuilder.append(clomn).append("<=");
|
||||
if(isDate){
|
||||
whereBuilder.append("DATE_FORMAT('")
|
||||
.append(value).append("','%Y-%m-%d %H:%i:%S')");
|
||||
}else if(value.indexOf(" ")>-1){
|
||||
whereBuilder.append("'").append(requestMap.get(paramName)[0]).append("'");
|
||||
}else{
|
||||
whereBuilder.append(requestMap.get(paramName)[0]);
|
||||
}
|
||||
whereBuilder.append(" and ");
|
||||
}else{
|
||||
if(StringUtils.isNotBlank(alias)) whereBuilder.append(alias.trim()+".");
|
||||
whereBuilder.append(clomn).append("=");
|
||||
if(isDate){
|
||||
whereBuilder.append("date_format('")
|
||||
.append(value).append("','%Y-%m-%d %H:%i:%S')");
|
||||
}else if(value.indexOf(" ")>-1){
|
||||
whereBuilder.append("'").append(requestMap.get(paramName)[0]).append("'");
|
||||
}else{
|
||||
whereBuilder.append(requestMap.get(paramName)[0]);
|
||||
}
|
||||
whereBuilder.append(" and ");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (whereBuilder.length() > 0) {
|
||||
whereBuilder.delete(whereBuilder.lastIndexOf(" and "), whereBuilder.length());
|
||||
}
|
||||
return whereBuilder.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 构造方法
|
||||
* @param pageNo 当前页码
|
||||
* @param pageSize 分页大小
|
||||
*/
|
||||
public PageLog(int pageNo, int pageSize) {
|
||||
this(pageNo, pageSize, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造方法
|
||||
* @param pageNo 当前页码
|
||||
* @param pageSize 分页大小
|
||||
* @param count 数据条数
|
||||
*/
|
||||
public PageLog(int pageNo, int pageSize, long count) {
|
||||
this(pageNo, pageSize, count, new ArrayList<T>());
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造方法
|
||||
* @param pageNo 当前页码
|
||||
* @param pageSize 分页大小
|
||||
* @param count 数据条数
|
||||
* @param list 本页数据对象列表
|
||||
*/
|
||||
public PageLog(int pageNo, int pageSize, long count, List<T> list) {
|
||||
this.setCount(count);
|
||||
this.setPageNo(pageNo);
|
||||
this.pageSize = pageSize;
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化参数
|
||||
*/
|
||||
public void initialize(){
|
||||
|
||||
//1
|
||||
this.first = 1;
|
||||
|
||||
//首页
|
||||
if (this.pageNo <= 1) {
|
||||
this.pageNo = this.first;
|
||||
this.firstPage=true;
|
||||
}
|
||||
|
||||
//最后一页
|
||||
if(list.size()<this.pageSize){
|
||||
this.lastPage=true;
|
||||
}
|
||||
|
||||
//下一页
|
||||
if (list.size() >= this.pageSize) {
|
||||
this.next = this.pageNo + 1;
|
||||
}
|
||||
// 上一页
|
||||
if (pageNo > 1) {
|
||||
this.prev = this.pageNo - 1;
|
||||
} else {
|
||||
this.prev = this.first;
|
||||
}
|
||||
|
||||
//2
|
||||
if (this.pageNo < this.first) {// 如果当前页小于首页
|
||||
this.pageNo = this.first;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认输出当前分页标签
|
||||
* <div class="page">${page}</div>
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
|
||||
if(list != null && list.isEmpty()&&pageNo<=1) {
|
||||
return "<div class=\"none-data\"><i class=\"fa fa-warning font-red-flamingo\"></i> "+requestContext.getMessage("noneData")+"</div>";
|
||||
}
|
||||
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append("<li><a href=\"javascript:\" onclick=\""+funcName+"("+first+","+pageSize+",'"+funcParam+"');\">"+requestContext.getMessage("firstPage")+"</a></li>\n");
|
||||
if (pageNo == first) {// 如果是首页
|
||||
sb.append("<li class=\"disabled\"><a href=\"javascript:\">« "+requestContext.getMessage("previousPage")+"</a></li>\n");
|
||||
} else {
|
||||
sb.append("<li><a href=\"javascript:\" onclick=\""+funcName+"("+prev+","+pageSize+",'"+funcParam+"');\">« "+requestContext.getMessage("previousPage")+"</a></li>\n");
|
||||
}
|
||||
|
||||
sb.append("<li class=\"disabled\"><a href=\"javascript:\">"+pageNo+"</a></li>\n");
|
||||
|
||||
// 最后一页 未铺满 集合不为空
|
||||
if (list != null && !list.isEmpty()&&list.size()<pageSize) {
|
||||
sb.append("<li class=\"disabled\"><a href=\"javascript:\">"+requestContext.getMessage("nextPage")+" »</a></li>\n");
|
||||
}else if(pageNo>1&&list.isEmpty()){
|
||||
sb.append("<li class=\"disabled\"><a href=\"javascript:\">"+requestContext.getMessage("nextPage")+" »</a></li>\n");
|
||||
}else {
|
||||
sb.append("<li><a href=\"javascript:\" onclick=\""+funcName+"("+next+","+pageSize+",'"+funcParam+"');\">"
|
||||
+ ""+requestContext.getMessage("nextPage")+" »</a></li>\n");
|
||||
}
|
||||
|
||||
|
||||
sb.insert(0,"<ul>\n").append("</ul>\n");
|
||||
|
||||
sb.append("<div style=\"clear:both;\"></div>");
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分页HTML代码
|
||||
* @return
|
||||
*/
|
||||
@JsonIgnore
|
||||
public String getHtml(){
|
||||
return toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取设置总数
|
||||
* @return
|
||||
*/
|
||||
public long getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置数据总数
|
||||
* @param count
|
||||
*/
|
||||
public void setCount(long count) {
|
||||
this.count = count;
|
||||
if (pageSize >= count){
|
||||
pageNo = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前页码
|
||||
* @return
|
||||
*/
|
||||
public int getPageNo() {
|
||||
return pageNo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置当前页码
|
||||
* @param pageNo
|
||||
*/
|
||||
public void setPageNo(int pageNo) {
|
||||
this.pageNo = pageNo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取页面大小
|
||||
* @return
|
||||
*/
|
||||
public int getPageSize() {
|
||||
return pageSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置页面大小(最大500)
|
||||
* @param pageSize
|
||||
*/
|
||||
public void setPageSize(int pageSize) {
|
||||
if (pageSize == -1 || pageSize > 0 ) {
|
||||
this.pageSize = pageSize;
|
||||
} else {
|
||||
this.pageSize = Integer.valueOf(Configurations.getIntProperty("page.pageSize", 30));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页索引
|
||||
* @return
|
||||
*/
|
||||
@JsonIgnore
|
||||
public int getFirst() {
|
||||
return first;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 是否为第一页
|
||||
* @return
|
||||
*/
|
||||
@JsonIgnore
|
||||
public boolean isFirstPage() {
|
||||
return firstPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为最后一页
|
||||
* @return
|
||||
*/
|
||||
@JsonIgnore
|
||||
public boolean isLastPage() {
|
||||
return lastPage;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return where
|
||||
*/
|
||||
@JsonIgnore
|
||||
public String getWhere() {
|
||||
return where;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param where 要设置的 where
|
||||
*/
|
||||
public void setWhere(String where) {
|
||||
this.where = where;
|
||||
}
|
||||
|
||||
/**
|
||||
* 上一页索引值
|
||||
* @return
|
||||
*/
|
||||
@JsonIgnore
|
||||
public int getPrev() {
|
||||
if (isFirstPage()) {
|
||||
return pageNo;
|
||||
} else {
|
||||
return pageNo - 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 下一页索引值
|
||||
* @return
|
||||
*/
|
||||
@JsonIgnore
|
||||
public int getNext() {
|
||||
if (isLastPage()) {
|
||||
return pageNo;
|
||||
} else {
|
||||
return pageNo + 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取本页数据对象列表
|
||||
* @return List<T>
|
||||
*/
|
||||
public List<T> getList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置本页数据对象列表
|
||||
* @param list
|
||||
*/
|
||||
public PageLog<T> setList(List<T> list) {
|
||||
this.list = list;
|
||||
initialize();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取查询排序字符串
|
||||
* @return
|
||||
*/
|
||||
@JsonIgnore
|
||||
public String getOrderBy() {
|
||||
// SQL过滤,防止注入
|
||||
String reg = "(?:')|(?:--)|(/\\*(?:.|[\\n\\r])*?\\*/)|"
|
||||
+ "(\\b(select|update|and|or|delete|insert|trancate|char|into|substr|ascii|declare|exec|count|master|into|drop|execute)\\b)";
|
||||
Pattern sqlPattern = Pattern.compile(reg, Pattern.CASE_INSENSITIVE);
|
||||
if (sqlPattern.matcher(orderBy).find()) {
|
||||
return "";
|
||||
}
|
||||
return orderBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置查询排序,标准查询有效, 实例: updatedate desc, name asc
|
||||
*/
|
||||
public void setOrderBy(String orderBy) {
|
||||
this.orderBy = orderBy;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return fields 字段属性查询,拼接用,分隔
|
||||
*/
|
||||
@JsonIgnore
|
||||
public String getFields() {
|
||||
return fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fields 要设置的 fields
|
||||
*/
|
||||
public void setFields(String fields) {
|
||||
this.fields = fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取点击页码调用的js函数名称
|
||||
* function ${page.funcName}(pageNo){location="${ctx}/list-${category.id}${urlSuffix}?pageNo="+i;}
|
||||
* @return
|
||||
*/
|
||||
@JsonIgnore
|
||||
public String getFuncName() {
|
||||
return funcName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置点击页码调用的js函数名称,默认为page,在一页有多个分页对象时使用。
|
||||
* @param funcName 默认为page
|
||||
*/
|
||||
public void setFuncName(String funcName) {
|
||||
this.funcName = funcName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分页函数的附加参数
|
||||
* @return
|
||||
*/
|
||||
@JsonIgnore
|
||||
public String getFuncParam() {
|
||||
return funcParam;
|
||||
}
|
||||
@JsonIgnore
|
||||
public int getMaxExportSize() {
|
||||
return maxExportSize;
|
||||
}
|
||||
public void setMaxExportSize(int maxExportSize) {
|
||||
this.maxExportSize = maxExportSize;
|
||||
}
|
||||
/**
|
||||
* 设置分页函数的附加参数
|
||||
* @return
|
||||
*/
|
||||
public void setFuncParam(String funcParam) {
|
||||
this.funcParam = funcParam;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置提示消息,显示在“共n条”之后
|
||||
* @param message
|
||||
*/
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页是否有效
|
||||
* @return this.pageSize==-1
|
||||
*/
|
||||
@JsonIgnore
|
||||
public boolean isDisabled() {
|
||||
return this.pageSize==-1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否进行总数统计
|
||||
* @return this.count==-1
|
||||
*/
|
||||
@JsonIgnore
|
||||
public boolean isNotCount() {
|
||||
return this.count==-1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 Hibernate FirstResult
|
||||
*/
|
||||
@JsonIgnore
|
||||
public int getFirstResult(){
|
||||
int firstResult = (getPageNo() - 1) * getPageSize();
|
||||
if (firstResult >= getCount()) {
|
||||
firstResult = 0;
|
||||
}
|
||||
return firstResult;
|
||||
}
|
||||
/**
|
||||
* 获取 Hibernate MaxResults
|
||||
*/
|
||||
@JsonIgnore
|
||||
public int getMaxResults(){
|
||||
return getPageSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* alias
|
||||
* @return alias
|
||||
*/
|
||||
|
||||
public String getAlias() {
|
||||
return alias;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param alias the alias to set
|
||||
*/
|
||||
public void setAlias(String alias) {
|
||||
this.alias = alias;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -64,17 +64,19 @@ public class HttpClientUtil {
|
||||
//请求结果
|
||||
CloseableHttpResponse response = null;
|
||||
String content ="";
|
||||
// try {
|
||||
try {
|
||||
//执行get方法
|
||||
response = httpclient.execute(httpget);
|
||||
// if(response.getStatusLine().getStatusCode()==200){
|
||||
content = EntityUtils.toString(response.getEntity(),"utf-8");
|
||||
// }
|
||||
// } catch (ClientProtocolException e) {
|
||||
// e.printStackTrace();
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
if(response.getStatusLine().getStatusCode()==HttpStatus.SC_OK){
|
||||
content = EntityUtils.toString(response.getEntity(),"utf-8");
|
||||
logger.debug("获取消息成功,相应内容如下: " + content);
|
||||
}
|
||||
} catch (ClientProtocolException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
logger.info("dashboard请求路径:"+url);
|
||||
return content;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.PageLog;
|
||||
import com.nis.domain.log.NtcAppLog;
|
||||
import com.nis.domain.maat.LogRecvData;
|
||||
import com.nis.util.Constants;
|
||||
@@ -43,7 +44,7 @@ public class AppLogController extends BaseController{
|
||||
|
||||
try {
|
||||
|
||||
Page<NtcAppLog> page = new Page<NtcAppLog>(request, response);
|
||||
PageLog<NtcAppLog> page = new PageLog<NtcAppLog>(request, response);
|
||||
Map<String, Object> params=new HashMap<>();
|
||||
params.put("pageSize", page.getPageSize());
|
||||
params.put("pageNo", page.getPageNo());
|
||||
@@ -59,9 +60,7 @@ public class AppLogController extends BaseController{
|
||||
LogRecvData<NtcAppLog> fromJson = gson.fromJson(jsonString, new TypeToken<LogRecvData<NtcAppLog>>(){}.getType());
|
||||
|
||||
if (fromJson.getStatus().intValue() == 200) {
|
||||
// BeanUtils.copyProperties(fromJson.getData(), page);
|
||||
Page<NtcAppLog> data = fromJson.getData();
|
||||
page.setCount(200);
|
||||
page.setList(data.getList());
|
||||
List<NtcAppLog> list = page.getList();
|
||||
for (NtcAppLog l : list) {
|
||||
|
||||
@@ -18,6 +18,7 @@ import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.PageLog;
|
||||
import com.nis.domain.log.NtcDdosLog;
|
||||
import com.nis.domain.maat.LogRecvData;
|
||||
import com.nis.util.Constants;
|
||||
@@ -42,7 +43,7 @@ public class DdosLogController extends BaseController{
|
||||
|
||||
try {
|
||||
|
||||
Page<NtcDdosLog> page = new Page<NtcDdosLog>(request, response);
|
||||
PageLog<NtcDdosLog> page = new PageLog<NtcDdosLog>(request, response);
|
||||
Map<String, Object> params=new HashMap<>();
|
||||
params.put("pageSize", page.getPageSize());
|
||||
params.put("pageNo", page.getPageNo());
|
||||
@@ -58,9 +59,7 @@ public class DdosLogController extends BaseController{
|
||||
LogRecvData<NtcDdosLog> fromJson = gson.fromJson(jsonString, new TypeToken<LogRecvData<NtcDdosLog>>(){}.getType());
|
||||
|
||||
if (fromJson.getStatus().intValue() == 200) {
|
||||
// BeanUtils.copyProperties(fromJson.getData(), page);
|
||||
Page<NtcDdosLog> data = fromJson.getData();
|
||||
page.setCount(200);
|
||||
page.setList(data.getList());
|
||||
List<NtcDdosLog> list = page.getList();
|
||||
for (NtcDdosLog l : list) {
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.PageLog;
|
||||
import com.nis.domain.log.NtcDnsLog;
|
||||
import com.nis.domain.maat.LogRecvData;
|
||||
import com.nis.util.Constants;
|
||||
@@ -32,7 +33,7 @@ public class DnsLogController extends BaseController {
|
||||
@RequestMapping("list")
|
||||
public String list(@ModelAttribute("log") NtcDnsLog log, Model model, HttpServletRequest request, HttpServletResponse response) {
|
||||
try {
|
||||
Page<NtcDnsLog> page = new Page<NtcDnsLog>(request, response);
|
||||
PageLog<NtcDnsLog> page = new PageLog<NtcDnsLog>(request, response);
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("pageSize", page.getPageSize());
|
||||
params.put("pageNo", page.getPageNo());
|
||||
@@ -49,7 +50,8 @@ public class DnsLogController extends BaseController {
|
||||
|
||||
LogRecvData<NtcDnsLog> fromJson = gson.fromJson(recv, new TypeToken<LogRecvData<NtcDnsLog>>(){}.getType());
|
||||
if (fromJson.getStatus().intValue() == 200) {
|
||||
BeanUtils.copyProperties(fromJson.getData(), page);
|
||||
// BeanUtils.copyProperties(fromJson.getData(), page);
|
||||
page.setList(fromJson.getData().getList());
|
||||
List<NtcDnsLog> list = page.getList();
|
||||
for (NtcDnsLog l : list) {
|
||||
l.setFunctionId(log.getFunctionId());
|
||||
|
||||
@@ -19,7 +19,9 @@ import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.PageLog;
|
||||
import com.nis.domain.log.NtcFtpLog;
|
||||
import com.nis.domain.log.NtcOpenVpnLog;
|
||||
import com.nis.domain.maat.LogRecvData;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.httpclient.HttpClientUtil;
|
||||
@@ -43,7 +45,7 @@ public class FtpLogController extends BaseController{
|
||||
|
||||
try {
|
||||
|
||||
Page<NtcFtpLog> page = new Page<NtcFtpLog>(request, response);
|
||||
PageLog<NtcFtpLog> page = new PageLog<NtcFtpLog>(request, response);
|
||||
Map<String, Object> params=new HashMap<>();
|
||||
params.put("pageSize", page.getPageSize());
|
||||
params.put("pageNo", page.getPageNo());
|
||||
@@ -59,7 +61,9 @@ public class FtpLogController extends BaseController{
|
||||
LogRecvData<NtcFtpLog> fromJson = gson.fromJson(jsonString, new TypeToken<LogRecvData<NtcFtpLog>>(){}.getType());
|
||||
|
||||
if (fromJson.getStatus().intValue() == 200) {
|
||||
BeanUtils.copyProperties(fromJson.getData(), page);
|
||||
// BeanUtils.copyProperties(fromJson.getData(), page);
|
||||
Page<NtcFtpLog> data = fromJson.getData();
|
||||
page.setList(data.getList());
|
||||
List<NtcFtpLog> list = page.getList();
|
||||
for (NtcFtpLog l : list) {
|
||||
l.setFunctionId(entry.getFunctionId());
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.PageLog;
|
||||
import com.nis.domain.log.NtcHttpLog;
|
||||
import com.nis.domain.maat.LogRecvData;
|
||||
import com.nis.util.Constants;
|
||||
@@ -32,7 +33,7 @@ public class HttpLogController extends BaseController {
|
||||
@RequestMapping("list")
|
||||
public String list(@ModelAttribute("log") NtcHttpLog log, Model model, HttpServletRequest request, HttpServletResponse response) {
|
||||
try {
|
||||
Page<NtcHttpLog> page = new Page<NtcHttpLog>(request, response);
|
||||
PageLog<NtcHttpLog> page = new PageLog<NtcHttpLog>(request, response);
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("pageSize", page.getPageSize());
|
||||
params.put("pageNo", page.getPageNo());
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.PageLog;
|
||||
import com.nis.domain.log.NtcIpLog;
|
||||
import com.nis.domain.maat.LogRecvData;
|
||||
import com.nis.exceptions.MaatConvertException;
|
||||
@@ -36,7 +37,7 @@ public class IpLogController extends BaseController {
|
||||
@RequestMapping("list")
|
||||
public String list(@ModelAttribute("log") NtcIpLog log, Model model, HttpServletRequest request, HttpServletResponse response) {
|
||||
try {
|
||||
Page<NtcIpLog> page = new Page<NtcIpLog>(request, response);
|
||||
PageLog<NtcIpLog> page = new PageLog<NtcIpLog>(request, response);
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("pageSize", page.getPageSize());
|
||||
params.put("pageNo", page.getPageNo());
|
||||
@@ -50,7 +51,8 @@ public class IpLogController extends BaseController {
|
||||
Gson gson = new GsonBuilder().create();
|
||||
LogRecvData<NtcIpLog> fromJson = gson.fromJson(recv, new TypeToken<LogRecvData<NtcIpLog>>(){}.getType());
|
||||
if (fromJson.getStatus().intValue() == 200) {
|
||||
BeanUtils.copyProperties(fromJson.getData(), page);
|
||||
// BeanUtils.copyProperties(fromJson.getData(), page);
|
||||
page.setList(fromJson.getData().getList());
|
||||
List<NtcIpLog> list = page.getList();
|
||||
for (NtcIpLog l : list) {
|
||||
l.setFunctionId(log.getFunctionId());
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.PageLog;
|
||||
import com.nis.domain.log.NtcIpsecLog;
|
||||
import com.nis.domain.log.NtcIpsecLog;
|
||||
import com.nis.domain.maat.LogRecvData;
|
||||
@@ -44,7 +45,7 @@ public class IpsecLogController extends BaseController{
|
||||
|
||||
try {
|
||||
|
||||
Page<NtcIpsecLog> page = new Page<NtcIpsecLog>(request, response);
|
||||
PageLog<NtcIpsecLog> page = new PageLog<NtcIpsecLog>(request, response);
|
||||
Map<String, Object> params=new HashMap<>();
|
||||
params.put("pageSize", page.getPageSize());
|
||||
params.put("pageNo", page.getPageNo());
|
||||
@@ -60,8 +61,8 @@ public class IpsecLogController extends BaseController{
|
||||
LogRecvData<NtcIpsecLog> fromJson = gson.fromJson(jsonString, new TypeToken<LogRecvData<NtcIpsecLog>>(){}.getType());
|
||||
|
||||
if (fromJson.getStatus().intValue() == 200) {
|
||||
BeanUtils.copyProperties(fromJson.getData(), page);
|
||||
List<NtcIpsecLog> list = page.getList();
|
||||
List<NtcIpsecLog> list = fromJson.getData().getList();
|
||||
page.setList(list);
|
||||
for (NtcIpsecLog l : list) {
|
||||
l.setFunctionId(entry.getFunctionId());
|
||||
setLogAction(l);
|
||||
|
||||
@@ -18,6 +18,7 @@ import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.PageLog;
|
||||
import com.nis.domain.log.NtcL2tpLog;
|
||||
import com.nis.domain.maat.LogRecvData;
|
||||
import com.nis.util.Constants;
|
||||
@@ -31,7 +32,7 @@ public class L2tpLogController extends BaseController {
|
||||
@RequestMapping(value = {"/list"})
|
||||
public String list(HttpServletRequest request, HttpServletResponse response, Model model, @ModelAttribute("log")NtcL2tpLog ntcL2tpLog) {
|
||||
|
||||
Page<NtcL2tpLog> page = new Page<NtcL2tpLog>(request,response);
|
||||
PageLog<NtcL2tpLog> page = new PageLog<NtcL2tpLog>(request,response);
|
||||
Map<String, Object> params = new HashMap<String,Object>();
|
||||
params.put("pageSize", page.getPageSize());
|
||||
params.put("pageNo", page.getPageNo());
|
||||
@@ -47,7 +48,7 @@ public class L2tpLogController extends BaseController {
|
||||
LogRecvData<NtcL2tpLog> fromJson = gson.fromJson(resJson, new TypeToken<LogRecvData<NtcL2tpLog>>() {}.getType());
|
||||
if(fromJson.getStatus().intValue() == 200) {
|
||||
Page<NtcL2tpLog> fromPage = fromJson.getData();
|
||||
BeanUtils.copyProperties(fromPage, page);
|
||||
page.setList(fromPage.getList());
|
||||
List<NtcL2tpLog> list = fromPage.getList();
|
||||
for (NtcL2tpLog log : list) {
|
||||
log.setFunctionId(ntcL2tpLog.getFunctionId());
|
||||
|
||||
@@ -18,6 +18,7 @@ import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.PageLog;
|
||||
import com.nis.domain.log.NtcMailLog;
|
||||
import com.nis.domain.maat.LogRecvData;
|
||||
import com.nis.util.Constants;
|
||||
@@ -31,7 +32,7 @@ public class MailLogController extends BaseController {
|
||||
@RequestMapping("list")
|
||||
public String list(@ModelAttribute("log") NtcMailLog log, Model model, HttpServletRequest request, HttpServletResponse response) {
|
||||
try {
|
||||
Page<NtcMailLog> page = new Page<NtcMailLog>(request, response);
|
||||
PageLog<NtcMailLog> page = new PageLog<NtcMailLog>(request, response);
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("pageSize", page.getPageSize());
|
||||
params.put("pageNo", page.getPageNo());
|
||||
@@ -45,7 +46,7 @@ public class MailLogController extends BaseController {
|
||||
Gson gson = new GsonBuilder().create();
|
||||
LogRecvData<NtcMailLog> fromJson = gson.fromJson(recv, new TypeToken<LogRecvData<NtcMailLog>>(){}.getType());
|
||||
if (fromJson.getStatus().intValue() == 200) {
|
||||
BeanUtils.copyProperties(fromJson.getData(), page);
|
||||
page.setList(fromJson.getData().getList());
|
||||
List<NtcMailLog> list = page.getList();
|
||||
for (NtcMailLog l : list) {
|
||||
l.setFunctionId(log.getFunctionId());
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.PageLog;
|
||||
import com.nis.domain.log.NtcOpenVpnLog;
|
||||
import com.nis.domain.log.NtcOpenVpnLog;
|
||||
import com.nis.domain.maat.LogRecvData;
|
||||
@@ -44,7 +45,7 @@ public class OpenVpnLogController extends BaseController{
|
||||
|
||||
try {
|
||||
|
||||
Page<NtcOpenVpnLog> page = new Page<NtcOpenVpnLog>(request, response);
|
||||
PageLog<NtcOpenVpnLog> page = new PageLog<NtcOpenVpnLog>(request, response);
|
||||
Map<String, Object> params=new HashMap<>();
|
||||
params.put("pageSize", page.getPageSize());
|
||||
params.put("pageNo", page.getPageNo());
|
||||
@@ -60,9 +61,7 @@ public class OpenVpnLogController extends BaseController{
|
||||
LogRecvData<NtcOpenVpnLog> fromJson = gson.fromJson(jsonString, new TypeToken<LogRecvData<NtcOpenVpnLog>>(){}.getType());
|
||||
|
||||
if (fromJson.getStatus().intValue() == 200) {
|
||||
// BeanUtils.copyProperties(fromJson.getData(), page);
|
||||
Page<NtcOpenVpnLog> data = fromJson.getData();
|
||||
page.setCount(200);
|
||||
page.setList(data.getList());
|
||||
List<NtcOpenVpnLog> list = page.getList();
|
||||
for (NtcOpenVpnLog l : list) {
|
||||
|
||||
@@ -18,6 +18,7 @@ import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.PageLog;
|
||||
import com.nis.domain.log.NtcPptpLog;
|
||||
import com.nis.domain.maat.LogRecvData;
|
||||
import com.nis.util.Constants;
|
||||
@@ -31,7 +32,7 @@ public class PptpLogController extends BaseController {
|
||||
@RequestMapping(value = {"/list"})
|
||||
public String list(HttpServletRequest request, HttpServletResponse response, Model model, @ModelAttribute("log")NtcPptpLog ntcPptpLog) {
|
||||
|
||||
Page<NtcPptpLog> page = new Page<NtcPptpLog>(request,response);
|
||||
PageLog<NtcPptpLog> page = new PageLog<NtcPptpLog>(request,response);
|
||||
Map<String, Object> params = new HashMap<String,Object>();
|
||||
params.put("pageSize", page.getPageSize());
|
||||
params.put("pageNo", page.getPageNo());
|
||||
@@ -47,8 +48,8 @@ public class PptpLogController extends BaseController {
|
||||
LogRecvData<NtcPptpLog> fromJson = gson.fromJson(resJson, new TypeToken<LogRecvData<NtcPptpLog>>() {}.getType());
|
||||
if(fromJson.getStatus().intValue() == 200) {
|
||||
Page<NtcPptpLog> fromPage = fromJson.getData();
|
||||
BeanUtils.copyProperties(fromPage, page);
|
||||
List<NtcPptpLog> list = fromPage.getList();
|
||||
page.setList(list);
|
||||
for (NtcPptpLog log : list) {
|
||||
log.setFunctionId(ntcPptpLog.getFunctionId());
|
||||
setLogAction(log);
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.PageLog;
|
||||
import com.nis.domain.log.NtcSshLog;
|
||||
import com.nis.domain.log.NtcSshLog;
|
||||
import com.nis.domain.maat.LogRecvData;
|
||||
@@ -44,7 +45,7 @@ public class SshLogController extends BaseController{
|
||||
|
||||
try {
|
||||
|
||||
Page<NtcSshLog> page = new Page<NtcSshLog>(request, response);
|
||||
PageLog<NtcSshLog> page = new PageLog<NtcSshLog>(request, response);
|
||||
Map<String, Object> params=new HashMap<>();
|
||||
params.put("pageSize", page.getPageSize());
|
||||
params.put("pageNo", page.getPageNo());
|
||||
@@ -60,7 +61,8 @@ public class SshLogController extends BaseController{
|
||||
LogRecvData<NtcSshLog> fromJson = gson.fromJson(jsonString, new TypeToken<LogRecvData<NtcSshLog>>(){}.getType());
|
||||
|
||||
if (fromJson.getStatus().intValue() == 200) {
|
||||
BeanUtils.copyProperties(fromJson.getData(), page);
|
||||
Page<NtcSshLog> data = fromJson.getData();
|
||||
page.setList(data.getList());
|
||||
List<NtcSshLog> list = page.getList();
|
||||
for (NtcSshLog l : list) {
|
||||
l.setFunctionId(entry.getFunctionId());
|
||||
|
||||
@@ -18,6 +18,7 @@ import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.PageLog;
|
||||
import com.nis.domain.log.NtcSslLog;
|
||||
import com.nis.domain.maat.LogRecvData;
|
||||
import com.nis.util.Constants;
|
||||
@@ -32,7 +33,7 @@ public class SslLogController extends BaseController {
|
||||
@RequestMapping(value = {"/list"})
|
||||
public String list(HttpServletRequest request, HttpServletResponse response, Model model, @ModelAttribute("log")NtcSslLog ntcSslLog) {
|
||||
|
||||
Page<NtcSslLog> page = new Page<NtcSslLog>(request,response);
|
||||
PageLog<NtcSslLog> page = new PageLog<NtcSslLog>(request,response);
|
||||
Map<String, Object> params = new HashMap<String,Object>();
|
||||
params.put("pageSize", page.getPageSize());
|
||||
params.put("pageNo", page.getPageNo());
|
||||
@@ -50,8 +51,8 @@ public class SslLogController extends BaseController {
|
||||
LogRecvData<NtcSslLog> fromJson = gson.fromJson(resJson, new TypeToken<LogRecvData<NtcSslLog>>() {}.getType());
|
||||
if(fromJson.getStatus().intValue() == 200) {
|
||||
Page<NtcSslLog> fromPage = fromJson.getData();
|
||||
BeanUtils.copyProperties(fromPage, page);
|
||||
List<NtcSslLog> list = fromPage.getList();
|
||||
page.setList(list);
|
||||
for (NtcSslLog log : list) {
|
||||
log.setFunctionId(ntcSslLog.getFunctionId());
|
||||
setLogAction(log);
|
||||
|
||||
Reference in New Issue
Block a user