diff --git a/src/main/java/com/nis/web/controller/configuration/ntc/WhiteListController.java b/src/main/java/com/nis/web/controller/configuration/ntc/WhiteListController.java index b1e23828b..826ca3a86 100644 --- a/src/main/java/com/nis/web/controller/configuration/ntc/WhiteListController.java +++ b/src/main/java/com/nis/web/controller/configuration/ntc/WhiteListController.java @@ -1,5 +1,6 @@ package com.nis.web.controller.configuration.ntc; +import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -19,13 +20,15 @@ import org.springframework.web.multipart.MultipartFile; import org.springframework.web.servlet.mvc.support.RedirectAttributes; import com.nis.domain.Page; -import com.nis.domain.configuration.BaseIpCfg; +import com.nis.domain.configuration.CfgIndexInfo; import com.nis.domain.configuration.HttpUrlCfg; import com.nis.domain.configuration.IpPortCfg; +import com.nis.domain.configuration.NtcSubscribeIdCfg; import com.nis.domain.configuration.template.WhiteListIpTemplate; import com.nis.exceptions.MaatConvertException; import com.nis.util.Constants; import com.nis.web.controller.configuration.CommonController; +import com.nis.web.security.UserUtils; /** * 白名单 @@ -38,14 +41,87 @@ public class WhiteListController extends CommonController{ @RequestMapping(value = {"ip/list"}) //@RequiresPermissions(value={"whitelist:ip:config","whitelist:ip:confirm","whitelist:ip:aduit"},logical=Logical.OR) - public String ipList(Model model,@ModelAttribute("cfg")IpPortCfg cfg,HttpServletRequest request,HttpServletResponse response) { - cfg.setTableName(IpPortCfg.getTablename()); - Page searchPage=new Page(request,response,"r"); - Page page = ipCfgService.findPage(searchPage, cfg); + public String ipList(Model model,@ModelAttribute("cfg")CfgIndexInfo cfg,HttpServletRequest request,HttpServletResponse response) { + Page searchPage=new Page(request,response,"a"); + Page page = websiteCfgService.getWebsiteList(searchPage, cfg); model.addAttribute("page", page); initPageCondition(model,cfg); return "/cfg/whitelist/ipList"; } + @RequestMapping(value = {"ajaxIpSubList"}) + public String ajaxIpSubList(Model model,Long cfgId,Integer index) { + CfgIndexInfo cfg = ipCfgService.getIpPortCfg(cfgId); + List tabList = new ArrayList(); + if(cfg.getIpPortList()!=null){ + String cfgType = null; + for(IpPortCfg ip:cfg.getIpPortList()){ + if(!ip.getCfgType().equals(cfgType)){ + tabList.add(new String[]{"1",ip.getCfgType()}); + cfgType = ip.getCfgType(); + } + } + } + if(cfg.getNtcSubscribeIdCfgList()!=null){ + String cfgType = null; + for(NtcSubscribeIdCfg keyword:cfg.getNtcSubscribeIdCfgList()){ + if(!keyword.getCfgType().equals(cfgType)){ + tabList.add(new String[]{"2",keyword.getCfgType()}); + cfgType = keyword.getCfgType(); + } + } + } + model.addAttribute("_cfg", cfg); + model.addAttribute("index", index); + model.addAttribute("tabList", tabList); + return "/cfg/whitelist/ipSubList"; + } + @RequestMapping(value = {"ip/form"}) + @RequiresPermissions(value={"whitelist:ip:config"}) + public String ipForm(Model model,String ids,CfgIndexInfo entity) { + if(StringUtils.isNotBlank(ids)){ + + entity = this.ipCfgService.getIpPortCfg(Long.parseLong(ids)); + entity = this.websiteCfgService.getSslCfg(Long.parseLong(ids)); + initUpdateFormCondition(model,entity); + }else{ + initFormCondition(model,entity); + } + model.addAttribute("_cfg", entity); + return "/cfg/whitelist/ipForm"; + } + @RequestMapping(value = {"ip/save"}) + public String saveIpCfg(Model model,HttpServletRequest request,HttpServletResponse response,String ids,CfgIndexInfo entity) { + ipCfgService.saveIpCfg(entity); + return "redirect:" + adminPath +"/ntc/whitelist/ip/list?functionId="+entity.getFunctionId(); + } + @RequestMapping(value = {"ip/audit"}) + @RequiresPermissions("whitelist:ip:confirm") + public String auditIp(Integer isAudit,Integer isValid,String ids,Integer functionId, RedirectAttributes redirectAttributes) { + CfgIndexInfo entity = new CfgIndexInfo(); + String[] idArray = ids.split(","); + for(String id :idArray){ + entity = ipCfgService.getIpPortCfg(Long.parseLong(id)); + entity.setIsAudit(isAudit); + entity.setIsValid(isValid); + entity.setAuditorId(UserUtils.getUser().getId()); + entity.setAuditTime(new Date()); + entity.setFunctionId(functionId); + try { + ipCfgService.auditIpCfg(entity,isAudit); + } catch (MaatConvertException e) { + e.printStackTrace(); + logger.info("ip配置下发失败:"+e.getMessage()); + addMessage(redirectAttributes, e.getMessage()); + } + } + return "redirect:" + adminPath +"/ntc/whitelist/ip/list?functionId="+entity.getFunctionId(); + } + @RequestMapping(value = {"updateIpValid"}) + @RequiresPermissions(value={"whitelist:ip:config"}) + public String updateIpCfgValid(Integer isValid,String ids,Integer functionId) { + ipCfgService.updateIpCfgValid(isValid,ids,functionId); + return "redirect:" + adminPath +"/ntc/website/sslList?functionId="+functionId; + } @RequestMapping(value = {"domain/list"}) //@RequiresPermissions(value={"whitelist:domain:config","whitelist:domain:confirm","whitelist:domain:aduit"},logical=Logical.OR) public String domainList(Model model,@ModelAttribute("cfg")HttpUrlCfg cfg,HttpServletRequest request,HttpServletResponse response) { @@ -56,25 +132,7 @@ public class WhiteListController extends CommonController{ initPageCondition(model,cfg); return "/cfg/whitelist/domainList"; } - @RequestMapping(value = {"ip/form"}) - @RequiresPermissions(value={"whitelist:ip:config"}) - public String ipForm(Model model,String ids,BaseIpCfg entity) { - if(StringUtils.isNotBlank(ids)){ - entity = ipCfgService.getIpCfgById(IpPortCfg.getTablename(),Long.parseLong(ids)); - } - initFormCondition(model,entity); - if(entity.getCfgId()!=null){ - model.addAttribute("_cfg", entity); - }else{ - IpPortCfg cfg=new IpPortCfg(); - cfg.initDefaultValueImpl(); - cfg.setFunctionId(entity.getFunctionId()); - cfg.setProtocolId(entity.getProtocolId()); - model.addAttribute("_cfg", cfg); - } - - return "/cfg/whitelist/ipForm"; - } + @RequestMapping(value = {"domain/form"}) @RequiresPermissions(value={"whitelist:domain:config"}) public String domainForm(Model model,String ids,HttpUrlCfg entity) { @@ -93,30 +151,6 @@ public class WhiteListController extends CommonController{ return "/cfg/whitelist/domainForm"; } - @RequestMapping(value = {"ip/saveOrUpdate"}) - public String saveOrUpdateIp(RedirectAttributes model, IpPortCfg cfg) { - cfg.setTableName(IpPortCfg.getTablename()); - logger.info("saveOrUpdateIp loaded"); - try{ - Date date=new Date(); - cfg.setIsValid(Constants.VALID_NO); - cfg.setIsAudit(Constants.AUDIT_NOT_YET); - if(cfg.getCfgId()==null){//新增 - cfg.setCreatorId(cfg.getCurrentUser().getId()); - cfg.setCreateTime(date); - ipCfgService.addIpCfg(cfg); - }else{//修改 - cfg.setEditorId(cfg.getCurrentUser().getId()); - cfg.setEditTime(new Date()); - ipCfgService.updateIpCfg(cfg); - } - addMessage(model,"save_success"); - }catch(Exception e){ - logger.error("保存失败",e); - addMessage(model,"save_failed"); - } - return "redirect:" + adminPath +"/ntc/whitelist/ip/list?functionId="+cfg.getFunctionId(); - } @RequestMapping(value = {"domain/saveOrUpdate"}) public String saveOrUpdateDomain(RedirectAttributes model, HttpUrlCfg cfg) { cfg.setTableName(HttpUrlCfg.getTablename()); @@ -142,18 +176,6 @@ public class WhiteListController extends CommonController{ return "redirect:" + adminPath +"/ntc/whitelist/domain/list?functionId="+cfg.getFunctionId(); } - @RequestMapping(value = {"ip/delete"}) - @RequiresPermissions("whitelist:ip:config") - public String deleteIp(String ids,Integer functionId,RedirectAttributes model) { - try{ - ipCfgService.deleteIp(ids,null,functionId.intValue()); - addMessage(model,"delete_success"); - }catch(Exception e){ - logger.error("删除失败", e); - addMessage(model,"delete_failed"); - } - return "redirect:" + adminPath +"/ntc/whitelist/ip/list?functionId="+functionId; - } @RequestMapping(value = {"domain/delete"}) @RequiresPermissions("whitelist:domain:config") public String deleteDomain(String ids,Integer functionId,RedirectAttributes model) { @@ -166,33 +188,7 @@ public class WhiteListController extends CommonController{ } return "redirect:" + adminPath +"/ntc/whitelist/domain/list?functionId="+functionId; } - @RequestMapping(value = {"ip/audit"}) - @RequiresPermissions("whitelist:ip:confirm") - public String auditIp(String ids,IpPortCfg cfg,RedirectAttributes redirectAttributes) { - try{ - for(String id:ids.split(",")){ - Long.parseLong(id); - } - List beans=ipCfgService.getListByCfgId(IpPortCfg.getTablename(),cfg.getFunctionId().intValue(),ids); - Date date=new Date(); - for(BaseIpCfg bean:beans){ - bean.setTableName(IpPortCfg.getTablename()); - bean.setAuditorId(bean.getCurrentUser().getId()); - bean.setAuditTime(date); - bean.setIsAudit(cfg.getIsAudit()); - bean.setIsValid(cfg.getIsValid()); - ipCfgService.auditWhiteIp(bean); - } - addMessage(redirectAttributes,"audit_success"); - }catch(MaatConvertException e){ - logger.error("审核失败", e); - addMessage(redirectAttributes, e.getMessage()); - }catch(Exception e){ - logger.error("审核失败", e); - addMessage(redirectAttributes, "audit_failed"); - } - return "redirect:" + adminPath +"/ntc/whitelist/ip/list?functionId="+cfg.getFunctionId(); - } + @RequestMapping(value = {"domain/audit"}) @RequiresPermissions("whitelist:domain:confirm") public String auditDomain(String ids,HttpUrlCfg cfg,RedirectAttributes redirectAttributes) { diff --git a/src/main/java/com/nis/web/dao/configuration/IpCfgDao.java b/src/main/java/com/nis/web/dao/configuration/IpCfgDao.java index 9f3e6ff00..eda34d006 100644 --- a/src/main/java/com/nis/web/dao/configuration/IpCfgDao.java +++ b/src/main/java/com/nis/web/dao/configuration/IpCfgDao.java @@ -4,7 +4,10 @@ import java.util.List; import org.apache.ibatis.annotations.Param; +import com.nis.domain.configuration.BaseCfg; import com.nis.domain.configuration.BaseIpCfg; +import com.nis.domain.configuration.CfgIndexInfo; +import com.nis.domain.configuration.IpPortCfg; import com.nis.web.dao.CrudDao; import com.nis.web.dao.MyBatisDao; @@ -31,4 +34,15 @@ public interface IpCfgDao extends CrudDao{ public int getIsAudit(BaseIpCfg entity); public int deleteByCompileId(BaseIpCfg entity); public int deleteByCompileIds(@Param("user")long user,@Param("tableName")String tableName,@Param("compileIds")String compileIds); + /******************************new ***********************************/ + + public CfgIndexInfo getCfgIndexInfo(Long id); + public List getIpPortList(CfgIndexInfo entity); + public void saveCfgIndex(CfgIndexInfo entity); + public void saveIpPortCfg(IpPortCfg entity); + public void updateCfgIndex(CfgIndexInfo entity); + public void deleteIpCfg(CfgIndexInfo entity); + public void updateCfgValid(BaseCfg entity); + public void auditCfg(BaseCfg entity); + } diff --git a/src/main/java/com/nis/web/dao/configuration/IpCfgDao.xml b/src/main/java/com/nis/web/dao/configuration/IpCfgDao.xml index b5b9e3a01..90e496f8b 100644 --- a/src/main/java/com/nis/web/dao/configuration/IpCfgDao.xml +++ b/src/main/java/com/nis/web/dao/configuration/IpCfgDao.xml @@ -43,13 +43,77 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - CFG_ID, CFG_DESC,CFG_REGION_CODE,CFG_TYPE, IP_TYPE, IP_PATTERN, SRC_IP_ADDRESS,DEST_IP_ADDRESS, PORT_PATTERN,SRC_PORT,DEST_PORT, DIRECTION,PROTOCOL,PROTOCOL_ID,ACTION,IS_VALID,IS_AUDIT, @@ -127,6 +191,22 @@ #{userRegion4,jdbcType=VARCHAR}, #{userRegion5,jdbcType=VARCHAR} + + + a.CFG_ID,a.CFG_DESC,a.ACTION,a.IS_VALID,a.IS_AUDIT, + a.CREATOR_ID,a.CREATE_TIME,a.EDITOR_ID,a.EDIT_TIME,a.AUDITOR_ID,a.AUDIT_TIME, + a.SERVICE_ID,a.REQUEST_ID,a.COMPILE_ID,a.IS_AREA_EFFECTIVE,a.CLASSIFY, + a.ATTRIBUTE,a.LABLE,a.AREA_EFFECTIVE_IDS,a.function_id,a.dns_strategy_id,a.user_region1, + a.user_region2,a.user_region3,a.user_region4,a.user_region5,a.do_log + + + a.cfg_id,a.cfg_desc,a.ip_type,a.src_ip_address,a.ip_pattern,a.port_pattern,a.src_port + ,a.protocol,a.protocol_id,a.direction,a.cfg_type,a.action,a.dest_port,a.dest_ip_address + ,a.is_valid,a.is_audit,a.creator_id,a.create_time,a.editor_id + ,a.edit_time,a.auditor_id,a.audit_time,a.service_id,a.request_id, + a.compile_id,a.is_area_effective,a.classify,a.attribute,a.lable + ,a.area_effective_ids,a.function_id,a.cfg_region_code + + + + + + + + SELECT LAST_INSERT_ID() + + insert into cfg_index_info( + CFG_DESC, + 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, + AREA_EFFECTIVE_IDS, + function_id, + dns_strategy_id, + user_region1, + user_region2, + user_region3, + user_region4, + user_region5, + do_log + )values ( + #{cfgDesc,jdbcType=VARCHAR}, + #{action,jdbcType=INTEGER}, + 0, + 0, + #{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}, + #{areaEffectiveIds,jdbcType=VARCHAR}, + #{functionId,jdbcType=INTEGER}, + #{dnsStrategyId,jdbcType=INTEGER}, + #{userRegion1,jdbcType=VARCHAR}, + #{userRegion2,jdbcType=VARCHAR}, + #{userRegion3,jdbcType=VARCHAR}, + #{userRegion4,jdbcType=VARCHAR}, + #{userRegion5,jdbcType=VARCHAR}, + #{doLog,jdbcType=INTEGER} + ) + + + + + SELECT LAST_INSERT_ID() + + insert into ip_port_cfg ( + CFG_DESC, + 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, + AREA_EFFECTIVE_IDS, + function_id, + ip_type, + src_ip_address, + ip_pattern, + port_pattern, + src_port, + protocol, + protocol_id, + direction, + dest_port, + dest_ip_address, + cfg_type, + cfg_region_code, + user_region1, + user_region2, + user_region3, + user_region4, + user_region5 + )values ( + #{cfgDesc,jdbcType=VARCHAR}, + #{action,jdbcType=INTEGER}, + 0, + 0, + #{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}, + #{areaEffectiveIds,jdbcType=VARCHAR}, + #{functionId,jdbcType=INTEGER}, + #{ipType,jdbcType=INTEGER}, + #{srcIpAddress,jdbcType=VARCHAR}, + #{ipPattern,jdbcType=INTEGER}, + #{portPattern,jdbcType=INTEGER}, + #{srcPort,jdbcType=VARCHAR}, + #{protocol,jdbcType=INTEGER}, + #{protocolId,jdbcType=INTEGER}, + #{direction,jdbcType=INTEGER}, + #{destPort,jdbcType=VARCHAR}, + #{destIpAddress,jdbcType=VARCHAR}, + #{cfgType,jdbcType=VARCHAR}, + #{cfgRegionCode,jdbcType=INTEGER}, + #{userRegion1,jdbcType=VARCHAR}, + #{userRegion2,jdbcType=VARCHAR}, + #{userRegion3,jdbcType=VARCHAR}, + #{userRegion4,jdbcType=VARCHAR}, + #{userRegion5,jdbcType=VARCHAR} + ) + + + update cfg_index_info + + + + cfg_desc = #{cfgDesc,jdbcType=VARCHAR}, + + + action = #{action,jdbcType=INTEGER}, + + + do_log = #{doLog,jdbcType=INTEGER}, + + + is_valid = #{isValid,jdbcType=INTEGER}, + + + is_audit = #{isAudit,jdbcType=INTEGER}, + + + creator_id = #{creatorId,jdbcType=INTEGER}, + + + create_time = #{createTime,jdbcType=TIMESTAMP}, + + + editor_id = #{editorId,jdbcType=INTEGER}, + + edit_time = #{editTime,jdbcType=TIMESTAMP}, + + service_id = #{serviceId,jdbcType=INTEGER}, + + + request_id = #{requestId,jdbcType=INTEGER}, + + + is_area_effective = #{isAreaEffective,jdbcType=INTEGER}, + + + classify = #{classify,jdbcType=VARCHAR}, + + + attribute = #{attribute,jdbcType=VARCHAR}, + + + lable = #{lable,jdbcType=VARCHAR}, + + + area_effective_ids = #{areaEffectiveIds,jdbcType=VARCHAR}, + + + function_id = #{functionId,jdbcType=INTEGER}, + + 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}, + dns_strategy_id = #{dnsStrategyId,jdbcType=INTEGER}, + + + where cfg_id = #{cfgId,jdbcType=BIGINT} + + + delete from ip_port_cfg where compile_id=#{compileId} and function_id=#{functionId} + + + update ${tableName} set is_valid = #{isValid,jdbcType=INTEGER}, + editor_id = #{editorId,jdbcType=INTEGER} , + edit_time = #{editTime,jdbcType=TIMESTAMP} + + + AND cfg_id = #{cfgId,jdbcType=BIGINT} + + + AND compile_id = #{compileId,jdbcType=INTEGER} + + and function_id=#{functionId,jdbcType=INTEGER} + + + + update ${tableName} set is_audit = #{isAudit,jdbcType=INTEGER}, + auditor_id = #{auditorId,jdbcType=INTEGER}, + audit_time = #{auditTime,jdbcType=TIMESTAMP} + + ,is_valid = #{isValid,jdbcType=INTEGER} + + + + AND cfg_id = #{cfgId,jdbcType=BIGINT} + + + AND compile_id = #{compileId,jdbcType=INTEGER} + + and function_id=#{functionId,jdbcType=INTEGER} + + \ No newline at end of file diff --git a/src/main/java/com/nis/web/service/configuration/IpCfgService.java b/src/main/java/com/nis/web/service/configuration/IpCfgService.java index c6f75eb7b..e5642736c 100644 --- a/src/main/java/com/nis/web/service/configuration/IpCfgService.java +++ b/src/main/java/com/nis/web/service/configuration/IpCfgService.java @@ -17,7 +17,9 @@ import com.nis.domain.FunctionRegionDict; import com.nis.domain.callback.InlineIp; import com.nis.domain.configuration.AreaIpCfg; import com.nis.domain.configuration.BaseIpCfg; +import com.nis.domain.configuration.CfgIndexInfo; import com.nis.domain.configuration.IpPortCfg; +import com.nis.domain.configuration.NtcSubscribeIdCfg; import com.nis.domain.maat.MaatCfg; import com.nis.domain.maat.MaatCfg.DigestCfg; import com.nis.domain.maat.MaatCfg.GroupCfg; @@ -34,6 +36,8 @@ import com.nis.util.DictUtils; import com.nis.util.StringUtil; import com.nis.web.dao.configuration.AreaIpCfgDao; import com.nis.web.dao.configuration.IpCfgDao; +import com.nis.web.dao.configuration.StringCfgDao; +import com.nis.web.security.UserUtils; import com.nis.web.service.CrudService; /** @@ -46,6 +50,8 @@ public class IpCfgService extends CrudService { @Autowired protected IpCfgDao ipCfgDao; @Autowired + protected StringCfgDao stringCfgDao; + @Autowired protected AreaIpCfgDao areaIpCfgDao; /** * @@ -90,6 +96,124 @@ public class IpCfgService extends CrudService { } } + @Transactional(readOnly=false,rollbackFor=RuntimeException.class) + public void saveIpCfg(CfgIndexInfo entity){ + //设置区域运营商信息 + setAreaEffectiveIds(entity); + + entity.setIsValid(0); + entity.setIsAudit(0); + + if(entity.getCfgId()==null){ + Integer compileId = 0; + try { + List idList = ConfigServiceUtil.getId(1, 1); + if(idList!=null && idList.size()>0){ + compileId = idList.get(0); + } + } catch (MaatConvertException e) { + logger.info("获取编译ID出错"); + throw new MaatConvertException(""); + } + entity.setCompileId(compileId); + entity.setCreateTime(new Date()); + entity.setCreatorId(entity.getCurrentUser().getId()); + ipCfgDao.saveCfgIndex(entity); + if(entity.getIpPortList()!=null){ + for(IpPortCfg cfg:entity.getIpPortList()){ + BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"}); + ipCfgDao.saveIpPortCfg(cfg); + } + } + if(entity.getNtcSubscribeIdCfgList()!=null){ + for(NtcSubscribeIdCfg cfg:entity.getNtcSubscribeIdCfgList()){ + if(StringUtils.isNotBlank(cfg.getCfgKeywords())){ + BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"}); + stringCfgDao.saveSubscribeIdCfg(cfg); + } + } + } + //保存区域IP信息 + if(entity.getAreaCfg()!=null){ + for(AreaIpCfg cfg:entity.getAreaCfg()){ + cfg.initDefaultValue(); + BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"}); + areaIpCfgDao.saveAreaIpCfg(cfg); + } + } + + }else{ + ipCfgDao.updateCfgIndex(entity); + //无效子配置后,再新增子配置 + ipCfgDao.deleteIpCfg(entity); + stringCfgDao.deleteSubscribeIdCfgByCfgIndexInfo(entity); + AreaIpCfg area = new AreaIpCfg(); + area.setCompileId(entity.getCompileId()); + area.setFunctionId(entity.getFunctionId()); + areaIpCfgDao.deleteAreaIpCfg(area); + entity.setCreateTime(new Date()); + entity.setCreatorId(entity.getCurrentUser().getId()); + if(entity.getIpPortList()!=null){ + for(IpPortCfg cfg:entity.getIpPortList()){ + BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"}); + ipCfgDao.saveIpPortCfg(cfg); + } + } + if(entity.getNtcSubscribeIdCfgList()!=null){ + for(NtcSubscribeIdCfg cfg:entity.getNtcSubscribeIdCfgList()){ + if(StringUtils.isNotBlank(cfg.getCfgKeywords())){ + BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"}); + stringCfgDao.saveSubscribeIdCfg(cfg); + } + } + } + //保存区域IP信息 + if(entity.getAreaCfg()!=null){ + for(AreaIpCfg cfg:entity.getAreaCfg()){ + cfg.initDefaultValue(); + BeanUtils.copyProperties(entity, cfg,new String[]{"cfgDesc","cfgRegionCode","cfgType"}); + areaIpCfgDao.saveAreaIpCfg(cfg); + } + } + } + } + public void updateIpCfgValid(Integer isValid,String ids,Integer functionId){ + CfgIndexInfo entity = new CfgIndexInfo(); + String[] idArray = ids.split(","); + for(String id :idArray){ + entity.setCfgId(Long.parseLong(id)); + entity.setIsValid(isValid); + entity.setEditorId(UserUtils.getUser().getId()); + entity.setEditTime(new Date()); + entity.setTableName(CfgIndexInfo.getTablename()); + entity.setFunctionId(functionId); + ipCfgDao.updateCfgValid(entity); + //查询子配置 + entity = this.getIpPortCfg(Long.parseLong(id)); + if(entity.getIpPortList()!=null && entity.getIpPortList().size()>0){ + IpPortCfg cfg = new IpPortCfg(); + BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"}); + cfg.setTableName(IpPortCfg.getTablename()); + ipCfgDao.updateCfgValid(cfg); + } + if(entity.getNtcSubscribeIdCfgList()!=null && entity.getNtcSubscribeIdCfgList().size()>0) + { + NtcSubscribeIdCfg cfg = new NtcSubscribeIdCfg(); + BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"}); + cfg.setTableName(NtcSubscribeIdCfg.getTablename()); + ipCfgDao.updateCfgValid(cfg); + } + //保存区域IP信息 + if(entity.getAreaCfg()!=null && entity.getAreaCfg().size()>0){ + AreaIpCfg cfg = new AreaIpCfg(); + BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"}); + cfg.setTableName(AreaIpCfg.getTablename()); + ipCfgDao.updateCfgValid(cfg); + } + + } + + } /** * * updateIpCfg(更新IP类配置) @@ -369,7 +493,107 @@ public class IpCfgService extends CrudService { } } } - + public void auditIpCfg(CfgIndexInfo entity,Integer isAudit) throws MaatConvertException{ + //修改数据库审核状态信息 + entity.setTableName(CfgIndexInfo.getTablename()); + ipCfgDao.auditCfg(entity); + + ToMaatBean maatBean = new ToMaatBean(); + MaatCfg maatCfg = new MaatCfg(); + List configCompileList = new ArrayList(); + List groupRelationList = new ArrayList(); + List ipRegionList = new ArrayList(); + List strRegionList = new ArrayList(); + List numRegionList = new ArrayList(); + List digestRegionList = new ArrayList(); + List areaIpRegionList = new ArrayList(); + + //查询子配置并修改审核状态 + entity = this.getIpPortCfg(entity.getCfgId()); + if(entity.getIpPortList()!=null && entity.getIpPortList().size()>0){ + IpPortCfg cfg = new IpPortCfg(); + BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"}); + cfg.setTableName(IpPortCfg.getTablename()); + ipCfgDao.auditCfg(cfg); + if(isAudit==1){ + Map map = cfgConvert(ipRegionList,entity.getIpPortList(),1,entity,groupRelationList); + groupRelationList=map.get("groupList"); + ipRegionList=map.get("dstList"); + if(map.get("numRegionList")!=null){ + numRegionList.addAll(map.get("numRegionList")); + } + } + } + if(entity.getNtcSubscribeIdCfgList()!=null && entity.getNtcSubscribeIdCfgList().size()>0){ + NtcSubscribeIdCfg cfg = new NtcSubscribeIdCfg(); + BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"}); + cfg.setTableName(NtcSubscribeIdCfg.getTablename()); + ipCfgDao.auditCfg(cfg); + if(isAudit==1){ + Map map = cfgConvert(strRegionList,entity.getNtcSubscribeIdCfgList(),2,entity,groupRelationList); + groupRelationList=map.get("groupList"); + strRegionList=map.get("dstList"); + } + } + //保存区域IP信息 + List areaIpCfgList=areaIpCfgDao.getByCompileId(entity.getCompileId()); + if(!StringUtil.isEmpty(areaIpCfgList)){ + AreaIpCfg cfg = new AreaIpCfg(); + BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"}); + cfg.setTableName(AreaIpCfg.getTablename()); + ipCfgDao.auditCfg(cfg); + if(isAudit==1){ + Map map = cfgConvert(areaIpRegionList,areaIpCfgList,1,entity,groupRelationList); + groupRelationList=map.get("groupList"); + areaIpRegionList=map.get("dstList"); + } + } + //构造提交综合服务参数格式,一条配置提交一次综合服务 + if(isAudit==1){ + maatCfg.initDefaultValue(); + BeanUtils.copyProperties(entity, maatCfg); + maatCfg.setAction(entity.getAction()); + maatCfg.setAuditTime(entity.getAuditTime()); + maatCfg.setIpRegionList(ipRegionList); + maatCfg.setStrRegionList(strRegionList); + maatCfg.setNumRegionList(numRegionList); + maatCfg.setDigestRegionList(digestRegionList); + maatCfg.setGroupRelationList(groupRelationList); + maatCfg.setGroupNum(groupRelationList.size()); + maatCfg.setAreaIpRegionList(areaIpRegionList); + maatCfg.setIsValid(entity.getIsValid()); + + configCompileList.add(maatCfg); + maatBean.setConfigCompileList(configCompileList); + maatBean.setAuditTime(entity.getAuditTime()); + maatBean.setCreatorName(entity.getCurrentUser().getName()); + maatBean.setVersion(Constants.MAAT_VERSION); + maatBean.setOpAction(Constants.INSERT_ACTION); + //调用服务接口下发配置数据 + String json=gsonToJson(maatBean); + logger.info("ip配置下发配置参数:"+json); + //调用服务接口下发配置 + ToMaatResult result = ConfigServiceUtil.postMaatCfg(json); + logger.info("ip配置下发响应信息:"+result.getMsg()); + + }else if(isAudit==3){ + maatCfg.setCompileId(entity.getCompileId()); + maatCfg.setServiceId(entity.getServiceId()); + maatCfg.setIsValid(0);//无效 + configCompileList.add(maatCfg); + maatBean.setConfigCompileList(configCompileList); + maatBean.setAuditTime(entity.getAuditTime()); + maatBean.setCreatorName(entity.getCurrentUser().getName()); + maatBean.setVersion(Constants.MAAT_VERSION); + maatBean.setOpAction(Constants.UPDATE_ACTION); + //调用服务接口取消配置 + String json=gsonToJson(maatBean); + logger.info("ip配置下发配置参数:"+json); + //调用服务接口下发配置 + ToMaatResult result = ConfigServiceUtil.put(json,1); + logger.info("ip配置取消配置响应信息:"+result.getMsg()); + } + } @Transactional(readOnly=false,rollbackFor=RuntimeException.class) public void deleteIp(String ids,String compileIds,int functionId){ if(StringUtils.isNotBlank(compileIds)){ @@ -431,6 +655,14 @@ public class IpCfgService extends CrudService { public BaseIpCfg getIpCfgById(BaseIpCfg baseIpCfg){ return ipCfgDao.getById(baseIpCfg.getTableName(), baseIpCfg.getCfgId()); } + public CfgIndexInfo getIpPortCfg(Long cfgId){ + CfgIndexInfo entity = ipCfgDao.getCfgIndexInfo(cfgId); + List ipPortList = ipCfgDao.getIpPortList(entity); + List subscribeIdList = stringCfgDao.findSubscribeIdCfgListByCfgIndexInfo(entity); + entity.setIpPortList(ipPortList); + entity.setNtcSubscribeIdCfgList(subscribeIdList); + return entity; + } public BaseIpCfg getIpCfgById(String tableName,long id){ return ipCfgDao.getById(tableName, id); } diff --git a/src/main/resources/sql/update_function_region_dict_data.sql b/src/main/resources/sql/update_function_region_dict_data.sql index 87237ab84..70ca7e31a 100644 --- a/src/main/resources/sql/update_function_region_dict_data.sql +++ b/src/main/resources/sql/update_function_region_dict_data.sql @@ -1,3 +1,9 @@ +#ip地址白名单 +INSERT INTO function_region_dict (config_service_type,config_multi_keywords,config_expr_type,config_hex,config_match_method +,function_id,config_region_code,config_region_value,config_desc,is_valid,is_maat,region_type,config_region_sort) +VALUES('subscribe_id',1,'0,1','0,1,2','0,1,2,3',3,2,'WHITE_LIST_SUBSCRIBE_ID','全局IP白名单SUBSCRIBE配置',1,1,2,2); +UPDATE function_service_dict SET region_code='1,2' WHERE function_id=3 AND ACTION=128 +UPDATE function_region_dict SET config_ip_port_show='1,2' ,config_ip_type='4,6',config_ip_pattern='1,2,3',config_port_pattern='1,2',config_direction='0',config_protocol='0' WHERE dict_id=7; #ip地址 UPDATE function_service_dict SET region_code=1 WHERE function_id=5 AND ACTION IN(16,1); UPDATE function_service_dict SET region_code=2 WHERE function_id=5 AND ACTION IN(32,96); @@ -21,9 +27,6 @@ UPDATE function_region_dict SET config_ip_port_show='1,2' ,config_ip_type='4,6,4 #APP IP UPDATE function_service_dict SET region_code=1 WHERE function_id=405 AND ACTION IN(1); UPDATE function_region_dict SET config_ip_port_show='1,2' ,config_ip_type='4,6',config_ip_pattern='1,2,3',config_port_pattern='1,2',config_direction='0',config_protocol='0,6,17' WHERE dict_id=62; -#IP白名单 -UPDATE function_service_dict SET region_code=1 WHERE function_id=3 AND ACTION IN(128); -UPDATE function_region_dict SET config_ip_port_show='1,2' ,config_ip_type='4,6',config_ip_pattern='1,2,3',config_port_pattern='1,2',config_direction='0',config_protocol='0,6,17' WHERE dict_id=7; #http ip UPDATE function_service_dict SET region_code='1,2,3,4,5,6' WHERE function_id=8 AND ACTION IN(16,1); UPDATE function_region_dict SET config_ip_port_show='1,2' ,config_ip_type='4,6,46,64,10',config_ip_pattern='1,2,3',config_port_pattern='1,2',config_direction='0,1',config_protocol='0,6,17' WHERE dict_id=14; diff --git a/src/main/webapp/WEB-INF/sitemesh3.xml b/src/main/webapp/WEB-INF/sitemesh3.xml index 8c4b7a6ea..d323a8666 100644 --- a/src/main/webapp/WEB-INF/sitemesh3.xml +++ b/src/main/webapp/WEB-INF/sitemesh3.xml @@ -32,6 +32,8 @@ + + /articles/* diff --git a/src/main/webapp/WEB-INF/views/cfg/whitelist/ipCfgForm.jsp b/src/main/webapp/WEB-INF/views/cfg/whitelist/ipCfgForm.jsp new file mode 100644 index 000000000..2c1113912 --- /dev/null +++ b/src/main/webapp/WEB-INF/views/cfg/whitelist/ipCfgForm.jsp @@ -0,0 +1,161 @@ +<%@ page contentType="text/html;charset=UTF-8"%> +<%@ include file="/WEB-INF/include/taglib.jsp"%> + + + + + +<%-- + --%> + + + + <%-- + --%> + +
+
+ +
+
+
+
+
+ +
+ +
+
+
+
+ +
+
+ +
+ +
+
+
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+
+ +
+ +
+
+
+
+
+ + + + +
+ +
+
+ + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/views/cfg/whitelist/ipForm.jsp b/src/main/webapp/WEB-INF/views/cfg/whitelist/ipForm.jsp index 89b9651af..9b126f6a3 100644 --- a/src/main/webapp/WEB-INF/views/cfg/whitelist/ipForm.jsp +++ b/src/main/webapp/WEB-INF/views/cfg/whitelist/ipForm.jsp @@ -2,224 +2,374 @@ <%@ include file="/WEB-INF/include/taglib.jsp"%> -<spring:message code="ip_whitelist"></spring:message> +<spring:message code="${cfgName}"></spring:message> + + -
-

