radius日志增加导出

action和cfgid隐藏
This commit is contained in:
leijun
2018-12-15 20:34:10 +08:00
parent 2386f2ce92
commit 48e488cb68
6 changed files with 141 additions and 17 deletions

View File

@@ -1,26 +1,24 @@
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.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.log.IrDnatLog;
import com.nis.domain.log.IrSnatLog;
import com.nis.domain.log.NtcCollectRadiusLog;
import com.nis.domain.maat.LogRecvData;
import com.nis.util.Constants;
@@ -33,14 +31,21 @@ import com.nis.web.controller.BaseController;
public class NtcCollectRadiusLogController extends BaseController {
@RequestMapping(value = {"list", ""})
public String list(@ModelAttribute("log") IrSnatLog log, Model model, HttpServletRequest request, HttpServletResponse response) {
public String list(@ModelAttribute("log") NtcCollectRadiusLog log, Model model, HttpServletRequest request, HttpServletResponse response) {
try {
PageLog<NtcCollectRadiusLog> page = new PageLog<NtcCollectRadiusLog>(request, response);
Map<String, Object> params = new HashMap<String, Object>();
params.put("pageSize", page.getPageSize());
params.put("pageNo", page.getPageNo());
initLogSearchValue(log, params);
// 请求参数判断
if(StringUtils.isNotBlank(log.getNasIp())) {
params.put("searchNasIp", log.getNasIp());
}else if(StringUtils.isNotBlank(log.getFramedIp())) {
params.put("searchFramedIp", log.getFramedIp());
}else if(StringUtils.isNotBlank(log.getAccount())) {
params.put("searchAccount", log.getAccount());
}
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(log.getFunctionId());
model.addAttribute("serviceList", serviceList);
@@ -71,4 +76,53 @@ public class NtcCollectRadiusLogController extends BaseController {
return "/log/ntc/radiusLogList";
}
//bgp配置导出
@RequestMapping(value = "exportRadius")
public void exportbgp(@ModelAttribute("log") NtcCollectRadiusLog log, Model model, 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<NtcCollectRadiusLog> page = new PageLog<NtcCollectRadiusLog>(request, response);
page.setPageNo(1);
page.setPageSize(Constants.MAX_EXPORT_SIZE);
Map<String, Object> params = new HashMap<String, Object>();
params.put("pageSize", page.getPageSize());
params.put("pageNo", page.getPageNo());
initLogSearchValue(log, params);
// 请求参数判断
if(StringUtils.isNotBlank(log.getNasIp())) {
params.put("searchNasIp", log.getNasIp());
}else if(StringUtils.isNotBlank(log.getFramedIp())) {
params.put("searchFramedIp", log.getFramedIp());
}else if(StringUtils.isNotBlank(log.getAccount())) {
params.put("searchAccount", log.getAccount());
}
List<NtcCollectRadiusLog> list=new ArrayList<NtcCollectRadiusLog>();
String url =Constants.LOG_BASE_URL + Constants.NTC_COLLECT_RADIUS_LOG;
String recv = HttpClientUtil.getMsg(url, params, request);
if (StringUtils.isNotBlank(recv)) {
Gson gson = new GsonBuilder().create();
LogRecvData<NtcCollectRadiusLog> fromJson = gson.fromJson(recv, new TypeToken<LogRecvData<NtcCollectRadiusLog>>(){}.getType());
if (fromJson.getStatus().intValue() == 200) {
Page<NtcCollectRadiusLog> data = fromJson.getData();
list= data.getList();
}
}
titleList.add("radius_log");
classMap.put("radius_log", NtcCollectRadiusLog.class);
String cfgIndexInfoNoExport="";
noExportMap.put("radius_log",cfgIndexInfoNoExport);
dataMap.put("radius_log",list);
/*}*/
this._export(model, request, response, redirectAttributes,"radius_log",titleList,classMap,dataMap,noExportMap);
} catch (Exception e) {
logger.error("radius export failed",e);
addMessage(redirectAttributes,"error","export_failed");
}
}
}