1.新增 日志检索->流量日志->HTTP泛收界面
2.新增 日志检索->白名单->IP白名单界面 3.修改 日志检索->IP地址界面 动作默认为监测 4.移除 日志检索->流量日志->邮件泛收和SSL泛收的动作条件
This commit is contained in:
48
src/main/java/com/nis/domain/log/NtcHttpRecordLog.java
Normal file
48
src/main/java/com/nis/domain/log/NtcHttpRecordLog.java
Normal file
@@ -0,0 +1,48 @@
|
||||
package com.nis.domain.log;
|
||||
|
||||
import com.nis.util.excel.ExcelField;
|
||||
|
||||
public class NtcHttpRecordLog extends BaseLogEntity<NtcHttpRecordLog> {
|
||||
|
||||
private static final long serialVersionUID = -7697668215327123848L;
|
||||
|
||||
@ExcelField(title = "URL", sort = 2)
|
||||
private String url;
|
||||
|
||||
@ExcelField(title = "referer", sort = 3)
|
||||
private String referer;// 入口页面
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getReferer() {
|
||||
return referer;
|
||||
}
|
||||
|
||||
public void setReferer(String referer) {
|
||||
this.referer = referer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "NtcHttpRecordLog [url=" + url + ", referer=" + referer + ", cfgId=" + cfgId + ", foundTime=" + foundTime
|
||||
+ ", recvTime=" + recvTime + ", transProto=" + transProto + ", addrType=" + addrType + ", dIp=" + dIp
|
||||
+ ", sIp=" + sIp + ", dPort=" + dPort + ", sPort=" + sPort + ", service=" + service + ", entranceId="
|
||||
+ entranceId + ", deviceId=" + deviceId + ", direction=" + direction + ", streamDir=" + streamDir
|
||||
+ ", capIp=" + capIp + ", addrList=" + addrList + ", serverLocate=" + serverLocate + ", clientLocate="
|
||||
+ clientLocate + ", sAsn=" + sAsn + ", dAsn=" + dAsn + ", sSubscribeId=" + sSubscribeId
|
||||
+ ", dSubscribeId=" + dSubscribeId + ", sceneFile=" + sceneFile + ", functionId=" + functionId
|
||||
+ ", action=" + action + ", date=" + date + ", seltype=" + seltype + ", searchFoundStartTime="
|
||||
+ searchFoundStartTime + ", searchFoundEndTime=" + searchFoundEndTime + ", isLogTotalSearch="
|
||||
+ isLogTotalSearch + ", orderBy=" + orderBy + ", encapType=" + encapType + ", linkId=" + linkId
|
||||
+ ", innerSmac=" + innerSmac + ", innerDmac=" + innerDmac + ", id=" + id + ", currentUser="
|
||||
+ currentUser + ", page=" + page + ", pageLog=" + pageLog + ", sqlMap=" + sqlMap + ", isNewRecord="
|
||||
+ isNewRecord + ", isFilterAction=" + isFilterAction + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -814,4 +814,8 @@ public final class Constants {
|
||||
* 流量日志的SSL泛收接口URL
|
||||
*/
|
||||
public static final String NTC_SSL_RECORD_LOG = Configurations.getStringProperty("ntcSslRecordLog","");
|
||||
/**
|
||||
* 流量日志的HTTP泛收接口URL
|
||||
*/
|
||||
public static final String NTC_HTTP_RECORD_LOG = Configurations.getStringProperty("ntcHttpRecordLog","");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,183 @@
|
||||
package com.nis.web.controller.log.ntc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang.StringEscapeUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.nis.domain.FunctionServiceDict;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.PageLog;
|
||||
import com.nis.domain.SysUser;
|
||||
import com.nis.domain.log.NtcHttpRecordLog;
|
||||
import com.nis.domain.log.NtcHttpRecordLog;
|
||||
import com.nis.domain.maat.LogRecvData;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.DictUtils;
|
||||
import com.nis.util.Encodes;
|
||||
import com.nis.util.httpclient.HttpClientUtil;
|
||||
import com.nis.web.controller.BaseController;
|
||||
import com.nis.web.security.UserUtils;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("${adminPath}/log/ntc/httpRecord")
|
||||
public class HttpRecordLogController extends BaseController {
|
||||
|
||||
@RequestMapping(value = { "list", "" })
|
||||
public String list(@ModelAttribute("log") NtcHttpRecordLog log, Model model, HttpServletRequest request,
|
||||
HttpServletResponse response) {
|
||||
try {
|
||||
PageLog<NtcHttpRecordLog> page = new PageLog<NtcHttpRecordLog>(request, response);
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("pageSize", page.getPageSize());
|
||||
params.put("pageNo", page.getPageNo());
|
||||
if (StringUtils.isNotBlank(log.getUrl())) {
|
||||
String httpurl = StringEscapeUtils.unescapeHtml(log.getUrl());
|
||||
params.put("searchUrl", httpurl);
|
||||
}
|
||||
initLogSearchValue(log, params);
|
||||
|
||||
if (StringUtils.isNotBlank(log.getdPort())) {
|
||||
params.put("searchDPort", log.getdPort());
|
||||
}
|
||||
if (StringUtils.isNotBlank(log.getsPort())) {
|
||||
params.put("searchSPort", log.getsPort());
|
||||
}
|
||||
if (StringUtils.isNotBlank(log.getReferer())) {
|
||||
params.put("searchReferer", log.getReferer());
|
||||
}
|
||||
if (null != log.getDeviceId()) {
|
||||
params.put("searchDeviceId", log.getDeviceId());
|
||||
}
|
||||
|
||||
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(log.getFunctionId());
|
||||
serviceList.addAll(DictUtils.getFunctionServiceDictList(635));
|
||||
model.addAttribute("serviceList", serviceList);
|
||||
|
||||
String url = Constants.LOG_BASE_URL + Constants.NTC_HTTP_RECORD_LOG;
|
||||
String recv = HttpClientUtil.getMsg(url, params, request);
|
||||
|
||||
Gson gson = new GsonBuilder().create();
|
||||
|
||||
LogRecvData<NtcHttpRecordLog> fromJson = gson.fromJson(recv,
|
||||
new TypeToken<LogRecvData<NtcHttpRecordLog>>() {
|
||||
}.getType());
|
||||
if (fromJson.getStatus().intValue() == 200) {
|
||||
Page<NtcHttpRecordLog> data = fromJson.getData();
|
||||
page.setCount(data.getCount());
|
||||
page.setLast(data.getLast());
|
||||
page.setList(data.getList());
|
||||
List<NtcHttpRecordLog> list = page.getList();
|
||||
for (NtcHttpRecordLog l : list) {
|
||||
l.setFunctionId(log.getFunctionId());
|
||||
setLogAction(l, serviceList);
|
||||
}
|
||||
model.addAttribute("page", page);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("查询失败", e);
|
||||
addMessageLog(model, e.getMessage());
|
||||
}
|
||||
|
||||
return "/log/ntc/httpRecordList";
|
||||
}
|
||||
|
||||
// http泛收配置导出
|
||||
@RequestMapping(value = "exportHttp")
|
||||
public void exportHttp(@ModelAttribute("log") NtcHttpRecordLog log, Model model, String hColumns, String type,
|
||||
HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) {
|
||||
try {
|
||||
// export data info
|
||||
List<String> titleList = new ArrayList<String>();
|
||||
Map<String, Class<?>> classMap = new HashMap<String, Class<?>>();
|
||||
Map<String, List> dataMap = new HashMap<String, List>();
|
||||
Map<String, String> noExportMap = new HashMap<String, String>();
|
||||
// ---------------------------
|
||||
PageLog<NtcHttpRecordLog> page = new PageLog<NtcHttpRecordLog>(request, response);
|
||||
page.setPageNo(1);
|
||||
page.setPageSize(Constants.MAX_LOG_EXPORT_SIZE);
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("pageSize", page.getPageSize());
|
||||
params.put("pageNo", page.getPageNo());
|
||||
if (StringUtils.isNotBlank(log.getUrl())) {
|
||||
String httpurl = StringEscapeUtils.unescapeHtml(log.getUrl());
|
||||
params.put("searchUrl", httpurl);
|
||||
}
|
||||
initLogSearchValue(log, params);
|
||||
|
||||
if (StringUtils.isNotBlank(log.getdPort())) {
|
||||
params.put("searchDport", log.getdPort());
|
||||
}
|
||||
if (StringUtils.isNotBlank(log.getsPort())) {
|
||||
params.put("searchSport", log.getsPort());
|
||||
}
|
||||
if (StringUtils.isNotBlank(log.getReferer())) {
|
||||
params.put("searchReferer", log.getReferer());
|
||||
}
|
||||
if (null != log.getDeviceId()) {
|
||||
params.put("searchDeviceId", log.getDeviceId());
|
||||
}
|
||||
|
||||
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(log.getFunctionId());
|
||||
serviceList.addAll(DictUtils.getFunctionServiceDictList(635));
|
||||
model.addAttribute("serviceList", serviceList);
|
||||
|
||||
String url = Constants.LOG_BASE_URL + Constants.NTC_HTTP_RECORD_LOG;
|
||||
String recv = HttpClientUtil.getMsg(url, params, request);
|
||||
List<NtcHttpRecordLog> list = new ArrayList<NtcHttpRecordLog>();
|
||||
if (StringUtils.isNotBlank(recv)) {
|
||||
Gson gson = new GsonBuilder().create();
|
||||
LogRecvData<NtcHttpRecordLog> fromJson = gson.fromJson(recv,
|
||||
new TypeToken<LogRecvData<NtcHttpRecordLog>>() {
|
||||
}.getType());
|
||||
if (fromJson.getStatus().intValue() == 200) {
|
||||
Page<NtcHttpRecordLog> data = fromJson.getData();
|
||||
list = data.getList();
|
||||
}
|
||||
}
|
||||
for (NtcHttpRecordLog l : list) {
|
||||
l.setFunctionId(log.getFunctionId());
|
||||
setLogAction(l, serviceList);
|
||||
}
|
||||
titleList.add("http_record");
|
||||
classMap.put("http_record", NtcHttpRecordLog.class);
|
||||
SysUser user = UserUtils.getUser();
|
||||
if (!user.isAdmin()) {
|
||||
hColumns += "";
|
||||
} else {
|
||||
hColumns += ",";
|
||||
}
|
||||
String cfgIndexInfoNoExport = ",action,cfg_id,recv_time,clj_ip,transport_layer_protocol,addr_type,link_id,encap_type,direction,inner_smac,inner_dmac,stream_type,nest_addr_list,server_locate,client_locate,s_asn,d_asn,s_subscribe_id,d_subscribe_id,scene_file,"
|
||||
+ hColumns;
|
||||
noExportMap.put("http_record", cfgIndexInfoNoExport);
|
||||
dataMap.put("http_record", list);
|
||||
String timeRange = initLogMap(log, "http_record");
|
||||
noExportMap.put("timeRange", timeRange);
|
||||
/* } */
|
||||
if ("csv".equals(type)) {
|
||||
this._exportCsv(model, request, response, redirectAttributes, "http_record", titleList, classMap,
|
||||
dataMap, noExportMap);
|
||||
} else {
|
||||
this._export(model, request, response, redirectAttributes, "http_record", titleList, classMap, dataMap,
|
||||
noExportMap);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("http_record export failed", e);
|
||||
addMessage(redirectAttributes, "error", "export_failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@ import com.nis.domain.log.NtcIpLog;
|
||||
import com.nis.domain.maat.LogRecvData;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.DictUtils;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.util.httpclient.HttpClientUtil;
|
||||
import com.nis.web.controller.BaseController;
|
||||
import com.nis.web.security.UserUtils;
|
||||
@@ -31,25 +32,31 @@ import com.nis.web.security.UserUtils;
|
||||
@Controller
|
||||
@RequestMapping("${adminPath}/log/ntc/ip")
|
||||
public class IpLogController extends BaseController {
|
||||
|
||||
|
||||
@RequestMapping("list")
|
||||
public String list(@ModelAttribute("log") NtcIpLog log, Model model, HttpServletRequest request, HttpServletResponse response) {
|
||||
public String list(@ModelAttribute("log") NtcIpLog log, Model model, HttpServletRequest request,
|
||||
HttpServletResponse response) {
|
||||
try {
|
||||
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());
|
||||
initLogSearchValue(log, params);
|
||||
|
||||
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(log.getFunctionId());
|
||||
model.addAttribute("serviceList", serviceList);
|
||||
|
||||
|
||||
if (StringUtil.isEmpty(log.getService())) {
|
||||
log.setService(128);
|
||||
}
|
||||
|
||||
initLogSearchValue(log, params);
|
||||
|
||||
String url = Constants.LOG_BASE_URL + Constants.NTC_IP_LOG;
|
||||
String recv = HttpClientUtil.getMsg(url, params, request);
|
||||
|
||||
|
||||
if (StringUtils.isNotBlank(recv)) {
|
||||
Gson gson = new GsonBuilder().create();
|
||||
LogRecvData<NtcIpLog> fromJson = gson.fromJson(recv, new TypeToken<LogRecvData<NtcIpLog>>(){}.getType());
|
||||
LogRecvData<NtcIpLog> fromJson = gson.fromJson(recv, new TypeToken<LogRecvData<NtcIpLog>>() {
|
||||
}.getType());
|
||||
if (fromJson.getStatus().intValue() == 200) {
|
||||
Page<NtcIpLog> data = fromJson.getData();
|
||||
page.setCount(data.getCount());
|
||||
@@ -58,7 +65,7 @@ public class IpLogController extends BaseController {
|
||||
List<NtcIpLog> list = page.getList();
|
||||
for (NtcIpLog l : list) {
|
||||
l.setFunctionId(log.getFunctionId());
|
||||
setLogAction(l,serviceList);
|
||||
setLogAction(l, serviceList);
|
||||
}
|
||||
model.addAttribute("page", page);
|
||||
}
|
||||
@@ -67,34 +74,36 @@ public class IpLogController extends BaseController {
|
||||
logger.error("查询失败", e);
|
||||
addMessageLog(model, e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
return "/log/ntc/ipList";
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("testlist")
|
||||
public String testlist(@ModelAttribute("log") NtcIpLog log, Model model, HttpServletRequest request, HttpServletResponse response) {
|
||||
public String testlist(@ModelAttribute("log") NtcIpLog log, Model model, HttpServletRequest request,
|
||||
HttpServletResponse response) {
|
||||
Page<NtcIpLog> page = new Page<NtcIpLog>(request, response);
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("pageSize", page.getPageSize());
|
||||
params.put("pageNo", page.getPageNo());
|
||||
initLogSearchValue(log, params);
|
||||
|
||||
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(log.getFunctionId());
|
||||
model.addAttribute("serviceList", serviceList);
|
||||
|
||||
|
||||
initLogSearchValue(log, params);
|
||||
|
||||
String url = "http://10.0.6.121:8080/gwall/test/logTest";
|
||||
try {
|
||||
String recv = HttpClientUtil.getMsg(url, params, request);
|
||||
|
||||
|
||||
Gson gson = new GsonBuilder().create();
|
||||
|
||||
LogRecvData<NtcIpLog> fromJson = gson.fromJson(recv, new TypeToken<LogRecvData<NtcIpLog>>(){}.getType());
|
||||
|
||||
LogRecvData<NtcIpLog> fromJson = gson.fromJson(recv, new TypeToken<LogRecvData<NtcIpLog>>() {
|
||||
}.getType());
|
||||
if (fromJson.getStatus().intValue() == 200) {
|
||||
BeanUtils.copyProperties(fromJson.getData(), page);
|
||||
List<NtcIpLog> list = page.getList();
|
||||
for (NtcIpLog l : list) {
|
||||
l.setFunctionId(log.getFunctionId());
|
||||
setLogAction(l,serviceList);
|
||||
setLogAction(l, serviceList);
|
||||
}
|
||||
model.addAttribute("page", page);
|
||||
}
|
||||
@@ -102,73 +111,77 @@ public class IpLogController extends BaseController {
|
||||
logger.error("查询失败", e);
|
||||
addMessageLog(model, e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
return "/log/ntc/ipList";
|
||||
}
|
||||
|
||||
// Ip配置导出
|
||||
@RequestMapping(value = "exportIp")
|
||||
public void exportIp(@ModelAttribute("log") NtcIpLog log, Model model, String hColumns, String type,
|
||||
HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) {
|
||||
try {
|
||||
// export data info
|
||||
List<String> titleList = new ArrayList<String>();
|
||||
Map<String, Class<?>> classMap = new HashMap<String, Class<?>>();
|
||||
Map<String, List> dataMap = new HashMap<String, List>();
|
||||
Map<String, String> noExportMap = new HashMap<String, String>();
|
||||
// ---------------------------
|
||||
PageLog<NtcIpLog> page = new PageLog<NtcIpLog>(request, response);
|
||||
page.setPageNo(1);
|
||||
page.setPageSize(Constants.MAX_LOG_EXPORT_SIZE);
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("pageSize", page.getPageSize());
|
||||
params.put("pageNo", page.getPageNo());
|
||||
initLogSearchValue(log, params);
|
||||
|
||||
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(log.getFunctionId());
|
||||
model.addAttribute("serviceList", serviceList);
|
||||
|
||||
String url = Constants.LOG_BASE_URL + Constants.NTC_IP_LOG;
|
||||
String recv = HttpClientUtil.getMsg(url, params, request);
|
||||
List<NtcIpLog> list = new ArrayList<NtcIpLog>();
|
||||
if (StringUtils.isNotBlank(recv)) {
|
||||
Gson gson = new GsonBuilder().create();
|
||||
LogRecvData<NtcIpLog> fromJson = gson.fromJson(recv, new TypeToken<LogRecvData<NtcIpLog>>() {
|
||||
}.getType());
|
||||
if (fromJson.getStatus().intValue() == 200) {
|
||||
Page<NtcIpLog> data = fromJson.getData();
|
||||
list = data.getList();
|
||||
}
|
||||
}
|
||||
for (NtcIpLog l : list) {
|
||||
l.setFunctionId(log.getFunctionId());
|
||||
setLogAction(l, serviceList);
|
||||
}
|
||||
|
||||
titleList.add("ip_control");
|
||||
classMap.put("ip_control", NtcIpLog.class);
|
||||
SysUser user = UserUtils.getUser();
|
||||
if (!user.isAdmin()) {
|
||||
hColumns += ",scene_file,";
|
||||
} else {
|
||||
hColumns += ",";
|
||||
}
|
||||
String cfgIndexInfoNoExport = "," + hColumns;
|
||||
noExportMap.put("ip_control", cfgIndexInfoNoExport);
|
||||
dataMap.put("ip_control", list);
|
||||
String timeRange= initLogMap(log,"ip_control");
|
||||
noExportMap.put("timeRange", timeRange);
|
||||
if ("csv".equals(type)) {
|
||||
this._exportCsv(model, request, response, redirectAttributes, "ip_control", titleList, classMap,
|
||||
dataMap, noExportMap);
|
||||
} else {
|
||||
this._export(model, request, response, redirectAttributes, "ip_control", titleList, classMap, dataMap,
|
||||
noExportMap);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("Ip" +" export failed", e);
|
||||
addMessage(redirectAttributes, "error", "export_failed");
|
||||
// Ip配置导出
|
||||
@RequestMapping(value = "exportIp")
|
||||
public void exportIp(@ModelAttribute("log") NtcIpLog log, Model model, String hColumns, String type,
|
||||
HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) {
|
||||
try {
|
||||
// export data info
|
||||
List<String> titleList = new ArrayList<String>();
|
||||
Map<String, Class<?>> classMap = new HashMap<String, Class<?>>();
|
||||
Map<String, List> dataMap = new HashMap<String, List>();
|
||||
Map<String, String> noExportMap = new HashMap<String, String>();
|
||||
// ---------------------------
|
||||
PageLog<NtcIpLog> page = new PageLog<NtcIpLog>(request, response);
|
||||
page.setPageNo(1);
|
||||
page.setPageSize(Constants.MAX_LOG_EXPORT_SIZE);
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("pageSize", page.getPageSize());
|
||||
params.put("pageNo", page.getPageNo());
|
||||
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(log.getFunctionId());
|
||||
model.addAttribute("serviceList", serviceList);
|
||||
|
||||
if (StringUtil.isEmpty(log.getService())) {
|
||||
log.setService(128);
|
||||
}
|
||||
|
||||
initLogSearchValue(log, params);
|
||||
|
||||
String url = Constants.LOG_BASE_URL + Constants.NTC_IP_LOG;
|
||||
String recv = HttpClientUtil.getMsg(url, params, request);
|
||||
List<NtcIpLog> list = new ArrayList<NtcIpLog>();
|
||||
if (StringUtils.isNotBlank(recv)) {
|
||||
Gson gson = new GsonBuilder().create();
|
||||
LogRecvData<NtcIpLog> fromJson = gson.fromJson(recv, new TypeToken<LogRecvData<NtcIpLog>>() {
|
||||
}.getType());
|
||||
if (fromJson.getStatus().intValue() == 200) {
|
||||
Page<NtcIpLog> data = fromJson.getData();
|
||||
list = data.getList();
|
||||
}
|
||||
}
|
||||
for (NtcIpLog l : list) {
|
||||
l.setFunctionId(log.getFunctionId());
|
||||
setLogAction(l, serviceList);
|
||||
}
|
||||
|
||||
titleList.add("ip_control");
|
||||
classMap.put("ip_control", NtcIpLog.class);
|
||||
SysUser user = UserUtils.getUser();
|
||||
if (!user.isAdmin()) {
|
||||
hColumns += ",scene_file,";
|
||||
} else {
|
||||
hColumns += ",";
|
||||
}
|
||||
String cfgIndexInfoNoExport = "," + hColumns;
|
||||
noExportMap.put("ip_control", cfgIndexInfoNoExport);
|
||||
dataMap.put("ip_control", list);
|
||||
String timeRange = initLogMap(log, "ip_control");
|
||||
noExportMap.put("timeRange", timeRange);
|
||||
if ("csv".equals(type)) {
|
||||
this._exportCsv(model, request, response, redirectAttributes, "ip_control", titleList, classMap,
|
||||
dataMap, noExportMap);
|
||||
} else {
|
||||
this._export(model, request, response, redirectAttributes, "ip_control", titleList, classMap, dataMap,
|
||||
noExportMap);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("Ip" + " export failed", e);
|
||||
addMessage(redirectAttributes, "error", "export_failed");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
package com.nis.web.controller.log.ntc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.nis.domain.FunctionServiceDict;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.PageLog;
|
||||
import com.nis.domain.SysUser;
|
||||
import com.nis.domain.log.NtcIpLog;
|
||||
import com.nis.domain.maat.LogRecvData;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.DictUtils;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.util.httpclient.HttpClientUtil;
|
||||
import com.nis.web.controller.BaseController;
|
||||
import com.nis.web.security.UserUtils;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("${adminPath}/log/ntc/ipWhiteList")
|
||||
public class IpWhiteLogController extends BaseController {
|
||||
|
||||
@RequestMapping(value={"list",""})
|
||||
public String list(@ModelAttribute("log") NtcIpLog log, Model model, HttpServletRequest request,
|
||||
HttpServletResponse response) {
|
||||
try {
|
||||
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());
|
||||
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(log.getFunctionId());
|
||||
model.addAttribute("serviceList", serviceList);
|
||||
|
||||
if(StringUtil.isEmpty(log.getAction())){
|
||||
for(int i=0;i<serviceList.size();i++){
|
||||
log.setAction(serviceList.get(i).getAction());
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
initLogSearchValue(log, params);
|
||||
|
||||
String url = Constants.LOG_BASE_URL + Constants.NTC_IP_LOG;
|
||||
String recv = HttpClientUtil.getMsg(url, params, request);
|
||||
|
||||
if (StringUtils.isNotBlank(recv)) {
|
||||
Gson gson = new GsonBuilder().create();
|
||||
LogRecvData<NtcIpLog> fromJson = gson.fromJson(recv, new TypeToken<LogRecvData<NtcIpLog>>() {
|
||||
}.getType());
|
||||
if (fromJson.getStatus().intValue() == 200) {
|
||||
Page<NtcIpLog> data = fromJson.getData();
|
||||
page.setCount(data.getCount());
|
||||
page.setLast(data.getLast());
|
||||
page.setList(data.getList());
|
||||
List<NtcIpLog> list = page.getList();
|
||||
for (NtcIpLog l : list) {
|
||||
l.setFunctionId(log.getFunctionId());
|
||||
setLogAction(l, serviceList);
|
||||
}
|
||||
model.addAttribute("page", page);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("查询失败", e);
|
||||
addMessageLog(model, e.getMessage());
|
||||
}
|
||||
|
||||
return "/log/ntc/ipWhiteList";
|
||||
}
|
||||
|
||||
// Ip白名单导出
|
||||
@RequestMapping(value = "exportIp")
|
||||
public void exportIp(@ModelAttribute("log") NtcIpLog log, Model model, String hColumns, String type,
|
||||
HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) {
|
||||
try {
|
||||
// export data info
|
||||
List<String> titleList = new ArrayList<String>();
|
||||
Map<String, Class<?>> classMap = new HashMap<String, Class<?>>();
|
||||
Map<String, List> dataMap = new HashMap<String, List>();
|
||||
Map<String, String> noExportMap = new HashMap<String, String>();
|
||||
// ---------------------------
|
||||
PageLog<NtcIpLog> page = new PageLog<NtcIpLog>(request, response);
|
||||
page.setPageNo(1);
|
||||
page.setPageSize(Constants.MAX_LOG_EXPORT_SIZE);
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("pageSize", page.getPageSize());
|
||||
params.put("pageNo", page.getPageNo());
|
||||
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(log.getFunctionId());
|
||||
model.addAttribute("serviceList", serviceList);
|
||||
|
||||
if(StringUtil.isEmpty(log.getAction())){
|
||||
for(int i=0;i<serviceList.size();i++){
|
||||
log.setAction(serviceList.get(i).getAction());
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
initLogSearchValue(log, params);
|
||||
|
||||
String url = Constants.LOG_BASE_URL + Constants.NTC_IP_LOG;
|
||||
String recv = HttpClientUtil.getMsg(url, params, request);
|
||||
List<NtcIpLog> list = new ArrayList<NtcIpLog>();
|
||||
if (StringUtils.isNotBlank(recv)) {
|
||||
Gson gson = new GsonBuilder().create();
|
||||
LogRecvData<NtcIpLog> fromJson = gson.fromJson(recv, new TypeToken<LogRecvData<NtcIpLog>>() {
|
||||
}.getType());
|
||||
if (fromJson.getStatus().intValue() == 200) {
|
||||
Page<NtcIpLog> data = fromJson.getData();
|
||||
list = data.getList();
|
||||
}
|
||||
}
|
||||
for (NtcIpLog l : list) {
|
||||
l.setFunctionId(log.getFunctionId());
|
||||
setLogAction(l, serviceList);
|
||||
}
|
||||
|
||||
titleList.add("ip_control");
|
||||
classMap.put("ip_control", NtcIpLog.class);
|
||||
SysUser user = UserUtils.getUser();
|
||||
if (!user.isAdmin()) {
|
||||
hColumns += ",scene_file,";
|
||||
} else {
|
||||
hColumns += ",";
|
||||
}
|
||||
String cfgIndexInfoNoExport = "," + hColumns;
|
||||
noExportMap.put("ip_control", cfgIndexInfoNoExport);
|
||||
dataMap.put("ip_control", list);
|
||||
String timeRange = initLogMap(log, "ip_control");
|
||||
noExportMap.put("timeRange", timeRange);
|
||||
if ("csv".equals(type)) {
|
||||
this._exportCsv(model, request, response, redirectAttributes, "ip_control", titleList, classMap,
|
||||
dataMap, noExportMap);
|
||||
} else {
|
||||
this._export(model, request, response, redirectAttributes, "ip_control", titleList, classMap, dataMap,
|
||||
noExportMap);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("Ip" + " export failed", e);
|
||||
addMessage(redirectAttributes, "error", "export_failed");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user