- -

-
-
-
-
-
- - - + + +
+

+ +

+
+
+
+
+
+ + + + + + + +
-
-
- -
-
- - - - - - +
+ + + + + + - - - - - - - - - - - - - - - - - - -

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

+ + +

+ + <%-- --%> + + + + +
+ <%@include file="/WEB-INF/views/cfg/whitelist/ipCfgForm.jsp"%> +
+ +
+
+
+ + + + +
+ +
+ + +

+ + +

+ + + + + + + <%-- --%> + + + + + + +
+ <%@include file="/WEB-INF/views/cfg/complexCfgForm.jsp"%> +
+ + + + +
+
+
+ + + + + + +
+ + + + + +
+ <%@include file="/WEB-INF/views/cfg/complexCfgForm.jsp"%> +
+ + +
+
+
+ + + + + + +
+ + + + + + + + + +
+
+
+
+ <%--@include file="/WEB-INF/include/form/areaInfo.jsp"--%> +
+ <%--@include file="/WEB-INF/include/form/basicInfo.jsp"--%> +
+
+
+
+
+ + +
+
+
+
+
+
+ + +
+ + <%-- END FORM--%> +
+
+
-
\ No newline at end of file diff --git a/src/main/webapp/WEB-INF/views/cfg/whitelist/ipList.jsp b/src/main/webapp/WEB-INF/views/cfg/whitelist/ipList.jsp index 6ddcf1470..eae562de0 100644 --- a/src/main/webapp/WEB-INF/views/cfg/whitelist/ipList.jsp +++ b/src/main/webapp/WEB-INF/views/cfg/whitelist/ipList.jsp @@ -2,27 +2,22 @@ <%@ include file="/WEB-INF/include/taglib.jsp"%> -<spring:message code="ip_whitelist"></spring:message> +<spring:message code="${cfgName}"></spring:message> + +
- - - <%@include file="/WEB-INF/include/excel/importIp.jsp" %> - +

