diff --git a/src/main/java/com/nis/domain/basics/UrlCommCfg.java b/src/main/java/com/nis/domain/basics/UrlCommCfg.java new file mode 100644 index 000000000..2729f4f70 --- /dev/null +++ b/src/main/java/com/nis/domain/basics/UrlCommCfg.java @@ -0,0 +1,64 @@ +package com.nis.domain.basics; + +import com.nis.domain.configuration.BaseStringCfg; +import com.nis.util.excel.ExcelField; + +public class UrlCommCfg extends BaseStringCfg{ + + private static final long serialVersionUID = 398247881810945300L; + private static final String tableName="http_url_cfg"; + + @ExcelField(title="key_word",sort=3) + protected String cfgKeywords;//url关键字配置 + + // protected Integer exprType;//表达式类型 +// protected Integer matchMethod;//匹配类型 + protected Integer isHexbin;//是否大小写敏感 + protected String ratelimit;//限速比例,0到1之间 + @ExcelField(title="group_name",sort=108) + protected String groupName;//公共组名称 + + + + public String getCfgKeywords() { + return cfgKeywords; + } + public void setCfgKeywords(String cfgKeywords) { + this.cfgKeywords = cfgKeywords; + } + // public Integer getExprType() { +// return exprType; +// } +// public void setExprType(Integer exprType) { +// this.exprType = exprType; +// } +// public Integer getMatchMethod() { +// return matchMethod; +// } +// public void setMatchMethod(Integer matchMethod) { +// this.matchMethod = matchMethod; +// } + public Integer getIsHexbin() { + return isHexbin; + } + public void setIsHexbin(Integer isHexbin) { + this.isHexbin = isHexbin; + } + public String getRatelimit() { + return ratelimit; + } + public void setRatelimit(String ratelimit) { + this.ratelimit = ratelimit; + } + public static String getTablename() { + return tableName; + } + + public String getGroupName() { + return groupName; + } + public void setGroupName(String groupName) { + this.groupName = groupName; + } + +} \ No newline at end of file diff --git a/src/main/java/com/nis/domain/configuration/template/UrlCommCfgTemplate.java b/src/main/java/com/nis/domain/configuration/template/UrlCommCfgTemplate.java new file mode 100644 index 000000000..820df4741 --- /dev/null +++ b/src/main/java/com/nis/domain/configuration/template/UrlCommCfgTemplate.java @@ -0,0 +1,23 @@ +package com.nis.domain.configuration.template; + +import com.nis.util.excel.ExcelField; + +/** + * URL公共组配置 导入模板 + * @author dell + * + */ +public class UrlCommCfgTemplate extends StringAllTemplate{ + + @ExcelField(title="url_group",align=2,sort=10) + private Integer groupId; + + public Integer getGroupId() { + return groupId; + } + + public void setGroupId(Integer groupId) { + this.groupId = groupId; + } + +} diff --git a/src/main/java/com/nis/web/controller/basics/CommonGroupManageController.java b/src/main/java/com/nis/web/controller/basics/CommonGroupManageController.java index ea66d9a20..9ae4625d0 100644 --- a/src/main/java/com/nis/web/controller/basics/CommonGroupManageController.java +++ b/src/main/java/com/nis/web/controller/basics/CommonGroupManageController.java @@ -2,28 +2,23 @@ package com.nis.web.controller.basics; import java.util.ArrayList; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Set; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.apache.commons.lang.StringUtils; 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.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.servlet.mvc.support.RedirectAttributes; import com.nis.domain.Page; import com.nis.domain.basics.CommonGroupInfo; -import com.nis.domain.basics.PolicyGroupInfo; import com.nis.util.Constants; import com.nis.util.LogUtils; import com.nis.util.StringUtil; diff --git a/src/main/java/com/nis/web/controller/basics/UrlCommGroupController.java b/src/main/java/com/nis/web/controller/basics/UrlCommGroupController.java new file mode 100644 index 000000000..75b71f145 --- /dev/null +++ b/src/main/java/com/nis/web/controller/basics/UrlCommGroupController.java @@ -0,0 +1,246 @@ +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.apache.shiro.authz.annotation.RequiresPermissions; +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 page = urlCommGroupService.findPage(new Page(request, response,"r"), entity); + List regionList = DictUtils.getFunctionRegionDictList(entity.getFunctionId()); + List serviceList = DictUtils.getFunctionServiceDictList(entity.getFunctionId()); + List 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){ + +// UrlCommGroupCfg urlCfg = new UrlCommGroupCfg(); +// urlCfg.setCfgType("NTC_URL_REGION"); +// cfg.setUrlCommGroupCfg(urlCfg); +// List urlList = new ArrayList(); +// urlList.add(urlCfg); +// cfg.setUrlCommGroupList(urlList); +// initFormCondition(model, entity); + cfg.setGroupType(11); + initFormCondition(model,cfg); + List 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)); +// initUpdateFormCondition(model, cfg); + cfg.setGroupType(11); + initUpdateFormCondition(model,cfg); + List 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 = {"/audit"}) + public String audit(Model model,@ModelAttribute("cfg")UrlCommCfg cfg + ,Integer isAudit + ,Integer isValid + ,String ids + ,Integer functionId + , HttpServletRequest request + ,HttpServletResponse response + ,RedirectAttributes redirectAttributes) { + //选中配置审核 + if(!StringUtil.isEmpty(ids)) { + List urlGroupCfgs=urlCommGroupService.getByIds(ids); +// Map> urlcfgMap=Maps.newHashMap(); +// for(UrlCommGroupCfg urlCommCfg:urlGroupCfgs) { +// urlCommCfg.setIsAudit(isAudit); +// urlCommCfg.setIsValid(isValid); +// urlCommCfg.setAuditorId(UserUtils.getUser().getId()); +// urlCommCfg.setAuditTime(new Date()); +// urlCommCfg.setFunctionId(functionId); +// if(urlcfgMap.containsKey(Long.parseLong(urlCommCfg.getUserRegion3()))) { +// urlcfgMap.get(Long.parseLong(urlCommCfg.getUserRegion3())).add(urlCommCfg); +// }else { +// List _urlCfgs=Lists.newArrayList(); +// _urlCfgs.add(urlCommCfg); +// urlcfgMap.put(Long.parseLong(urlCommCfg.getUserRegion3()), _urlCfgs); +// } +// } + /********************每次下发一个组的region,保证事物********************/ +// for (Long groupId : urlcfgMap.keySet()) { +// try { +// urlCommGroupService.audit(urlcfgMap.get(groupId),groupId,isValid); +// } catch (Exception e) { +// logger.error("配置下发失败:",e); +// if(e instanceof MaatConvertException) { +// addMessage(redirectAttributes,"error", "request_service_failed"); +// }else { +// addMessage(redirectAttributes,"error", "audit_failed"); +// } +// +// } +// } + for (UrlCommCfg urlCommGroup : urlGroupCfgs) { + try { + urlCommGroupService.audit(urlCommGroup,isAudit,isValid); + } catch (Exception e) { + logger.error("审核失败",e); + addMessage(redirectAttributes,"error","audit_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; + } + //urlComm配置导出 + @RequestMapping(value = "/exportUrlComm") + public void exportAsnIp(Model model,HttpServletRequest request,HttpServletResponse response, + @ModelAttribute("cfg")UrlCommCfg entity,String ids,RedirectAttributes redirectAttributes){ + try { + //export data info + List titleList=new ArrayList(); + Map> classMap=new HashMap>(); + Map dataMap=new HashMap(); + Map noExportMap=new HashMap(); + List list = new ArrayList(); + if (!StringUtil.isEmpty(ids)) { + list = urlCommGroupService.findByPage(ids); + } else { + Page pageInfo=new Page(request, response,"r"); + pageInfo.setPageNo(1); + pageInfo.setPageSize(Constants.MAX_EXPORT_SIZE); + Page 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"); + } + //return "redirect:" + adminPath +"/ntc/iplist/list?functionId="+entity.getFunctionId(); + } +} \ No newline at end of file diff --git a/src/main/java/com/nis/web/dao/basics/UrlCommGroupDao.java b/src/main/java/com/nis/web/dao/basics/UrlCommGroupDao.java new file mode 100644 index 000000000..cbe345e5d --- /dev/null +++ b/src/main/java/com/nis/web/dao/basics/UrlCommGroupDao.java @@ -0,0 +1,41 @@ +package com.nis.web.dao.basics; + +import java.util.List; + +import org.apache.ibatis.annotations.Param; + +import com.nis.domain.basics.IpCommCfg; +import com.nis.domain.basics.UrlCommCfg; +import com.nis.web.dao.CrudDao; +import com.nis.web.dao.MyBatisDao; + +@MyBatisDao +public interface UrlCommGroupDao extends CrudDao{ + + // 查询列表 + public List findAllPageList(UrlCommCfg entity); + + public List findByPage(@Param("ids")String ids); + + public List findInfoByCfgId(@Param("cfgId")Long cfgId); + //新增 + public int insertUrlCommGroupCfg(UrlCommCfg entity); + + public Integer findUrlUdFlag(@Param("groupId")Integer groupId); + + public int updateUrlUdFlag(@Param("groupId")Integer groupId,@Param("udFlag")Integer udFlag); + + //修改 + public int update(UrlCommCfg entity); + + //删除 + public int delete(@Param("ids")String ids); + + public List getByIds(@Param("ids")String ids); + + + public Integer getGroupIdCount(@Param("groupId")String groupId); + + // 校验分组是否被引用 + public List getCfgInfoByGroupIds(@Param("ids")String ids); +} diff --git a/src/main/java/com/nis/web/dao/basics/UrlCommGroupDao.xml b/src/main/java/com/nis/web/dao/basics/UrlCommGroupDao.xml new file mode 100644 index 000000000..24e45726f --- /dev/null +++ b/src/main/java/com/nis/web/dao/basics/UrlCommGroupDao.xml @@ -0,0 +1,388 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + r.cfg_id,r.cfg_desc,r.cfg_keywords,r.action,r.is_valid,r.is_audit,r.creator_id, + r.create_time,r.editor_id,r.edit_time,r.auditor_id,r.audit_time,r.service_id, + r.request_id,r.compile_id,r.is_area_effective,r.classify,r.attribute,r.lable, + r.expr_type,r.match_method,r.is_hexbin,r.area_effective_ids,r.function_id, + r.cfg_region_code,r.cfg_type,r.ratelimit,r.user_region1,r.user_region2, + r.user_region3,r.user_region4,r.user_region5 + + + + + + + + + + + + + + + + + insert into http_url_cfg ( + CFG_DESC, + cfg_keywords, + action, + is_valid, + is_audit, + creator_id, + create_time, + editor_id, + edit_time, + auditor_id, + audit_time, + service_id, + request_id, + compile_id, + IS_AREA_EFFECTIVE, + CLASSIFY, + ATTRIBUTE, + LABLE, + expr_type, + match_method, + is_hexbin, + area_effective_ids, + function_id, + cfg_region_code, + cfg_type, + ratelimit, + user_region1, + user_region2, + user_region3, + user_region4, + user_region5 + )values ( + #{cfgDesc,jdbcType=VARCHAR}, + #{cfgKeywords,jdbcType=VARCHAR}, + #{action,jdbcType=INTEGER}, + #{isValid,jdbcType=INTEGER}, + #{isAudit,jdbcType=INTEGER}, + #{creatorId,jdbcType=INTEGER}, + #{createTime,jdbcType=TIMESTAMP}, + #{editorId,jdbcType=INTEGER}, + #{editTime,jdbcType=TIMESTAMP}, + #{auditorId,jdbcType=INTEGER}, + #{auditTime,jdbcType=TIMESTAMP}, + #{serviceId,jdbcType=INTEGER}, + #{requestId,jdbcType=INTEGER}, + #{compileId,jdbcType=INTEGER}, + #{isAreaEffective,jdbcType=INTEGER}, + #{classify,jdbcType=VARCHAR}, + #{attribute,jdbcType=VARCHAR}, + #{lable,jdbcType=VARCHAR}, + #{exprType,jdbcType=INTEGER}, + #{matchMethod,jdbcType=INTEGER}, + #{isHexbin,jdbcType=INTEGER}, + #{areaEffectiveIds,jdbcType=VARCHAR}, + #{functionId,jdbcType=INTEGER}, + #{cfgRegionCode,jdbcType=INTEGER}, + #{cfgType,jdbcType=VARCHAR}, + #{ratelimit,jdbcType=VARCHAR}, + #{userRegion1,jdbcType=VARCHAR}, + #{userRegion2,jdbcType=VARCHAR}, + #{userRegion3,jdbcType=VARCHAR}, + #{userRegion4,jdbcType=VARCHAR}, + #{userRegion5,jdbcType=VARCHAR} + ) + + + + + + UPDATE policy_group_info SET ud_flag =#{udFlag} + WHERE service_group_id=#{groupId} + and group_type=11 + + + + update http_url_cfg + + + + cfg_desc = #{cfgDesc,jdbcType=VARCHAR}, + + + cfg_keywords = #{cfgKeywords,jdbcType=VARCHAR}, + + + action = #{action,jdbcType=INTEGER}, + + + is_valid = #{isValid,jdbcType=INTEGER}, + + + is_audit = #{isAudit,jdbcType=INTEGER}, + + + editor_id = #{editorId,jdbcType=INTEGER}, + + + edit_time = #{editTime,jdbcType=TIMESTAMP}, + + + AUDITOR_ID = #{auditorId,jdbcType=INTEGER}, + + + AUDIT_TIME = #{auditTime,jdbcType=TIMESTAMP}, + + + service_id = #{serviceId,jdbcType=INTEGER}, + + + request_id = #{requestId,jdbcType=INTEGER}, + + + compile_id = #{compileId,jdbcType=INTEGER}, + + + is_area_effective = #{isAreaEffective,jdbcType=INTEGER}, + + + classify = #{classify,jdbcType=VARCHAR}, + + + attribute = #{attribute,jdbcType=VARCHAR}, + + + lable = #{lable,jdbcType=VARCHAR}, + + + expr_type = #{exprType,jdbcType=INTEGER}, + + + match_method = #{matchMethod,jdbcType=INTEGER}, + + + is_hexbin = #{isHexbin,jdbcType=INTEGER}, + + + area_effective_ids = #{areaEffectiveIds,jdbcType=VARCHAR}, + + + function_id = #{functionId,jdbcType=INTEGER}, + + + cfg_type = #{cfgType,jdbcType=VARCHAR}, + + + cfg_region_code = #{cfgRegionCode,jdbcType=INTEGER}, + + + ratelimit = #{ratelimit,jdbcType=VARCHAR}, + + + user_region1 = #{userRegion1,jdbcType=VARCHAR}, + + + user_region2 = #{userRegion2,jdbcType=VARCHAR}, + + + user_region3 = #{userRegion3,jdbcType=VARCHAR}, + + + user_region4 = #{userRegion4,jdbcType=VARCHAR}, + + + user_region5 = #{userRegion5,jdbcType=VARCHAR}, + + + + + and cfg_id = #{cfgId,jdbcType=INTEGER} + + + + + delete from http_url_cfg where cfg_id in (${ids}) + + + + + + diff --git a/src/main/java/com/nis/web/service/basics/CommonGroupManageService.java b/src/main/java/com/nis/web/service/basics/CommonGroupManageService.java index b252298c7..83c5349ea 100644 --- a/src/main/java/com/nis/web/service/basics/CommonGroupManageService.java +++ b/src/main/java/com/nis/web/service/basics/CommonGroupManageService.java @@ -14,11 +14,8 @@ import org.springframework.transaction.annotation.Transactional; import com.nis.domain.Page; import com.nis.domain.basics.CommonGroupInfo; import com.nis.domain.basics.IpCommCfg; -import com.nis.domain.basics.PolicyGroupInfo; import com.nis.domain.basics.UrlCommCfg; -import com.nis.domain.specific.ConfigGroupInfo; import com.nis.exceptions.MaatConvertException; -import com.nis.util.ConfigServiceUtil; import com.nis.util.StringUtil; import com.nis.web.dao.basics.AsnIpCfgDao; import com.nis.web.dao.basics.CommonGroupManageDao; diff --git a/src/main/java/com/nis/web/service/basics/UrlCommGroupService.java b/src/main/java/com/nis/web/service/basics/UrlCommGroupService.java new file mode 100644 index 000000000..1e2ae29d1 --- /dev/null +++ b/src/main/java/com/nis/web/service/basics/UrlCommGroupService.java @@ -0,0 +1,153 @@ +package com.nis.web.service.basics; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import org.apache.ibatis.session.ExecutorType; +import org.apache.ibatis.session.SqlSession; +import org.apache.ibatis.session.SqlSessionFactory; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.nis.domain.Page; +import com.nis.domain.basics.AsnGroupInfo; +import com.nis.domain.basics.AsnIpCfg; +import com.nis.domain.basics.UrlCommCfg; +import com.nis.domain.configuration.BaseIpCfg; +import com.nis.domain.configuration.CfgIndexInfo; +import com.nis.domain.maat.GroupReuseAddBean; +import com.nis.domain.maat.GroupReuseCfg; +import com.nis.domain.maat.MaatCfg; +import com.nis.domain.maat.ToMaatBean; +import com.nis.domain.maat.ToMaatResult; +import com.nis.domain.maat.MaatCfg.DigestCfg; +import com.nis.domain.maat.MaatCfg.GroupCfg; +import com.nis.domain.maat.MaatCfg.IpCfg; +import com.nis.domain.maat.MaatCfg.NumBoundaryCfg; +import com.nis.domain.maat.MaatCfg.StringCfg; +import com.nis.util.ConfigServiceUtil; +import com.nis.util.Constants; +import com.nis.util.StringUtil; +import com.nis.web.dao.CrudDao; +import com.nis.web.dao.basics.UrlCommGroupDao; +import com.nis.web.dao.configuration.IpCfgDao; +import com.nis.web.security.UserUtils; +import com.nis.web.service.CrudService; +import com.nis.web.service.SpringContextHolder; + +@Service +public class UrlCommGroupService extends CrudService, UrlCommCfg>{ + + @Autowired + private UrlCommGroupDao urlCommGroupDao; + + + public Page findPage(Page page, UrlCommCfg entity) { + entity.getSqlMap().put("dsf", configScopeFilter(entity.getCurrentUser(),"r")); + entity.setPage(page); + List list=urlCommGroupDao.findAllPageList(entity); + for (int i = 0; i < list.size(); i++) { + String key=list.get(i).getCfgKeywords().replace("***and***", " "); + list.get(i).setCfgKeywords(key); + } + page.setList(list); + return page; + } + + + public List findByPage(String ids) { + List list=urlCommGroupDao.findByPage(ids); + return list; + } + + + + public UrlCommCfg get(Long id ) { + return urlCommGroupDao.get(id); + } + + //新增 insertUrlCommGroupCfg + @Transactional(readOnly=false,rollbackFor=RuntimeException.class) + public void saveUrlCommGroupCfg(CfgIndexInfo entity) { + Date createTime=new Date(); + if(entity.getUrlCommGroupList()!=null) { + for (int i = 0; i < entity.getUrlCommGroupList().size(); i++) { + BeanUtils.copyProperties(entity, entity.getUrlCommGroupList().get(i), new String[]{"cfgId"}); + entity.getUrlCommGroupList().get(i).setRequestId(0); + entity.getUrlCommGroupList().get(i).setClassify("0"); + entity.getUrlCommGroupList().get(i).setAttribute("0"); + entity.getUrlCommGroupList().get(i).setLable("0"); + entity.getUrlCommGroupList().get(i).setIsHexbin(0); + entity.getUrlCommGroupList().get(i).setCreateTime(createTime); + entity.getUrlCommGroupList().get(i).setCreatorId(entity.getCurrentUser().getId()); + entity.getUrlCommGroupList().get(i).setIsValid(Constants.VALID_NO); + entity.getUrlCommGroupList().get(i).setIsAudit(Constants.AUDIT_NOT_YET); + if(entity.getUrlCommGroupList().get(i).getCfgKeywords().contains("***and***")){ + entity.getUrlCommGroupList().get(i).setExprType(1); + }else{ + entity.getUrlCommGroupList().get(i).setExprType(0); + } + urlCommGroupDao.insertUrlCommGroupCfg(entity.getUrlCommGroupList().get(i)); + } +// //修改公共组的标识 +// Integer udFlag=urlCommGroupDao.findUrlUdFlag(Integer.parseInt(entity.getUserRegion3())); +// if(udFlag == 0){ +// urlCommGroupDao.updateUrlUdFlag(Integer.parseInt(entity.getUserRegion3()), 1); +// } + } + } + + @Transactional(readOnly=false,rollbackFor=RuntimeException.class) + public void update(UrlCommCfg entity){ + Date editTime=new Date(); + entity.setIsValid(0); + entity.setIsAudit(0); + entity.setEditTime(editTime); + entity.setEditorId(entity.getCurrentUser().getId()); + if(entity.getCfgKeywords().contains("***and***")){ + entity.setExprType(1); + }else{ + entity.setExprType(0); + } + urlCommGroupDao.update(entity); + } + + + @Transactional(readOnly=false,rollbackFor=RuntimeException.class) + public void delete(String ids) { + + urlCommGroupDao.delete(ids); + } + + public List getByIds(String ids) { + if(ids==null) { + throw new RuntimeException("ids is null!"); + } + return urlCommGroupDao.getByIds(ids); + } + + @Transactional(readOnly=false,rollbackFor=RuntimeException.class) + public void audit(UrlCommCfg urlGroupCfg,Integer isAudit,Integer isValid) { + + if(!StringUtil.isEmpty(urlGroupCfg)){ + urlGroupCfg.setIsValid(isValid); + urlGroupCfg.setIsAudit(isAudit); + urlGroupCfg.setAuditorId(UserUtils.getUser().getId()); + urlGroupCfg.setAuditTime(new Date()); + + urlCommGroupDao.update(urlGroupCfg); + } + //下发配置时改变公共组udFlag标识 + //查询有效的url配置个数 + Integer groupCount=urlCommGroupDao.getGroupIdCount(urlGroupCfg.getUserRegion3()); + if(groupCount>0){//udFlag 设置为1 + urlCommGroupDao.updateUrlUdFlag(Integer.parseInt(urlGroupCfg.getUserRegion3()), 1); + }else{//udFlag 设置为0 + urlCommGroupDao.updateUrlUdFlag(Integer.parseInt(urlGroupCfg.getUserRegion3()), 0); + } + } + +} diff --git a/src/main/resources/sql/20190603/ip_comm_cfg.sql b/src/main/resources/sql/20190603/ip_comm_cfg.sql new file mode 100644 index 000000000..376967743 --- /dev/null +++ b/src/main/resources/sql/20190603/ip_comm_cfg.sql @@ -0,0 +1,46 @@ +CREATE TABLE `ip_comm_cfg` ( + `cfg_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键,自增', + `cfg_desc` varchar(128) DEFAULT NULL, + `cfg_type` varchar(64) DEFAULT '', + `cfg_region_code` int(11) DEFAULT NULL, + `ip_type` int(11) NOT NULL COMMENT 'IPV4=4,IPV6=6', + `src_ip_pattern` int(11) DEFAULT NULL COMMENT '源ip格式', + `dest_ip_pattern` int(11) DEFAULT NULL COMMENT '目的ip格式', + `src_ip_address` varchar(128) NOT NULL, + `dest_ip_address` varchar(128) NOT NULL, + `src_port_pattern` int(11) DEFAULT NULL COMMENT '源端口格式', + `dest_port_pattern` int(11) DEFAULT NULL COMMENT '目的端口格式', + `src_port` varchar(16) NOT NULL, + `dest_port` varchar(16) NOT NULL, + `direction` int(11) NOT NULL COMMENT '0双向,1单向,默认缺省为双向。', + `protocol` int(11) NOT NULL COMMENT '6表示tcp,17表示udp,0表示任意', + `protocol_id` int(11) NOT NULL COMMENT '非0时,maat规范需写入通用IP配置表与通用协议类型配置表 此表固定写0', + `action` int(11) NOT NULL COMMENT '1:阻断,2:监测, 5: FD 白名单,6:监测白名单,7: FD 监测都白名单,应与业务ID所代表的逻辑相匹配,8-灰名单', + `is_valid` int(11) NOT NULL COMMENT '0无效,1有效,-1删除\r\n1) 未审核时配置可删除\r\n2) 审核通过,此字段置1\r\n3) 取消审核通过,此字段置0', + `is_audit` int(11) NOT NULL COMMENT '0未审核,1审核通过,2审核未通过,3取消审核通过\r\n1) 审核未通过,配置可修改\r\n2) 审核通过,配置不可删除,只能取消审核通过', + `creator_id` int(11) NOT NULL COMMENT '取自sys_user.id', + `create_time` datetime NOT NULL, + `editor_id` int(11) DEFAULT NULL COMMENT '取自sys_user.id', + `edit_time` datetime DEFAULT NULL, + `auditor_id` int(11) DEFAULT NULL COMMENT '取自sys_user.id', + `audit_time` datetime DEFAULT NULL, + `service_id` int(11) NOT NULL COMMENT '参考系统业务类型管理表', + `request_id` int(11) NOT NULL COMMENT '取自request_info.id', + `compile_id` int(11) NOT NULL COMMENT '取自服务接口返回的maat配置的编译id,配置初始入库时获取。', + `is_area_effective` int(11) NOT NULL COMMENT '0否,1是', + `classify` varchar(128) DEFAULT NULL COMMENT '分类id,多个用英文逗号分隔', + `attribute` varchar(128) DEFAULT NULL COMMENT '性质id,多个用英文逗号分隔', + `lable` varchar(128) DEFAULT NULL COMMENT '标签id,多个用英文逗号分隔', + `area_effective_ids` varchar(1024) DEFAULT NULL COMMENT '多个英文逗号分隔', + `function_id` int(11) NOT NULL, + `ratelimit` varchar(10) DEFAULT NULL COMMENT '限速比例,0到1之间', + `region_id` int(11) DEFAULT NULL, + `group_id` int(11) DEFAULT NULL, + `user_region1` varchar(1024) DEFAULT NULL COMMENT '预留自定义域1', + `user_region2` varchar(1024) DEFAULT NULL COMMENT '预留自定义域2', + `user_region3` varchar(1024) DEFAULT NULL COMMENT '预留自定义域3', + `user_region4` varchar(1024) DEFAULT NULL COMMENT '预留自定义域4', + `user_region5` varchar(1024) DEFAULT NULL COMMENT '预留自定义域5', + `cancel_request_id` int(11) DEFAULT NULL COMMENT '取消审核来函', + PRIMARY KEY (`cfg_id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC; diff --git a/src/main/resources/sql/20190603/object_list_group.sql b/src/main/resources/sql/20190603/object_list_group.sql new file mode 100644 index 000000000..d405a53ce --- /dev/null +++ b/src/main/resources/sql/20190603/object_list_group.sql @@ -0,0 +1,39 @@ +# 菜单 +INSERT INTO `sys_menu` (`parent_id`, `parent_ids`, `code`, `name`, `sort`, `href`, `target`, `icon`, `is_show`, `permission`, `create_by`, `create_date`, `update_by`, `update_date`, `remarks`, `del_flag`, `menu_bg`, `quick_action`, `is_top`, `function_id`) VALUES ('717', '0,1,86,717,', 'ip_group_configuration', 'IP公共组管理', '340', '/basics/ip/list', '', '', '1', 'ip:common:config', '1', '2019-05-27 14:06:23', '1', '2019-05-27 14:37:33', '', '1', NULL, '0', '0', '605'); +INSERT INTO `sys_menu` (`parent_id`, `parent_ids`, `code`, `name`, `sort`, `href`, `target`, `icon`, `is_show`, `permission`, `create_by`, `create_date`, `update_by`, `update_date`, `remarks`, `del_flag`, `menu_bg`, `quick_action`, `is_top`, `function_id`) VALUES ('750', '0,1,150,750,', 'ip_group_configuration', 'IP公共组管理', '490', '/basics/ip/list', '', '', '1', 'ip:common:confirm', '1', '2019-05-27 14:08:56', '1', '2019-05-27 14:37:53', '', '1', NULL, '0', '0', '605'); +INSERT INTO `sys_menu` (`parent_id`, `parent_ids`, `code`, `name`, `sort`, `href`, `target`, `icon`, `is_show`, `permission`, `create_by`, `create_date`, `update_by`, `update_date`, `remarks`, `del_flag`, `menu_bg`, `quick_action`, `is_top`, `function_id`) VALUES ('865', '0,1,151,865,', 'ip_group_configuration', 'IP公共组管理', '490', '/basics/ip/list', '', '', '1', 'ip:common:audit', '1', '2019-05-27 14:09:45', '1', '2019-05-27 14:38:11', '', '1', NULL, '0', '0', '605'); + +INSERT INTO `sys_menu` (`parent_id`, `parent_ids`, `code`, `name`, `sort`, `href`, `target`, `icon`, `is_show`, `permission`, `create_by`, `create_date`, `update_by`, `update_date`, `remarks`, `del_flag`, `menu_bg`, `quick_action`, `is_top`, `function_id`) VALUES ('717', '0,1,86,717,', 'url_group_configuration', 'URL公共组管理', '350', '/basics/url/list', '', '', '1', 'url:common:config', '1', '2019-05-27 15:54:43', '1', '2019-05-27 15:55:05', '', '1', NULL, '0', '0', '606'); +INSERT INTO `sys_menu` (`parent_id`, `parent_ids`, `code`, `name`, `sort`, `href`, `target`, `icon`, `is_show`, `permission`, `create_by`, `create_date`, `update_by`, `update_date`, `remarks`, `del_flag`, `menu_bg`, `quick_action`, `is_top`, `function_id`) VALUES ('750', '0,1,150,750,', 'ip_group_configuration', 'URL公共组管理', '500', '/basics/url/list', '', '', '1', 'url:common:confirm', '1', '2019-05-27 15:55:58', '1', '2019-05-27 15:55:58', '', '1', NULL, '0', '0', '606'); +INSERT INTO `sys_menu` (`parent_id`, `parent_ids`, `code`, `name`, `sort`, `href`, `target`, `icon`, `is_show`, `permission`, `create_by`, `create_date`, `update_by`, `update_date`, `remarks`, `del_flag`, `menu_bg`, `quick_action`, `is_top`, `function_id`) VALUES ('865', '0,1,151,865,', 'url_group_configuration', 'URL公共组管理', '500', '/basics/url/list', '', '', '1', 'url:common:audit', '1', '2019-05-27 15:56:47', '1', '2019-05-27 15:56:47', '', '1', NULL, '0', '0', '606'); + +INSERT INTO `sys_menu` (`parent_id`, `parent_ids`, `code`, `name`, `sort`, `href`, `target`, `icon`, `is_show`, `permission`, `create_by`, `create_date`, `update_by`, `update_date`, `remarks`, `del_flag`, `menu_bg`, `quick_action`, `is_top`, `function_id`) VALUES ('109', '0,1,109,', 'common_group_manage', '公共组管理', '5090', '/basics/commonGroup/list', '', 'fa fa-object-ungroup', '1', '', '1', '2019-05-27 16:15:23', '1', '2019-05-28 15:28:59', '', '1', NULL, '0', '0', NULL); + +# 配置 +INSERT INTO `function_region_dict` (`function_id`, `config_district`, `config_region_code`, `config_region_value`, `config_desc`, `is_valid`, `is_maat`, `region_type`, `creator_id`, `create_time`, `editor_id`, `edit_time`, `config_service_type`, `config_expr_type`, `config_match_method`, `config_ip_type`, `config_hex`, `config_multi_keywords`, `config_ip_pattern`, `config_port_pattern`, `config_direction`, `config_protocol`, `config_ip_port_show`, `config_region_sort`, `is_import`) VALUES ('605', '', '1', 'IP_COMMON_GROUP', 'IP公共组管理', '1', '1', '1', NULL, '2019-05-27 14:50:16', NULL, NULL, '', '', '', '4,6', '', '', '1,2,3;1,2,3', '1,2;1,2', '0,1', '0,6,17', '3,4', '1', '1'); +INSERT INTO `function_region_dict` (`function_id`, `config_district`, `config_region_code`, `config_region_value`, `config_desc`, `is_valid`, `is_maat`, `region_type`, `creator_id`, `create_time`, `editor_id`, `edit_time`, `config_service_type`, `config_expr_type`, `config_match_method`, `config_ip_type`, `config_hex`, `config_multi_keywords`, `config_ip_pattern`, `config_port_pattern`, `config_direction`, `config_protocol`, `config_ip_port_show`, `config_region_sort`, `is_import`) VALUES ('606', '', '2', 'URL_COMMON_GROUP', 'URL公共组管理', '1', '1', '2', NULL, '2019-05-27 16:00:39', NULL, NULL, '', '0,1', '0,1,2,3', '', '0', '1', NULL, NULL, NULL, NULL, NULL, '1', '1'); + +INSERT INTO `function_service_dict` (`function_id`, `protocol_id`, `action`, `action_code`, `service_id`, `service_name`, `service_desc`, `is_valid`, `creator_id`, `create_time`, `editor_id`, `edit_time`, `region_code`, `is_import`, `sort`, `config_do_log`) VALUES ('605', '0', '1', 'monit', '0', 'ip_common_group', NULL, '1', '1', '2019-05-27 14:47:47', NULL, NULL, '1', '1', '0', '0;2;2'); +INSERT INTO `function_service_dict` (`function_id`, `protocol_id`, `action`, `action_code`, `service_id`, `service_name`, `service_desc`, `is_valid`, `creator_id`, `create_time`, `editor_id`, `edit_time`, `region_code`, `is_import`, `sort`, `config_do_log`) VALUES ('606', '0', '1', 'monit', '0', 'url_common_group', NULL, '1', '1', '2019-05-27 15:59:43', NULL, NULL, '2', '1', '0', NULL); + + +# 字典 +INSERT INTO `sys_data_dictionary_item` ( + `item_code`, + `item_value`, + `item_desc`, + `item_sort`, + `status`, + `type`, + `dictionary_id` +) +VALUES + ( + '7', + 'URL GROUP', + '普通URL组', + '0', + '1', + '1', + (SELECT id FROM sys_data_dictionary_name WHERE mark = 'GROUP_TYPE') + ); \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/views/basics/urlCommGroupFormAdd.jsp b/src/main/webapp/WEB-INF/views/basics/urlCommGroupFormAdd.jsp new file mode 100644 index 000000000..a42617ec3 --- /dev/null +++ b/src/main/webapp/WEB-INF/views/basics/urlCommGroupFormAdd.jsp @@ -0,0 +1,449 @@ +<%@ page contentType="text/html;charset=UTF-8"%> +<%@ include file="/WEB-INF/include/taglib.jsp"%> + + + <spring:message code="url_group_configuration"></spring:message> + + + + + +
+ +

+ +

+ +
+
+
+
+
+ + +
+
+
+ +
+ + + + + + + + + + + + + + + + +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ +
+ +
+
+
+
+
+ + +

+ + +

+ + +
+ + <%--
+ +
--%> + + +
+
+
+
+
+ + +
+
+
+
+
+
+
+ +
+
+
+
+
+ + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/views/basics/urlCommGroupFormUpdate.jsp b/src/main/webapp/WEB-INF/views/basics/urlCommGroupFormUpdate.jsp new file mode 100644 index 000000000..152700ea8 --- /dev/null +++ b/src/main/webapp/WEB-INF/views/basics/urlCommGroupFormUpdate.jsp @@ -0,0 +1,297 @@ +<%@ page contentType="text/html;charset=UTF-8"%> +<%@ include file="/WEB-INF/include/taglib.jsp"%> + + + <spring:message code="url_group_configuration"></spring:message> + + + + + +
+ +

+ +

+ +
+
+
+
+
+ + +
+
+
+ +
+ + + + + + + + + + <%-- + --%> + + + + + + + +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ +
+ <%-- --%> + +
+
+
+
+
+ + +

+ + +

+ + + +
+
+ + <%-- --%> + <%-- --%> + +
+
+
+ + + +
+ domainCheck urlCheck " type="text" id="tags_${tabName}${status.index}" + name="cfgKeywords" + value="${_cfg.cfgKeywords}"> +
+
+ + +
+ domainCheck + urlCheck + " + type="text" + name="cfgKeywords" + value="${_cfg.cfgKeywords}"> +
+
+
+
+
+
+
+
+
+ + +
+ + + + + --%> + + checked + + > + + + + + + + + + + + + + +
+
+ +
+
+ +
+
+ +
+ +
+
+
+
+
+ + +
+
+ +
+
+
+
+
+
+ + +
+
+
+
+
+
+
+ +
+
+
+
+
+ + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/views/basics/urlCommGroupList.jsp b/src/main/webapp/WEB-INF/views/basics/urlCommGroupList.jsp new file mode 100644 index 000000000..ea7a63be2 --- /dev/null +++ b/src/main/webapp/WEB-INF/views/basics/urlCommGroupList.jsp @@ -0,0 +1,323 @@ +<%@ page contentType="text/html;charset=UTF-8"%> +<%@ include file="/WEB-INF/include/taglib.jsp"%> + + + <spring:message code="url_group_configuration"></spring:message> + + + + +
+ + +

+ + +

+ +
+
+
+
+ + + + + + + + + + + +
+ <%--
+ + + + + + + + +
--%> + +
+
+
+ + + + + <%-- --%> + + +
+ + +
+ + + + + +
+
+
+
+ + + + + + +
+ +
+ + + +
+
+ + + + + +
+ + +
+ + <%-- +
+ + +
+
--%> + href="javascript:;"> + + +
+
+ + + +
+
+
+
+ + +
+
+ +
+
+ + " onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/> + +
+
+ +
+
+ + " onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/> + +
+
+ +
+
+ + " onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/> + +
+
+ +
+
+ + " onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/> + +
+
+ +
+
+ + " onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/> + +
+
+
+ + +
+ + +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
URL
${cfg.compileId }${cfg.cfgDesc }${cfg.cfgKeywords } + + + + + + + ${cfg.groupName } + + + + + + + + + + ${cfg.creatorName }${cfg.editorName }${cfg.auditorName }
+
${page}
+
+
+
+
+
+ + +<%@include file="/WEB-INF/include/excel/importModal.jsp" %> + + \ No newline at end of file