(1)IP类配置页面修改,支持多选的删除,审核,操作按钮上移
(2)修复验证方法ipCheck影响多个IP配置的bug
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
/**
|
||||
*@Title: HttpsContentReplaceConfig.java
|
||||
*@Package com.nis.domain.restful
|
||||
*@Description TODO
|
||||
*@author dell
|
||||
*@date 2018年2月6日 上午10:30:46
|
||||
*@version 版本号
|
||||
*/
|
||||
package com.nis.domain.configuration;
|
||||
|
||||
/**
|
||||
* @ClassName: HttpsContentReplaceConfig.java
|
||||
* @Description: TODO
|
||||
* @author (dell)
|
||||
* @date 2018年2月6日 上午10:30:46
|
||||
* @version V1.0
|
||||
*/
|
||||
public class HttpsContentReplaceCfg extends BaseStringCfg {
|
||||
|
||||
/**
|
||||
* @Fields serialVersionUID:TODO(用一句话描述这个变量表示什么)
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
private static final long serialVersionUID = -116828220692786004L;
|
||||
/**
|
||||
* 网站名称
|
||||
*/
|
||||
private String webName;
|
||||
/**
|
||||
* 源内容
|
||||
*/
|
||||
private String srcContent;
|
||||
/**
|
||||
* 替换内容
|
||||
*/
|
||||
private String destContent;
|
||||
/**
|
||||
* webName
|
||||
* @return webName
|
||||
*/
|
||||
|
||||
public String getWebName() {
|
||||
return webName;
|
||||
}
|
||||
/**
|
||||
* @param webName the webName to set
|
||||
*/
|
||||
public void setWebName(String webName) {
|
||||
this.webName = webName;
|
||||
}
|
||||
/**
|
||||
* srcContent
|
||||
* @return srcContent
|
||||
*/
|
||||
|
||||
public String getSrcContent() {
|
||||
return srcContent;
|
||||
}
|
||||
/**
|
||||
* @param srcContent the srcContent to set
|
||||
*/
|
||||
public void setSrcContent(String srcContent) {
|
||||
this.srcContent = srcContent;
|
||||
}
|
||||
/**
|
||||
* destContent
|
||||
* @return destContent
|
||||
*/
|
||||
|
||||
public String getDestContent() {
|
||||
return destContent;
|
||||
}
|
||||
/**
|
||||
* @param destContent the destContent to set
|
||||
*/
|
||||
public void setDestContent(String destContent) {
|
||||
this.destContent = destContent;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.nis.domain.configuration.BaseStringCfg#initDefaultValue()
|
||||
*/
|
||||
@Override
|
||||
public void initDefaultValue() {
|
||||
// TODO Auto-generated method stub
|
||||
super.initDefaultValue();
|
||||
this.exprType=0;
|
||||
this.matchMethod=3;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,19 +19,20 @@ import java.util.Map;
|
||||
* @version V1.0
|
||||
*/
|
||||
public class MultipleCfg extends BaseCfg<MultipleCfg> {
|
||||
|
||||
/**
|
||||
* @Fields serialVersionUID:TODO(用一句话描述这个变量表示什么)
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
private static final long serialVersionUID = -8369567908781421920L;
|
||||
/**
|
||||
* 配置关系表,一个compileId 中有哪些表存了数据
|
||||
*/
|
||||
private MultipleCfgRelation relation;
|
||||
private String mainTable;
|
||||
private String mainTableType;
|
||||
private String mainTableDesc;
|
||||
private List<TableBean> otherTables;//key 表名,value 类型
|
||||
// private BaseCfg mainCfg;
|
||||
//ip配置
|
||||
private Map<String,BaseIpCfg> ipCfg;
|
||||
//字符串配置
|
||||
@@ -168,4 +169,18 @@ public class MultipleCfg extends BaseCfg<MultipleCfg> {
|
||||
public void setMainTableDesc(String mainTableDesc) {
|
||||
this.mainTableDesc = mainTableDesc;
|
||||
}
|
||||
/**
|
||||
* relation
|
||||
* @return relation
|
||||
*/
|
||||
|
||||
public MultipleCfgRelation getRelation() {
|
||||
return relation;
|
||||
}
|
||||
/**
|
||||
* @param relation the relation to set
|
||||
*/
|
||||
public void setRelation(MultipleCfgRelation relation) {
|
||||
this.relation = relation;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
/**
|
||||
*@Title: MultipleCfgRelation.java
|
||||
*@Package com.nis.domain.configuration
|
||||
*@Description TODO
|
||||
*@author dell
|
||||
*@date 2018年4月10日 上午11:11:53
|
||||
*@version 版本号
|
||||
*/
|
||||
package com.nis.domain.configuration;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @ClassName: MultipleCfgRelation.java
|
||||
* @Description: TODO
|
||||
* @author (dell)
|
||||
* @date 2018年4月10日 上午11:11:53
|
||||
* @version V1.0
|
||||
*/
|
||||
public class MultipleCfgRelation implements Serializable{
|
||||
|
||||
/**
|
||||
* @Fields serialVersionUID:TODO(用一句话描述这个变量表示什么)
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
private static final long serialVersionUID = -615924510840736781L;
|
||||
private int compileId;
|
||||
private String tableName;
|
||||
private int isValid;
|
||||
/**
|
||||
* compileId
|
||||
* @return compileId
|
||||
*/
|
||||
|
||||
public int getCompileId() {
|
||||
return compileId;
|
||||
}
|
||||
/**
|
||||
* @param compileId the compileId to set
|
||||
*/
|
||||
public void setCompileId(int compileId) {
|
||||
this.compileId = compileId;
|
||||
}
|
||||
/**
|
||||
* tableName
|
||||
* @return tableName
|
||||
*/
|
||||
|
||||
public String getTableName() {
|
||||
return tableName;
|
||||
}
|
||||
/**
|
||||
* @param tableName the tableName to set
|
||||
*/
|
||||
public void setTableName(String tableName) {
|
||||
this.tableName = tableName;
|
||||
}
|
||||
/**
|
||||
* isValid
|
||||
* @return isValid
|
||||
*/
|
||||
|
||||
public int getIsValid() {
|
||||
return isValid;
|
||||
}
|
||||
/**
|
||||
* @param isValid the isValid to set
|
||||
*/
|
||||
public void setIsValid(int isValid) {
|
||||
this.isValid = isValid;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.nis.web.controller.configuration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@@ -7,6 +8,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.authz.annotation.Logical;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
@@ -31,12 +33,9 @@ import com.nis.web.controller.BaseController;
|
||||
public class IpCfgController extends BaseController{
|
||||
/**
|
||||
*
|
||||
* ipCfgList(配置列表与审核列表,需要根据参数判断是哪个列表,以便显示隐藏对应的界面菜单,按钮)
|
||||
* cfgList(配置列表)
|
||||
* (这里描述这个方法适用条件 – 可选)
|
||||
* @param model
|
||||
* @param audit
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param cfgName
|
||||
* @param ipCfg
|
||||
* @param request
|
||||
@@ -46,7 +45,32 @@ public class IpCfgController extends BaseController{
|
||||
* @exception
|
||||
* @since 1.0.0
|
||||
*/
|
||||
// @RequestMapping(value = {"cfgList"})
|
||||
// @RequiresPermissions("cfg:ip:edit")
|
||||
// public String cfgList(Model model,String cfgName,@ModelAttribute("ipCfg")BaseIpCfg ipCfg,HttpServletRequest request,HttpServletResponse response){
|
||||
// return ipCfgList(model,Constants.CFG_PAGE,cfgName,ipCfg,request,response);
|
||||
// }
|
||||
/**
|
||||
*
|
||||
* auditList(审核列表)
|
||||
* (这里描述这个方法适用条件 – 可选)
|
||||
* @param model
|
||||
* @param cfgName
|
||||
* @param ipCfg
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*String
|
||||
* @exception
|
||||
* @since 1.0.0
|
||||
*/
|
||||
// @RequestMapping(value = {"auditList"})
|
||||
// @RequiresPermissions("cfg:ip:audit")
|
||||
// public String auditList(Model model,String cfgName,@ModelAttribute("ipCfg")BaseIpCfg ipCfg,HttpServletRequest request,HttpServletResponse response){
|
||||
// return ipCfgList(model,Constants.AUDIT_PAGE,cfgName,ipCfg,request,response);
|
||||
// }
|
||||
@RequestMapping(value = {"list"})
|
||||
@RequiresPermissions(value={"cfg:ip:add","cfg:ip:edit","cfg:ip:delete","cfg:ip:audit"},logical=Logical.OR)
|
||||
public String ipCfgList(Model model,Integer audit,String cfgName,@ModelAttribute("ipCfg")BaseIpCfg ipCfg,HttpServletRequest request,HttpServletResponse response) {
|
||||
model.addAttribute("cfgName", cfgName);
|
||||
model.addAttribute("audit", audit);
|
||||
@@ -61,7 +85,21 @@ public class IpCfgController extends BaseController{
|
||||
if(!StringUtils.isBlank(tableName)){
|
||||
logger.info("table name is "+tableName);
|
||||
ipCfg.setTableName(tableName);
|
||||
Page<BaseIpCfg> page = ipCfgService.findPage(new Page<BaseIpCfg>(request,response,"r"), ipCfg);
|
||||
Page<BaseIpCfg> searchPage=new Page<BaseIpCfg>(request,response,"r");
|
||||
String addWhrere=null;
|
||||
if(audit==Constants.CFG_PAGE){//
|
||||
addWhrere="r.is_audit in ("+Constants.AUDIT_NOT_YET+","+Constants.AUDIT_NO+")";
|
||||
}else if(audit==Constants.AUDIT_PAGE){
|
||||
addWhrere="r.is_audit in ("+Constants.AUDIT_NOT_YET+","+Constants.AUDIT_YES+")";
|
||||
}
|
||||
if(addWhrere!=null){
|
||||
if(StringUtils.isNotBlank(searchPage.getWhere())){
|
||||
searchPage.setWhere(searchPage.getWhere()+" AND "+addWhrere);
|
||||
}else{
|
||||
searchPage.setWhere(addWhrere);
|
||||
}
|
||||
}
|
||||
Page<BaseIpCfg> page = ipCfgService.findPage(searchPage, ipCfg);
|
||||
model.addAttribute("page", page);
|
||||
model.addAttribute("action", ipCfg.getAction());
|
||||
model.addAttribute("tableName", tableName);
|
||||
@@ -72,7 +110,6 @@ public class IpCfgController extends BaseController{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return "/cfg/ipCfgList";
|
||||
}
|
||||
|
||||
@@ -92,6 +129,7 @@ public class IpCfgController extends BaseController{
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@RequestMapping(value = {"form"})
|
||||
@RequiresPermissions("cfg:ip:add")
|
||||
public String ipCfgForm(int action,String cfgName,Integer serviceId,Model model,HttpServletRequest request,HttpServletResponse response) {
|
||||
model.addAttribute("cfgName", cfgName);
|
||||
model.addAttribute("serviceId", serviceId);
|
||||
@@ -152,9 +190,9 @@ public class IpCfgController extends BaseController{
|
||||
* @exception
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@RequiresPermissions("sys:cfg:edit")
|
||||
@RequiresPermissions("cfg:ip:edit")
|
||||
@RequestMapping(value = {"updateForm"})
|
||||
public String updateIpCfgForm(String tableName,int action,long cfgId,String cfgName,Integer serviceId,Model model) {
|
||||
public String updateIpCfgForm(String tableName,int action,int compileId,String cfgName,Integer serviceId,Model model) {
|
||||
model.addAttribute("cfgName", cfgName);
|
||||
model.addAttribute("serviceId", serviceId);
|
||||
model.addAttribute("action", action);
|
||||
@@ -169,9 +207,9 @@ public class IpCfgController extends BaseController{
|
||||
if(!StringUtils.isBlank(tableName)){
|
||||
logger.info("table name is "+tableName);
|
||||
BaseIpCfg searchBean=new BaseIpCfg();
|
||||
searchBean.setCfgId(cfgId);
|
||||
searchBean.setCompileId(compileId);
|
||||
searchBean.setTableName(tableName);
|
||||
BaseIpCfg ipCfg=ipCfgService.getIpCfgById(searchBean);
|
||||
BaseIpCfg ipCfg=ipCfgService.get(searchBean);
|
||||
model.addAttribute("_cfg", ipCfg);
|
||||
model.addAttribute("tableName", tableName);
|
||||
initUpdateFormCondition(model,ipCfg);
|
||||
@@ -194,6 +232,7 @@ public class IpCfgController extends BaseController{
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@RequestMapping(value = {"saveOrUpdateCfg"})
|
||||
@RequiresPermissions(value={"cfg:ip:add","cfg:ip:edit"},logical=Logical.OR)
|
||||
public String saveOrUpdateIpCfg(String cfgName,Model model, BaseIpCfg ipCfg,String areaCfgIds) {
|
||||
model.addAttribute("cfgName",cfgName);
|
||||
model.addAttribute("cfgType", "ip");
|
||||
@@ -220,50 +259,65 @@ public class IpCfgController extends BaseController{
|
||||
* @exception
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@RequestMapping(value = {"auditCfg"})
|
||||
public String auditIpCfg(String cfgName,BaseIpCfg ipCfg,Model model) {
|
||||
@RequestMapping(value = {"audit"})
|
||||
@RequiresPermissions("cfg:ip:audit")
|
||||
public String auditIpCfg(String cfgName,int serviceId,int isAudit,int action,String tableName,String ids,Model model) {
|
||||
model.addAttribute("cfgName", cfgName);
|
||||
model.addAttribute("cfgType", "ip");
|
||||
model.addAttribute("audit", Constants.AUDIT_PAGE);
|
||||
model.addAttribute("serviceId", ipCfg.getServiceId());
|
||||
model.addAttribute("action", ipCfg.getAction());
|
||||
model.addAttribute("serviceId", serviceId);
|
||||
model.addAttribute("action", action);
|
||||
try{
|
||||
String tableName=ipCfg.getTableName();
|
||||
String maatTable=null;
|
||||
ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(ipCfg.getServiceId());
|
||||
ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId);
|
||||
if(serviceConfigInfo!=null){
|
||||
if(StringUtils.isBlank(tableName)){
|
||||
tableName=serviceConfigInfo.getTableName();
|
||||
ipCfg.setTableName(tableName);
|
||||
}
|
||||
maatTable=serviceConfigInfo.getMaatTable();
|
||||
}
|
||||
BaseIpCfg bean=ipCfgService.getIpCfgById(ipCfg);
|
||||
bean.setTableName(tableName);
|
||||
int audit=bean.getIsAudit().intValue();
|
||||
if(audit==Constants.AUDIT_YES&&ipCfg.getIsAudit()!=Constants.AUDIT_NOT_YES){
|
||||
logger.error("审核通过的配置只能取消审核通过!");
|
||||
}else{
|
||||
ipCfg.setAuditorId(ipCfg.getCurrentUser().getId());
|
||||
ipCfg.setAuditTime(new Date());
|
||||
bean.setIsAudit(ipCfg.getIsAudit());
|
||||
if(ipCfg.getIsAudit()==Constants.AUDIT_NOT_YES){//取消审核通过,设置有效标志为0
|
||||
ipCfg.setIsValid(Constants.VALID_NO);
|
||||
bean.setIsValid(Constants.VALID_NO);
|
||||
bean.setMaatTable(maatTable);
|
||||
}else if(ipCfg.getIsAudit()==Constants.AUDIT_YES){//审核通过,设置有效标志为1
|
||||
ipCfg.setIsValid(Constants.VALID_YES);
|
||||
bean.setIsValid(Constants.VALID_YES);
|
||||
bean.setMaatTable(maatTable);
|
||||
if(StringUtils.isNotBlank(ids)){
|
||||
List<BaseIpCfg> beans=ipCfgService.getList(tableName,ids);
|
||||
List<BaseIpCfg> auditBeans=new ArrayList<>();
|
||||
List<AreaIpCfg> auditAreaBeans=new ArrayList<>();
|
||||
Date date=new Date();
|
||||
for(BaseIpCfg bean:beans){
|
||||
BaseIpCfg auditBean=new BaseIpCfg();
|
||||
auditBean.setTableName(tableName);
|
||||
auditBean.setCfgId(bean.getCfgId());
|
||||
bean.setTableName(tableName);
|
||||
int audit=bean.getIsAudit().intValue();
|
||||
if(audit==Constants.AUDIT_YES&&isAudit!=Constants.AUDIT_NOT_YES){
|
||||
logger.error("审核通过的配置只能取消审核通过!");
|
||||
addMessage(model, "audit_failed");
|
||||
return "/cfg/resultPage";
|
||||
}else{
|
||||
auditBean.setAuditorId(bean.getCurrentUser().getId());
|
||||
auditBean.setAuditTime(date);
|
||||
auditBean.setIsAudit(isAudit);
|
||||
bean.setAuditorId(bean.getCurrentUser().getId());
|
||||
bean.setAuditTime(date);
|
||||
bean.setIsAudit(isAudit);
|
||||
if(isAudit==Constants.AUDIT_NOT_YES){//取消审核通过,设置有效标志为0
|
||||
auditBean.setIsValid(Constants.VALID_NO);
|
||||
auditBean.setMaatTable(maatTable);
|
||||
bean.setIsValid(Constants.VALID_NO);
|
||||
bean.setMaatTable(maatTable);
|
||||
}else if(isAudit==Constants.AUDIT_YES){//审核通过,设置有效标志为1
|
||||
auditBean.setIsValid(Constants.VALID_YES);
|
||||
auditBean.setMaatTable(maatTable);
|
||||
bean.setIsValid(Constants.VALID_YES);
|
||||
bean.setMaatTable(maatTable);
|
||||
}
|
||||
List<AreaIpCfg> areaCfg=ipCfgService.getAreaCfgByCompileId(bean.getCompileId());
|
||||
bean.setAreaCfg(areaCfg);
|
||||
auditAreaBeans.addAll(areaCfg);
|
||||
}
|
||||
auditBeans.add(auditBean);
|
||||
}
|
||||
int result=ipCfgService.auditIpCfg(bean,ipCfg);
|
||||
if(result!=0){
|
||||
addMessage(model,"audit_success");
|
||||
}else{
|
||||
addMessage(model, "audit_failed");
|
||||
}
|
||||
|
||||
ipCfgService.auditIpCfg(isAudit,auditBeans,auditAreaBeans,beans);
|
||||
}
|
||||
addMessage(model,"audit_success");
|
||||
}catch(Exception e){
|
||||
logger.error("审核失败", e);
|
||||
addMessage(model, "audit_failed");
|
||||
@@ -272,16 +326,16 @@ public class IpCfgController extends BaseController{
|
||||
}
|
||||
/**
|
||||
*
|
||||
* auditIpCfg(删除IP配置,逻辑删除)
|
||||
* deleteIpCfg(删除IP配置,逻辑删除)
|
||||
* (这里描述这个方法适用条件 – 可选)
|
||||
* @return
|
||||
*String
|
||||
* @exception
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@RequiresPermissions("sys:cfg:edit")
|
||||
@RequestMapping(value = {"deleteCfg"})
|
||||
public String deleteIpCfg(String tableName,int action,long cfgId,int compileId,String cfgName,Integer serviceId,Model model) {
|
||||
@RequiresPermissions("cfg:ip:edit")
|
||||
@RequestMapping(value = {"delete"})
|
||||
public String deleteIpCfg(String tableName,int action,String ids,String cfgName,Integer serviceId,Model model) {
|
||||
model.addAttribute("cfgName", cfgName);
|
||||
model.addAttribute("serviceId", serviceId);
|
||||
model.addAttribute("action", action);
|
||||
@@ -296,31 +350,58 @@ public class IpCfgController extends BaseController{
|
||||
}
|
||||
}
|
||||
model.addAttribute("tableName", tableName);
|
||||
int audit=ipCfgService.getIsAudit(tableName,cfgId);
|
||||
List<AreaIpCfg> areaCfg=ipCfgService.getAreaCfgByCompileId(compileId);
|
||||
if(areaCfg!=null&&areaCfg.size()>0){
|
||||
for(AreaIpCfg c:areaCfg){
|
||||
c.setTableName(AreaIpCfg.getTablename());
|
||||
List<BaseIpCfg> ipCfgs=new ArrayList<BaseIpCfg>();
|
||||
List<AreaIpCfg> areaCfgs=new ArrayList<AreaIpCfg>();
|
||||
Date date =new Date();
|
||||
if(StringUtils.isNotBlank(ids)){
|
||||
for(String compileIdStr:ids.split(",")){
|
||||
if(StringUtils.isNotBlank(compileIdStr)){
|
||||
List<AreaIpCfg> areaCfg=ipCfgService.getAreaCfgByCompileId(Integer.parseInt(compileIdStr));
|
||||
if(areaCfg!=null&&areaCfg.size()>0){
|
||||
for(AreaIpCfg c:areaCfg){
|
||||
c.setTableName(AreaIpCfg.getTablename());
|
||||
c.setEditorId(c.getCurrentUser().getId());
|
||||
c.setEditTime(date);
|
||||
}
|
||||
}
|
||||
areaCfgs.addAll(areaCfg);
|
||||
BaseIpCfg ipCfg=new BaseIpCfg();
|
||||
ipCfg.setCompileId(Integer.parseInt(compileIdStr));
|
||||
ipCfg.setTableName(tableName);
|
||||
ipCfg.setEditorId(ipCfg.getCurrentUser().getId());
|
||||
ipCfg.setEditTime(date);
|
||||
ipCfg.setIsValid(Constants.VALID_DEL);
|
||||
ipCfgs.add(ipCfg);
|
||||
}
|
||||
}
|
||||
// int audit=ipCfgService.getIsAudit(tableName,cfgId);
|
||||
// List<AreaIpCfg> areaCfg=ipCfgService.getAreaCfgByCompileId(compileId);
|
||||
// if(areaCfg!=null&&areaCfg.size()>0){
|
||||
// for(AreaIpCfg c:areaCfg){
|
||||
// c.setTableName(AreaIpCfg.getTablename());
|
||||
// }
|
||||
// }
|
||||
//未审核时可删除
|
||||
// if(audit!=Constants.AUDIT_YES&&audit!=Constants.AUDIT_NOT_YES){
|
||||
// BaseIpCfg ipCfg=new BaseIpCfg();
|
||||
// ipCfg.setCfgId(cfgId);
|
||||
// ipCfg.setTableName(tableName);
|
||||
// ipCfg.setEditorId(ipCfg.getCurrentUser().getId());
|
||||
// ipCfg.setEditTime(new Date());
|
||||
// ipCfg.setIsValid(Constants.VALID_DEL);
|
||||
// int result=ipCfgService.deleteIpCfg(ipCfg,areaCfg);
|
||||
// if(result==0){
|
||||
// addMessage(model,"delete_failed");
|
||||
// }else{
|
||||
// addMessage(model,"delete_success");
|
||||
// }
|
||||
// }else{
|
||||
// logger.error("通过审核/取消审核通过的配置不能删除!");
|
||||
// addMessage(model,"delete_failed");
|
||||
// }
|
||||
}
|
||||
//未审核时可删除
|
||||
if(audit!=Constants.AUDIT_YES&&audit!=Constants.AUDIT_NOT_YES){
|
||||
BaseIpCfg ipCfg=new BaseIpCfg();
|
||||
ipCfg.setCfgId(cfgId);
|
||||
ipCfg.setTableName(tableName);
|
||||
ipCfg.setEditorId(ipCfg.getCurrentUser().getId());
|
||||
ipCfg.setEditTime(new Date());
|
||||
ipCfg.setIsValid(Constants.VALID_DEL);
|
||||
int result=ipCfgService.deleteIpCfg(ipCfg,areaCfg);
|
||||
if(result==0){
|
||||
addMessage(model,"delete_failed");
|
||||
}else{
|
||||
addMessage(model,"delete_success");
|
||||
}
|
||||
}else{
|
||||
logger.error("通过审核/取消审核通过的配置不能删除!");
|
||||
addMessage(model,"delete_failed");
|
||||
}
|
||||
ipCfgService.deleteIpCfg(ipCfgs,areaCfgs);
|
||||
addMessage(model,"delete_success");
|
||||
}catch(Exception e){
|
||||
logger.error("删除失败", e);
|
||||
addMessage(model,"delete_failed");
|
||||
|
||||
@@ -61,5 +61,15 @@ public interface CrudDao<T> {
|
||||
* @return
|
||||
*/
|
||||
public int delete(T entity);
|
||||
|
||||
/**
|
||||
* audit(审核数据)
|
||||
* (这里描述这个方法适用条件 – 可选)
|
||||
* @param t
|
||||
*void
|
||||
* @exception
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public int audit(T entity);
|
||||
|
||||
}
|
||||
@@ -18,6 +18,7 @@ public interface IpCfgDao extends CrudDao<BaseIpCfg>{
|
||||
public BaseIpCfg getById(@Param("tableName")String tableName,@Param("cfgId")Long id) ;
|
||||
public BaseIpCfg get(BaseIpCfg entity) ;
|
||||
public List<BaseIpCfg> findList(BaseIpCfg entity) ;
|
||||
public List<BaseIpCfg> getList(@Param("tableName")String tableName,@Param("ids")String ids) ;
|
||||
public int insert(BaseIpCfg entity) ;
|
||||
public int updateByPrimaryKeySelective(BaseIpCfg entity) ;
|
||||
public int updateValid(BaseIpCfg entity) ;
|
||||
|
||||
@@ -161,6 +161,11 @@
|
||||
AND IS_VALID!=-1
|
||||
</trim>
|
||||
</select>
|
||||
<select id="getList" resultMap="BaseIpMap" >
|
||||
SELECT
|
||||
<include refid="BaseIpCfg_Column_List_with_id" />
|
||||
FROM ${tableName} WHERE IS_VALID!=-1 AND COMPILE_ID in (${ids})
|
||||
</select>
|
||||
<select id="findList" resultMap="BaseIpMapWithUser">
|
||||
select
|
||||
<!--<choose>
|
||||
@@ -538,7 +543,7 @@
|
||||
<update id="updateValid" parameterType="com.nis.domain.configuration.BaseIpCfg" >
|
||||
update ${tableName} set is_valid = #{isValid,jdbcType=INTEGER}, editor_id = #{editorId,jdbcType=INTEGER} , edit_time = #{editTime,jdbcType=TIMESTAMP} where cfg_id = #{cfgId,jdbcType=BIGINT}
|
||||
</update>
|
||||
<update id="audit" parameterType="com.nis.domain.configuration.BaseIpCfg" >
|
||||
<update id="audit">
|
||||
update ${tableName} set is_audit = #{isAudit,jdbcType=INTEGER}, auditor_id = #{auditorId,jdbcType=INTEGER}, audit_time = #{auditTime,jdbcType=TIMESTAMP}
|
||||
<if test="isValid != null" >
|
||||
,is_valid = #{isValid,jdbcType=INTEGER}
|
||||
@@ -554,7 +559,15 @@
|
||||
WHERE CFG_ID = #{cfgId,jdbcType=BIGINT}
|
||||
</select>
|
||||
<update id="delete" parameterType="com.nis.domain.configuration.BaseIpCfg" >
|
||||
update ${tableName} set is_valid = -1, editor_id = #{editorId,jdbcType=INTEGER} , edit_time = #{editTime,jdbcType=TIMESTAMP} where cfg_id = #{cfgId,jdbcType=BIGINT}
|
||||
update ${tableName} set is_valid = -1, editor_id = #{editorId,jdbcType=INTEGER} , edit_time = #{editTime,jdbcType=TIMESTAMP}
|
||||
<trim prefix="WHERE" prefixOverrides="AND |OR ">
|
||||
<if test="cfgId !=null ">
|
||||
AND cfg_id = #{cfgId,jdbcType=BIGINT}
|
||||
</if>
|
||||
<if test="compileId !=null ">
|
||||
AND compile_id = #{compileId,jdbcType=INTEGER}
|
||||
</if>
|
||||
</trim>
|
||||
</update>
|
||||
<update id="deleteByCompileId" parameterType="com.nis.domain.configuration.BaseIpCfg" >
|
||||
update ${tableName} set is_valid = -1, editor_id = #{editorId,jdbcType=INTEGER} , edit_time = #{editTime,jdbcType=TIMESTAMP} where compile_id = #{compileId,jdbcType=INTEGER}
|
||||
|
||||
@@ -123,15 +123,21 @@ public abstract class CrudService<D extends CrudDao<T>, T extends BaseEntity<T>>
|
||||
((CrudDao<T>) batchSqlSession.getMapper(mClass)).insert(t);
|
||||
}
|
||||
batchSqlSession.commit();
|
||||
// }catch (Exception e){
|
||||
// batchSqlSession.rollback();
|
||||
// throw e;
|
||||
}finally {
|
||||
if(batchSqlSession != null){
|
||||
batchSqlSession.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
* saveIpBatch(非Ip类配置调用,批量新增区域IP)
|
||||
* (这里描述这个方法适用条件 – 可选)
|
||||
* @param areaIpCfgs
|
||||
*void
|
||||
* @exception
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public void saveIpBatch(List<AreaIpCfg> areaIpCfgs) {
|
||||
SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class);
|
||||
SqlSession batchSqlSession = null;
|
||||
@@ -142,9 +148,6 @@ public abstract class CrudService<D extends CrudDao<T>, T extends BaseEntity<T>>
|
||||
((CrudDao<BaseIpCfg>) batchSqlSession.getMapper(IpCfgDao.class)).insert(t);
|
||||
}
|
||||
batchSqlSession.commit();
|
||||
// }catch (Exception e){
|
||||
// batchSqlSession.rollback();
|
||||
// throw e;
|
||||
}finally {
|
||||
if(batchSqlSession != null){
|
||||
batchSqlSession.close();
|
||||
@@ -171,16 +174,21 @@ public abstract class CrudService<D extends CrudDao<T>, T extends BaseEntity<T>>
|
||||
((CrudDao<T>) batchSqlSession.getMapper(mClass)).update(t);
|
||||
}
|
||||
batchSqlSession.commit();
|
||||
// }catch (Exception e){
|
||||
// batchSqlSession.rollback();
|
||||
// throw e;
|
||||
}finally {
|
||||
if(batchSqlSession != null){
|
||||
batchSqlSession.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
/**
|
||||
*
|
||||
* updateIpBatch(非IP类配置调用,批量更新区域IP)
|
||||
* (这里描述这个方法适用条件 – 可选)
|
||||
* @param areaCfg
|
||||
*void
|
||||
* @exception
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public void updateIpBatch(List<AreaIpCfg> areaCfg) {
|
||||
SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class);
|
||||
SqlSession batchSqlSession = null;
|
||||
@@ -191,9 +199,6 @@ public abstract class CrudService<D extends CrudDao<T>, T extends BaseEntity<T>>
|
||||
((CrudDao<BaseIpCfg>) batchSqlSession.getMapper(IpCfgDao.class)).update(t);
|
||||
}
|
||||
batchSqlSession.commit();
|
||||
// }catch (Exception e){
|
||||
// batchSqlSession.rollback();
|
||||
// throw e;
|
||||
}finally {
|
||||
if(batchSqlSession != null){
|
||||
batchSqlSession.close();
|
||||
@@ -221,15 +226,72 @@ public abstract class CrudService<D extends CrudDao<T>, T extends BaseEntity<T>>
|
||||
((CrudDao<T>) batchSqlSession.getMapper(mClass)).delete(t);
|
||||
}
|
||||
batchSqlSession.commit();
|
||||
// }catch (Exception e){
|
||||
// batchSqlSession.rollback();
|
||||
// throw e;
|
||||
}finally {
|
||||
if(batchSqlSession != null){
|
||||
batchSqlSession.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
* auditBatch(批量审核)
|
||||
* (这里描述这个方法适用条件 – 可选)
|
||||
* @param data 数据集合
|
||||
* @param mClass 传入的dao.xml里的mapper
|
||||
* @author wx
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public void auditBatch(List<T> data,@SuppressWarnings("rawtypes") Class mClass) {
|
||||
SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class);
|
||||
SqlSession batchSqlSession = null;
|
||||
try{
|
||||
batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
|
||||
for(int index = 0; index < data.size();index++){
|
||||
T t = data.get(index);
|
||||
((CrudDao<T>) batchSqlSession.getMapper(mClass)).audit(t);
|
||||
}
|
||||
batchSqlSession.commit();
|
||||
}finally {
|
||||
if(batchSqlSession != null){
|
||||
batchSqlSession.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
* auditIpBatch(非IP类配置用,审核区域IP)
|
||||
* (这里描述这个方法适用条件 – 可选)
|
||||
* @param data
|
||||
*void
|
||||
* @exception
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public void auditIpBatch(List<AreaIpCfg> data) {
|
||||
SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class);
|
||||
SqlSession batchSqlSession = null;
|
||||
try{
|
||||
batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
|
||||
for(int index = 0; index < data.size();index++){
|
||||
BaseIpCfg t = data.get(index);
|
||||
((CrudDao<BaseIpCfg>) batchSqlSession.getMapper(IpCfgDao.class)).audit(t);
|
||||
}
|
||||
batchSqlSession.commit();
|
||||
}finally {
|
||||
if(batchSqlSession != null){
|
||||
batchSqlSession.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
* deleteIpBatch(非IP类配置调用,批量删除区域IP)
|
||||
* (这里描述这个方法适用条件 – 可选)
|
||||
* @param data
|
||||
*void
|
||||
* @exception
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public void deleteIpBatch(List<AreaIpCfg> data) {
|
||||
SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class);
|
||||
SqlSession batchSqlSession = null;
|
||||
@@ -240,15 +302,238 @@ public abstract class CrudService<D extends CrudDao<T>, T extends BaseEntity<T>>
|
||||
((CrudDao<BaseIpCfg>) batchSqlSession.getMapper(IpCfgDao.class)).delete(t);
|
||||
}
|
||||
batchSqlSession.commit();
|
||||
// }catch (Exception e){
|
||||
// batchSqlSession.rollback();
|
||||
// throw e;
|
||||
}finally {
|
||||
}finally {
|
||||
if(batchSqlSession != null){
|
||||
batchSqlSession.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
* sendToMaatConvertorBatch(批量转换配置到maat转换工具)
|
||||
* (这里描述这个方法适用条件 – 可选)
|
||||
* @param operation
|
||||
* @param cfgs
|
||||
* @return
|
||||
* @throws Exception
|
||||
*boolean
|
||||
* @exception
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public boolean sendToMaatConvertorBatch(int operation,List<BaseCfg[]> cfgs) throws Exception{
|
||||
if(cfgs==null){
|
||||
throw new RuntimeException("转换出错,配置为空");
|
||||
}
|
||||
Gson gson=new GsonBuilder().disableHtmlEscaping()
|
||||
/*.setPrettyPrinting().serializeNulls()*/
|
||||
.excludeFieldsWithoutExposeAnnotation()
|
||||
.create();
|
||||
if(Constants.AUDIT_NOT_YES==operation){
|
||||
List<ToMaatUnAuditBean> beans=new ArrayList<ToMaatUnAuditBean>();
|
||||
for(BaseCfg[] cfg:cfgs){
|
||||
ToMaatUnAuditBean toMaatUnAuditBean=new ToMaatUnAuditBean();
|
||||
toMaatUnAuditBean.setServiceCfg(new ArrayList<UnAuditBean>());
|
||||
for(BaseCfg c:cfg){
|
||||
if(c.getCompileId()==null||c.getCompileId()==0){
|
||||
throw new RuntimeException("转换出错,未获取到正确的compileId");
|
||||
}
|
||||
if(StringUtils.isBlank(c.getMaatTable())){
|
||||
throw new RuntimeException("转换出错,未获取到正确的maatTalbe");
|
||||
}
|
||||
//针对含有多个maatTable的表
|
||||
if(c.getMaatTable().contains(",")){
|
||||
for(String maatTable:c.getMaatTable().split(",")){
|
||||
UnAuditBean bean=new UnAuditBean();
|
||||
bean.setCompileId(c.getCompileId());
|
||||
bean.setMaatTable(maatTable);
|
||||
toMaatUnAuditBean.getServiceCfg().add(bean);
|
||||
}
|
||||
}else{
|
||||
UnAuditBean bean=new UnAuditBean();
|
||||
bean.setCompileId(c.getCompileId());
|
||||
bean.setMaatTable(c.getMaatTable());
|
||||
toMaatUnAuditBean.getServiceCfg().add(bean);
|
||||
}
|
||||
|
||||
}
|
||||
beans.add(toMaatUnAuditBean);
|
||||
}
|
||||
String json=gson.toJson(beans);
|
||||
logger.info("to maat json:"+json);
|
||||
//发送至maat,待完成
|
||||
return new ConvertTool().setConfigInValid(json);
|
||||
}else{
|
||||
List<ToMaatBean> beans=new ArrayList<ToMaatBean>();
|
||||
for(BaseCfg[] cfg:cfgs){
|
||||
int compileId=0;
|
||||
ToMaatBean toMaatBean=new ToMaatBean();
|
||||
toMaatBean.setServiceCfg(new ArrayList<MaatCfg>());
|
||||
MaatCfg maatCfg=new MaatCfg();
|
||||
for(BaseCfg c:cfg){
|
||||
if(c instanceof BaseIpCfg){
|
||||
compileId=compileId==0?c.getCompileId():compileId;
|
||||
int protocolId= ((BaseIpCfg) c).getProtocolId().intValue();
|
||||
String maatTable=c.getMaatTable();
|
||||
if(maatTable.contains(",")){
|
||||
if(protocolId!=0){
|
||||
for(String _maatTable:maatTable.split(",")){
|
||||
if(_maatTable.toLowerCase().indexOf("ip")>-1){
|
||||
BaseIpCfg ipCfg=(BaseIpCfg)c.clone();
|
||||
ipCfg.setMaatTable(_maatTable);
|
||||
if(maatCfg.getIpCfg()==null){
|
||||
List<BaseIpCfg> list=new ArrayList<>();
|
||||
list.add(ipCfg);
|
||||
maatCfg.setIpCfg(list);
|
||||
}else{
|
||||
List<BaseIpCfg> list=maatCfg.getIpCfg();
|
||||
list.add(ipCfg);
|
||||
}
|
||||
}else{
|
||||
NumBoundaryCfg numCfg=new NumBoundaryCfg();
|
||||
numCfg.initDefaultValue();
|
||||
numCfg.setLowBounadry((long)protocolId);
|
||||
numCfg.setUpBoundary((long)protocolId);
|
||||
numCfg.setMaatTable(_maatTable);
|
||||
if(maatCfg.getNumCfg()==null){
|
||||
List<NumBoundaryCfg> numlist=new ArrayList<>();
|
||||
numlist.add(numCfg);
|
||||
maatCfg.setNumCfg(numlist);
|
||||
}else{
|
||||
List<NumBoundaryCfg> numlist=maatCfg.getNumCfg();
|
||||
numlist.add(numCfg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
throw new RuntimeException("protocolId等于0,却对应两个maat_table "+maatTable);
|
||||
}
|
||||
}else{
|
||||
if(maatCfg.getIpCfg()==null){
|
||||
List<BaseIpCfg> list=new ArrayList<>();
|
||||
list.add((BaseIpCfg)c);
|
||||
maatCfg.setIpCfg(list);
|
||||
}else{
|
||||
List<BaseIpCfg> list=maatCfg.getIpCfg();
|
||||
list.add((BaseIpCfg)c);
|
||||
}
|
||||
}
|
||||
}else if(c instanceof BaseStringCfg){
|
||||
compileId=compileId==0?c.getCompileId():compileId;
|
||||
String maatTable=c.getMaatTable();
|
||||
if(maatTable.contains(",")){
|
||||
for(String _maatTable:maatTable.split(",")){
|
||||
BaseStringCfg strCfg=(BaseStringCfg)c.clone();
|
||||
strCfg.setMaatTable(_maatTable);
|
||||
if(maatCfg.getStrCfg()==null){
|
||||
List<BaseStringCfg> list=new ArrayList<BaseStringCfg>();
|
||||
list.add(strCfg);
|
||||
maatCfg.setStrCfg(list);
|
||||
}else{
|
||||
List<BaseStringCfg> list=maatCfg.getStrCfg();
|
||||
list.add(strCfg);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(maatCfg.getStrCfg()==null){
|
||||
List<BaseStringCfg> list=new ArrayList<BaseStringCfg>();
|
||||
list.add((BaseStringCfg)c);
|
||||
maatCfg.setStrCfg(list);
|
||||
}else{
|
||||
List<BaseStringCfg> list=maatCfg.getStrCfg();
|
||||
list.add((BaseStringCfg)c);
|
||||
}
|
||||
}
|
||||
}else if(c instanceof ComplexkeywordCfg){
|
||||
compileId=compileId==0?c.getCompileId():compileId;
|
||||
String maatTable=c.getMaatTable();
|
||||
if(maatTable.contains(",")){
|
||||
for(String _maatTable:maatTable.split(",")){
|
||||
ComplexkeywordCfg complexCfg=(ComplexkeywordCfg)c.clone();
|
||||
complexCfg.setMaatTable(_maatTable);
|
||||
if(maatCfg.getComplexStrCfg()==null){
|
||||
List<ComplexkeywordCfg> list=new ArrayList<ComplexkeywordCfg>();
|
||||
list.add(complexCfg);
|
||||
maatCfg.setComplexStrCfg(list);
|
||||
}else{
|
||||
List<ComplexkeywordCfg> list=maatCfg.getComplexStrCfg();
|
||||
list.add(complexCfg);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(maatCfg.getComplexStrCfg()==null){
|
||||
List<ComplexkeywordCfg> list=new ArrayList<ComplexkeywordCfg>();
|
||||
list.add((ComplexkeywordCfg)c);
|
||||
maatCfg.setComplexStrCfg(list);
|
||||
}else{
|
||||
List<ComplexkeywordCfg> list=maatCfg.getComplexStrCfg();
|
||||
list.add((ComplexkeywordCfg)c);
|
||||
}
|
||||
}
|
||||
|
||||
}else if(c instanceof NumBoundaryCfg){
|
||||
compileId=compileId==0?c.getCompileId():compileId;
|
||||
if(maatCfg.getNumCfg()==null){
|
||||
List<NumBoundaryCfg> list=new ArrayList<NumBoundaryCfg>();
|
||||
list.add((NumBoundaryCfg)c);
|
||||
maatCfg.setNumCfg(list);
|
||||
}else{
|
||||
List<NumBoundaryCfg> list=maatCfg.getNumCfg();
|
||||
list.add((NumBoundaryCfg)c);
|
||||
}
|
||||
}
|
||||
if(c.getAreaCfg()!=null){
|
||||
if(toMaatBean.getAreaCfg()!=null){
|
||||
toMaatBean.getAreaCfg().addAll(c.getAreaCfg());
|
||||
}else{
|
||||
toMaatBean.setAreaCfg(new ArrayList<AreaIpCfg>());
|
||||
toMaatBean.getAreaCfg().addAll(c.getAreaCfg());
|
||||
}
|
||||
}
|
||||
}
|
||||
toMaatBean.getServiceCfg().add(maatCfg);
|
||||
BaseCfg baseCfg=(BaseCfg)cfg[0];
|
||||
if(compileId==0){
|
||||
throw new RuntimeException("转换出错,未获取到正确的compileId");
|
||||
}else{
|
||||
toMaatBean.setCompileId(compileId);
|
||||
}
|
||||
if(baseCfg.getAction()==null){
|
||||
throw new RuntimeException("转换出错,未获取到正确的action");
|
||||
}else{
|
||||
toMaatBean.setAction(baseCfg.getAction());
|
||||
}
|
||||
if(baseCfg.getIsAreaEffective()==null){
|
||||
throw new RuntimeException("转换出错,未获取到正确的isAreaEffective");
|
||||
}else{
|
||||
toMaatBean.setIsAreaEffective(baseCfg.getIsAreaEffective());
|
||||
}
|
||||
if(baseCfg.getIsValid()==null){
|
||||
throw new RuntimeException("转换出错,未获取到正确的isValid");
|
||||
}else{
|
||||
toMaatBean.setIsValid(baseCfg.getIsValid());
|
||||
}
|
||||
if(baseCfg.getRequestId()==null){
|
||||
throw new RuntimeException("转换出错,未获取到正确的requestId");
|
||||
}else{
|
||||
toMaatBean.setRequestId(baseCfg.getRequestId());
|
||||
}
|
||||
if(baseCfg.getServiceId()==null){
|
||||
throw new RuntimeException("转换出错,未获取到正确的serviceId");
|
||||
}else{
|
||||
toMaatBean.setServiceId(baseCfg.getServiceId());
|
||||
}
|
||||
toMaatBean.setAreaEffectiveIds(baseCfg.getAreaEffectiveIds()==null?"":baseCfg.getAreaEffectiveIds());
|
||||
toMaatBean.setAttribute(baseCfg.getAttribute()==null?"":baseCfg.getAttribute());
|
||||
toMaatBean.setClassify(baseCfg.getClassify()==null?"":baseCfg.getClassify());
|
||||
toMaatBean.setLable(baseCfg.getLable()==null?"":baseCfg.getLable());
|
||||
beans.add(toMaatBean);
|
||||
}
|
||||
String json=gson.toJson(beans);
|
||||
logger.info("to maat json:"+json);
|
||||
//发送至maat,待完成
|
||||
return new ConvertTool().saveConfig(json);
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
* sendToMaatConvertor(转换配置为Maat格式)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.nis.web.service.configuration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -7,6 +8,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.nis.domain.configuration.AreaIpCfg;
|
||||
import com.nis.domain.configuration.BaseCfg;
|
||||
import com.nis.domain.configuration.BaseIpCfg;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.web.dao.configuration.AreaIpCfgDao;
|
||||
@@ -76,17 +78,28 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public int auditIpCfg(BaseIpCfg sendCfg,BaseIpCfg baseIpCfg) throws Exception{
|
||||
if(Constants.AUDIT_NOT_YES==baseIpCfg.getIsAudit().intValue()||
|
||||
Constants.AUDIT_YES==baseIpCfg.getIsAudit().intValue()){//审核通过,取消审核通过需要发到maat
|
||||
if(sendToMaatConvertor(baseIpCfg.getIsAudit(),null,sendCfg)){
|
||||
return ipCfgDao.audit(baseIpCfg);
|
||||
public void auditIpCfg(int isAduit,List<BaseIpCfg> auditCfg,List<AreaIpCfg> areaCfg,List<BaseIpCfg> sendCfg) throws Exception{
|
||||
List<BaseCfg[]> sendCfgs=new ArrayList<BaseCfg[]>();
|
||||
for(BaseIpCfg c:sendCfg){
|
||||
BaseCfg[] cArr=new BaseCfg[1];
|
||||
cArr[0]=c;
|
||||
sendCfgs.add(cArr);
|
||||
}
|
||||
if(Constants.AUDIT_NOT_YES==isAduit||
|
||||
Constants.AUDIT_YES==isAduit){//审核通过,取消审核通过需要发到maat
|
||||
if(sendToMaatConvertorBatch(isAduit,sendCfgs)){
|
||||
if(areaCfg!=null&&areaCfg.size()>0){
|
||||
this.auditIpBatch(areaCfg);
|
||||
}
|
||||
this.auditBatch(auditCfg, IpCfgDao.class);
|
||||
}
|
||||
}else{
|
||||
return ipCfgDao.audit(baseIpCfg);
|
||||
if(areaCfg!=null&&areaCfg.size()>0){
|
||||
this.auditIpBatch(areaCfg);
|
||||
}
|
||||
this.auditBatch(auditCfg, IpCfgDao.class);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
/**
|
||||
*
|
||||
@@ -99,11 +112,16 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public int deleteIpCfg(BaseIpCfg baseIpCfg, List<AreaIpCfg> areaCfg){
|
||||
public void deleteIpCfg(List<BaseIpCfg> baseIpCfg, List<AreaIpCfg> areaCfg){
|
||||
List<BaseIpCfg> cfgs=new ArrayList<>();
|
||||
cfgs.addAll(areaCfg);
|
||||
if(areaCfg!=null&&areaCfg.size()>0){
|
||||
this.deleteIpBatch(areaCfg);
|
||||
this.deleteBatch(cfgs,IpCfgDao.class);
|
||||
}
|
||||
return ipCfgDao.updateValid(baseIpCfg);
|
||||
if(baseIpCfg!=null&&baseIpCfg.size()>0){
|
||||
this.deleteBatch(baseIpCfg, IpCfgDao.class);
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
*
|
||||
@@ -134,4 +152,7 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
public List<AreaIpCfg> getAreaCfgByCompileId(int compileId){
|
||||
return areaIpCfgDao.getByCompileId(compileId);
|
||||
}
|
||||
public List<BaseIpCfg> getList(String tableName,String ids){
|
||||
return ipCfgDao.getList(tableName,ids);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ $(function(){
|
||||
$(this).selectpicker("refresh");
|
||||
});
|
||||
obj.removeClass("hidden");
|
||||
switchIpType(obj.find("select[name$='ipType']"));
|
||||
obj.find("select[name$='ipType']").on("change",function(){
|
||||
switchIpType($(this));
|
||||
});
|
||||
@@ -181,7 +182,6 @@ function delAreaIsp(obj){
|
||||
<label class="control-label col-md-3"><font color="red">*</font><spring:message code="ip_type"/></label>
|
||||
<div class="col-md-6">
|
||||
<select id="_areaCfg.ipType" class="show-tick form-control required">
|
||||
<option value=""><spring:message code="select"/></option>
|
||||
<option value="4">V4</option>
|
||||
<option value="6">V6</option>
|
||||
</select>
|
||||
@@ -325,7 +325,6 @@ function delAreaIsp(obj){
|
||||
<label class="control-label col-md-3"><font color="red">*</font><spring:message code="ip_type"/></label>
|
||||
<div class="col-md-6">
|
||||
<select name="areaCfg[${status.index}].ipType" class="selectpicker show-tick form-control required">
|
||||
<option value=""><spring:message code="select"/></option>
|
||||
<option value="4" <c:if test="${areaCfg.ipType==4}">selected</c:if>>V4</option>
|
||||
<option value="6" <c:if test="${areaCfg.ipType==6}">selected</c:if>>V6</option>
|
||||
</select>
|
||||
|
||||
@@ -42,6 +42,19 @@
|
||||
$("#searchForm").submit();
|
||||
return false;
|
||||
}
|
||||
var edit=function(url){
|
||||
var cked = $('tbody tr td input.i-checks:checkbox:checked');
|
||||
if(cked.val()==1){
|
||||
top.$.jBox.tip("<spring:message code='has_approved'/>", "<spring:message code='info'/>");
|
||||
return;
|
||||
}
|
||||
if(cked.length==1){
|
||||
window.location = url+"&compileId="+cked.attr("id");
|
||||
}else{
|
||||
top.$.jBox.tip("<spring:message code='check_one'/>", "<spring:message code='info'/>");
|
||||
return;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
@@ -50,10 +63,12 @@
|
||||
<div class="theme-panel hidden-xs hidden-sm">
|
||||
<%-- <button type="button" class="btn btn-default" onclick="location='${ctx}/cfg/ip/list?serviceId=${serviceId}&action=${action}&cfgName=${cfgName}&audit=${audit}'"><spring:message code="refresh"></spring:message></button> --%>
|
||||
<c:if test="${audit==0}">
|
||||
<shiro:hasPermission name="cfg:ip:add">
|
||||
<button type="button" class="btn btn-primary"
|
||||
onClick="javascript:window.location='${ctx}/cfg/ip/form?serviceId=${serviceId}&action=${action}&cfgName=${cfgName}&audit=${audit}'">
|
||||
<i class="fa fa-plus"></i>
|
||||
<spring:message code="add"></spring:message></button>
|
||||
</shiro:hasPermission>
|
||||
</c:if>
|
||||
</div>
|
||||
<h3 class="page-title">
|
||||
@@ -104,72 +119,40 @@
|
||||
<input id="intype" class="form-control input-medium" type="text" value="">
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<%-- <div class="input-group">
|
||||
<div class="input-group-btn">
|
||||
<form:select path="seltype" class="selectpicker select2 input-small" >
|
||||
<form:option value="cfgDesc"><spring:message code="config_describe"></spring:message></form:option>
|
||||
<form:option value="srcIp"><spring:message code="client_ip"></spring:message></form:option>
|
||||
<form:option value="dstIp"><spring:message code="server_ip"></spring:message></form:option>
|
||||
</form:select>
|
||||
</div>
|
||||
|
||||
<input id="intype" class="form-control input-medium" type="text" value="">
|
||||
|
||||
<div class="input-group-btn">
|
||||
<button class="btn btn-default btn-search" type="button" onclick="page()"><i class="fa fa-search"></i></button>
|
||||
</div>
|
||||
|
||||
</div> --%>
|
||||
</div>
|
||||
<!-- <div class="pull-right">
|
||||
<button type="button" class="btn btn-default">
|
||||
<i class="fa fa-edit"></i> 编辑</button>
|
||||
<button type="button" class="btn btn-default">
|
||||
<i class="fa fa-trash"></i> 删除</button>
|
||||
<button type="button" class="btn btn-default">
|
||||
<i class="fa fa-download"></i> 导出</button>
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
|
||||
<i class="fa fa-wrench"></i> 审核
|
||||
<i class="fa fa-angle-down"></i>
|
||||
</button>
|
||||
<ul class="dropdown-menu pull-right">
|
||||
<li><a href="javascript:void(0);" onclick="passOpt()"><i class="fa fa-check"></i> 通过</a></li>
|
||||
<li><a href="javascript:void(0);" onclick="noPassOpt()"><i class="fa fa-remove"></i> 未通过</a></li>
|
||||
<li><a href="javascript:void(0);" onclick="cancelPassOpt()"><i class="fa fa-undo"></i> 配置取消</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<a class="btn btn-icon-only btn-default setfields tooltips"
|
||||
data-container="body" data-placement="top" data-original-title="自定义列字段" href="javascript:;">
|
||||
<i class="icon-wrench"></i>
|
||||
</a>
|
||||
</div> -->
|
||||
<%-- <button type="button" class="btn btn-default btn-sm" onclick="return page()">
|
||||
<i class="fa fa-edit"></i><spring:message code="search"></spring:message>
|
||||
</button> --%>
|
||||
|
||||
<%-- <div class="pull-left">
|
||||
<select name="orderBy" class="selectpicker select2 input-small">
|
||||
<option value="" <c:if test="${empty page.orderBy}">selected</c:if> ><spring:message code="sort"/></option>
|
||||
<option value="${page.alias}.create_time asc" <c:if test="${fn:contains(page.orderBy,'create_time asc') }">selected</c:if> ><spring:message code="createTime_asc"/></option>
|
||||
<option value="${page.alias}.create_time desc" <c:if test="${fn:contains(page.orderBy , 'create_time desc') }">selected</c:if> ><spring:message code="createTime_desc"/></option>
|
||||
<option value="${page.alias}.edit_time asc" <c:if test="${fn:contains(page.orderBy , 'edit_time asc') }">selected</c:if> ><spring:message code="editTime_asc"/></option>
|
||||
<option value="${page.alias}.edit_time desc" <c:if test="${fn:contains(page.orderBy , 'edit_time desc') }">selected</c:if> ><spring:message code="editTime_desc"/></option>
|
||||
<option value="${page.alias}.audit_time asc" <c:if test="${fn:contains(page.orderBy , 'audit_time asc') }">selected</c:if> ><spring:message code="auditTime_asc"/></option>
|
||||
<option value="${page.alias}.audit_time desc" <c:if test="${fn:contains(page.orderBy , 'audit_time desc') }">selected</c:if> ><spring:message code="auditTime_desc"/></option>
|
||||
</select>
|
||||
</div> --%>
|
||||
|
||||
<div class="pull-left">
|
||||
<button type="button" class="btn blue" onClick="return page()"> <i class="fa fa-search"></i> <spring:message code="search"/> </button>
|
||||
<button type="button" class="btn btn-default" id="resetBtn" > <i class="fa fa-refresh"></i> <spring:message code="reset"/> </button>
|
||||
<button type="button" class="btn btn-default" id="filter-btn"> 筛选 <i class="fa fa-angle-double-down"></i></button>
|
||||
<button type="button" class="btn btn-default" id="filter-btn"> <spring:message code="filter"/><i class="fa fa-angle-double-down"></i></button>
|
||||
</div>
|
||||
<div class="pull-right">
|
||||
<c:if test="${audit==0}">
|
||||
<shiro:hasPermission name="cfg:ip:edit">
|
||||
<button type="button" class="btn btn-default" onClick="edit('${ctx}/cfg/ip/updateForm?serviceId=${serviceId}&action=${action}&tableName=${tableName}&cfgName=${cfgName}')">
|
||||
<i class="fa fa-edit"></i> <spring:message code="edit"></spring:message></button>
|
||||
</shiro:hasPermission>
|
||||
<shiro:hasPermission name="cfg:ip:delete">
|
||||
<sys:delRow url="${ctx}/cfg/ip/delete?serviceId=${serviceId}&action=${action}&tableName=${tableName}&cfgName=${cfgName}" id="contentTable" label="delete"></sys:delRow>
|
||||
</shiro:hasPermission>
|
||||
<!-- <button type="button" class="btn btn-default">
|
||||
<i class="fa fa-download"></i> 导出</button> -->
|
||||
</c:if>
|
||||
|
||||
<shiro:hasPermission name="cfg:ip:audit">
|
||||
<c:if test="${audit==1}">
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
|
||||
<i class="fa fa-wrench"></i> <spring:message code="examine"></spring:message>
|
||||
<i class="fa fa-angle-down"></i>
|
||||
</button>
|
||||
<ul class="dropdown-menu pull-right">
|
||||
<li><sys:delRow url="${ctx}/cfg/ip/audit?serviceId=${serviceId}&action=${action}&tableName=${tableName}&cfgName=${cfgName}&isAudit=1" id="contentTable" label="approved"></sys:delRow></li>
|
||||
<li><sys:delRow url="${ctx}/cfg/ip/audit?serviceId=${serviceId}&action=${action}&tableName=${tableName}&cfgName=${cfgName}&isAudit=2" id="contentTable" label="unapproved"></sys:delRow></li>
|
||||
<li><sys:delRow url="${ctx}/cfg/ip/audit?serviceId=${serviceId}&action=${action}&tableName=${tableName}&cfgName=${cfgName}&isAudit=3" id="contentTable" label="cancelPass"></sys:delRow></li>
|
||||
</ul>
|
||||
</div>
|
||||
</c:if>
|
||||
</shiro:hasPermission>
|
||||
<a class="btn btn-icon-only btn-default setfields tooltips"
|
||||
data-container="body" data-placement="top" data-original-title=<spring:message code="custom_columns"/> href="javascript:;">
|
||||
<i class="icon-wrench"></i>
|
||||
@@ -303,6 +286,7 @@
|
||||
<table id="contentTable" class="table table-striped table-bordered table-condensed text-nowrap">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><input type="checkbox" class="i-checks" id="checkAll"></th>
|
||||
<%-- <th><spring:message code="seq"/></th> --%>
|
||||
<th><spring:message code="config_describe"/></th>
|
||||
<th>ip<spring:message code="type"/></th>
|
||||
@@ -340,12 +324,13 @@
|
||||
<th class="sort-column r.edit_time"><spring:message code="edit_time"/></th>
|
||||
<th><spring:message code="auditor"/></th>
|
||||
<th class="sort-column r.audit_time"><spring:message code="audit_time"/></th>
|
||||
<th><spring:message code="operation"></spring:message></th>
|
||||
<%-- <th><spring:message code="operation"></spring:message></th> --%>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<c:forEach items="${page.list }" var="ipCfg" varStatus="status" step="1">
|
||||
<tr pId="${status.index}">
|
||||
<td><input type="checkbox" class="i-checks" id="${ipCfg.compileId}" value="${ipCfg.isAudit}"></td>
|
||||
<%-- <td>${status.index+1 }</td> --%>
|
||||
<td>${ipCfg.cfgDesc }</td>
|
||||
<td>V${ipCfg.ipType }</td>
|
||||
@@ -440,7 +425,7 @@
|
||||
<td><fmt:formatDate value="${ipCfg.editTime }" pattern="yyyy-MM-dd HH:mm:ss"/></td>
|
||||
<td>${ipCfg.auditorName }</td>
|
||||
<td><fmt:formatDate value="${ipCfg.auditTime }" pattern="yyyy-MM-dd HH:mm:ss"/></td>
|
||||
<td>
|
||||
<%-- <td>
|
||||
<div class="btn-group btn-xs">
|
||||
<a class="btn btn-primary btn-xs dropdown-toggle" data-toggle="dropdown" href="#"><spring:message code="operation"></spring:message><span class="caret"></span></a>
|
||||
<ul class="dropdown-menu btn-xs">
|
||||
@@ -451,24 +436,24 @@
|
||||
</c:when>
|
||||
<c:when test="${ipCfg.isAudit eq '0'}">
|
||||
<li><a href="${ctx}/cfg/ip/updateForm?serviceId=${ipCfg.serviceId}&action=${ipCfg.action}&tableName=${ipCfg.tableName}&cfgId=${ipCfg.cfgId}&cfgName=${cfgName}" onclick="javascript:return confirm('sure?', this.href)"><spring:message code="edit"></spring:message></a></li>
|
||||
<li><a href="${ctx}/cfg/ip/deleteCfg?serviceId=${ipCfg.serviceId}&action=${ipCfg.action}&tableName=${ipCfg.tableName}&cfgId=${ipCfg.cfgId}&cfgName=${cfgName}&compileId=${ipCfg.compileId}" onclick="return confirm('sure?', this.href)"><spring:message code="delete"></spring:message></a></li>
|
||||
<li><a href="${ctx}/cfg/ip/delete?serviceId=${ipCfg.serviceId}&action=${ipCfg.action}&tableName=${ipCfg.tableName}&cfgId=${ipCfg.cfgId}&cfgName=${cfgName}&compileId=${ipCfg.compileId}" onclick="return confirm('sure?', this.href)"><spring:message code="delete"></spring:message></a></li>
|
||||
</c:when>
|
||||
</c:choose>
|
||||
</c:if>
|
||||
<c:if test="${audit==1}">
|
||||
<c:choose>
|
||||
<c:when test="${ipCfg.isAudit eq '1'}">
|
||||
<li><a href="${ctx}/cfg/ip/auditCfg?serviceId=${ipCfg.serviceId}&action=${ipCfg.action}&tableName=${ipCfg.tableName}&cfgId=${ipCfg.cfgId}&isAudit=3&cfgName=${cfgName}" onclick="return confirm('sure?', this.href)"><spring:message code="cancel"></spring:message></a></li>
|
||||
<li><a href="${ctx}/cfg/ip/audit?serviceId=${ipCfg.serviceId}&action=${ipCfg.action}&tableName=${ipCfg.tableName}&cfgId=${ipCfg.cfgId}&isAudit=3&cfgName=${cfgName}" onclick="return confirm('sure?', this.href)"><spring:message code="cancel"></spring:message></a></li>
|
||||
</c:when>
|
||||
<c:when test="${ipCfg.isAudit eq '0'}">
|
||||
<li><a href="${ctx}/cfg/ip/auditCfg?serviceId=${ipCfg.serviceId}&action=${ipCfg.action}&tableName=${ipCfg.tableName}&cfgId=${ipCfg.cfgId}&isAudit=1&cfgName=${cfgName}" onclick="return confirm('sure?', this.href)"><spring:message code="approved"></spring:message></a></li>
|
||||
<li><a href="${ctx}/cfg/ip/auditCfg?serviceId=${ipCfg.serviceId}&action=${ipCfg.action}&tableName=${ipCfg.tableName}&cfgId=${ipCfg.cfgId}&isAudit=2&cfgName=${cfgName}" onclick="return confirm('sure?', this.href)"><spring:message code="unapproved"></spring:message></a></li>
|
||||
<li><a href="${ctx}/cfg/ip/audit?serviceId=${ipCfg.serviceId}&action=${ipCfg.action}&tableName=${ipCfg.tableName}&cfgId=${ipCfg.cfgId}&isAudit=1&cfgName=${cfgName}" onclick="return confirm('sure?', this.href)"><spring:message code="approved"></spring:message></a></li>
|
||||
<li><a href="${ctx}/cfg/ip/audit?serviceId=${ipCfg.serviceId}&action=${ipCfg.action}&tableName=${ipCfg.tableName}&cfgId=${ipCfg.cfgId}&isAudit=2&cfgName=${cfgName}" onclick="return confirm('sure?', this.href)"><spring:message code="unapproved"></spring:message></a></li>
|
||||
</c:when>
|
||||
</c:choose>
|
||||
</c:if>
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
</td> --%>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</tbody>
|
||||
|
||||
@@ -169,7 +169,7 @@ jQuery.validator.addMethod("notStartZero",function(value, element) {
|
||||
//ip地址校验
|
||||
jQuery.validator.addMethod("ipCheck",function(value, element) {
|
||||
if(value.length==0||value.trim().length==0){return true;}
|
||||
var typeInt=$("select[name$='ipType']").val();
|
||||
var typeInt=$(element).parents(".row").siblings().find("select[name$='ipType']").val();
|
||||
if(typeInt==4){
|
||||
return this.optional(element)||(/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/.test(value) && (RegExp.$1 <256 && RegExp.$2<256 && RegExp.$3<256 && RegExp.$4<256));
|
||||
}else if(typeInt==6){
|
||||
@@ -179,7 +179,7 @@ jQuery.validator.addMethod("ipCheck",function(value, element) {
|
||||
jQuery.validator.addMethod("ipMask",function(value, element) {
|
||||
if(value.length==0||value.trim().length==0){return true;}
|
||||
obj=value;
|
||||
var typeInt=$("select[name$='ipType']").val();
|
||||
var typeInt=$(element).parents(".row").siblings().find("select[name$='ipType']").val();
|
||||
if(typeInt==4){
|
||||
if(obj=="255.255.255.255"){
|
||||
return true;
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
$(function(){
|
||||
//全选及取消
|
||||
$("#checkAll").change(function(){
|
||||
if($("#checkAll").prop("checked")){
|
||||
$("input.i-checks").prop("checked",true);
|
||||
}else{
|
||||
$("input.i-checks").prop("checked",false);
|
||||
}
|
||||
});
|
||||
});
|
||||
var switchIpType=function(obj){
|
||||
var type=$(obj).val();
|
||||
var row=$(obj).parents('.row');
|
||||
@@ -64,6 +74,18 @@ var switchIpType=function(obj){
|
||||
}else if($(dstIp).val()=="0.0.0.0"){
|
||||
$(dstIp).val("::");
|
||||
}
|
||||
if(!$(srcPort).val()){
|
||||
$(srcPort).val("0");
|
||||
}
|
||||
if(!$(dstPort).val()){
|
||||
$(dstPort).val("0");
|
||||
}
|
||||
if(!$(srcPortMask).val()){
|
||||
$(srcPortMask).val("65535");
|
||||
}
|
||||
if(!$(dstPortMask).val()){
|
||||
$(dstPortMask).val("65535");
|
||||
}
|
||||
}
|
||||
}
|
||||
var areaControlInit=function(){
|
||||
|
||||
Reference in New Issue
Block a user