diff --git a/src/main/java/com/nis/domain/configuration/HttpUrlCfg.java b/src/main/java/com/nis/domain/configuration/HttpUrlCfg.java index 53f768927..fc936f9fa 100644 --- a/src/main/java/com/nis/domain/configuration/HttpUrlCfg.java +++ b/src/main/java/com/nis/domain/configuration/HttpUrlCfg.java @@ -8,6 +8,8 @@ */ package com.nis.domain.configuration; +import com.nis.util.Constants; + /** * @ClassName: HttpDomainConfig.java * @Description: TODO diff --git a/src/main/java/com/nis/web/controller/configuration/ntc/WebsiteController.java b/src/main/java/com/nis/web/controller/configuration/ntc/WebsiteController.java index 6f42d928e..3700bb67d 100644 --- a/src/main/java/com/nis/web/controller/configuration/ntc/WebsiteController.java +++ b/src/main/java/com/nis/web/controller/configuration/ntc/WebsiteController.java @@ -59,46 +59,88 @@ public class WebsiteController extends BaseController{ public String httpForm(Model model,String ids,CfgIndexInfo entity) { if(StringUtils.isNotBlank(ids)){ entity = websiteCfgService.getHttpCfg(Long.parseLong(ids)); + + //设置http各类配置的配置域类型 + IpPortCfg ipCfg = new IpPortCfg(); + ipCfg.setCfgType(Constants.HTTP_IP_REGION); + entity.setIpPort(ipCfg); + HttpUrlCfg urlCfg = new HttpUrlCfg(); + urlCfg.setCfgType(Constants.HTTP_URL_REGION); + entity.setHttpUrl(urlCfg); + HttpReqHeadCfg reqHdrCfg = new HttpReqHeadCfg(); + reqHdrCfg.setCfgType(Constants.HTTP_REQ_HEAD_REGION); + entity.setHttpReqHdr(reqHdrCfg); + HttpResHeadCfg resHdrCfg = new HttpResHeadCfg(); + resHdrCfg.setCfgType(Constants.HTTP_RES_HEAD_REGION); + entity.setHttpResHdr(resHdrCfg); + HttpBodyCfg reqBodyCfg = new HttpBodyCfg(); + reqBodyCfg.setCfgType(Constants.HTTP_REQ_BODY_REGION); + entity.setHttpReqBody(reqBodyCfg); + HttpBodyCfg resBodyCfg = new HttpBodyCfg(); + resBodyCfg.setCfgType(Constants.HTTP_RES_BODY_REGION); + entity.setHttpResBody(resBodyCfg); + if(entity.getIpPortList().size()==0){ - entity.getIpPortList().add(new IpPortCfg()); + entity.getIpPortList().add(ipCfg); } if(entity.getHttpUrlList().size()==0){ - entity.getHttpUrlList().add(new HttpUrlCfg()); + entity.getHttpUrlList().add(urlCfg); } if(entity.getHttpReqHdrList().size()==0){ - entity.getHttpReqHdrList().add(new HttpReqHeadCfg()); + entity.getHttpReqHdrList().add(reqHdrCfg); } if(entity.getHttpResHdrList().size()==0){ - entity.getHttpResHdrList().add(new HttpResHeadCfg()); + entity.getHttpResHdrList().add(resHdrCfg); } if(entity.getHttpReqBodyList().size()==0){ - entity.getHttpReqBodyList().add(new HttpBodyCfg()); + entity.getHttpReqBodyList().add(reqBodyCfg); } if(entity.getHttpResBodyList().size()==0){ - entity.getHttpResBodyList().add(new HttpBodyCfg()); + entity.getHttpResBodyList().add(resBodyCfg); } + model.addAttribute("areaCfgs", entity.getAreaCfg()); }else{ + //设置http各类配置的配置域类型 + IpPortCfg ipCfg = new IpPortCfg(); + ipCfg.setCfgType(Constants.HTTP_IP_REGION); + entity.setIpPort(ipCfg); + HttpUrlCfg urlCfg = new HttpUrlCfg(); + urlCfg.setCfgType(Constants.HTTP_URL_REGION); + entity.setHttpUrl(urlCfg); + HttpReqHeadCfg reqHdrCfg = new HttpReqHeadCfg(); + reqHdrCfg.setCfgType(Constants.HTTP_REQ_HEAD_REGION); + entity.setHttpReqHdr(reqHdrCfg); + HttpResHeadCfg resHdrCfg = new HttpResHeadCfg(); + resHdrCfg.setCfgType(Constants.HTTP_RES_HEAD_REGION); + entity.setHttpResHdr(resHdrCfg); + HttpBodyCfg reqBodyCfg = new HttpBodyCfg(); + reqBodyCfg.setCfgType(Constants.HTTP_REQ_BODY_REGION); + entity.setHttpReqBody(reqBodyCfg); + HttpBodyCfg resBodyCfg = new HttpBodyCfg(); + resBodyCfg.setCfgType(Constants.HTTP_RES_BODY_REGION); + entity.setHttpResBody(resBodyCfg); + List ipList=new ArrayList(); - ipList.add(new IpPortCfg()); + ipList.add(ipCfg); entity.setIpPortList(ipList); List urlList=new ArrayList(); - urlList.add(new HttpUrlCfg()); + urlList.add(urlCfg); entity.setHttpUrlList(urlList); List reqHdrList=new ArrayList(); - reqHdrList.add(new HttpReqHeadCfg()); + reqHdrList.add(reqHdrCfg); entity.setHttpReqHdrList(reqHdrList); List resHdrList=new ArrayList(); - resHdrList.add(new HttpResHeadCfg()); + resHdrList.add(resHdrCfg); entity.setHttpResHdrList(resHdrList); List reqBodyList=new ArrayList(); - reqBodyList.add(new HttpBodyCfg()); + reqBodyList.add(reqBodyCfg); entity.setHttpReqBodyList(reqBodyList); List resBodyList=new ArrayList(); - resBodyList.add(new HttpBodyCfg()); + resBodyList.add(resBodyCfg); entity.setHttpResBodyList(resBodyList); } initFormCondition(model,entity); - model.addAttribute("_cfg", entity); + model.addAttribute("_cfg", entity); return "/cfg/website/httpForm"; } @RequestMapping(value = {"saveHttpCfg"}) diff --git a/src/main/java/com/nis/web/dao/configuration/AreaIpCfgDao.java b/src/main/java/com/nis/web/dao/configuration/AreaIpCfgDao.java index bd4532356..0474fde20 100644 --- a/src/main/java/com/nis/web/dao/configuration/AreaIpCfgDao.java +++ b/src/main/java/com/nis/web/dao/configuration/AreaIpCfgDao.java @@ -16,4 +16,6 @@ import com.nis.web.dao.MyBatisDao; @MyBatisDao public interface AreaIpCfgDao extends CrudDao{ public List getByCompileId(@Param("compileId") int compileId) ; + public void saveAreaIpCfg(AreaIpCfg entity); + public void deleteAreaIpCfg(AreaIpCfg entity); } diff --git a/src/main/java/com/nis/web/dao/configuration/AreaIpCfgDao.xml b/src/main/java/com/nis/web/dao/configuration/AreaIpCfgDao.xml index 6bfc80b0c..2092f3142 100644 --- a/src/main/java/com/nis/web/dao/configuration/AreaIpCfgDao.xml +++ b/src/main/java/com/nis/web/dao/configuration/AreaIpCfgDao.xml @@ -53,4 +53,80 @@ AND IS_VALID!=-1 + + + + + SELECT LAST_INSERT_ID() + + insert into area_ip_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 + )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} + ) + + + + delete from area_ip_cfg where compile_id=#{compileId} and function_id=#{functionId} + \ No newline at end of file diff --git a/src/main/java/com/nis/web/service/configuration/WebsiteCfgService.java b/src/main/java/com/nis/web/service/configuration/WebsiteCfgService.java index 7e0cf76bd..4243c6341 100644 --- a/src/main/java/com/nis/web/service/configuration/WebsiteCfgService.java +++ b/src/main/java/com/nis/web/service/configuration/WebsiteCfgService.java @@ -16,6 +16,7 @@ import org.springframework.util.Assert; import org.springframework.util.ClassUtils; import com.nis.domain.Page; +import com.nis.domain.configuration.AreaIpCfg; import com.nis.domain.configuration.BaseIpCfg; import com.nis.domain.configuration.CfgIndexInfo; import com.nis.domain.configuration.HttpBodyCfg; @@ -25,6 +26,7 @@ import com.nis.domain.configuration.HttpUrlCfg; import com.nis.domain.configuration.IpPortCfg; import com.nis.exceptions.MaatConvertException; import com.nis.util.ConfigServiceUtil; +import com.nis.web.dao.configuration.AreaIpCfgDao; import com.nis.web.dao.configuration.IpCfgDao; import com.nis.web.dao.configuration.WebsiteCfgDao; import com.nis.web.service.BaseService; @@ -39,6 +41,8 @@ import com.nis.web.service.CrudService; public class WebsiteCfgService extends CrudService { @Autowired protected WebsiteCfgDao websiteCfgDao; + @Autowired + protected AreaIpCfgDao areaIpCfgDao; public CfgIndexInfo getHttpCfg(Long cfgId){ CfgIndexInfo entity = websiteCfgDao.getCfgIndexInfo(cfgId); @@ -48,12 +52,14 @@ public class WebsiteCfgService extends CrudService { List httpResHdrList = websiteCfgDao.getHttpResHdrList(entity); List httpReqBodyList = websiteCfgDao.getHttpReqBodyList(entity); List httpResBodyList = websiteCfgDao.getHttpResBodyList(entity); + List areaCfg = areaIpCfgDao.getByCompileId(entity.getCompileId()); entity.setIpPortList(ipPortList); entity.setHttpReqBodyList(httpReqBodyList); entity.setHttpReqHdrList(httpReqHdrList); entity.setHttpResBodyList(httpResBodyList); entity.setHttpResHdrList(httpResHdrList); entity.setHttpUrlList(httpUrlList); + entity.setAreaCfg(areaCfg); return entity; } public Page getHttpList(Page page, CfgIndexInfo entity){ @@ -130,6 +136,13 @@ public class WebsiteCfgService extends CrudService { websiteCfgDao.saveHttpBodyCfg(cfg); } } + //保存区域IP信息 + if(entity.getAreaCfg()!=null){ + for(AreaIpCfg cfg:entity.getAreaCfg()){ + BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"}); + areaIpCfgDao.saveAreaIpCfg(cfg); + } + } } catch (Exception e) { e.printStackTrace(); logger.info("获取编译ID出错"); @@ -145,6 +158,10 @@ public class WebsiteCfgService extends CrudService { websiteCfgDao.deleteHttpReqHdrCfg(entity); websiteCfgDao.deleteHttpResHdrCfg(entity); websiteCfgDao.deleteHttpBodyCfg(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){ @@ -183,6 +200,13 @@ public class WebsiteCfgService extends CrudService { websiteCfgDao.saveHttpBodyCfg(cfg); } } + //保存区域IP信息 + if(entity.getAreaCfg()!=null){ + for(AreaIpCfg cfg:entity.getAreaCfg()){ + BeanUtils.copyProperties(entity, cfg,new String[]{"cfgDesc","cfgRegionCode","cfgType"}); + areaIpCfgDao.saveAreaIpCfg(cfg); + } + } } diff --git a/src/main/webapp/WEB-INF/views/cfg/website/httpForm.jsp b/src/main/webapp/WEB-INF/views/cfg/website/httpForm.jsp index 160dba5df..d713ad189 100644 --- a/src/main/webapp/WEB-INF/views/cfg/website/httpForm.jsp +++ b/src/main/webapp/WEB-INF/views/cfg/website/httpForm.jsp @@ -254,7 +254,7 @@ onClick="addContent(this,'${tabName}')" title="add"> - +
hidden disabled" > @@ -280,7 +280,7 @@ onClick="addContent(this,'${tabName}')" title="add"> - +
hidden disabled"> @@ -306,7 +306,7 @@ onClick="addContent(this,'${tabName}')" title="add"> - +
hidden disabled" > @@ -332,7 +332,7 @@ onClick="addContent(this,'${tabName}')" title="add"> - +
hidden disabled"> @@ -357,7 +357,7 @@ onClick="addContent(this,'${tabName}')" title="add"> - +
hidden disabled" >