修改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
*/
@Expose
@SerializedName("protocolId")
protected Integer protocolId ;
// @Expose
// @SerializedName("protocolId")
// protected Integer protocolId ;
/**
* ipType
@@ -101,15 +101,15 @@ public class AppIpCfg extends BaseCfg<AppIpCfg> {
* @return protocolId
*/
public Integer getProtocolId() {
return protocolId;
}
/**
* @param protocolId the protocolId to set
*/
public void setProtocolId(Integer protocolId) {
this.protocolId = protocolId;
}
// public Integer getProtocolId() {
// return protocolId;
// }
// /**
// * @param protocolId the protocolId to set
// */
// public void setProtocolId(Integer protocolId) {
// this.protocolId = protocolId;
// }
/**
* ipPattern

View File

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

View File

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

View File

@@ -98,9 +98,10 @@ public class AppCfgService extends BaseService {
return appCfgDao.getAppByteCfg(cfgId);
}
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public int saveOrUpdateAppPolicyCfg(AppPolicyCfg entity) throws Exception{
public void saveOrUpdateAppPolicyCfg(AppPolicyCfg entity) throws Exception{
//设置区域运营商信息
setAreaEffectiveIds(entity);
if(entity.getCfgId()==null){
Integer compileId = 0;
try {
@@ -113,7 +114,15 @@ public class AppCfgService extends BaseService {
entity.setCreatorId(entity.getCurrentUser().getId());
entity.setIsValid(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) {
e.printStackTrace();
logger.info("获取编译ID出错");
@@ -124,13 +133,30 @@ public class AppCfgService extends BaseService {
entity.setEditTime(new Date());
entity.setIsValid(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)
public int saveOrUpdateAppIpCfg(AppIpCfg entity) throws Exception{
public void saveOrUpdateAppIpCfg(AppIpCfg entity) throws Exception{
//设置区域运营商信息
setAreaEffectiveIds(entity);
if(entity.getCfgId()==null){
Integer compileId = 0;
try {
@@ -143,7 +169,19 @@ public class AppCfgService extends BaseService {
entity.setCreatorId(entity.getCurrentUser().getId());
entity.setIsValid(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) {
e.printStackTrace();
logger.info("获取编译ID出错");
@@ -154,11 +192,28 @@ public class AppCfgService extends BaseService {
entity.setEditTime(new Date());
entity.setIsValid(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)
public int saveOrUpdateAppHttpCfg(AppHttpCfg entity) throws Exception{
public void saveOrUpdateAppHttpCfg(AppHttpCfg entity) throws Exception{
//设置区域运营商信息
setAreaEffectiveIds(entity);
if(entity.getCfgId()==null){
@@ -173,7 +228,17 @@ public class AppCfgService extends BaseService {
entity.setCreatorId(entity.getCurrentUser().getId());
entity.setIsValid(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) {
e.printStackTrace();
logger.info("获取编译ID出错");
@@ -184,11 +249,83 @@ public class AppCfgService extends BaseService {
entity.setEditTime(new Date());
entity.setIsValid(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)
public int saveOrUpdateAppDomainCfg(AppDomainCfg entity) throws Exception{
public void saveOrUpdateAppByteCfg(AppByteCfg entity) throws Exception{
//设置区域运营商信息
setAreaEffectiveIds(entity);
if(entity.getCfgId()==null){
@@ -203,37 +340,15 @@ public class AppCfgService extends BaseService {
entity.setCreatorId(entity.getCurrentUser().getId());
entity.setIsValid(0);
entity.setIsAudit(0);
return appCfgDao.insertAppDomainCfg(entity);
}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);
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);
appCfgDao.insertAppByteCfg(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);
}
}
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) {
e.printStackTrace();
logger.info("获取编译ID出错");
@@ -244,7 +359,22 @@ public class AppCfgService extends BaseService {
entity.setEditTime(new Date());
entity.setIsValid(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){

View File

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