1.日志增加app,Ddos 2.修改日志类名3.增加国际化代码及日志nis配置4.修改页面需要的标签类

This commit is contained in:
zhanghongqing
2018-07-11 18:15:59 +08:00
parent d303ffc9d7
commit 34892e5fd8
25 changed files with 1027 additions and 43 deletions

View File

@@ -0,0 +1,188 @@
package com.nis.web.controller.dashboard;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.google.gson.Gson;
import com.nis.util.JsonMapper;
import com.nis.web.controller.BaseController;
import com.nis.web.service.dashboard.DashboardService;
import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
@SuppressWarnings({ "rawtypes", "unchecked" })
@RestController
@RequestMapping(value = "${servicePath}/log/v1")
@Api(value = "DashboardServiceController", description = "首页图表基本服务接口")
public class DashboardServiceController extends BaseController{
@Autowired
public DashboardService dashboardService;
/**
* 协议统计
*/
@RequestMapping(value="trafficProtocol", method = RequestMethod.GET)
@ApiOperation(value = "协议统计", httpMethod = "GET", notes = "对应协议统计实时统计查询服务。")
public String trafficProtocol(){
dashboardService.systemList();
Map map = new HashMap();
try {
List<Map> ipActiveChart = dashboardService.protocolChart();
if (ipActiveChart.size() > 0) {
String jsonString = JsonMapper.toJsonString(ipActiveChart);
List<HashMap> list = (java.util.List<HashMap>) JsonMapper.fromJsonList(jsonString,
HashMap.class);
map.put("data", list);
logger.info(list);
}
} catch (Exception e) {
e.printStackTrace();
logger.error(e);
}
return JsonMapper.toJsonString(map);
}
/**
* 活跃IP TOP10
*/
@RequestMapping(value = "trafficIpActive", method = RequestMethod.GET)
@ApiOperation(value = "活跃IP统计", httpMethod = "GET", notes = "对应活跃IP实时统计查询服务。")
public String trafficIpActive(/*Model model, HttpServletRequest request,
HttpServletResponse response*/) {
Map map = new LinkedHashMap();
try {
List<LinkedHashMap> ipActiveChart = dashboardService.ipActiveChart();
if (ipActiveChart.size() > 0) {
String jsonString = JsonMapper.toJsonString(ipActiveChart);
ArrayList<LinkedHashMap> list = (ArrayList<LinkedHashMap>) JsonMapper.fromJsonList(jsonString,
LinkedHashMap.class);
map.put("data", list);
}
} catch (Exception e) {
e.printStackTrace();
logger.error(e);
}
String jsonString = JsonMapper.toJsonString(map);
return jsonString;
}
/**
* app流量分析 TOP10
*/
@RequestMapping(value = "trafficApp", method = RequestMethod.GET)
@ApiOperation(value = "app流量分析统计", httpMethod = "GET", notes = "对应app流量分析实时统计查询服务。")
public String trafficApp(/*Model model, HttpServletRequest request,
HttpServletResponse response*/) {
Map map = new HashMap();
try {
List<Map> appChart = dashboardService.appChart();
if (appChart.size() > 0) {
String jsonString = JsonMapper.toJsonString(appChart);
List<HashMap> list = (java.util.List<HashMap>) JsonMapper.fromJsonList(jsonString,
HashMap.class);
map.put("data", list);
}
} catch (Exception e) {
e.printStackTrace();
logger.error(e);
}
return JsonMapper.toJsonString(map);
}
@RequestMapping(value = "trafficOsList", method = RequestMethod.GET)
@ApiOperation(value = "操作系统流量分析统计", httpMethod = "GET", notes = "对应终端用户的操作系统列表显示")
public String trafficOsList(/*,Model model, HttpServletRequest request,
HttpServletResponse response*/) {
Map map = new HashMap();
try {
List<Map> osChart = dashboardService.systemList();
if (osChart.size() > 0) {
String jsonString = JsonMapper.toJsonString(osChart);
List<HashMap> list = (java.util.List<HashMap>) JsonMapper.fromJsonList(jsonString,
HashMap.class);
map.put("data", list);
}
} catch (Exception e) {
e.printStackTrace();
logger.error(e);
}
return JsonMapper.toJsonString(map);
}
@RequestMapping(value = "trafficBrowserChart", method = RequestMethod.GET)
@ApiOperation(value = "操作系统下浏览器流量分析统计", httpMethod = "GET", notes = "对应终端用户某个操作系统的浏览器分类统计显示")
public String trafficBrowserChart(Integer osType/*,Model model, HttpServletRequest request,
HttpServletResponse response*/) {
Map map = new HashMap();
try {
List<Map> osChart = dashboardService.getBrowserBySystem(osType);
if (osChart.size() > 0) {
String jsonString = JsonMapper.toJsonString(osChart);
List<HashMap> list = (java.util.List<HashMap>) JsonMapper.fromJsonList(jsonString,
HashMap.class);
map.put("data", list);
}
} catch (Exception e) {
e.printStackTrace();
logger.error(e);
}
return JsonMapper.toJsonString(map);
}
@RequestMapping(value = "trafficBsList", method = RequestMethod.GET)
@ApiOperation(value = "浏览器流量分析统计", httpMethod = "GET", notes = "对应终端用户的浏览器列表显示")
public String trafficBsList(/*,Model model, HttpServletRequest request,
HttpServletResponse response*/) {
Map map = new HashMap();
try {
List<Map> bsChart = dashboardService.browserList();
if (bsChart.size() > 0) {
String jsonString = JsonMapper.toJsonString(bsChart);
List<HashMap> list = (java.util.List<HashMap>) JsonMapper.fromJsonList(jsonString,
HashMap.class);
map.put("data", list);
}
} catch (Exception e) {
e.printStackTrace();
logger.error(e);
}
return JsonMapper.toJsonString(map);
}
@RequestMapping(value = "trafficSystemChart", method = RequestMethod.GET)
@ApiOperation(value = "浏览器下操作系统流量分析统计", httpMethod = "GET", notes = "对应终端用户某个浏览器的操作系统分类统计显示")
public String trafficSystemChart(Integer bsType/*,Model model, HttpServletRequest request,
HttpServletResponse response*/) {
Map map = new HashMap();
try {
List<Map> bsChart = dashboardService.getSystemBybrowser(bsType);
if (bsChart.size() > 0) {
String jsonString = JsonMapper.toJsonString(bsChart);
List<HashMap> list = (java.util.List<HashMap>) JsonMapper.fromJsonList(jsonString,
HashMap.class);
map.put("data", list);
}
} catch (Exception e) {
e.printStackTrace();
logger.error(e);
}
return JsonMapper.toJsonString(map);
}
}

