修改app相关配置的区域IP配置新增修改逻辑

This commit is contained in:
zhangwei
2018-06-25 10:44:38 +08:00
parent aa322b3ef4
commit 98016b5232
5 changed files with 190 additions and 59 deletions

View File

@@ -49,9 +49,9 @@ public class AppIpCfg extends BaseCfg<AppIpCfg> {
/** /**
* 协议ID * 协议ID
*/ */
@Expose // @Expose
@SerializedName("protocolId") // @SerializedName("protocolId")
protected Integer protocolId ; // protected Integer protocolId ;
/** /**
* ipType * ipType
@@ -101,15 +101,15 @@ public class AppIpCfg extends BaseCfg<AppIpCfg> {
* @return protocolId * @return protocolId
*/ */
public Integer getProtocolId() { // public Integer getProtocolId() {
return protocolId; // return protocolId;
} // }
/** // /**
* @param protocolId the protocolId to set // * @param protocolId the protocolId to set
*/ // */
public void setProtocolId(Integer protocolId) { // public void setProtocolId(Integer protocolId) {
this.protocolId = protocolId; // this.protocolId = protocolId;
} // }
/** /**
* ipPattern * ipPattern

View File

@@ -21,6 +21,7 @@ import com.nis.domain.configuration.AppIpCfg;
import com.nis.domain.configuration.AppPolicyCfg; import com.nis.domain.configuration.AppPolicyCfg;
import com.nis.domain.specific.SpecificServiceCfg; import com.nis.domain.specific.SpecificServiceCfg;
import com.nis.exceptions.MaatConvertException; import com.nis.exceptions.MaatConvertException;
import com.nis.util.Constants;
import com.nis.web.controller.BaseController; import com.nis.web.controller.BaseController;
import com.nis.web.security.UserUtils; import com.nis.web.security.UserUtils;
@@ -258,6 +259,7 @@ public class AppCfgController extends BaseController {
for(AppHttpCfg entity:page.getList()){ for(AppHttpCfg entity:page.getList()){
SpecificServiceCfg app = specificServiceCfgService.getBySpecServiceId(entity.getSpecServiceId()); SpecificServiceCfg app = specificServiceCfgService.getBySpecServiceId(entity.getSpecServiceId());
entity.setAppName(app.getSpecServiceName()); entity.setAppName(app.getSpecServiceName());
entity.setCfgKeywords(entity.getCfgKeywords().replace(Constants.KEYWORD_EXPR, "&"));
} }
model.addAttribute("page", page); model.addAttribute("page", page);
initPageCondition(model,cfg); initPageCondition(model,cfg);

View File

@@ -1066,7 +1066,7 @@
<if test="lable != null and lable != ''" > <if test="lable != null and lable != ''" >
lable = #{lable,jdbcType=VARCHAR}, lable = #{lable,jdbcType=VARCHAR},
</if> </if>
<if test="areaEffectiveIds != null and areaEffectiveIds != ''" > <if test="areaEffectiveIds != null" >
area_effective_ids = #{areaEffectiveIds,jdbcType=VARCHAR}, area_effective_ids = #{areaEffectiveIds,jdbcType=VARCHAR},
</if> </if>
<if test="functionId != null" > <if test="functionId != null" >
@@ -1147,7 +1147,7 @@
<if test="lable != null and lable != ''" > <if test="lable != null and lable != ''" >
lable = #{lable,jdbcType=VARCHAR}, lable = #{lable,jdbcType=VARCHAR},
</if> </if>
<if test="areaEffectiveIds != null and areaEffectiveIds != ''" > <if test="areaEffectiveIds != null" >
area_effective_ids = #{areaEffectiveIds,jdbcType=VARCHAR}, area_effective_ids = #{areaEffectiveIds,jdbcType=VARCHAR},
</if> </if>
<if test="functionId != null" > <if test="functionId != null" >
@@ -1254,7 +1254,7 @@
<if test="lable != null and lable != ''" > <if test="lable != null and lable != ''" >
lable = #{lable,jdbcType=VARCHAR}, lable = #{lable,jdbcType=VARCHAR},
</if> </if>
<if test="areaEffectiveIds != null and areaEffectiveIds != ''" > <if test="areaEffectiveIds != null" >
area_effective_ids = #{areaEffectiveIds,jdbcType=VARCHAR}, area_effective_ids = #{areaEffectiveIds,jdbcType=VARCHAR},
</if> </if>
<if test="functionId != null" > <if test="functionId != null" >
@@ -1349,7 +1349,7 @@
<if test="lable != null and lable != ''" > <if test="lable != null and lable != ''" >
lable = #{lable,jdbcType=VARCHAR}, lable = #{lable,jdbcType=VARCHAR},
</if> </if>
<if test="areaEffectiveIds != null and areaEffectiveIds != ''" > <if test="areaEffectiveIds != null" >
area_effective_ids = #{areaEffectiveIds,jdbcType=VARCHAR}, area_effective_ids = #{areaEffectiveIds,jdbcType=VARCHAR},
</if> </if>
<if test="functionId != null" > <if test="functionId != null" >
@@ -1441,7 +1441,7 @@
<if test="lable != null and lable != ''" > <if test="lable != null and lable != ''" >
lable = #{lable,jdbcType=VARCHAR}, lable = #{lable,jdbcType=VARCHAR},
</if> </if>
<if test="areaEffectiveIds != null and areaEffectiveIds != ''" > <if test="areaEffectiveIds != null" >
area_effective_ids = #{areaEffectiveIds,jdbcType=VARCHAR}, area_effective_ids = #{areaEffectiveIds,jdbcType=VARCHAR},
</if> </if>
<if test="functionId != null" > <if test="functionId != null" >

View File

@@ -98,9 +98,10 @@ public class AppCfgService extends BaseService {
return appCfgDao.getAppByteCfg(cfgId); return appCfgDao.getAppByteCfg(cfgId);
} }
@Transactional(readOnly=false,rollbackFor=RuntimeException.class) @Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public int saveOrUpdateAppPolicyCfg(AppPolicyCfg entity) throws Exception{ public void saveOrUpdateAppPolicyCfg(AppPolicyCfg entity) throws Exception{
//设置区域运营商信息 //设置区域运营商信息
setAreaEffectiveIds(entity); setAreaEffectiveIds(entity);
if(entity.getCfgId()==null){ if(entity.getCfgId()==null){
Integer compileId = 0; Integer compileId = 0;
try { try {
@@ -113,7 +114,15 @@ public class AppCfgService extends BaseService {
entity.setCreatorId(entity.getCurrentUser().getId()); entity.setCreatorId(entity.getCurrentUser().getId());
entity.setIsValid(0); entity.setIsValid(0);
entity.setIsAudit(0); entity.setIsAudit(0);
return appCfgDao.insertAppPolicyCfg(entity); appCfgDao.insertAppPolicyCfg(entity);
//保存区域IP信息
if(entity.getAreaCfg()!=null){
for(AreaIpCfg cfg:entity.getAreaCfg()){
cfg.initDefaultValue();
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgDesc","cfgRegionCode","cfgType"});
areaIpCfgDao.saveAreaIpCfg(cfg);
}
}
}catch (Exception e) { }catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
logger.info("获取编译ID出错"); logger.info("获取编译ID出错");
@@ -124,13 +133,30 @@ public class AppCfgService extends BaseService {
entity.setEditTime(new Date()); entity.setEditTime(new Date());
entity.setIsValid(0); entity.setIsValid(0);
entity.setIsAudit(0); entity.setIsAudit(0);
return appCfgDao.updateAppPolicyCfg(entity); appCfgDao.updateAppPolicyCfg(entity);
//删除旧的区域IP新增新的区域IP
AreaIpCfg area = new AreaIpCfg();
area.setCompileId(entity.getCompileId());
area.setFunctionId(entity.getFunctionId());
areaIpCfgDao.deleteAreaIpCfg(area);
entity.setCreateTime(new Date());
entity.setCreatorId(entity.getCurrentUser().getId());
//保存区域IP信息
if(entity.getAreaCfg()!=null){
for(AreaIpCfg cfg:entity.getAreaCfg()){
cfg.initDefaultValue();
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgDesc","cfgRegionCode","cfgType"});
areaIpCfgDao.saveAreaIpCfg(cfg);
}
}
} }
} }
@Transactional(readOnly=false,rollbackFor=RuntimeException.class) @Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public int saveOrUpdateAppIpCfg(AppIpCfg entity) throws Exception{ public void saveOrUpdateAppIpCfg(AppIpCfg entity) throws Exception{
//设置区域运营商信息 //设置区域运营商信息
setAreaEffectiveIds(entity); setAreaEffectiveIds(entity);
if(entity.getCfgId()==null){ if(entity.getCfgId()==null){
Integer compileId = 0; Integer compileId = 0;
try { try {
@@ -143,7 +169,19 @@ public class AppCfgService extends BaseService {
entity.setCreatorId(entity.getCurrentUser().getId()); entity.setCreatorId(entity.getCurrentUser().getId());
entity.setIsValid(0); entity.setIsValid(0);
entity.setIsAudit(0); entity.setIsAudit(0);
return appCfgDao.insertAppIpCfg(entity); appCfgDao.insertAppIpCfg(entity);
//保存区域IP信息
if(entity.getAreaCfg()!=null){
for(AreaIpCfg cfg:entity.getAreaCfg()){
cfg.initDefaultValue();
BeanUtils.copyProperties(entity, cfg,
new String[]{"cfgRegionCode","cfgType","ipType","isAreaEffective",
"areaEffectiveIds","protocol","portPattern","srcPort","destPort","direction",
"destIpAddress","srcIpAddress","ipPattern"});
areaIpCfgDao.saveAreaIpCfg(cfg);
}
}
}catch (Exception e) { }catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
logger.info("获取编译ID出错"); logger.info("获取编译ID出错");
@@ -154,11 +192,28 @@ public class AppCfgService extends BaseService {
entity.setEditTime(new Date()); entity.setEditTime(new Date());
entity.setIsValid(0); entity.setIsValid(0);
entity.setIsAudit(0); entity.setIsAudit(0);
return appCfgDao.updateAppIpCfg(entity); appCfgDao.updateAppIpCfg(entity);
//删除旧的区域IP新增新的区域IP
AreaIpCfg area = new AreaIpCfg();
area.setCompileId(entity.getCompileId());
area.setFunctionId(entity.getFunctionId());
areaIpCfgDao.deleteAreaIpCfg(area);
entity.setCreateTime(new Date());
entity.setCreatorId(entity.getCurrentUser().getId());
//保存区域IP信息
if(entity.getAreaCfg()!=null){
for(AreaIpCfg cfg:entity.getAreaCfg()){
cfg.initDefaultValue();
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType","ipType","isAreaEffective",
"areaEffectiveIds","protocol","portPattern","srcPort","destPort","direction",
"destIpAddress","srcIpAddress","ipPattern"});
areaIpCfgDao.saveAreaIpCfg(cfg);
}
}
} }
} }
@Transactional(readOnly=false,rollbackFor=RuntimeException.class) @Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public int saveOrUpdateAppHttpCfg(AppHttpCfg entity) throws Exception{ public void saveOrUpdateAppHttpCfg(AppHttpCfg entity) throws Exception{
//设置区域运营商信息 //设置区域运营商信息
setAreaEffectiveIds(entity); setAreaEffectiveIds(entity);
if(entity.getCfgId()==null){ if(entity.getCfgId()==null){
@@ -173,7 +228,17 @@ public class AppCfgService extends BaseService {
entity.setCreatorId(entity.getCurrentUser().getId()); entity.setCreatorId(entity.getCurrentUser().getId());
entity.setIsValid(0); entity.setIsValid(0);
entity.setIsAudit(0); entity.setIsAudit(0);
return appCfgDao.insertAppHttpCfg(entity); appCfgDao.insertAppHttpCfg(entity);
//保存区域IP信息
if(entity.getAreaCfg()!=null){
for(AreaIpCfg cfg:entity.getAreaCfg()){
cfg.initDefaultValue();
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出错");
@@ -184,11 +249,83 @@ public class AppCfgService extends BaseService {
entity.setEditTime(new Date()); entity.setEditTime(new Date());
entity.setIsValid(0); entity.setIsValid(0);
entity.setIsAudit(0); entity.setIsAudit(0);
return appCfgDao.updateAppHttpCfg(entity); appCfgDao.updateAppHttpCfg(entity);
//删除旧的区域IP新增新的区域IP
AreaIpCfg area = new AreaIpCfg();
area.setCompileId(entity.getCompileId());
area.setFunctionId(entity.getFunctionId());
areaIpCfgDao.deleteAreaIpCfg(area);
entity.setCreateTime(new Date());
entity.setCreatorId(entity.getCurrentUser().getId());
//保存区域IP信息
if(entity.getAreaCfg()!=null){
for(AreaIpCfg cfg:entity.getAreaCfg()){
cfg.initDefaultValue();
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgDesc","cfgRegionCode","cfgType"});
areaIpCfgDao.saveAreaIpCfg(cfg);
}
}
}
}
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public void saveOrUpdateAppDomainCfg(AppDomainCfg entity) throws Exception{
//设置区域运营商信息
setAreaEffectiveIds(entity);
if(entity.getCfgId()==null){
Integer compileId = 0;
try {
List<Integer> idList = ConfigServiceUtil.getId(1, 1);
if(idList!=null && idList.size()>0){
compileId = idList.get(0);
}
entity.setCompileId(compileId);
entity.setCreateTime(new Date());
entity.setCreatorId(entity.getCurrentUser().getId());
entity.setIsValid(0);
entity.setIsAudit(0);
appCfgDao.insertAppDomainCfg(entity);
//保存区域IP信息
if(entity.getAreaCfg()!=null){
for(AreaIpCfg cfg:entity.getAreaCfg()){
cfg.initDefaultValue();
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgDesc","cfgRegionCode","cfgType"});
areaIpCfgDao.saveAreaIpCfg(cfg);
}
}
}catch (Exception e) {
e.printStackTrace();
logger.info("获取编译ID出错");
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
}
}else{
entity.setEditorId(entity.getCurrentUser().getId());
entity.setEditTime(new Date());
entity.setIsValid(0);
entity.setIsAudit(0);
appCfgDao.updateAppDomainCfg(entity);
//删除旧的区域IP新增新的区域IP
AreaIpCfg area = new AreaIpCfg();
area.setCompileId(entity.getCompileId());
area.setFunctionId(entity.getFunctionId());
areaIpCfgDao.deleteAreaIpCfg(area);
entity.setCreateTime(new Date());
entity.setCreatorId(entity.getCurrentUser().getId());
//保存区域IP信息
if(entity.getAreaCfg()!=null){
for(AreaIpCfg cfg:entity.getAreaCfg()){
cfg.initDefaultValue();
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgDesc","cfgRegionCode","cfgType"});
areaIpCfgDao.saveAreaIpCfg(cfg);
}
}
} }
} }
@Transactional(readOnly=false,rollbackFor=RuntimeException.class) @Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public int saveOrUpdateAppDomainCfg(AppDomainCfg entity) throws Exception{ public void saveOrUpdateAppByteCfg(AppByteCfg entity) throws Exception{
//设置区域运营商信息 //设置区域运营商信息
setAreaEffectiveIds(entity); setAreaEffectiveIds(entity);
if(entity.getCfgId()==null){ if(entity.getCfgId()==null){
@@ -203,37 +340,15 @@ public class AppCfgService extends BaseService {
entity.setCreatorId(entity.getCurrentUser().getId()); entity.setCreatorId(entity.getCurrentUser().getId());
entity.setIsValid(0); entity.setIsValid(0);
entity.setIsAudit(0); entity.setIsAudit(0);
return appCfgDao.insertAppDomainCfg(entity); appCfgDao.insertAppByteCfg(entity);
}catch (Exception e) { //保存区域IP信息
e.printStackTrace(); if(entity.getAreaCfg()!=null){
logger.info("获取编译ID出错"); for(AreaIpCfg cfg:entity.getAreaCfg()){
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage()); cfg.initDefaultValue();
} BeanUtils.copyProperties(entity, cfg,new String[]{"cfgDesc","cfgRegionCode","cfgType"});
}else{ areaIpCfgDao.saveAreaIpCfg(cfg);
entity.setEditorId(entity.getCurrentUser().getId()); }
entity.setEditTime(new Date());
entity.setIsValid(0);
entity.setIsAudit(0);
return appCfgDao.updateAppDomainCfg(entity);
}
}
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public int saveOrUpdateAppByteCfg(AppByteCfg entity) throws Exception{
//设置区域运营商信息
setAreaEffectiveIds(entity);
if(entity.getCfgId()==null){
Integer compileId = 0;
try {
List<Integer> idList = ConfigServiceUtil.getId(1, 1);
if(idList!=null && idList.size()>0){
compileId = idList.get(0);
} }
entity.setCompileId(compileId);
entity.setCreateTime(new Date());
entity.setCreatorId(entity.getCurrentUser().getId());
entity.setIsValid(0);
entity.setIsAudit(0);
return appCfgDao.insertAppByteCfg(entity);
}catch (Exception e) { }catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
logger.info("获取编译ID出错"); logger.info("获取编译ID出错");
@@ -244,7 +359,22 @@ public class AppCfgService extends BaseService {
entity.setEditTime(new Date()); entity.setEditTime(new Date());
entity.setIsValid(0); entity.setIsValid(0);
entity.setIsAudit(0); entity.setIsAudit(0);
return appCfgDao.updateAppByteCfg(entity); appCfgDao.updateAppByteCfg(entity);
//删除旧的区域IP新增新的区域IP
AreaIpCfg area = new AreaIpCfg();
area.setCompileId(entity.getCompileId());
area.setFunctionId(entity.getFunctionId());
areaIpCfgDao.deleteAreaIpCfg(area);
entity.setCreateTime(new Date());
entity.setCreatorId(entity.getCurrentUser().getId());
//保存区域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 auditAppPolicyCfg(AppPolicyCfg entity,Integer isAudit){ public void auditAppPolicyCfg(AppPolicyCfg entity,Integer isAudit){

View File

@@ -47,7 +47,6 @@ $(function(){
<input type="hidden" name="functionId" value="${_cfg.functionId}"> <input type="hidden" name="functionId" value="${_cfg.functionId}">
<input type="hidden" id="serviceId" name="serviceId" value="${_cfg.serviceId}"> <input type="hidden" id="serviceId" name="serviceId" value="${_cfg.serviceId}">
<input type="hidden" id="appCode" name="appCode" value="${_cfg.appCode}"> <input type="hidden" id="appCode" name="appCode" value="${_cfg.appCode}">
<input type="hidden" id="protocolId" name="protocolId" value="${_cfg.protocolId}">
<input type="hidden" id="direction" name="direction" value="0"> <input type="hidden" id="direction" name="direction" value="0">
<!-- 配置域类型 --> <!-- 配置域类型 -->
<c:forEach items="${regionList}" var="region"> <c:forEach items="${regionList}" var="region">