IP白名单配置新增直接生效(需要分配权限,此功能才可开启).

ip白名单配置生效状态下可修改(修改delRow的判断才可开启此功能).
This commit is contained in:
段冬梅
2019-04-13 09:01:24 +08:00
parent bca7de6990
commit a478bee5f3
8 changed files with 94 additions and 25 deletions

View File

@@ -194,7 +194,7 @@ public class IpController extends BaseController{
/*if(StringUtils.isNoneBlank(entity.getUserRegion4())) {
ipCfgService.auditAsnCfg(entity, isAudit);
}else {*/
ipCfgService.auditIpCfg(entity,isAudit);
ipCfgService.auditIpCfg(entity,isAudit,Constants.INSERT_ACTION);
/*}*/
addMessage(redirectAttributes,"success", "audit_success");
} catch (Exception e) {

View File

@@ -97,9 +97,24 @@ public class WhiteListController extends CommonController {
}
@RequestMapping(value = { "ip/save" })
public String saveIpCfg(RedirectAttributes model, HttpServletRequest request, HttpServletResponse response,
public String saveIpCfg(RedirectAttributes model, HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes,
String ids, CfgIndexInfo entity) {
ipCfgService.saveIpCfg(entity);
try {
ipCfgService.saveIpCfg(entity);
//配置仅保存
if(StringUtil.isEmpty(entity.getIsValid()) || entity.getIsValid()!=1) {
addMessage(redirectAttributes, "success", "save_success");
}else {
//配置直接生效
addMessage(redirectAttributes, "success", "audit_success");
}
} catch (MaatConvertException e) {
logger.error("ip白名单配置下发失败",e);
addMessage(redirectAttributes, "error", "request_service_failed");
} catch (Exception e) {
logger.error("ip白名单配置保存失败",e);
addMessage(redirectAttributes, "error", "save_failed");
}
return "redirect:" + adminPath + "/ntc/whitelist/ip/list?functionId=" + entity.getFunctionId();
}
@@ -115,11 +130,9 @@ public class WhiteListController extends CommonController {
entity = ipCfgService.getIpPortCfg(Long.parseLong(id), null);
entity.setIsAudit(isAudit);
entity.setIsValid(isValid);
entity.setAuditorId(UserUtils.getUser().getId());
entity.setAuditTime(new Date());
entity.setFunctionId(functionId);
try {
ipCfgService.auditIpCfg(entity, isAudit);
ipCfgService.auditIpCfg(entity, isAudit,Constants.INSERT_ACTION);
addMessage(redirectAttributes, "success", "audit_success");
} catch (MaatConvertException e) {
logger.info("ip配置下发失败" + e.getMessage());

View File

@@ -115,6 +115,10 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
//设置区域运营商信息
setAreaEffectiveIds(entity);
int isValid=0;
if(!StringUtil.isEmpty(entity.getIsValid()) && entity.getIsValid()==1) {
isValid=1;
}
entity.setIsValid(0);
entity.setIsAudit(0);
@@ -189,6 +193,11 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
}
}
if(isValid==1) {
entity.setIsAudit(1);
entity.setIsValid(1);
auditIpCfg(entity, isValid,Constants.INSERT_ACTION);
}
}else{
entity.setEditTime(new Date());
entity.setEditorId(entity.getCurrentUser().getId());
@@ -262,6 +271,12 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
}
}
if(isValid==1) {
entity.setIsAudit(1);
entity.setIsValid(1);
auditIpCfg(entity, isValid,Constants.INSERT_ACTION);
}
}
}
public void updateIpCfgValid(Integer isValid,String ids,Integer functionId){
@@ -526,12 +541,15 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
}
}
}
public void auditIpCfg(CfgIndexInfo entity,Integer isAudit) throws MaatConvertException{
public void auditIpCfg(CfgIndexInfo entity,Integer isAudit,Integer opAction) throws MaatConvertException{
Properties props=this.getMsgProp();
//修改数据库审核状态信息
entity.setTableName(CfgIndexInfo.getTablename());
entity.setIsAudit(isAudit);
entity.setAuditorId(UserUtils.getUser().getId());
entity.setAuditTime(new Date());
ipCfgDao.auditCfg(entity);
ToMaatBean maatBean = new ToMaatBean();
MaatCfg maatCfg = new MaatCfg();
List<MaatCfg> configCompileList = new ArrayList();
@@ -665,7 +683,7 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
maatBean.setAuditTime(entity.getAuditTime());
maatBean.setCreatorName(entity.getCurrentUser().getName());
maatBean.setVersion(Constants.MAAT_VERSION);
maatBean.setOpAction(Constants.INSERT_ACTION);
maatBean.setOpAction(opAction);
//限速需要发Droprate=0.001 暂不支持Bandwidth=200kbps
if(entity.getAction().equals(Constants.RATELIMIT_ACTION)){
if(entity.getUserRegion1().equals("0")){//丢包率