View File

@@ -0,0 +1,81 @@
package com.nis.web.controller.log.ntc;
import java.io.IOException;
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.http.client.ClientProtocolException;
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 com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.nis.domain.Page;
import com.nis.domain.log.NtcAppLog;
import com.nis.domain.maat.LogRecvData;
import com.nis.util.Constants;
import com.nis.util.httpclient.HttpClientUtil;
import com.nis.web.controller.BaseController;
@Controller
@RequestMapping(value = "${adminPath}/log/ntc/ntcAppLogs")
public class AppLogController 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")NtcAppLog entry,HttpServletRequest request, HttpServletResponse response) throws ClientProtocolException, IOException {
try {
Page<NtcAppLog> page = new Page<NtcAppLog>(request, response);
Map<String, Object> params=new HashMap<>();
params.put("pageSize", page.getPageSize());
params.put("pageNo", page.getPageNo());
//查询值判断
initLogSearchValue(entry,params);
String url = "";
url = Constants.LOG_BASE_URL+Constants.NTC_APP_LOG;
String jsonString = HttpClientUtil.getMsg(url,params,request);
Gson gson = new GsonBuilder().create();
//gson泛型支持
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) {
l.setFunctionId(entry.getFunctionId());
setLogAction(l);
}
model.addAttribute("page", page);
logger.info("查询App日志成功");
}
} catch (Exception e) {
logger.info("查询App日志失败", e);
addMessage(model, e.getMessage());
}
return "/log/ntc/appList";
}
}