-
- + + +
+ - - - + + + +
-
-
-
- - - - - - - - - -
- - - -
-
+
+ +
+
+ + + + + <%-- + + + --%> + + +
+ + + +
+
- - + +
- - - - - - -
- - -
-
- + + + + + +
+ + +
+
href="javascript:;">
- +
+
+ +
+ +
+ + + + + + + + +
+ +
+ +
+ +
+ + + + + + + +
+ +
+ +
+ +
+ + + + + + + + +
+ +
+ +
+ +
+ + + + + + + +
+ +
+ +
+
@@ -168,6 +258,7 @@
+
@@ -176,6 +267,7 @@
+
@@ -184,6 +276,7 @@
+
@@ -192,6 +285,7 @@
+
@@ -201,86 +295,153 @@
-
+ + +
+
- - <%-- --%> - - - - - - - - - - - - - - - - - - <%-- --%> + + + + + + + + + + + + + + + + + + - - - - <%-- --%> - - - - - - - - + + - <%-- --%> + + - - - - - - + + + + + + + + + + + + + +
${status.index+1 }${cfg.cfgDesc } - - - - - - ${fns:abbr(cfg.srcIpAddress, 42)}${cfg.srcPort }${fns:abbr(cfg.destIpAddress, 42)}${cfg.destPort }
- - - + + ${cfg.areaEffectiveIds }${indexCfg.compileId }${indexCfg.cfgDesc } - - - + + + + + - - - - - - + + + + + ${cfg.creatorName }${cfg.editorName }${cfg.auditorName } + + + + + + + ${indexCfg.requestName } + + + + + + + + + + + + + + + ${fns:abbr(classify,20)} + + + + + + + + + + + + + + + + + ${fns:abbr(attribute,20)} + + + + + + + + + + + + + + + + + + ${fns:abbr(lableInfo,20)} + + + + + + + + + + + + +
${indexCfg.creatorName }${indexCfg.editorName }${indexCfg.auditorName }
-
${page}
+
${page}
diff --git a/src/main/webapp/WEB-INF/views/cfg/whitelist/ipSubList.jsp b/src/main/webapp/WEB-INF/views/cfg/whitelist/ipSubList.jsp new file mode 100644 index 000000000..1eebb9e1c --- /dev/null +++ b/src/main/webapp/WEB-INF/views/cfg/whitelist/ipSubList.jsp @@ -0,0 +1,228 @@ +<%@ page contentType="text/html;charset=UTF-8"%> +<%@ include file="/WEB-INF/include/taglib.jsp"%> + + + + + + + +
+ + +
+
+ +
+ + + + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+
+
+
+ + + +
+
+
+
+ +
+
+
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+
+
+
+ + + +
+
+
+
+ +
+
+
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+
+
+
+
+ \ No newline at end of file