网站HTTP配置增加区域ip配置信息处理。

This commit is contained in:
zhangwei
2018-05-28 15:47:33 +08:00
parent 317e3ae048
commit da189660d8
6 changed files with 164 additions and 18 deletions

View File

@@ -8,6 +8,8 @@
*/ */
package com.nis.domain.configuration; package com.nis.domain.configuration;
import com.nis.util.Constants;
/** /**
* @ClassName: HttpDomainConfig.java * @ClassName: HttpDomainConfig.java
* @Description: TODO * @Description: TODO

View File

@@ -59,46 +59,88 @@ public class WebsiteController extends BaseController{
public String httpForm(Model model,String ids,CfgIndexInfo entity) { public String httpForm(Model model,String ids,CfgIndexInfo entity) {
if(StringUtils.isNotBlank(ids)){ if(StringUtils.isNotBlank(ids)){
entity = websiteCfgService.getHttpCfg(Long.parseLong(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){ if(entity.getIpPortList().size()==0){
entity.getIpPortList().add(new IpPortCfg()); entity.getIpPortList().add(ipCfg);
} }
if(entity.getHttpUrlList().size()==0){ if(entity.getHttpUrlList().size()==0){
entity.getHttpUrlList().add(new HttpUrlCfg()); entity.getHttpUrlList().add(urlCfg);
} }
if(entity.getHttpReqHdrList().size()==0){ if(entity.getHttpReqHdrList().size()==0){
entity.getHttpReqHdrList().add(new HttpReqHeadCfg()); entity.getHttpReqHdrList().add(reqHdrCfg);
} }
if(entity.getHttpResHdrList().size()==0){ if(entity.getHttpResHdrList().size()==0){
entity.getHttpResHdrList().add(new HttpResHeadCfg()); entity.getHttpResHdrList().add(resHdrCfg);
} }
if(entity.getHttpReqBodyList().size()==0){ if(entity.getHttpReqBodyList().size()==0){
entity.getHttpReqBodyList().add(new HttpBodyCfg()); entity.getHttpReqBodyList().add(reqBodyCfg);
} }
if(entity.getHttpResBodyList().size()==0){ if(entity.getHttpResBodyList().size()==0){
entity.getHttpResBodyList().add(new HttpBodyCfg()); entity.getHttpResBodyList().add(resBodyCfg);
} }
model.addAttribute("areaCfgs", entity.getAreaCfg());
}else{ }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<IpPortCfg> ipList=new ArrayList<IpPortCfg>(); List<IpPortCfg> ipList=new ArrayList<IpPortCfg>();
ipList.add(new IpPortCfg()); ipList.add(ipCfg);
entity.setIpPortList(ipList); entity.setIpPortList(ipList);
List<HttpUrlCfg> urlList=new ArrayList<HttpUrlCfg>(); List<HttpUrlCfg> urlList=new ArrayList<HttpUrlCfg>();
urlList.add(new HttpUrlCfg()); urlList.add(urlCfg);
entity.setHttpUrlList(urlList); entity.setHttpUrlList(urlList);
List<HttpReqHeadCfg> reqHdrList=new ArrayList<HttpReqHeadCfg>(); List<HttpReqHeadCfg> reqHdrList=new ArrayList<HttpReqHeadCfg>();
reqHdrList.add(new HttpReqHeadCfg()); reqHdrList.add(reqHdrCfg);
entity.setHttpReqHdrList(reqHdrList); entity.setHttpReqHdrList(reqHdrList);
List<HttpResHeadCfg> resHdrList=new ArrayList<HttpResHeadCfg>(); List<HttpResHeadCfg> resHdrList=new ArrayList<HttpResHeadCfg>();
resHdrList.add(new HttpResHeadCfg()); resHdrList.add(resHdrCfg);
entity.setHttpResHdrList(resHdrList); entity.setHttpResHdrList(resHdrList);
List<HttpBodyCfg> reqBodyList=new ArrayList<HttpBodyCfg>(); List<HttpBodyCfg> reqBodyList=new ArrayList<HttpBodyCfg>();
reqBodyList.add(new HttpBodyCfg()); reqBodyList.add(reqBodyCfg);
entity.setHttpReqBodyList(reqBodyList); entity.setHttpReqBodyList(reqBodyList);
List<HttpBodyCfg> resBodyList=new ArrayList<HttpBodyCfg>(); List<HttpBodyCfg> resBodyList=new ArrayList<HttpBodyCfg>();
resBodyList.add(new HttpBodyCfg()); resBodyList.add(resBodyCfg);
entity.setHttpResBodyList(resBodyList); entity.setHttpResBodyList(resBodyList);
} }
initFormCondition(model,entity); initFormCondition(model,entity);
model.addAttribute("_cfg", entity); model.addAttribute("_cfg", entity);
return "/cfg/website/httpForm"; return "/cfg/website/httpForm";
} }
@RequestMapping(value = {"saveHttpCfg"}) @RequestMapping(value = {"saveHttpCfg"})

View File

@@ -16,4 +16,6 @@ import com.nis.web.dao.MyBatisDao;
@MyBatisDao @MyBatisDao
public interface AreaIpCfgDao extends CrudDao<AreaIpCfg>{ public interface AreaIpCfgDao extends CrudDao<AreaIpCfg>{
public List<AreaIpCfg> getByCompileId(@Param("compileId") int compileId) ; public List<AreaIpCfg> getByCompileId(@Param("compileId") int compileId) ;
public void saveAreaIpCfg(AreaIpCfg entity);
public void deleteAreaIpCfg(AreaIpCfg entity);
} }

View File

@@ -53,4 +53,80 @@
AND IS_VALID!=-1 AND IS_VALID!=-1
</trim> </trim>
</select> </select>
<!-- insert area_ip_cfg表信息 -->
<insert id="saveAreaIpCfg" parameterType="com.nis.domain.configuration.AreaIpCfg" >
<selectKey resultType="java.lang.Long" order="AFTER" keyProperty="cfgId">
SELECT LAST_INSERT_ID()
</selectKey>
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}
)
</insert>
<!-- 删除区域IP配置 -->
<delete id="deleteAreaIpCfg" >
delete from area_ip_cfg where compile_id=#{compileId} and function_id=#{functionId}
</delete>
</mapper> </mapper>

View File

@@ -16,6 +16,7 @@ import org.springframework.util.Assert;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
import com.nis.domain.Page; import com.nis.domain.Page;
import com.nis.domain.configuration.AreaIpCfg;
import com.nis.domain.configuration.BaseIpCfg; import com.nis.domain.configuration.BaseIpCfg;
import com.nis.domain.configuration.CfgIndexInfo; import com.nis.domain.configuration.CfgIndexInfo;
import com.nis.domain.configuration.HttpBodyCfg; 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.domain.configuration.IpPortCfg;
import com.nis.exceptions.MaatConvertException; import com.nis.exceptions.MaatConvertException;
import com.nis.util.ConfigServiceUtil; 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.IpCfgDao;
import com.nis.web.dao.configuration.WebsiteCfgDao; import com.nis.web.dao.configuration.WebsiteCfgDao;
import com.nis.web.service.BaseService; import com.nis.web.service.BaseService;
@@ -39,6 +41,8 @@ import com.nis.web.service.CrudService;
public class WebsiteCfgService extends CrudService<WebsiteCfgDao,CfgIndexInfo> { public class WebsiteCfgService extends CrudService<WebsiteCfgDao,CfgIndexInfo> {
@Autowired @Autowired
protected WebsiteCfgDao websiteCfgDao; protected WebsiteCfgDao websiteCfgDao;
@Autowired
protected AreaIpCfgDao areaIpCfgDao;
public CfgIndexInfo getHttpCfg(Long cfgId){ public CfgIndexInfo getHttpCfg(Long cfgId){
CfgIndexInfo entity = websiteCfgDao.getCfgIndexInfo(cfgId); CfgIndexInfo entity = websiteCfgDao.getCfgIndexInfo(cfgId);
@@ -48,12 +52,14 @@ public class WebsiteCfgService extends CrudService<WebsiteCfgDao,CfgIndexInfo> {
List<HttpResHeadCfg> httpResHdrList = websiteCfgDao.getHttpResHdrList(entity); List<HttpResHeadCfg> httpResHdrList = websiteCfgDao.getHttpResHdrList(entity);
List<HttpBodyCfg> httpReqBodyList = websiteCfgDao.getHttpReqBodyList(entity); List<HttpBodyCfg> httpReqBodyList = websiteCfgDao.getHttpReqBodyList(entity);
List<HttpBodyCfg> httpResBodyList = websiteCfgDao.getHttpResBodyList(entity); List<HttpBodyCfg> httpResBodyList = websiteCfgDao.getHttpResBodyList(entity);
List<AreaIpCfg> areaCfg = areaIpCfgDao.getByCompileId(entity.getCompileId());
entity.setIpPortList(ipPortList); entity.setIpPortList(ipPortList);
entity.setHttpReqBodyList(httpReqBodyList); entity.setHttpReqBodyList(httpReqBodyList);
entity.setHttpReqHdrList(httpReqHdrList); entity.setHttpReqHdrList(httpReqHdrList);
entity.setHttpResBodyList(httpResBodyList); entity.setHttpResBodyList(httpResBodyList);
entity.setHttpResHdrList(httpResHdrList); entity.setHttpResHdrList(httpResHdrList);
entity.setHttpUrlList(httpUrlList); entity.setHttpUrlList(httpUrlList);
entity.setAreaCfg(areaCfg);
return entity; return entity;
} }
public Page<CfgIndexInfo> getHttpList(Page<CfgIndexInfo> page, CfgIndexInfo entity){ public Page<CfgIndexInfo> getHttpList(Page<CfgIndexInfo> page, CfgIndexInfo entity){
@@ -130,6 +136,13 @@ public class WebsiteCfgService extends CrudService<WebsiteCfgDao,CfgIndexInfo> {
websiteCfgDao.saveHttpBodyCfg(cfg); 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) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
logger.info("获取编译ID出错"); logger.info("获取编译ID出错");
@@ -145,6 +158,10 @@ public class WebsiteCfgService extends CrudService<WebsiteCfgDao,CfgIndexInfo> {
websiteCfgDao.deleteHttpReqHdrCfg(entity); websiteCfgDao.deleteHttpReqHdrCfg(entity);
websiteCfgDao.deleteHttpResHdrCfg(entity); websiteCfgDao.deleteHttpResHdrCfg(entity);
websiteCfgDao.deleteHttpBodyCfg(entity); websiteCfgDao.deleteHttpBodyCfg(entity);
AreaIpCfg area = new AreaIpCfg();
area.setCompileId(entity.getCompileId());
area.setFunctionId(entity.getFunctionId());
areaIpCfgDao.deleteAreaIpCfg(area);
entity.setCreateTime(new Date()); entity.setCreateTime(new Date());
entity.setCreatorId(entity.getCurrentUser().getId()); entity.setCreatorId(entity.getCurrentUser().getId());
if(entity.getIpPortList()!=null){ if(entity.getIpPortList()!=null){
@@ -183,6 +200,13 @@ public class WebsiteCfgService extends CrudService<WebsiteCfgDao,CfgIndexInfo> {
websiteCfgDao.saveHttpBodyCfg(cfg); 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);
}
}
} }

View File

@@ -254,7 +254,7 @@
onClick="addContent(this,'${tabName}')" title="add"></span></small> onClick="addContent(this,'${tabName}')" title="add"></span></small>
</h4> </h4>
<c:set var="cfgName" value="httpUrlList"></c:set> <c:set var="cfgName" value="httpUrlList"></c:set>
<c:set var="regionValue" value="http_url"></c:set> <c:set var="regionValue" value="${_cfg.httpUrl.cfgType}"></c:set>
<c:forEach items="${_cfg.httpUrlList}" var="strCfg" <c:forEach items="${_cfg.httpUrlList}" var="strCfg"
varStatus="status"> varStatus="status">
<div class="row boxSolid ${tabName}${status.index} <c:if test="${empty strCfg.cfgId}">hidden disabled</c:if>" > <div class="row boxSolid ${tabName}${status.index} <c:if test="${empty strCfg.cfgId}">hidden disabled</c:if>" >
@@ -280,7 +280,7 @@
onClick="addContent(this,'${tabName}')" title="add"></span></small> onClick="addContent(this,'${tabName}')" title="add"></span></small>
</h4> </h4>
<c:set var="cfgName" value="httpReqHdrList"></c:set> <c:set var="cfgName" value="httpReqHdrList"></c:set>
<c:set var="regionValue" value="http_req_hdr"></c:set> <c:set var="regionValue" value="${_cfg.httpReqHdr.cfgType}"></c:set>
<c:forEach items="${_cfg.httpReqHdrList}" var="complexCfg" <c:forEach items="${_cfg.httpReqHdrList}" var="complexCfg"
varStatus="status"> varStatus="status">
<div class="row boxSolid ${tabName}${status.index} <c:if test="${empty complexCfg.cfgId}">hidden disabled</c:if>"> <div class="row boxSolid ${tabName}${status.index} <c:if test="${empty complexCfg.cfgId}">hidden disabled</c:if>">
@@ -306,7 +306,7 @@
onClick="addContent(this,'${tabName}')" title="add"></span></small> onClick="addContent(this,'${tabName}')" title="add"></span></small>
</h4> </h4>
<c:set var="cfgName" value="httpReqBodyList"></c:set> <c:set var="cfgName" value="httpReqBodyList"></c:set>
<c:set var="regionValue" value="http_req_body"></c:set> <c:set var="regionValue" value="${_cfg.httpReqBody.cfgType}"></c:set>
<c:forEach items="${_cfg.httpReqBodyList}" var="strCfg" <c:forEach items="${_cfg.httpReqBodyList}" var="strCfg"
varStatus="status"> varStatus="status">
<div class="row boxSolid ${tabName}${status.index} <c:if test="${empty strCfg.cfgId}">hidden disabled</c:if>" > <div class="row boxSolid ${tabName}${status.index} <c:if test="${empty strCfg.cfgId}">hidden disabled</c:if>" >
@@ -332,7 +332,7 @@
onClick="addContent(this,'${tabName}')" title="add"></span></small> onClick="addContent(this,'${tabName}')" title="add"></span></small>
</h4> </h4>
<c:set var="cfgName" value="httpResHdrList"></c:set> <c:set var="cfgName" value="httpResHdrList"></c:set>
<c:set var="regionValue" value="http_res_hdr"></c:set> <c:set var="regionValue" value="${_cfg.httpResHdr.cfgType}"></c:set>
<c:forEach items="${_cfg.httpResHdrList}" var="complexCfg" <c:forEach items="${_cfg.httpResHdrList}" var="complexCfg"
varStatus="status"> varStatus="status">
<div class="row boxSolid ${tabName}${status.index} <c:if test="${empty complexCfg.cfgId}">hidden disabled</c:if>"> <div class="row boxSolid ${tabName}${status.index} <c:if test="${empty complexCfg.cfgId}">hidden disabled</c:if>">
@@ -357,7 +357,7 @@
onClick="addContent(this,'${tabName}')" title="add"></span></small> onClick="addContent(this,'${tabName}')" title="add"></span></small>
</h4> </h4>
<c:set var="cfgName" value="httpResBodyList"></c:set> <c:set var="cfgName" value="httpResBodyList"></c:set>
<c:set var="regionValue" value="http_res_body"></c:set> <c:set var="regionValue" value="${_cfg.httpResBody.cfgType}"></c:set>
<c:forEach items="${_cfg.httpResBodyList}" var="strCfg" <c:forEach items="${_cfg.httpResBodyList}" var="strCfg"
varStatus="status"> varStatus="status">
<div class="row boxSolid ${tabName}${status.index} <c:if test="${empty strCfg.cfgId}">hidden disabled</c:if>" > <div class="row boxSolid ${tabName}${status.index} <c:if test="${empty strCfg.cfgId}">hidden disabled</c:if>" >