Merge branch 'develop' of http://192.168.10.125/k18_web/NFS.git into develop

This commit is contained in:
段冬梅
2018-12-17 01:29:09 +08:00
3 changed files with 166 additions and 56 deletions

View File

@@ -1,5 +1,6 @@
package com.nis.web.controller.log.pxy;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -7,11 +8,13 @@ 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 org.springframework.web.servlet.support.RequestContext;
import com.google.gson.Gson;
@@ -20,6 +23,8 @@ 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.NtcCollectRadiusLog;
import com.nis.domain.log.NtcSslLog;
import com.nis.domain.log.PxyHttpLog;
import com.nis.domain.maat.LogRecvData;
@@ -27,33 +32,35 @@ import com.nis.util.Constants;
import com.nis.util.DictUtils;
import com.nis.util.httpclient.HttpClientUtil;
import com.nis.web.controller.BaseController;
import com.nis.web.security.UserUtils;
@Controller
@RequestMapping("${adminPath}/log/pxy")
public class PxyHttpLogController extends BaseController {
@RequestMapping(value = {"list", "ipInterceptlogs", "domainInterceptlogs", "httpBlocklogs",
"httpRedirectlogs", "httpReplacelogs", "httpMonitogs"})
public String list(@ModelAttribute("log") PxyHttpLog log, Model model, HttpServletRequest request, HttpServletResponse response) {
@RequestMapping(value = { "list", "ipInterceptlogs", "domainInterceptlogs", "httpBlocklogs", "httpRedirectlogs",
"httpReplacelogs", "httpMonitogs" })
public String list(@ModelAttribute("log") PxyHttpLog log, Model model, HttpServletRequest request,
HttpServletResponse response) {
try {
setLogInfo(request, model, log);
PageLog<PxyHttpLog> page = new PageLog<PxyHttpLog>(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);
String url = Constants.LOG_BASE_URL + Constants.PXY_HTTP_LOG;
String recv = HttpClientUtil.getMsg(url, params, request);
Gson gson = new GsonBuilder().create();
LogRecvData<PxyHttpLog> fromJson = gson.fromJson(recv, new TypeToken<LogRecvData<PxyHttpLog>>(){}.getType());
LogRecvData<PxyHttpLog> fromJson = gson.fromJson(recv, new TypeToken<LogRecvData<PxyHttpLog>>() {
}.getType());
if (fromJson.getStatus().intValue() == 200) {
Page<PxyHttpLog> data = fromJson.getData();
page.setCount(data.getCount());
@@ -62,24 +69,24 @@ public class PxyHttpLogController extends BaseController {
List<PxyHttpLog> list = page.getList();
for (PxyHttpLog l : list) {
l.setFunctionId(log.getFunctionId());
setLogAction(l,serviceList);
setLogAction(l, serviceList);
}
model.addAttribute("page", page);
}
} catch (Exception e) {
logger.error("查询失败", e);
addMessageLog(model, e.getMessage());
}
return "/log/pxy/pxyHttpList";
}
private void setLogInfo(HttpServletRequest request, Model model, PxyHttpLog log) {
int functionId = log.getFunctionId();
RequestContext requestContext = new RequestContext(request);
if (functionId == 200) {
model.addAttribute("logTitle", requestContext.getMessage("ip_intercept"));
log.setAction(1);
@@ -100,4 +107,81 @@ public class PxyHttpLogController extends BaseController {
log.setAction(1);
}
}
// proxy配置导出
@RequestMapping(value = "exportPxy")
public void exportPxy(@ModelAttribute("log") PxyHttpLog log, Model model, String hColumns, String type,
HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) {
String name= "pxy";
try {
// export data info
setLogInfo(request, model, log);
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<PxyHttpLog> page = new PageLog<PxyHttpLog>(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());
System.out.print(log.getFunctionId());
model.addAttribute("serviceList", serviceList);
String url = Constants.LOG_BASE_URL + Constants.PXY_HTTP_LOG;
String recv = HttpClientUtil.getMsg(url, params, request);
List<PxyHttpLog> list = new ArrayList<PxyHttpLog>();
if (StringUtils.isNotBlank(recv)) {
Gson gson = new GsonBuilder().create();
LogRecvData<PxyHttpLog> fromJson = gson.fromJson(recv, new TypeToken<LogRecvData<PxyHttpLog>>() {
}.getType());
if (fromJson.getStatus().intValue() == 200) {
Page<PxyHttpLog> data = fromJson.getData();
list = data.getList();
}
}
for (PxyHttpLog l : list) {
l.setFunctionId(log.getFunctionId());
setLogAction(l, serviceList);
}
if(log.getFunctionId()==210){
name="http_monit";
}else if(log.getFunctionId()==207){
name="http_block";
}else if(log.getFunctionId()==208){
name="http_redirect";
}else if(log.getFunctionId()==209){
name="http_replace";
}
titleList.add(name);
classMap.put(name, PxyHttpLog.class);
SysUser user = UserUtils.getUser();
if (!user.isAdmin()) {
hColumns += ",scene_file,";
} else {
hColumns += ",";
}
String cfgIndexInfoNoExport = "," + hColumns;
noExportMap.put(name, cfgIndexInfoNoExport);
dataMap.put(name, list);
if ("csv".equals(type)) {
this._exportCsv(model, request, response, redirectAttributes, name, titleList, classMap,
dataMap, noExportMap);
} else {
this._export(model, request, response, redirectAttributes, name, titleList, classMap, dataMap,
noExportMap);
}
} catch (Exception e) {
logger.error(name +" export failed", e);
addMessage(redirectAttributes, "error", "export_failed");
}
}
}