View File

@@ -0,0 +1,80 @@
package com.nis.web.controller.log.ntc;
import java.io.IOException;
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.http.client.ClientProtocolException;
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 com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.nis.domain.Page;
import com.nis.domain.log.NtcDdosLog;
import com.nis.domain.maat.LogRecvData;
import com.nis.util.Constants;
import com.nis.util.httpclient.HttpClientUtil;
import com.nis.web.controller.BaseController;
@Controller
@RequestMapping(value = "${adminPath}/log/ntc/ntcDdosLogs")
public class DdosLogController 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")NtcDdosLog entry,HttpServletRequest request, HttpServletResponse response) throws ClientProtocolException, IOException {
try {
Page<NtcDdosLog> page = new Page<NtcDdosLog>(request, response);
Map<String, Object> params=new HashMap<>();
params.put("pageSize", page.getPageSize());
params.put("pageNo", page.getPageNo());
//查询值判断
initLogSearchValue(entry,params);
String url = "";
url = Constants.LOG_BASE_URL+Constants.NTC_DDOS_LOG;
String jsonString = HttpClientUtil.getMsg(url,params,request);
Gson gson = new GsonBuilder().create();
//gson泛型支持
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) {
l.setFunctionId(entry.getFunctionId());
setLogAction(l);
}
model.addAttribute("page", page);
logger.info("查询Ddos日志成功");
}
} catch (Exception e) {
logger.info("查询Ddos日志失败", e);
addMessage(model, e.getMessage());
}
return "/log/ntc/ddosList";
}
}

View File

@@ -27,7 +27,7 @@ import com.nis.web.controller.BaseController;
@Controller
@RequestMapping(value = "${adminPath}/log/ntc/NtcFtpLogs")
public class FtpController extends BaseController{
public class FtpLogController extends BaseController{
/**
* @param model

View File

@@ -28,7 +28,7 @@ import com.nis.web.controller.BaseController;
@Controller
@RequestMapping(value = "${adminPath}/log/ntc/ntcIpsecLogs")
public class IpsecController extends BaseController{
public class IpsecLogController extends BaseController{
/**
* @param model

View File

@@ -1,22 +0,0 @@
package com.nis.web.controller.log.ntc;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.nis.web.controller.BaseController;
@Controller
@RequestMapping(value = "/log")
public class LogChartController extends BaseController{
@RequestMapping(value="logChart")
public String logChart(){
return "/log/chart";
}
@RequestMapping(value="ajaxChart")
@ResponseBody
public String ajaxChart(){
return "";
}
}

View File

@@ -28,7 +28,7 @@ import com.nis.web.controller.BaseController;
@Controller
@RequestMapping(value = "${adminPath}/log/ntc/ntcOpenvpnLogs")
public class OpenVpnController extends BaseController{
public class OpenVpnLogController extends BaseController{
/**
* @param model
@@ -60,7 +60,10 @@ public class OpenVpnController extends BaseController{
LogRecvData<NtcOpenVpnLog> fromJson = gson.fromJson(jsonString, new TypeToken<LogRecvData<NtcOpenVpnLog>>(){}.getType());
if (fromJson.getStatus().intValue() == 200) {
BeanUtils.copyProperties(fromJson.getData(), page);
// 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) {
l.setFunctionId(entry.getFunctionId());

View File

@@ -28,7 +28,7 @@ import com.nis.web.controller.BaseController;
@Controller
@RequestMapping(value = "${adminPath}/log/ntc/ntcSshLogs")
public class SshController extends BaseController{
public class SshLogController extends BaseController{
/**
* @param model