185 lines
8.4 KiB
Java
185 lines
8.4 KiB
Java
package com.nis.web.controller.basics;
|
|
|
|
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.springframework.beans.factory.annotation.Autowired;
|
|
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.nis.domain.FunctionRegionDict;
|
|
import com.nis.domain.FunctionServiceDict;
|
|
import com.nis.domain.Page;
|
|
import com.nis.domain.basics.CommonGroupInfo;
|
|
import com.nis.domain.basics.UrlCommCfg;
|
|
import com.nis.domain.configuration.CfgIndexInfo;
|
|
import com.nis.exceptions.MaatConvertException;
|
|
import com.nis.util.Constants;
|
|
import com.nis.util.DictUtils;
|
|
import com.nis.util.StringUtil;
|
|
import com.nis.web.controller.BaseController;
|
|
import com.nis.web.service.basics.UrlCommGroupService;
|
|
|
|
@Controller
|
|
@RequestMapping(value = "${adminPath}/basics/url")
|
|
public class UrlCommGroupController extends BaseController{
|
|
|
|
@Autowired
|
|
private UrlCommGroupService urlCommGroupService;
|
|
|
|
@RequestMapping(value = {"/list"})
|
|
public String list(Model model, @ModelAttribute("cfg")UrlCommCfg entity, HttpServletRequest request,HttpServletResponse response){
|
|
Page<UrlCommCfg> page = urlCommGroupService.findPage(new Page<UrlCommCfg>(request, response,"r"), entity);
|
|
List<FunctionRegionDict> regionList = DictUtils.getFunctionRegionDictList(entity.getFunctionId());
|
|
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(entity.getFunctionId());
|
|
List<CommonGroupInfo> groupInfos = commonGroupManageService.findCommonGroupInfosByType(7);
|
|
|
|
model.addAttribute("page", page);
|
|
model.addAttribute("regionList", regionList);
|
|
model.addAttribute("serviceList", serviceList);
|
|
model.addAttribute("policyGroupInfos", groupInfos);
|
|
return "/basics/urlCommGroupList";
|
|
}
|
|
|
|
@RequestMapping(value = {"/addForm"})
|
|
public String addForm(Model model, @ModelAttribute("cfg")CfgIndexInfo cfg, RedirectAttributes redirectAttributes,
|
|
HttpServletRequest request, HttpServletResponse response){
|
|
cfg.setGroupType(11);
|
|
initFormCondition(model,cfg);
|
|
List<CommonGroupInfo> groupInfos=commonGroupManageService.findCommonGroupInfosByType(7);
|
|
model.addAttribute("policyGroupInfos", groupInfos);
|
|
|
|
model.addAttribute("_cfg", cfg);
|
|
return "/basics/urlCommGroupFormAdd";
|
|
}
|
|
|
|
@RequestMapping(value = {"/save"})
|
|
public String save(Model model, @ModelAttribute("cfg")CfgIndexInfo cfg,RedirectAttributes redirectAttributes,
|
|
HttpServletRequest request,HttpServletResponse response){
|
|
try{
|
|
urlCommGroupService.saveUrlCommGroupCfg(cfg);
|
|
}catch(Exception e){
|
|
logger.error("信息保存失败",e);
|
|
if(e instanceof MaatConvertException) {
|
|
addMessage(redirectAttributes,"error",e.getMessage());
|
|
}else {
|
|
addMessage(redirectAttributes,"error","save_failed");
|
|
}
|
|
}
|
|
|
|
return "redirect:" + adminPath +"/basics/url/list?functionId="+cfg.getFunctionId();
|
|
}
|
|
|
|
@RequestMapping(value = {"/updateForm"})
|
|
public String updateForm(Model model,HttpServletRequest request
|
|
,HttpServletResponse response,String ids,@ModelAttribute("cfg")UrlCommCfg cfg
|
|
,RedirectAttributes redirectAttributes){
|
|
cfg = urlCommGroupService.get(Long.parseLong(ids));
|
|
cfg.setGroupType(11);
|
|
initUpdateFormCondition(model,cfg);
|
|
List<CommonGroupInfo> groupInfos=commonGroupManageService.findCommonGroupInfosByType(7);
|
|
model.addAttribute("policyGroupInfos", groupInfos);
|
|
model.addAttribute("_cfg", cfg);
|
|
return "/basics/urlCommGroupFormUpdate";
|
|
}
|
|
|
|
@RequestMapping(value = {"/update"})
|
|
public String update(Model model,HttpServletRequest request,HttpServletResponse response,@ModelAttribute("cfg")UrlCommCfg cfg,RedirectAttributes redirectAttributes){
|
|
try{
|
|
urlCommGroupService.update(cfg);
|
|
addMessage(redirectAttributes,"success","save_success");
|
|
}catch(Exception e){
|
|
logger.error("信息保存失败",e);
|
|
addMessage(redirectAttributes,"error","save_failed");
|
|
}
|
|
|
|
return "redirect:" + adminPath +"/basics/url/list?functionId="+cfg.getFunctionId();
|
|
}
|
|
|
|
@RequestMapping(value = {"/delete"})
|
|
public String delete(Integer isValid
|
|
,String ids,Integer functionId
|
|
,RedirectAttributes redirectAttributes){
|
|
try{
|
|
urlCommGroupService.delete(ids);
|
|
addMessage(redirectAttributes,"success","delete_success");
|
|
}catch(Exception e){
|
|
logger.error("Delete failed",e);
|
|
if(e instanceof MaatConvertException) {
|
|
addMessage(redirectAttributes,"error",e.getMessage());
|
|
}else {
|
|
addMessage(redirectAttributes,"error","delete_failed");
|
|
}
|
|
}
|
|
|
|
return "redirect:" + adminPath +"/basics/url/list?functionId="+functionId;
|
|
}
|
|
|
|
// 数据导出
|
|
@RequestMapping(value = "/exportUrlComm")
|
|
public void exportUrlComm(Model model,HttpServletRequest request,HttpServletResponse response,
|
|
@ModelAttribute("cfg")UrlCommCfg entity,String ids,RedirectAttributes redirectAttributes){
|
|
try {
|
|
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>();
|
|
List<UrlCommCfg> list = new ArrayList<UrlCommCfg>();
|
|
if (!StringUtil.isEmpty(ids)) {
|
|
list = urlCommGroupService.findByPage(ids);
|
|
} else {
|
|
Page<UrlCommCfg> pageInfo=new Page<UrlCommCfg>(request, response,"r");
|
|
pageInfo.setPageNo(1);
|
|
pageInfo.setPageSize(Constants.MAX_EXPORT_SIZE);
|
|
Page<UrlCommCfg> page = urlCommGroupService.findPage(pageInfo, entity);
|
|
list=page.getList();
|
|
}
|
|
|
|
titleList.add(entity.getMenuNameCode());
|
|
classMap.put(entity.getMenuNameCode(), UrlCommCfg.class);
|
|
String cfgIndexInfoNoExport=",block_type,do_log,action"
|
|
+ ",letter,whether_area_block,classification,attribute,label,expression_type,match_method"
|
|
+",userregion1,userregion2,userregion3,userregion4,userregion5,ir_type,asn_no,is_hex,is_case_insenstive,";
|
|
// 时间过滤
|
|
if (entity.getSearch_create_time_start() == null ) {
|
|
cfgIndexInfoNoExport = ",config_time" + cfgIndexInfoNoExport;
|
|
}
|
|
if (entity.getSearch_edit_time_start() == null) {
|
|
cfgIndexInfoNoExport = ",edit_time" + cfgIndexInfoNoExport;
|
|
}
|
|
if (entity.getSearch_audit_time_start() == null) {
|
|
cfgIndexInfoNoExport = ",audit_time" + cfgIndexInfoNoExport;
|
|
}
|
|
if (!StringUtil.isEmpty(entity.gethColumns())) {
|
|
cfgIndexInfoNoExport = "," + entity.gethColumns() + "," + cfgIndexInfoNoExport;
|
|
}
|
|
|
|
noExportMap.put(entity.getMenuNameCode(),cfgIndexInfoNoExport);
|
|
dataMap.put(entity.getMenuNameCode(), list);
|
|
String timeRange = initTimeMap(entity);
|
|
noExportMap.put("timeRange", timeRange);
|
|
|
|
if ("csv".equals(entity.getExType())) {
|
|
this._exportCsv(model, request, response, redirectAttributes, entity.getMenuNameCode(), titleList,
|
|
classMap, dataMap, noExportMap);
|
|
} else {
|
|
this._export(model, request, response, redirectAttributes, entity.getMenuNameCode(), titleList,
|
|
classMap, dataMap, noExportMap);
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
logger.error("urlGroupConfig export failed",e);
|
|
addMessage(redirectAttributes,"error","export_failed");
|
|
|
|
}
|
|
|
|
}
|
|
} |