(1)ip管控提交
(2)delRow.tag修改,删除的时候将编译ID也传过去 (3)配置取消修改,请求应当是put请求
This commit is contained in:
@@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.nis.domain.configuration.AreaBean;
|
||||
import com.nis.domain.configuration.AreaIpCfg;
|
||||
import com.nis.domain.configuration.BaseIpCfg;
|
||||
import com.nis.domain.configuration.IpPortCfg;
|
||||
@@ -52,10 +53,10 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public int addIpCfg(BaseIpCfg baseIpCfg,List<BaseIpCfg> areaIpCfgs){
|
||||
if(areaIpCfgs!=null&&areaIpCfgs.size()>0){
|
||||
this.saveIpBatch(areaIpCfgs);
|
||||
}
|
||||
public void addIpCfg(BaseIpCfg cfg){
|
||||
//区域IPsetAreaEffectiveIds设置
|
||||
List<AreaIpCfg> areaCfg=cfg.getAreaCfg();
|
||||
List<AreaBean> areaIsps=cfg.getAreaIsp();
|
||||
//调用服务接口获取compileId
|
||||
Integer compileId = 0;
|
||||
try {
|
||||
@@ -69,12 +70,71 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
|
||||
}
|
||||
if(compileId!=0){
|
||||
baseIpCfg.setCompileId(compileId);
|
||||
return ipCfgDao.insert(baseIpCfg);
|
||||
cfg.setCompileId(compileId);
|
||||
if(Constants.IS_AREA_EFFECTIVE_NO==cfg.getIsAreaEffective()){
|
||||
cfg.setAreaEffectiveIds("0");
|
||||
cfg.setAreaType(null);
|
||||
}else if(Constants.IS_AREA_EFFECTIVE_YES==cfg.getIsAreaEffective()){
|
||||
if(Constants.AREA_EFFECTIVE_TYPE_AREA_ISP==cfg.getAreaType()&&areaIsps!=null&&areaIsps.size()>0){
|
||||
StringBuffer areaEffectiveIds=new StringBuffer();
|
||||
for(int i=0;i<areaIsps.size();i++){
|
||||
if(StringUtils.isNotBlank(areaIsps.get(i).getArea())&&StringUtils.isNotBlank(areaIsps.get(i).getIsp())){
|
||||
areaEffectiveIds.append(areaIsps.get(i).getArea()+":"+areaIsps.get(i).getIsp());
|
||||
}else if(StringUtils.isNotBlank(areaIsps.get(i).getArea())){
|
||||
areaEffectiveIds.append(areaIsps.get(i).getArea());
|
||||
}else if(StringUtils.isNotBlank(areaIsps.get(i).getIsp())){
|
||||
areaEffectiveIds.append(areaIsps.get(i).getIsp());
|
||||
}
|
||||
if(i!=areaIsps.size()-1){
|
||||
areaEffectiveIds.append(",");
|
||||
}
|
||||
}
|
||||
cfg.setAreaEffectiveIds(areaEffectiveIds.toString());
|
||||
}else if(Constants.AREA_EFFECTIVE_TYPE_AREA_IP==cfg.getAreaType()&&areaCfg!=null&&areaCfg.size()>0){
|
||||
cfg.setAreaEffectiveIds("0");
|
||||
}
|
||||
if(areaCfg!=null&&areaCfg.size()>0){
|
||||
for(AreaIpCfg c:cfg.getAreaCfg()){
|
||||
c.initDefaultValue();
|
||||
BeanUtils.copyProperties(cfg, c,new String[]{"cfgId","ipType","direction",
|
||||
"protocol","protocolId","areaEffectiveIds","cfgRegionCode",
|
||||
"cfgType","ipPattern","srcIpAddress","portPattern","srcPort","destIpAddress","destPort"});
|
||||
c.setTableName(AreaIpCfg.getTablename());
|
||||
}
|
||||
this.saveIpBatch(cfg.getAreaCfg());
|
||||
}
|
||||
}
|
||||
|
||||
ipCfgDao.insert(cfg);
|
||||
}else{
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||
}
|
||||
|
||||
}
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void addIpCfg(BaseIpCfg baseIpCfg,List<BaseIpCfg> areaIpCfgs){
|
||||
// if(areaIpCfgs!=null&&areaIpCfgs.size()>0){
|
||||
// this.saveIpBatch(areaIpCfgs);
|
||||
// }
|
||||
// //调用服务接口获取compileId
|
||||
// Integer compileId = 0;
|
||||
// try {
|
||||
// List<Integer> compileIds = ConfigServiceUtil.getId(1,1);
|
||||
// if(!StringUtil.isEmpty(compileIds)){
|
||||
// compileId = compileIds.get(0);
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// logger.info("获取编译ID出错");
|
||||
// throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
|
||||
// }
|
||||
// if(compileId!=0){
|
||||
// baseIpCfg.setCompileId(compileId);
|
||||
// return ipCfgDao.insert(baseIpCfg);
|
||||
// }else{
|
||||
// throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||
// }
|
||||
|
||||
}
|
||||
/**
|
||||
*
|
||||
@@ -87,17 +147,71 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public int updateIpCfg(BaseIpCfg baseIpCfg,List<BaseIpCfg> addAreaCfg,List<BaseIpCfg> updateAreaCfg,List<BaseIpCfg> deleteAreaCfgs){
|
||||
if(addAreaCfg!=null&&addAreaCfg.size()>0){
|
||||
this.saveIpBatch(addAreaCfg);
|
||||
public void updateIpCfg(BaseIpCfg cfg){
|
||||
AreaIpCfg area=new AreaIpCfg();
|
||||
area.setCompileId(cfg.getCompileId());
|
||||
area.setFunctionId(cfg.getFunctionId());
|
||||
areaIpCfgDao.deleteAreaIpCfg(area);
|
||||
//区域IPsetAreaEffectiveIds设置
|
||||
List<AreaIpCfg> areaCfg=cfg.getAreaCfg();
|
||||
List<AreaBean> areaIsps=cfg.getAreaIsp();
|
||||
if(Constants.IS_AREA_EFFECTIVE_NO==cfg.getIsAreaEffective()){
|
||||
cfg.setAreaEffectiveIds("0");
|
||||
cfg.setAreaType(null);
|
||||
}else if(Constants.IS_AREA_EFFECTIVE_YES==cfg.getIsAreaEffective()){
|
||||
if(Constants.AREA_EFFECTIVE_TYPE_AREA_ISP==cfg.getAreaType()&&areaIsps!=null&&areaIsps.size()>0){
|
||||
StringBuffer areaEffectiveIds=new StringBuffer();
|
||||
for(int i=0;i<areaIsps.size();i++){
|
||||
if(StringUtils.isNotBlank(areaIsps.get(i).getArea())&&StringUtils.isNotBlank(areaIsps.get(i).getIsp())){
|
||||
areaEffectiveIds.append(areaIsps.get(i).getArea()+":"+areaIsps.get(i).getIsp());
|
||||
}else if(StringUtils.isNotBlank(areaIsps.get(i).getArea())){
|
||||
areaEffectiveIds.append(areaIsps.get(i).getArea());
|
||||
}else if(StringUtils.isNotBlank(areaIsps.get(i).getIsp())){
|
||||
areaEffectiveIds.append(areaIsps.get(i).getIsp());
|
||||
}
|
||||
if(i!=areaIsps.size()-1){
|
||||
areaEffectiveIds.append(",");
|
||||
}
|
||||
}
|
||||
cfg.setAreaEffectiveIds(areaEffectiveIds.toString());
|
||||
}else if(Constants.AREA_EFFECTIVE_TYPE_AREA_IP==cfg.getAreaType()&&areaCfg!=null&&areaCfg.size()>0){
|
||||
cfg.setAreaEffectiveIds("0");
|
||||
}
|
||||
if(areaCfg!=null&&areaCfg.size()>0){
|
||||
for(AreaIpCfg c:cfg.getAreaCfg()){
|
||||
c.initDefaultValue();
|
||||
BeanUtils.copyProperties(cfg, c,new String[]{"cfgId","ipType","direction",
|
||||
"protocol","protocolId","areaEffectiveIds","cfgRegionCode",
|
||||
"cfgType","ipPattern","srcIpAddress","portPattern","srcPort","destIpAddress","destPort"});
|
||||
c.setTableName(AreaIpCfg.getTablename());
|
||||
}
|
||||
this.saveIpBatch(cfg.getAreaCfg());
|
||||
}
|
||||
}
|
||||
if(updateAreaCfg!=null&&updateAreaCfg.size()>0){
|
||||
this.updateIpBatch(updateAreaCfg);
|
||||
}
|
||||
if(deleteAreaCfgs!=null&&deleteAreaCfgs.size()>0){
|
||||
this.deleteIpBatch(deleteAreaCfgs);
|
||||
}
|
||||
return ipCfgDao.update(baseIpCfg);
|
||||
ipCfgDao.update(cfg);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* updateIpCfg(更新IP类配置)
|
||||
* (继承BaseIpCfg这个类方可使用)
|
||||
* @param baseIpCfg
|
||||
* @return
|
||||
*int
|
||||
* @exception
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void updateIpCfg(BaseIpCfg baseIpCfg,List<BaseIpCfg> addAreaCfg,List<BaseIpCfg> updateAreaCfg,List<BaseIpCfg> deleteAreaCfgs){
|
||||
// if(addAreaCfg!=null&&addAreaCfg.size()>0){
|
||||
// this.saveIpBatch(addAreaCfg);
|
||||
// }
|
||||
// if(updateAreaCfg!=null&&updateAreaCfg.size()>0){
|
||||
// this.updateIpBatch(updateAreaCfg);
|
||||
// }
|
||||
// if(deleteAreaCfgs!=null&&deleteAreaCfgs.size()>0){
|
||||
// this.deleteIpBatch(deleteAreaCfgs);
|
||||
// }
|
||||
// return ipCfgDao.update(baseIpCfg);
|
||||
}
|
||||
public void auditWhiteIp(BaseIpCfg cfg) throws Exception{
|
||||
List<BaseIpCfg> beans=new ArrayList<>();
|
||||
@@ -160,11 +274,11 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
maatBean.setVersion(Constants.MAAT_VERSION);
|
||||
maatBean.setOpAction(Constants.UPDATE_ACTION);
|
||||
//调用服务接口取消配置
|
||||
String json=gsonToJson(beans);
|
||||
String json=gsonToJson(maatBean);
|
||||
logger.info("IP白名单配置参数:"+json);
|
||||
//调用服务接口取消配置
|
||||
try {
|
||||
ToMaatResult result = ConfigServiceUtil.put(json, 2);
|
||||
ToMaatResult result = ConfigServiceUtil.put(json, 1);
|
||||
logger.info("IP白名单取消配置响应信息:"+result.getMsg());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -250,8 +364,36 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
}
|
||||
|
||||
}
|
||||
// @Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
// public void deleteWhiteIp(String ids){
|
||||
// List<BaseIpCfg> ipCfgs=new ArrayList<BaseIpCfg>();
|
||||
// Date date =new Date();
|
||||
// if(StringUtils.isNotBlank(ids)){
|
||||
// for(String idStr:ids.split(",")){
|
||||
// if(StringUtils.isNotBlank(idStr)){
|
||||
// BaseIpCfg cfg=new BaseIpCfg();
|
||||
// cfg.setCfgId(Long.parseLong(idStr));
|
||||
// cfg.setTableName(IpPortCfg.getTablename());
|
||||
// cfg.setEditorId(cfg.getCurrentUser().getId());
|
||||
// cfg.setEditTime(date);
|
||||
// cfg.setIsValid(Constants.VALID_DEL);
|
||||
// ipCfgs.add(cfg);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// this.deleteBatch(ipCfgs, IpCfgDao.class);
|
||||
// }
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void deleteWhiteIp(String ids){
|
||||
public void deleteIp(String ids,String compileIds,int functionId){
|
||||
if(StringUtils.isNotBlank(compileIds)){
|
||||
for(String compileId:compileIds.split(",")){
|
||||
AreaIpCfg area=new AreaIpCfg();
|
||||
area.setCompileId(Integer.parseInt(compileId));
|
||||
area.setFunctionId(functionId);
|
||||
area.setIsValid(Constants.VALID_DEL);
|
||||
areaIpCfgDao.updateValid(area);
|
||||
}
|
||||
}
|
||||
List<BaseIpCfg> ipCfgs=new ArrayList<BaseIpCfg>();
|
||||
Date date =new Date();
|
||||
if(StringUtils.isNotBlank(ids)){
|
||||
|
||||
Reference in New Issue
Block a user