openvpn页面调整;后台默认时间设置
This commit is contained in:
@@ -35,6 +35,18 @@ public class BaseLogEntity<T> extends BaseEntity<T> {
|
||||
protected String searchFoundEndTime;//结束时间,格式同上
|
||||
|
||||
|
||||
public String getFoundTime() {
|
||||
return foundTime;
|
||||
}
|
||||
public void setFoundTime(String foundTime) {
|
||||
this.foundTime = foundTime;
|
||||
}
|
||||
public String getRecvTime() {
|
||||
return recvTime;
|
||||
}
|
||||
public void setRecvTime(String recvTime) {
|
||||
this.recvTime = recvTime;
|
||||
}
|
||||
public String getSearchFoundStartTime() {
|
||||
return searchFoundStartTime;
|
||||
}
|
||||
@@ -59,20 +71,6 @@ public class BaseLogEntity<T> extends BaseEntity<T> {
|
||||
public void setCfgId(Integer cfgId) {
|
||||
this.cfgId = cfgId;
|
||||
}
|
||||
public String getFoundTime() {
|
||||
Date date = new Date(Long.parseLong(this.foundTime));
|
||||
return DateUtils.formatDateTime(date);
|
||||
}
|
||||
public void setFoundTime(String foundTime) {
|
||||
this.foundTime = foundTime;
|
||||
}
|
||||
public String getRecvTime() {
|
||||
Date date = new Date(Long.parseLong(this.recvTime));
|
||||
return DateUtils.formatDateTime(date);
|
||||
}
|
||||
public void setRecvTime(String recvTime) {
|
||||
this.recvTime = recvTime;
|
||||
}
|
||||
public String getProtocol() {
|
||||
return protocol;
|
||||
}
|
||||
@@ -157,6 +155,16 @@ public class BaseLogEntity<T> extends BaseEntity<T> {
|
||||
public void setUserRegion(String userRegion) {
|
||||
this.userRegion = userRegion;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BaseLogEntity [cfgId=" + cfgId + ", foundTime=" + foundTime + ", recvTime=" + recvTime + ", protocol="
|
||||
+ protocol + ", addrType=" + addrType + ", serverIp=" + serverIp + ", clientIp=" + clientIp
|
||||
+ ", serverPort=" + serverPort + ", clientPort=" + clientPort + ", serviceType=" + serviceType
|
||||
+ ", entranceId=" + entranceId + ", deviceId=" + deviceId + ", direction=" + direction + ", streamType="
|
||||
+ streamType + ", cljIp=" + cljIp + ", nestAddrList=" + nestAddrList + ", userRegion=" + userRegion
|
||||
+ ", seltype=" + seltype + ", searchFoundStartTime=" + searchFoundStartTime + ", searchFoundEndTime="
|
||||
+ searchFoundEndTime + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.nis.web.controller.log.ntc;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -22,6 +23,9 @@ import com.google.gson.reflect.TypeToken;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.log.NtcOpenVpnLog;
|
||||
import com.nis.domain.maat.LogRecvData;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.DateUtils;
|
||||
import com.nis.util.StringUtils;
|
||||
import com.nis.util.httpclient.HttpClientUtil;
|
||||
import com.nis.web.controller.BaseController;
|
||||
|
||||
@@ -29,43 +33,78 @@ import com.nis.web.controller.BaseController;
|
||||
@RequestMapping(value = "${adminPath}/log/ntc/ntcOpenvpnLogs")
|
||||
public class OpenVpnController extends BaseController{
|
||||
|
||||
/**
|
||||
* @param model
|
||||
* @param entry
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
* @throws ClientProtocolException
|
||||
* @throws IOException
|
||||
*/
|
||||
@RequestMapping(value={"list",""})
|
||||
public String list(Model model,@ModelAttribute("log")NtcOpenVpnLog testEntry,HttpServletRequest request, HttpServletResponse response) throws ClientProtocolException, IOException {
|
||||
public String list(Model model,@ModelAttribute("log")NtcOpenVpnLog entry,HttpServletRequest request, HttpServletResponse response) throws ClientProtocolException, IOException {
|
||||
|
||||
Page<NtcOpenVpnLog> page = new Page<NtcOpenVpnLog>(request, response);
|
||||
int pageSize = page.getPageSize();
|
||||
int pageNo = page.getPageNo();
|
||||
Map<String, Object> params=new HashMap<>();
|
||||
// String jsonString = HttpClientUtil.getMsg("http://localhost:8080/gwall/view/logs/test",params);
|
||||
|
||||
String readAsString = FileUtil.readAsString(new File("D:/FeigeDownload/logTest.txt"));
|
||||
Gson gson = new GsonBuilder().create();
|
||||
//gson泛型支持
|
||||
LogRecvData<NtcOpenVpnLog> fromJson = gson.fromJson(readAsString, new TypeToken<LogRecvData<NtcOpenVpnLog>>(){}.getType());
|
||||
|
||||
Page<NtcOpenVpnLog> data = fromJson.getData();
|
||||
List<NtcOpenVpnLog> list = data.getList();
|
||||
page.setList(list);
|
||||
page.setCount(data.getCount());
|
||||
model.addAttribute("page", page);
|
||||
logger.info("查询OpenVpn日志成功");
|
||||
return "/log/ntc/openVpnList";
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
String readAsString;
|
||||
try {
|
||||
readAsString = FileUtil.readAsString(new File("D:/FeigeDownload/logTest.txt"));
|
||||
Gson gson = new GsonBuilder().create();
|
||||
//gson泛型支持
|
||||
LogRecvData<NtcOpenVpnLog> fromJson = gson.fromJson(readAsString, new TypeToken<LogRecvData<NtcOpenVpnLog>>(){}.getType());
|
||||
|
||||
Page<NtcOpenVpnLog> page = fromJson.getData();
|
||||
NtcOpenVpnLog object = page.getList().get(0);
|
||||
System.err.println(object.getCfgId());
|
||||
} catch (IOException e) {
|
||||
Page<NtcOpenVpnLog> page = new Page<NtcOpenVpnLog>(request, response);
|
||||
Map<String, Object> params=new HashMap<>();
|
||||
params.put("pageSize", page.getPageSize());
|
||||
params.put("pageNo", page.getPageNo());
|
||||
|
||||
if (StringUtils.isNotBlank(entry.getSearchFoundStartTime())&&StringUtils.isNotBlank(entry.getSearchFoundEndTime())) {
|
||||
params.put("searchFoundStartTime", entry.getSearchFoundStartTime());
|
||||
params.put("searchFoundEndTime", entry.getSearchFoundEndTime());
|
||||
}else{
|
||||
//设置默认查询当前时间及前五分钟
|
||||
String startTime = DateUtils.getDateTime();
|
||||
Date dateEnd = new Date(new Date().getTime()-Constants.LOG_TIME_RANGE);
|
||||
String endTime = DateUtils.formatDateTime(dateEnd);
|
||||
params.put("searchFoundStartTime", startTime);
|
||||
params.put("searchFoundEndTime",endTime );
|
||||
entry.setSearchFoundStartTime(startTime);
|
||||
entry.setSearchFoundEndTime(endTime);
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(entry.getProtocol())) {
|
||||
params.put("searchProtocol", entry.getProtocol());
|
||||
}
|
||||
if (entry.getServiceType()!=null) {
|
||||
params.put("searchServiceType", entry.getServiceType());
|
||||
}
|
||||
if (StringUtils.isNotBlank(entry.getServerIp())) {
|
||||
params.put("searchServerIp", entry.getServerIp());
|
||||
}
|
||||
if (StringUtils.isNotBlank(entry.getClientIp())) {
|
||||
params.put("searchClientIp", entry.getClientIp());
|
||||
}
|
||||
if (StringUtils.isNotBlank(entry.getCljIp())) {
|
||||
params.put("searchCljIp", entry.getCljIp());
|
||||
}
|
||||
if (entry.getDirection()!=null) {
|
||||
params.put("searchDirection", entry.getDirection());
|
||||
}
|
||||
if (entry.getEntranceId()!=null) {
|
||||
params.put("searchEntranceId", entry.getEntranceId());
|
||||
}
|
||||
String url = "";
|
||||
url = Constants.LOG_BASE_URL+Constants.NTC_OPENVPN_LOG;
|
||||
String jsonString = HttpClientUtil.getMsg(url,params);
|
||||
|
||||
Gson gson = new GsonBuilder().create();
|
||||
//gson泛型支持
|
||||
LogRecvData<NtcOpenVpnLog> fromJson = gson.fromJson(jsonString, new TypeToken<LogRecvData<NtcOpenVpnLog>>(){}.getType());
|
||||
|
||||
Page<NtcOpenVpnLog> data = fromJson.getData();
|
||||
List<NtcOpenVpnLog> list = data.getList();
|
||||
page.setList(list);
|
||||
page.setCount(data.getCount());
|
||||
model.addAttribute("page", page);
|
||||
logger.info("查询OpenVpn日志成功");
|
||||
} catch (Exception e) {
|
||||
logger.info("查询OpenVpn日志失败");
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "/log/ntc/openVpnList";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user