diff --git a/lib/maat-tools-0.0.1-SNAPSHOT.jar b/lib/maat-tools-0.0.1-SNAPSHOT.jar new file mode 100644 index 000000000..ab1ffed3c Binary files /dev/null and b/lib/maat-tools-0.0.1-SNAPSHOT.jar differ diff --git a/src/main/java/com/nis/domain/configuration/AppIdCfg.java b/src/main/java/com/nis/domain/configuration/AppIdCfg.java index 6e66b5556..20281e980 100644 --- a/src/main/java/com/nis/domain/configuration/AppIdCfg.java +++ b/src/main/java/com/nis/domain/configuration/AppIdCfg.java @@ -32,11 +32,6 @@ public class AppIdCfg extends BaseCfg { */ private String appId; - /** - * 编译id - */ - private Integer compileId; - /** * appName * @return appName @@ -69,22 +64,6 @@ public class AppIdCfg extends BaseCfg { this.appId = appId; } - /** - * compileId - * @return compileId - */ - - public Integer getCompileId() { - return compileId; - } - - /** - * @param compileId the compileId to set - */ - public void setCompileId(Integer compileId) { - this.compileId = compileId; - } - /* (non-Javadoc) * @see com.nis.domain.configuration.BaseCfg#initDefaultValue() */ diff --git a/src/main/java/com/nis/domain/configuration/BaseCfg.java b/src/main/java/com/nis/domain/configuration/BaseCfg.java index e5e153481..f89173a85 100644 --- a/src/main/java/com/nis/domain/configuration/BaseCfg.java +++ b/src/main/java/com/nis/domain/configuration/BaseCfg.java @@ -22,7 +22,12 @@ import com.nis.domain.BaseEntity; * @version V1.0 */ public class BaseCfg extends BaseEntity { + protected String seltype;//选中类型,页面搜索用 protected String tableName; + /** + * 编译id + */ + protected Integer compileId ; @Expose @SerializedName("maatTable") protected String maatTable; @@ -630,6 +635,33 @@ public class BaseCfg extends BaseEntity { public void setSearch_audit_time_end(Date search_audit_time_end) { this.search_audit_time_end = search_audit_time_end; } + /** + * seltype + * @return seltype + */ + public String getSeltype() { + return seltype; + } + /** + * @param seltype the seltype to set + */ + public void setSeltype(String seltype) { + this.seltype = seltype; + } + /** + * compileId + * @return compileId + */ + + public Integer getCompileId() { + return compileId; + } + /** + * @param compileId the compileId to set + */ + public void setCompileId(Integer compileId) { + this.compileId = compileId; + } } diff --git a/src/main/java/com/nis/domain/configuration/BaseIpCfg.java b/src/main/java/com/nis/domain/configuration/BaseIpCfg.java index 67ea4bdd9..586c01a3c 100644 --- a/src/main/java/com/nis/domain/configuration/BaseIpCfg.java +++ b/src/main/java/com/nis/domain/configuration/BaseIpCfg.java @@ -98,10 +98,6 @@ public class BaseIpCfg extends BaseCfg { @Expose @SerializedName("protocolId") protected Integer protocolId ; - /** - * 编译id - */ - protected Long compileId ; /** * ipType * @return ipType @@ -270,20 +266,6 @@ public class BaseIpCfg extends BaseCfg { public void setProtocolId(Integer protocolId) { this.protocolId = protocolId; } - /** - * compileId - * @return compileId - */ - - public Long getCompileId() { - return compileId; - } - /** - * @param compileId the compileId to set - */ - public void setCompileId(Long compileId) { - this.compileId = compileId; - } @Override public void initDefaultValue(){ super.initDefaultValue(); diff --git a/src/main/java/com/nis/domain/configuration/BaseStringCfg.java b/src/main/java/com/nis/domain/configuration/BaseStringCfg.java index 47644c805..b5f99ee4c 100644 --- a/src/main/java/com/nis/domain/configuration/BaseStringCfg.java +++ b/src/main/java/com/nis/domain/configuration/BaseStringCfg.java @@ -47,10 +47,6 @@ public class BaseStringCfg extends BaseCfg { public void setCfgKeywords(String cfgKeywords) { this.cfgKeywords = cfgKeywords; } - /** - * 编译id - */ - protected Long compileId ; /** * 表达式类型 */ @@ -120,19 +116,5 @@ public class BaseStringCfg extends BaseCfg { super.initDefaultValue(); this.isHexbin = 0; } - /** - * compile_id - * @return compile_id - */ - - public Long getCompileId() { - return compileId; - } - /** - * @param compile_id the compile_id to set - */ - public void setCompileId(Long compileId) { - this.compileId = compileId; - } } diff --git a/src/main/java/com/nis/domain/configuration/ComplexkeywordCfg.java b/src/main/java/com/nis/domain/configuration/ComplexkeywordCfg.java index e97195218..22435b107 100644 --- a/src/main/java/com/nis/domain/configuration/ComplexkeywordCfg.java +++ b/src/main/java/com/nis/domain/configuration/ComplexkeywordCfg.java @@ -19,7 +19,6 @@ import com.google.gson.annotations.SerializedName; * @version V1.0 */ public class ComplexkeywordCfg extends BaseCfg{ - protected String tableName; /** * @Fields serialVersionUID:TODO(用一句话描述这个变量表示什么) * @@ -33,16 +32,14 @@ public class ComplexkeywordCfg extends BaseCfg{ @Expose @SerializedName("district") protected String district ; + protected String districtShowName; /** * 关键字 */ @Expose @SerializedName("keywords") protected String keywords; - /** - * 编译id - */ - protected Long compileId; + protected String keywordsShowName; /** * 表达式类型 */ @@ -89,20 +86,6 @@ public class ComplexkeywordCfg extends BaseCfg{ public void setKeywords(String keywords) { this.keywords = keywords; } - /** - * compileId - * @return compileId - */ - - public Long getCompileId() { - return compileId; - } - /** - * @param compileId the compileId to set - */ - public void setCompileId(Long compileId) { - this.compileId = compileId; - } /** * exprType * 继承此类的类会覆盖该方法写自己的缺省值 @@ -158,19 +141,4 @@ public class ComplexkeywordCfg extends BaseCfg{ this.isHexbin = 0 ; this.matchMethod=3; } - /** - * tableName - * @return tableName - */ - - public String getTableName() { - return tableName; - } - /** - * @param tableName the tableName to set - */ - public void setTableName(String tableName) { - this.tableName = tableName; - } - } diff --git a/src/main/java/com/nis/domain/configuration/DnsIpCfg.java b/src/main/java/com/nis/domain/configuration/DnsIpCfg.java index 7ecb69b8c..3219b0dde 100644 --- a/src/main/java/com/nis/domain/configuration/DnsIpCfg.java +++ b/src/main/java/com/nis/domain/configuration/DnsIpCfg.java @@ -10,6 +10,7 @@ package com.nis.domain.configuration; import java.util.Date; +import com.google.gson.annotations.Expose; import com.nis.domain.BaseEntity; import com.nis.domain.SysUser; @@ -25,6 +26,7 @@ public class DnsIpCfg extends BaseEntity { /** * 配置ID */ + @Expose private Long cfgId; /** * 配置描述 @@ -33,46 +35,57 @@ public class DnsIpCfg extends BaseEntity { /** * ip类型 */ + @Expose private Integer ipType; /** * 源IP地址 */ + @Expose private String srcIp; /** * 源地址掩码 */ + @Expose private String srcIpMask ; /** * 源端口 */ + @Expose private String srcPort ; /** * 源端口掩码 */ + @Expose private String srcPortMask ; /** * 目的IP地址 */ + @Expose private String dstIp ; /** * 目的地址掩码 */ + @Expose private String dstIpMask ; /** * 目的端口 */ + @Expose private String dstPort ; /** * 目的端口掩码 */ + @Expose private String dstPortMask ; /** * 方向 */ + @Expose private Integer direction ; /** * 方向 */ + @Expose private Integer protocol ; /** * 有效标识 diff --git a/src/main/java/com/nis/domain/configuration/MultipleCfg.java b/src/main/java/com/nis/domain/configuration/MultipleCfg.java new file mode 100644 index 000000000..a7c04354c --- /dev/null +++ b/src/main/java/com/nis/domain/configuration/MultipleCfg.java @@ -0,0 +1,156 @@ +/** + *@Title: MultipleCfg.java + *@Package com.nis.domain.configuration + *@Description TODO + *@author dell + *@date 2018年3月13日 上午8:59:32 + *@version 版本号 + */ +package com.nis.domain.configuration; + +import java.util.List; +import java.util.Map; + +/** + * @ClassName: MultipleCfg.java + * @Description: TODO + * @author (dell) + * @date 2018年3月13日 上午8:59:32 + * @version V1.0 + */ +public class MultipleCfg extends BaseCfg { + + /** + * @Fields serialVersionUID:TODO(用一句话描述这个变量表示什么) + * + * @since 1.0.0 + */ + + private static final long serialVersionUID = -8369567908781421920L; + private String mainTable; + private String mainTableType; + private List otherTables;//key 表名,value 类型 +// private BaseCfg mainCfg; + //ip配置 + private Map ipCfg; + //字符串配置 + private Map stringCfg; + //数值类配置 + private Map numCfg; + //增强字符串配置 + private Map complexCfg; + //地域配置 + private AreaIpCfg areaIpCfg; + /** + * mainTable + * @return mainTable + */ + + public String getMainTable() { + return mainTable; + } + /** + * @param mainTable the mainTable to set + */ + public void setMainTable(String mainTable) { + this.mainTable = mainTable; + } + /** + * areaIpCfg + * @return areaIpCfg + */ + + public AreaIpCfg getAreaIpCfg() { + return areaIpCfg; + } + /** + * @param areaIpCfg the areaIpCfg to set + */ + public void setAreaIpCfg(AreaIpCfg areaIpCfg) { + this.areaIpCfg = areaIpCfg; + } + /** + * ipCfg + * @return ipCfg + */ + + public Map getIpCfg() { + return ipCfg; + } + /** + * @param ipCfg the ipCfg to set + */ + public void setIpCfg(Map ipCfg) { + this.ipCfg = ipCfg; + } + /** + * stringCfg + * @return stringCfg + */ + + public Map getStringCfg() { + return stringCfg; + } + /** + * @param stringCfg the stringCfg to set + */ + public void setStringCfg(Map stringCfg) { + this.stringCfg = stringCfg; + } + /** + * numCfg + * @return numCfg + */ + + public Map getNumCfg() { + return numCfg; + } + /** + * @param numCfg the numCfg to set + */ + public void setNumCfg(Map numCfg) { + this.numCfg = numCfg; + } + /** + * complexCfg + * @return complexCfg + */ + + public Map getComplexCfg() { + return complexCfg; + } + /** + * @param complexCfg the complexCfg to set + */ + public void setComplexCfg(Map complexCfg) { + this.complexCfg = complexCfg; + } + /** + * mainTableType + * @return mainTableType + */ + + public String getMainTableType() { + return mainTableType; + } + /** + * @param mainTableType the mainTableType to set + */ + public void setMainTableType(String mainTableType) { + this.mainTableType = mainTableType; + } + /** + * otherTables + * @return otherTables + */ + + public List getOtherTables() { + return otherTables; + } + /** + * @param otherTables the otherTables to set + */ + public void setOtherTables(List otherTables) { + this.otherTables = otherTables; + } +} diff --git a/src/main/java/com/nis/domain/configuration/MultipleSearchCfg.java b/src/main/java/com/nis/domain/configuration/MultipleSearchCfg.java new file mode 100644 index 000000000..76500dcbc --- /dev/null +++ b/src/main/java/com/nis/domain/configuration/MultipleSearchCfg.java @@ -0,0 +1,200 @@ +/** + *@Title: MultipleCfg.java + *@Package com.nis.domain.configuration + *@Description TODO + *@author dell + *@date 2018年3月13日 上午8:59:32 + *@version 版本号 + */ +package com.nis.domain.configuration; + +import java.util.List; + +/** + * @ClassName: MultipleCfg.java + * @Description: TODO + * @author (dell) + * @date 2018年3月13日 上午8:59:32 + * @version V1.0 + */ +public class MultipleSearchCfg extends BaseCfg { + + /** + * @Fields serialVersionUID:TODO(用一句话描述这个变量表示什么) + * + * @since 1.0.0 + */ + + private static final long serialVersionUID = -8369567908781421920L; + private String mainTable;//主表名 + private String mainTableType;//主表类型 + private String ipTable;//查询条件IP表名,界面限制查询条件除了共用属性之外只能查一个条件 + private String stringTable;//查询条件字符串表名,界面限制查询条件除了共用属性之外只能查一个条件 + private String complexTable;//查询条件增强字符串串表名,界面限制查询条件除了共用属性之外只能查一个条件 + private List otherTables;//key 表名,value 类型 + //ip配置 + private BaseIpCfg ipCfg; + //字符串配置 + private BaseStringCfg stringCfg; + //数值类配置 + private NumBoundaryCfg numCfg; + //增强字符串配置 + private ComplexkeywordCfg complexCfg; + //地域配置 + private AreaIpCfg areaIpCfg; + /** + * mainTable + * @return mainTable + */ + + public String getMainTable() { + return mainTable; + } + /** + * @param mainTable the mainTable to set + */ + public void setMainTable(String mainTable) { + this.mainTable = mainTable; + } + /** + * ipCfg + * @return ipCfg + */ + + public BaseIpCfg getIpCfg() { + return ipCfg; + } + /** + * @param ipCfg the ipCfg to set + */ + public void setIpCfg(BaseIpCfg ipCfg) { + this.ipCfg = ipCfg; + } + /** + * stringCfg + * @return stringCfg + */ + + public BaseStringCfg getStringCfg() { + return stringCfg; + } + /** + * @param stringCfg the stringCfg to set + */ + public void setStringCfg(BaseStringCfg stringCfg) { + this.stringCfg = stringCfg; + } + /** + * numCfg + * @return numCfg + */ + + public NumBoundaryCfg getNumCfg() { + return numCfg; + } + /** + * @param numCfg the numCfg to set + */ + public void setNumCfg(NumBoundaryCfg numCfg) { + this.numCfg = numCfg; + } + /** + * complexCfg + * @return complexCfg + */ + + public ComplexkeywordCfg getComplexCfg() { + return complexCfg; + } + /** + * @param complexCfg the complexCfg to set + */ + public void setComplexCfg(ComplexkeywordCfg complexCfg) { + this.complexCfg = complexCfg; + } + /** + * areaIpCfg + * @return areaIpCfg + */ + + public AreaIpCfg getAreaIpCfg() { + return areaIpCfg; + } + /** + * @param areaIpCfg the areaIpCfg to set + */ + public void setAreaIpCfg(AreaIpCfg areaIpCfg) { + this.areaIpCfg = areaIpCfg; + } + /** + * mainTableType + * @return mainTableType + */ + + public String getMainTableType() { + return mainTableType; + } + /** + * @param mainTableType the mainTableType to set + */ + public void setMainTableType(String mainTableType) { + this.mainTableType = mainTableType; + } + /** + * otherTables + * @return otherTables + */ + + public List getOtherTables() { + return otherTables; + } + /** + * @param otherTables the otherTables to set + */ + public void setOtherTables(List otherTables) { + this.otherTables = otherTables; + } + /** + * ipTable + * @return ipTable + */ + + public String getIpTable() { + return ipTable; + } + /** + * @param ipTable the ipTable to set + */ + public void setIpTable(String ipTable) { + this.ipTable = ipTable; + } + /** + * stringTable + * @return stringTable + */ + + public String getStringTable() { + return stringTable; + } + /** + * @param stringTable the stringTable to set + */ + public void setStringTable(String stringTable) { + this.stringTable = stringTable; + } + /** + * complexTable + * @return complexTable + */ + + public String getComplexTable() { + return complexTable; + } + /** + * @param complexTable the complexTable to set + */ + public void setComplexTable(String complexTable) { + this.complexTable = complexTable; + } + +} diff --git a/src/main/java/com/nis/domain/configuration/NumBoundaryCfg.java b/src/main/java/com/nis/domain/configuration/NumBoundaryCfg.java index f00eec491..8e917a89a 100644 --- a/src/main/java/com/nis/domain/configuration/NumBoundaryCfg.java +++ b/src/main/java/com/nis/domain/configuration/NumBoundaryCfg.java @@ -39,7 +39,6 @@ public class NumBoundaryCfg extends BaseCfg { @Expose @SerializedName("upBoundary") protected Long upBoundary; - protected Long compileId; /* (non-Javadoc) * @see com.nis.domain.configuration.BaseCfg#initDefaultValue() */ @@ -76,19 +75,4 @@ public class NumBoundaryCfg extends BaseCfg { public void setUpBoundary(Long upBoundary) { this.upBoundary = upBoundary; } - /** - * compileId - * @return compileId - */ - - public Long getCompileId() { - return compileId; - } - /** - * @param compileId the compileId to set - */ - public void setCompileId(Long compileId) { - this.compileId = compileId; - } - } diff --git a/src/main/java/com/nis/domain/configuration/TableBean.java b/src/main/java/com/nis/domain/configuration/TableBean.java new file mode 100644 index 000000000..62ad3ba8f --- /dev/null +++ b/src/main/java/com/nis/domain/configuration/TableBean.java @@ -0,0 +1,80 @@ +/** + *@Title: TableBean.java + *@Package com.nis.domain.configuration + *@Description TODO + *@author dell + *@date 2018年3月24日 下午5:20:51 + *@version 版本号 + */ +package com.nis.domain.configuration; + +import java.io.Serializable; + +/** + * @ClassName: TableBean.java + * @Description: TODO + * @author (dell) + * @date 2018年3月24日 下午5:20:51 + * @version V1.0 + */ +public class TableBean implements Serializable{ + /** + * @Fields serialVersionUID:TODO(用一句话描述这个变量表示什么) + * + * @since 1.0.0 + */ + + private static final long serialVersionUID = -7276874824312210708L; + private String tableName; + private String tableType; + private boolean canEmpty; + public TableBean(){ + + } + public TableBean(String tableName,String tableType){ + this.tableName=tableName; + this.tableType=tableType; + } + /** + * tableName + * @return tableName + */ + + public String getTableName() { + return tableName; + } + /** + * @param tableName the tableName to set + */ + public void setTableName(String tableName) { + this.tableName = tableName; + } + /** + * tableType + * @return tableType + */ + + public String getTableType() { + return tableType; + } + /** + * @param tableType the tableType to set + */ + public void setTableType(String tableType) { + this.tableType = tableType; + } + /** + * canEmpty + * @return canEmpty + */ + + public boolean isCanEmpty() { + return canEmpty; + } + /** + * @param canEmpty the canEmpty to set + */ + public void setCanEmpty(boolean canEmpty) { + this.canEmpty = canEmpty; + } +} diff --git a/src/main/java/com/nis/domain/maat/DnsIpRecvData.java b/src/main/java/com/nis/domain/maat/DnsIpRecvData.java new file mode 100644 index 000000000..fe568816a --- /dev/null +++ b/src/main/java/com/nis/domain/maat/DnsIpRecvData.java @@ -0,0 +1,30 @@ +package com.nis.domain.maat; + +import java.io.Serializable; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class DnsIpRecvData implements Serializable { + + private static final long serialVersionUID = -3438469380427993582L; + @Expose + @SerializedName("cfgId") + private Long cfgId; + @Expose + @SerializedName("fakeId") + private Integer fakeId; + + public Long getCfgId() { + return cfgId; + } + public void setCfgId(Long cfgId) { + this.cfgId = cfgId; + } + public Integer getFakeId() { + return fakeId; + } + public void setFakeId(Integer fakeId) { + this.fakeId = fakeId; + } +} diff --git a/src/main/java/com/nis/domain/maat/FromMaatBean.java b/src/main/java/com/nis/domain/maat/FromMaatBean.java new file mode 100644 index 000000000..41ecc6802 --- /dev/null +++ b/src/main/java/com/nis/domain/maat/FromMaatBean.java @@ -0,0 +1,24 @@ +package com.nis.domain.maat; + +import java.io.Serializable; +import java.util.List; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class FromMaatBean implements Serializable { + + private static final long serialVersionUID = 1277140754421705676L; + @Expose + @SerializedName("data") + private List data; + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + +} diff --git a/src/main/java/com/nis/domain/maat/MaatCfg.java b/src/main/java/com/nis/domain/maat/MaatCfg.java index 5a731b75b..1cecaf7b6 100644 --- a/src/main/java/com/nis/domain/maat/MaatCfg.java +++ b/src/main/java/com/nis/domain/maat/MaatCfg.java @@ -9,6 +9,7 @@ package com.nis.domain.maat; import java.io.Serializable; +import java.util.List; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; @@ -35,28 +36,28 @@ public class MaatCfg implements Serializable { private static final long serialVersionUID = -7745084076394247318L; @Expose @SerializedName("strCfg") - private BaseStringCfg[] strCfg; + private List strCfg; @Expose @SerializedName("ipCfg") - private BaseIpCfg[] ipCfg; + private List ipCfg; @Expose @SerializedName("numCfg") - private NumBoundaryCfg[] numCfg; + private List numCfg; @Expose @SerializedName("complexStrCfg") - private ComplexkeywordCfg[] complexStrCfg; + private List complexStrCfg; /** * strCfg * @return strCfg */ - public BaseStringCfg[] getStrCfg() { + public List getStrCfg() { return strCfg; } /** * @param strCfg the strCfg to set */ - public void setStrCfg(BaseStringCfg[] strCfg) { + public void setStrCfg(List strCfg) { this.strCfg = strCfg; } /** @@ -64,13 +65,13 @@ public class MaatCfg implements Serializable { * @return ipCfg */ - public BaseIpCfg[] getIpCfg() { + public List getIpCfg() { return ipCfg; } /** * @param ipCfg the ipCfg to set */ - public void setIpCfg(BaseIpCfg[] ipCfg) { + public void setIpCfg(List ipCfg) { this.ipCfg = ipCfg; } /** @@ -78,13 +79,13 @@ public class MaatCfg implements Serializable { * @return numCfg */ - public NumBoundaryCfg[] getNumCfg() { + public List getNumCfg() { return numCfg; } /** * @param numCfg the numCfg to set */ - public void setNumCfg(NumBoundaryCfg[] numCfg) { + public void setNumCfg(List numCfg) { this.numCfg = numCfg; } /** @@ -92,13 +93,13 @@ public class MaatCfg implements Serializable { * @return complexStrCfg */ - public ComplexkeywordCfg[] getComplexStrCfg() { + public List getComplexStrCfg() { return complexStrCfg; } /** * @param complexStrCfg the complexStrCfg to set */ - public void setComplexStrCfg(ComplexkeywordCfg[] complexStrCfg) { + public void setComplexStrCfg(List complexStrCfg) { this.complexStrCfg = complexStrCfg; } diff --git a/src/main/java/com/nis/domain/maat/MaatDnsIpCfg.java b/src/main/java/com/nis/domain/maat/MaatDnsIpCfg.java new file mode 100644 index 000000000..3c3112d9f --- /dev/null +++ b/src/main/java/com/nis/domain/maat/MaatDnsIpCfg.java @@ -0,0 +1,24 @@ +package com.nis.domain.maat; + +import java.io.Serializable; +import java.util.List; + +import com.google.gson.annotations.Expose; +import com.nis.domain.configuration.DnsIpCfg; + +public class MaatDnsIpCfg implements Serializable { + + private static final long serialVersionUID = 2407058503197501569L; + + @Expose + private List ipCfg; + + public List getIpCfg() { + return ipCfg; + } + + public void setIpCfg(List ipCfg) { + this.ipCfg = ipCfg; + } + +} diff --git a/src/main/java/com/nis/domain/maat/ToMaatBean.java b/src/main/java/com/nis/domain/maat/ToMaatBean.java index 8adca69c4..b892a799d 100644 --- a/src/main/java/com/nis/domain/maat/ToMaatBean.java +++ b/src/main/java/com/nis/domain/maat/ToMaatBean.java @@ -9,15 +9,11 @@ package com.nis.domain.maat; import java.io.Serializable; -import java.util.ArrayList; import java.util.List; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; import com.nis.domain.configuration.AreaIpCfg; -import com.nis.domain.configuration.IpPortCfg; /** * @ClassName: ToMaatBean.java @@ -37,7 +33,7 @@ public class ToMaatBean implements Serializable{ private static final long serialVersionUID = 5123156423588372849L; @Expose @SerializedName("serviceCfg") - private List serviceCfg; + private List serviceCfg; @Expose @SerializedName("areaCfg") private List areaCfg; @@ -58,7 +54,7 @@ public class ToMaatBean implements Serializable{ private String lable; @Expose @SerializedName("compileId") - private Long compileId; + private Integer compileId; @Expose @SerializedName("isAreaEffective") private Integer isAreaEffective; @@ -72,18 +68,19 @@ public class ToMaatBean implements Serializable{ @SerializedName("serviceId") private Integer serviceId; + /** * serviceCfg * @return serviceCfg */ - public List getServiceCfg() { + public List getServiceCfg() { return serviceCfg; } /** * @param serviceCfg the serviceCfg to set */ - public void setServiceCfg(List serviceCfg) { + public void setServiceCfg(List serviceCfg) { this.serviceCfg = serviceCfg; } /** @@ -176,13 +173,13 @@ public class ToMaatBean implements Serializable{ * @return compileId */ - public Long getCompileId() { + public Integer getCompileId() { return compileId; } /** * @param compileId the compileId to set */ - public void setCompileId(Long compileId) { + public void setCompileId(Integer compileId) { this.compileId = compileId; } /** @@ -242,22 +239,6 @@ public class ToMaatBean implements Serializable{ this.serviceId = serviceId; } public static void main(String[] args) { - Gson gson=new GsonBuilder().disableHtmlEscaping() - .setDateFormat("yyyy-MM-dd HH:mm:ss") - .setPrettyPrinting()/*.serializeNulls()*/ - .excludeFieldsWithoutExposeAnnotation() - .create(); - ToMaatBean bean=new ToMaatBean(); - List cfg=new ArrayList<>(); - MaatCfg[] ma=new MaatCfg[1]; - MaatCfg mc=new MaatCfg(); - IpPortCfg[] a=new IpPortCfg[1]; - a[0]=new IpPortCfg(); - mc.setIpCfg(a); - ma[0]=mc; - cfg.add(ma); - bean.setServiceCfg(cfg); - System.out.println(gson.toJson(bean)); } } diff --git a/src/main/java/com/nis/domain/maat/ToMaatDnsIpBean.java b/src/main/java/com/nis/domain/maat/ToMaatDnsIpBean.java new file mode 100644 index 000000000..206c95c7d --- /dev/null +++ b/src/main/java/com/nis/domain/maat/ToMaatDnsIpBean.java @@ -0,0 +1,62 @@ +package com.nis.domain.maat; + +import java.io.Serializable; +import java.util.List; + +import com.google.gson.annotations.Expose; + +public class ToMaatDnsIpBean implements Serializable { + + private static final long serialVersionUID = 5124353996884030213L; + + @Expose + private List serviceCfg; + @Expose + private String attribute; + @Expose + private String classify; + @Expose + private Integer isValid; + @Expose + private String lable; + @Expose + private Integer requestId; + + public List getServiceCfg() { + return serviceCfg; + } + public void setServiceCfg(List serviceCfg) { + this.serviceCfg = serviceCfg; + } + public String getAttribute() { + return attribute; + } + public void setAttribute(String attribute) { + this.attribute = attribute; + } + public String getClassify() { + return classify; + } + public void setClassify(String classify) { + this.classify = classify; + } + public Integer getIsValid() { + return isValid; + } + public void setIsValid(Integer isValid) { + this.isValid = isValid; + } + public String getLable() { + return lable; + } + public void setLable(String lable) { + this.lable = lable; + } + public Integer getRequestId() { + return requestId; + } + public void setRequestId(Integer requestId) { + this.requestId = requestId; + } + +} diff --git a/src/main/java/com/nis/domain/maat/ToMaatUnAuditBean.java b/src/main/java/com/nis/domain/maat/ToMaatUnAuditBean.java new file mode 100644 index 000000000..a05f22baa --- /dev/null +++ b/src/main/java/com/nis/domain/maat/ToMaatUnAuditBean.java @@ -0,0 +1,51 @@ +/** + *@Title: ToMaatBean.java + *@Package com.nis.domain.configuration + *@Description TODO + *@author dell + *@date 2018年2月28日 下午2:03:08 + *@version 版本号 + */ +package com.nis.domain.maat; + +import java.io.Serializable; +import java.util.List; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +/** + * @ClassName: ToMaatBean.java + * @Description: TODO + * @author (dell) + * @date 2018年2月28日 下午2:03:08 + * @version V1.0 + */ +public class ToMaatUnAuditBean implements Serializable{ + + /** + * @Fields serialVersionUID:TODO(转换为maat格式的java bean) + * + * @since 1.0.0 + */ + + private static final long serialVersionUID = 5123156423588372849L; + @Expose + @SerializedName("serviceCfg") + private List serviceCfg; + /** + * serviceCfg + * @return serviceCfg + */ + + public List getServiceCfg() { + return serviceCfg; + } + /** + * @param serviceCfg the serviceCfg to set + */ + public void setServiceCfg(List serviceCfg) { + this.serviceCfg = serviceCfg; + } + +} diff --git a/src/main/java/com/nis/domain/maat/UnAuditBean.java b/src/main/java/com/nis/domain/maat/UnAuditBean.java new file mode 100644 index 000000000..8dd8b8ec5 --- /dev/null +++ b/src/main/java/com/nis/domain/maat/UnAuditBean.java @@ -0,0 +1,66 @@ +/** + *@Title: UnAuditBean.java + *@Package com.nis.domain.maat + *@Description TODO + *@author dell + *@date 2018年3月26日 下午1:30:07 + *@version 版本号 + */ +package com.nis.domain.maat; + +import java.io.Serializable; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +/** + * @ClassName: UnAuditBean.java + * @Description: TODO + * @author (dell) + * @date 2018年3月26日 下午1:30:07 + * @version V1.0 + */ +public class UnAuditBean implements Serializable{ + + /** + * @Fields serialVersionUID:TODO(用一句话描述这个变量表示什么) + * + * @since 1.0.0 + */ + + private static final long serialVersionUID = -3497633085090859526L; + @Expose + @SerializedName("compileId") + private Integer compileId; + @Expose + @SerializedName("maatTable") + private String maatTable; + /** + * compileId + * @return compileId + */ + + public Integer getCompileId() { + return compileId; + } + /** + * @param compileId the compileId to set + */ + public void setCompileId(Integer compileId) { + this.compileId = compileId; + } + /** + * maatTable + * @return maatTable + */ + + public String getMaatTable() { + return maatTable; + } + /** + * @param maatTable the maatTable to set + */ + public void setMaatTable(String maatTable) { + this.maatTable = maatTable; + } +} diff --git a/src/main/java/com/nis/util/Constants.java b/src/main/java/com/nis/util/Constants.java index d9e85751c..ccf3c5578 100644 --- a/src/main/java/com/nis/util/Constants.java +++ b/src/main/java/com/nis/util/Constants.java @@ -11,7 +11,13 @@ public final class Constants { public static final String DEFAULT_CAPTCHA_PARAM = "captcha"; public static final String DEFAULT_MOBILE_PARAM = "mobileLogin"; public static final String DEFAULT_MESSAGE_PARAM = "message"; - + /** + * 表类型 + */ + public static final int TABLE_TYPE_IP = 1; + public static final int TABLE_TYPE_STRING = 2; + public static final int TABLE_TYPE_NUMBER = 3; + public static final int TABLE_TYPE_COMPLEX = 4; /** * 词典数据key */ diff --git a/src/main/java/com/nis/web/controller/configuration/ComplexStringCfgController.java b/src/main/java/com/nis/web/controller/configuration/ComplexStringCfgController.java index b0d980bfc..18b647137 100644 --- a/src/main/java/com/nis/web/controller/configuration/ComplexStringCfgController.java +++ b/src/main/java/com/nis/web/controller/configuration/ComplexStringCfgController.java @@ -13,10 +13,10 @@ import org.springframework.web.bind.annotation.RequestMapping; import com.nis.domain.Page; import com.nis.domain.ServiceConfigInfo; -import com.nis.domain.configuration.BaseCfg; +import com.nis.domain.basics.ServiceDictInfo; import com.nis.domain.configuration.ComplexkeywordCfg; import com.nis.domain.configuration.RequestInfo; -import com.nis.domain.basics.ServiceDictInfo; +import com.nis.main.ConvertTool; import com.nis.util.Constants; import com.nis.web.controller.BaseController; @@ -74,44 +74,39 @@ public class ComplexStringCfgController extends BaseController{ model.addAttribute("serviceId", serviceId); model.addAttribute("audit", Constants.CFG_PAGE); logger.info("sercice id is "+serviceId); - if(serviceId!=null){ - ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); - if(serviceConfigInfo!=null){ - String tableName=serviceConfigInfo.getTableName(); - if(!StringUtils.isBlank(tableName)){ - logger.info("table name is "+tableName); - String className=complexStringCfgService.getClassName(tableName); - logger.info("class name is "+className); - String packageName=ComplexkeywordCfg.class.getPackage().getName(); - try { - //通过反射获得ComplexkeywordCfg的子类的实例,并调用子类的initDefaultValue初始化默认值 - Class clazz=Class.forName(packageName+"."+className); - ComplexkeywordCfg cfg=(ComplexkeywordCfg)clazz.newInstance(); - cfg.setTableName(tableName); - cfg.initDefaultValue(); - cfg.setAction(action); - cfg.setServiceId(serviceId); - model.addAttribute("_cfg", cfg); - model.addAttribute("tableName", tableName); - List requestInfos=requestInfoService.getValidRequestInfo(); - model.addAttribute("requestInfos", requestInfos); - List fls=serviceDictInfoService.findFlDict(); - model.addAttribute("fls", fls); - List xzs=serviceDictInfoService.findXzDict(); - model.addAttribute("xzs", xzs); - List lables=serviceDictInfoService.findLableDict(); - model.addAttribute("lables", lables); - } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { - // TODO Auto-generated catch block - logger.error("打开新增IP窗口失败",e); - e.printStackTrace(); - } + ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); + if(serviceConfigInfo!=null){ + String tableName=serviceConfigInfo.getTableName(); + if(!StringUtils.isBlank(tableName)){ + logger.info("table name is "+tableName); + String className=complexStringCfgService.getClassName(tableName); + logger.info("class name is "+className); + String packageName=ComplexkeywordCfg.class.getPackage().getName(); + try { + //通过反射获得ComplexkeywordCfg的子类的实例,并调用子类的initDefaultValue初始化默认值 + Class clazz=Class.forName(packageName+"."+className); + ComplexkeywordCfg cfg=(ComplexkeywordCfg)clazz.newInstance(); + cfg.setTableName(tableName); + cfg.initDefaultValue(); + cfg.setAction(action); + cfg.setServiceId(serviceId); + model.addAttribute("_cfg", cfg); + model.addAttribute("tableName", tableName); + List requestInfos=requestInfoService.getValidRequestInfo(); + model.addAttribute("requestInfos", requestInfos); + List fls=serviceDictInfoService.findFlDict(); + model.addAttribute("fls", fls); + List xzs=serviceDictInfoService.findXzDict(); + model.addAttribute("xzs", xzs); + List lables=serviceDictInfoService.findLableDict(); + model.addAttribute("lables", lables); + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { + // TODO Auto-generated catch block + logger.error("打开新增IP窗口失败",e); + e.printStackTrace(); } } - }else{ - logger.error("未获取到正确的serviceId"); } - return "/cfg/complexCfgForm"; } @RequestMapping(value = {"updateForm"}) @@ -121,7 +116,13 @@ public class ComplexStringCfgController extends BaseController{ model.addAttribute("action", action); model.addAttribute("tableName", tableName); model.addAttribute("audit", Constants.CFG_PAGE); - if(!StringUtils.isBlank(tableName)){ + try{ + if(StringUtils.isBlank(tableName)){ + ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); + if(serviceConfigInfo!=null){ + tableName=serviceConfigInfo.getTableName(); + } + } logger.info("table name is "+tableName); ComplexkeywordCfg searchBean=new ComplexkeywordCfg(); searchBean.setCfgId(cfgId); @@ -136,32 +137,9 @@ public class ComplexStringCfgController extends BaseController{ model.addAttribute("xzs", xzs); List lables=serviceDictInfoService.findAllLableDict(); model.addAttribute("lables", lables); - }else if(serviceId!=null){ - ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); - if(serviceConfigInfo!=null){ - tableName=serviceConfigInfo.getTableName(); - if(!StringUtils.isBlank(tableName)){ - logger.info("table name is "+tableName); - ComplexkeywordCfg searchBean=new ComplexkeywordCfg(); - searchBean.setCfgId(cfgId); - searchBean.setTableName(tableName); - ComplexkeywordCfg cfg=complexStringCfgService.getStringCfgById(searchBean); - model.addAttribute("_cfg", cfg); - List requestInfos=requestInfoService.getAllRequestInfo(); - model.addAttribute("requestInfos", requestInfos); - List fls=serviceDictInfoService.findAllFlDict(); - model.addAttribute("fls", fls); - List xzs=serviceDictInfoService.findAllXzDict(); - model.addAttribute("xzs", xzs); - List lables=serviceDictInfoService.findAllLableDict(); - model.addAttribute("lables", lables); - - } - } - }else{ - logger.error("未获取到正确的表名"); + }catch(Exception e){ + logger.error("发生异常", e); } - return "/cfg/complexCfgForm"; } @@ -179,15 +157,21 @@ public class ComplexStringCfgController extends BaseController{ model.addAttribute("cfgName",cfgName); model.addAttribute("cfgType","complex"); model.addAttribute("audit", Constants.CFG_PAGE); + model.addAttribute("serviceId",cfg.getServiceId()); + model.addAttribute("action",cfg.getAction()); logger.info("saveOrUpdateStringCfg loaded"); - if(cfg==null){ - logger.error("无法保存空的配置!"); - addMessage(model,"保存失败!"); - }else if(!StringUtils.isBlank(cfg.getTableName())){ + try { + String tableName=cfg.getTableName(); int serviceId=cfg.getServiceId(); - long compileId=getCompileId(cfg); -// cfg.setCreatorId(cfg.getCurrentUser().getId()); -// cfg.setCreateTime(new Date()); + if(StringUtils.isBlank(cfg.getTableName())){ + + ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); + if(serviceConfigInfo!=null){ + tableName=serviceConfigInfo.getTableName(); + cfg.setTableName(tableName); + } + } + int compileId = new ConvertTool().getCompileId(); cfg.setIsValid(Constants.VALID_NO); cfg.setIsAudit(Constants.AUDIT_NOT_YET); cfg.setCompileId(compileId); @@ -200,41 +184,13 @@ public class ComplexStringCfgController extends BaseController{ cfg.setEditTime(new Date()); complexStringCfgService.updateStringCfg(cfg); } - model.addAttribute("serviceId",serviceId); - model.addAttribute("action",cfg.getAction()); addMessage(model,"保存成功,正在为您跳转页面..."); - }else if(cfg.getServiceId()!=null){ - int serviceId=cfg.getServiceId(); - ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); - if(serviceConfigInfo!=null){ - String tableName=serviceConfigInfo.getTableName(); - if(!StringUtils.isBlank(tableName)){ - long compileId=getCompileId(cfg); - cfg.setTableName(tableName); -// cfg.setCreatorId(cfg.getCurrentUser().getId()); -// cfg.setCreateTime(new Date()); - cfg.setIsValid(Constants.VALID_NO); - cfg.setIsAudit(Constants.AUDIT_NOT_YET); - cfg.setCompileId(compileId); - if(cfg.getCfgId()==null){ - cfg.setCreatorId(cfg.getCurrentUser().getId()); - cfg.setCreateTime(new Date()); - complexStringCfgService.addStringCfg(cfg); - }else{ - cfg.setEditorId(cfg.getCurrentUser().getId()); - cfg.setEditTime(new Date()); - complexStringCfgService.updateStringCfg(cfg); - } - model.addAttribute("serviceId",serviceId); - model.addAttribute("action",cfg.getAction()); - addMessage(model,"保存成功,正在为您跳转页面..."); - } - } - }else{ + } catch (Exception e) { + // TODO Auto-generated catch block + logger.error("保存失败!",e); addMessage(model,"保存失败!"); - logger.error("无法确定IP配置的表名!"); } - return "/cfg/resultPage";//StringEscapeUtils.escapeHtml4("?serviceId="+cfg.getServiceId()+"&action="+cfg.getAction()+"&cfgName="+cfgName); + return "/cfg/resultPage"; } /** @@ -250,55 +206,51 @@ public class ComplexStringCfgController extends BaseController{ public String auditStringCfg(String cfgName,ComplexkeywordCfg cfg,Model model) { model.addAttribute("cfgName", cfgName); model.addAttribute("audit", Constants.AUDIT_PAGE); - if(cfg==null){ - logger.error("无法审核空的配置!"); - }else if(!StringUtils.isBlank(cfg.getTableName())){ - int audit=complexStringCfgService.getIsAudit(cfg); + model.addAttribute("cfgType", "complex"); + model.addAttribute("serviceId", cfg.getServiceId()); + model.addAttribute("action", cfg.getAction()); + try{ + String tableName=cfg.getTableName(); + String maatTable=null; + ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(cfg.getServiceId()); + if(serviceConfigInfo!=null){ + if(StringUtils.isBlank(tableName)){ + tableName=serviceConfigInfo.getTableName(); + cfg.setTableName(tableName); + } + maatTable=serviceConfigInfo.getMaatTable(); + } + ComplexkeywordCfg bean=complexStringCfgService.getStringCfgById(cfg); + bean.setTableName(tableName); + int audit=bean.getIsAudit().intValue(); if(audit==Constants.AUDIT_YES&&cfg.getIsAudit()!=Constants.AUDIT_NOT_YES){ logger.error("审核通过的配置只能取消审核通过!"); }else{ cfg.setAuditorId(cfg.getCurrentUser().getId()); cfg.setAuditTime(new Date()); - + bean.setIsAudit(cfg.getIsAudit()); if(cfg.getIsAudit()==Constants.AUDIT_NOT_YES){//取消审核通过,设置有效标志为0 cfg.setIsValid(Constants.VALID_NO); + bean.setIsValid(Constants.VALID_NO); + bean.setMaatTable(maatTable); }else if(cfg.getIsAudit()==Constants.AUDIT_YES){//审核通过,设置有效标志为1 cfg.setIsValid(Constants.VALID_YES); + bean.setIsValid(Constants.VALID_YES); + bean.setMaatTable(maatTable); } - int result=complexStringCfgService.auditStringCfg(cfg); - model.addAttribute("serviceId", cfg.getServiceId()); - model.addAttribute("action", cfg.getAction()); - } - - }else if(cfg.getServiceId()!=null){ - int serviceId=cfg.getServiceId(); - ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); - if(serviceConfigInfo!=null){ - String tableName=serviceConfigInfo.getTableName(); - if(!StringUtils.isBlank(tableName)){ - cfg.setTableName(tableName); - int audit=complexStringCfgService.getIsAudit(cfg); - if(audit==Constants.AUDIT_YES&&cfg.getIsAudit()!=Constants.AUDIT_NOT_YES){ - logger.error("审核通过的配置只能取消审核通过!"); - }else{ - cfg.setAuditorId(cfg.getCurrentUser().getId()); - cfg.setAuditTime(new Date()); - - if(cfg.getIsAudit()==Constants.AUDIT_NOT_YES){//取消审核通过,设置有效标志为0 - cfg.setIsValid(Constants.VALID_NO); - }else if(cfg.getIsAudit()==Constants.AUDIT_YES){//审核通过,设置有效标志为1 - cfg.setIsValid(Constants.VALID_YES); - } - int result=complexStringCfgService.auditStringCfg(cfg); - model.addAttribute("serviceId", serviceId); - model.addAttribute("action", cfg.getAction()); - } + int result=complexStringCfgService.auditStringCfg(bean,cfg); + if(result!=0){ + addMessage(model,"审核成功!"); + }else{ + addMessage(model,"审核失败!"); } + } - }else{ - logger.error("无法确定IP配置的表名!"); + }catch(Exception e){ + logger.error("发生异常",e); + addMessage(model,"审核失败!"); } - return "redirect:" + adminPath + "/cfg/complex/list"; + return "/cfg/resultPage"; } /** * @@ -316,7 +268,13 @@ public class ComplexStringCfgController extends BaseController{ model.addAttribute("action", action); model.addAttribute("cfgType","complex"); model.addAttribute("audit", Constants.CFG_PAGE); - if(!StringUtils.isBlank(tableName)){ + try{ + if(StringUtils.isBlank(tableName)){ + ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); + if(serviceConfigInfo!=null){ + tableName=serviceConfigInfo.getTableName(); + } + } int audit=complexStringCfgService.getIsAudit(tableName,cfgId); //未审核时可删除 if(audit!=Constants.AUDIT_YES){ @@ -332,29 +290,9 @@ public class ComplexStringCfgController extends BaseController{ logger.error("通过审核的配置不能删除!"); } - }else if(serviceId!=null){ - ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); - if(serviceConfigInfo!=null){ - tableName=serviceConfigInfo.getTableName(); - if(!StringUtils.isBlank(tableName)){ - ComplexkeywordCfg cfg=new ComplexkeywordCfg(); - cfg.setCfgId(cfgId); - cfg.setTableName(tableName); - int audit=complexStringCfgService.getIsAudit(cfg); - //未审核时可删除 - if(audit!=Constants.AUDIT_YES){ - cfg.setEditorId(cfg.getCurrentUser().getId()); - cfg.setEditTime(new Date()); - cfg.setIsValid(Constants.VALID_DEL); - int result=complexStringCfgService.deleteStringCfg(cfg); - addMessage(model,"删除成功,正在为您跳转页面..."); - }else{ - logger.error("通过审核的配置不能删除!"); - } - } - } - }else{ - logger.error("无法确定IP配置的表名!"); + }catch(Exception e){ + logger.error("删除失败", e); + addMessage(model,"删除失败!"); } return "/cfg/resultPage"; } @@ -367,7 +305,14 @@ public class ComplexStringCfgController extends BaseController{ * @exception * @since 1.0.0 */ - protected long getCompileId(BaseCfg cfg){ - return 0; + protected long getCompileId(ComplexkeywordCfg cfg){ + long compileId=0l; + try { + compileId = cfg.getCompileId()==null?new ConvertTool().getCompileId():cfg.getCompileId(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return compileId; } } diff --git a/src/main/java/com/nis/web/controller/configuration/DnsIpCfgController.java b/src/main/java/com/nis/web/controller/configuration/DnsIpCfgController.java index 787806a96..2c25787a5 100644 --- a/src/main/java/com/nis/web/controller/configuration/DnsIpCfgController.java +++ b/src/main/java/com/nis/web/controller/configuration/DnsIpCfgController.java @@ -64,9 +64,14 @@ public class DnsIpCfgController extends BaseController { dnsIpCfg.setEditTime(now); } - dnsIpCfgService.save(dnsIpCfg); + try { + dnsIpCfgService.save(dnsIpCfg); + addMessage(redirectAttributes, "save_success"); + } catch (Exception e) { + e.printStackTrace(); + addMessage(redirectAttributes, "save_failed"); + } - addMessage(redirectAttributes, "保存成功"); return "redirect:" + adminPath + "/cfg/dnsIp/list"; } @@ -77,13 +82,13 @@ public class DnsIpCfgController extends BaseController { if (!StringUtils.isEmpty(cfgIds)) { try { dnsIpCfgService.delete(cfgIds); - addMessage(model, "删除成功"); + addMessage(model, "delete_success"); } catch (Exception e) { - e.printStackTrace(); - addMessage(model, "删除失败"); + logger.error("删除失败", e); + addMessage(model, "delete_failed"); } } else { - addMessage(model, "删除失败"); + addMessage(model, "delete_failed"); } Page page = dnsIpCfgService.findPage(new Page(request, response, 30), dnsIpCfg); diff --git a/src/main/java/com/nis/web/controller/configuration/IpCfgController.java b/src/main/java/com/nis/web/controller/configuration/IpCfgController.java index 7747fa609..45bb1c374 100644 --- a/src/main/java/com/nis/web/controller/configuration/IpCfgController.java +++ b/src/main/java/com/nis/web/controller/configuration/IpCfgController.java @@ -12,12 +12,15 @@ import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; import com.nis.domain.Page; import com.nis.domain.ServiceConfigInfo; import com.nis.domain.basics.ServiceDictInfo; import com.nis.domain.configuration.BaseIpCfg; import com.nis.domain.configuration.RequestInfo; +import com.nis.main.ConvertTool; import com.nis.util.Constants; import com.nis.web.controller.BaseController; @@ -123,7 +126,6 @@ public class IpCfgController extends BaseController{ ipcfg.setAction(action); ipcfg.setServiceId(serviceId); model.addAttribute("_cfg", ipcfg); - long compileId=this.getCompileId(); model.addAttribute("tableName", tableName); List requestInfos=requestInfoService.getValidRequestInfo(); model.addAttribute("requestInfos", requestInfos); @@ -230,13 +232,21 @@ public class IpCfgController extends BaseController{ model.addAttribute("cfgName",cfgName); model.addAttribute("cfgType", "ip"); model.addAttribute("audit", Constants.CFG_PAGE); + model.addAttribute("serviceId",ipCfg.getServiceId()); + model.addAttribute("action",ipCfg.getAction()); + model.addAttribute("tableName", ipCfg.getTableName()); logger.info("saveOrUpdateIpCfg loaded"); - if(ipCfg==null){ - logger.error("无法保存空的配置!"); - addMessage(model,"保存失败!"); - }else if(!StringUtils.isBlank(ipCfg.getTableName())){ + try{ + String tableName=ipCfg.getTableName(); int serviceId=ipCfg.getServiceId(); - long compileId=getCompileId(); + if(StringUtils.isBlank(tableName)){ + ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); + if(serviceConfigInfo!=null){ + tableName=serviceConfigInfo.getTableName(); + ipCfg.setTableName(tableName); + } + } + int compileId=new ConvertTool().getCompileId().intValue(); ipCfg.setIsValid(Constants.VALID_NO); ipCfg.setIsAudit(Constants.AUDIT_NOT_YET); ipCfg.setCompileId(compileId); @@ -249,42 +259,12 @@ public class IpCfgController extends BaseController{ ipCfg.setEditTime(new Date()); ipCfgService.updateIpCfg(ipCfg); } - model.addAttribute("serviceId",serviceId); - model.addAttribute("action",ipCfg.getAction()); - model.addAttribute("tableName", ipCfg.getTableName()); addMessage(model,"保存成功,正在为您跳转页面..."); - }else if(ipCfg.getServiceId()!=null){ - int serviceId=ipCfg.getServiceId(); - model.addAttribute("serviceId",serviceId); - ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); - if(serviceConfigInfo!=null){ - String tableName=serviceConfigInfo.getTableName(); - if(!StringUtils.isBlank(tableName)){ - long compileId=getCompileId(); - ipCfg.setTableName(tableName); -// ipCfg.setCreatorId(ipCfg.getCurrentUser().getId()); -// ipCfg.setCreateTime(new Date()); - ipCfg.setIsValid(Constants.VALID_NO); - ipCfg.setIsAudit(Constants.AUDIT_NOT_YET); - ipCfg.setCompileId(compileId); - if(ipCfg.getCfgId()==null){ - ipCfg.setCreatorId(ipCfg.getCurrentUser().getId()); - ipCfg.setCreateTime(new Date()); - }else{ - ipCfg.setEditorId(ipCfg.getCurrentUser().getId()); - ipCfg.setEditTime(new Date()); - ipCfgService.updateIpCfg(ipCfg); - } - model.addAttribute("action",ipCfg.getAction()); - model.addAttribute("tableName", ipCfg.getTableName()); - addMessage(model,"保存成功,正在为您跳转页面..."); - } - } - }else{ + }catch(Exception e){ + logger.error("保存失败",e); addMessage(model,"保存失败!"); - logger.error("无法确定IP配置的表名!"); } - return "/cfg/resultPage";//StringEscapeUtils.escapeHtml4("?serviceId="+ipCfg.getServiceId()+"&action="+ipCfg.getAction()+"&cfgName="+cfgName); + return "/cfg/resultPage"; } /** @@ -299,55 +279,52 @@ public class IpCfgController extends BaseController{ @RequestMapping(value = {"auditCfg"}) public String auditIpCfg(String cfgName,BaseIpCfg ipCfg,Model model) { model.addAttribute("cfgName", cfgName); + model.addAttribute("cfgType", "ip"); model.addAttribute("audit", Constants.AUDIT_PAGE); - if(ipCfg==null){ - logger.error("无法审核空的配置!"); - }else if(!StringUtils.isBlank(ipCfg.getTableName())){ - int audit=ipCfgService.getIsAudit(ipCfg); + model.addAttribute("serviceId", ipCfg.getServiceId()); + model.addAttribute("action", ipCfg.getAction()); + try{ + String tableName=ipCfg.getTableName(); + String maatTable=null; + ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(ipCfg.getServiceId()); + 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); } - int result=ipCfgService.auditIpCfg(ipCfg); - model.addAttribute("serviceId", ipCfg.getServiceId()); - model.addAttribute("action", ipCfg.getAction()); - } - }else if(ipCfg.getServiceId()!=null){ - int serviceId=ipCfg.getServiceId(); - ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); - if(serviceConfigInfo!=null){ - String tableName=serviceConfigInfo.getTableName(); - if(!StringUtils.isBlank(tableName)){ - ipCfg.setTableName(tableName); - int audit=ipCfgService.getIsAudit(ipCfg); - if(audit==Constants.AUDIT_YES&&ipCfg.getIsAudit()!=Constants.AUDIT_NOT_YES){ - logger.error("审核通过的配置只能取消审核通过!"); - }else{ - ipCfg.setAuditorId(ipCfg.getCurrentUser().getId()); - ipCfg.setAuditTime(new Date()); - - if(ipCfg.getIsAudit()==Constants.AUDIT_NOT_YES){//取消审核通过,设置有效标志为0 - ipCfg.setIsValid(Constants.VALID_NO); - }else if(ipCfg.getIsAudit()==Constants.AUDIT_YES){//审核通过,设置有效标志为1 - ipCfg.setIsValid(Constants.VALID_YES); - } - int result=ipCfgService.auditIpCfg(ipCfg); - model.addAttribute("serviceId", serviceId); - model.addAttribute("action", ipCfg.getAction()); - } + int result=ipCfgService.auditIpCfg(bean,ipCfg); + if(result!=0){ + addMessage(model,"审核成功!"); + }else{ + addMessage(model, "审核失败"); } + } - }else{ - logger.error("无法确定IP配置的表名!"); + }catch(Exception e){ + logger.error("审核失败", e); + addMessage(model, "审核失败"); } - return "redirect:" + adminPath + "/cfg/ip/list"; + return "/cfg/resultPage"; } /** * @@ -366,7 +343,13 @@ public class IpCfgController extends BaseController{ model.addAttribute("action", action); model.addAttribute("cfgType", "ip"); model.addAttribute("audit", Constants.AUDIT_PAGE); - if(!StringUtils.isBlank(tableName)){ + try{ + if(StringUtils.isBlank(tableName)){ + ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); + if(serviceConfigInfo!=null){ + tableName=serviceConfigInfo.getTableName(); + } + } int audit=ipCfgService.getIsAudit(tableName,cfgId); //未审核时可删除 if(audit!=Constants.AUDIT_YES){ @@ -381,32 +364,11 @@ public class IpCfgController extends BaseController{ addMessage(model,"删除成功,正在为您跳转页面..."); }else{ logger.error("通过审核的配置不能删除!"); + addMessage(model,"删除失败!"); } - - }else if(serviceId!=null){ - ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); - if(serviceConfigInfo!=null){ - tableName=serviceConfigInfo.getTableName(); - if(!StringUtils.isBlank(tableName)){ - BaseIpCfg ipCfg=new BaseIpCfg(); - ipCfg.setCfgId(cfgId); - ipCfg.setTableName(tableName); - int audit=ipCfgService.getIsAudit(ipCfg); - //未审核时可删除 - if(audit!=Constants.AUDIT_YES){ - ipCfg.setEditorId(ipCfg.getCurrentUser().getId()); - ipCfg.setEditTime(new Date()); - ipCfg.setIsValid(Constants.VALID_DEL); - int result=ipCfgService.deleteIpCfg(ipCfg); - model.addAttribute("tableName", tableName); - addMessage(model,"删除成功,正在为您跳转页面..."); - }else{ - logger.error("通过审核的配置不能删除!"); - } - } - } - }else{ - logger.error("无法确定IP配置的表名!"); + }catch(Exception e){ + logger.error("删除失败", e); + addMessage(model,"删除失败!"); } return "/cfg/resultPage"; } @@ -419,7 +381,14 @@ public class IpCfgController extends BaseController{ * @exception * @since 1.0.0 */ - protected long getCompileId(){ - return 0; + protected long getCompileId(BaseIpCfg cfg){ + long compileId=0l; + try { + compileId = cfg.getCompileId()==null?new ConvertTool().getCompileId():cfg.getCompileId(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return compileId; } } diff --git a/src/main/java/com/nis/web/controller/configuration/MultipleCfgController.java b/src/main/java/com/nis/web/controller/configuration/MultipleCfgController.java new file mode 100644 index 000000000..bf46b696b --- /dev/null +++ b/src/main/java/com/nis/web/controller/configuration/MultipleCfgController.java @@ -0,0 +1,1105 @@ +package com.nis.web.controller.configuration; +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; + +import com.nis.domain.Page; +import com.nis.domain.ServiceConfigInfo; +import com.nis.domain.basics.ServiceDictInfo; +import com.nis.domain.configuration.BaseCfg; +import com.nis.domain.configuration.BaseIpCfg; +import com.nis.domain.configuration.BaseStringCfg; +import com.nis.domain.configuration.ComplexkeywordCfg; +import com.nis.domain.configuration.MultipleCfg; +import com.nis.domain.configuration.MultipleSearchCfg; +import com.nis.domain.configuration.NumBoundaryCfg; +import com.nis.domain.configuration.RequestInfo; +import com.nis.domain.configuration.TableBean; +import com.nis.main.ConvertTool; +import com.nis.util.Constants; +import com.nis.web.controller.BaseController; +import com.nis.web.service.configuration.MultipleCfgService; + +/** + * 文本增强(多域)组合配置服务 + * @author dell + * + */ +@Controller +@RequestMapping("${adminPath}/cfg/multiple") +public class MultipleCfgController extends BaseController{ + @Autowired + protected MultipleCfgService multipleCfgService; + /** + * + * list(查询列表,分开查) + * (这里描述这个方法适用条件 – 可选) + * @param model + * @param audit + * @param cfgName + * @param cfg + * @param request + * @param response + * @return + *String + * @exception + * @since 1.0.0 + */ + @SuppressWarnings({"unchecked","rawtypes"}) + @RequestMapping(value = {"list"}) + public String list(Model model,Integer audit,String cfgName,@ModelAttribute("cfg")MultipleSearchCfg cfg,HttpServletRequest request,HttpServletResponse response) { + model.addAttribute("cfgName", cfgName); + model.addAttribute("cfgType", "multiple"); + model.addAttribute("audit", audit); + model.addAttribute("mainTable", cfg.getMainTable()); + Page resultPage=new Page(request,response); + Integer serviceId=cfg.getServiceId(); + model.addAttribute("serviceId", serviceId); + List otherTables=null; + if(cfg.getOtherTables()==null){ + otherTables=new ArrayList(); + cfg.setOtherTables(otherTables); + }else{ + otherTables=cfg.getOtherTables(); + } + if(cfg.getMainTable()==null){ + logger.error("cannot get main table"); + return "/cfg/multipleCfgList"; + }else{//从菜单url获取mainTable + String mainTable=cfg.getMainTable(); + //获取相关表名 + List serviceConfigInfos=serviceConfigInfoService.findList(serviceId); + List resultList=new ArrayList(); + resultPage.setList(resultList); + + List mainList=null; + //查询主表,将主表中的数据set到结果中 + for(ServiceConfigInfo info:serviceConfigInfos){ + int type=info.getTableType(); + String tableName=info.getTableName(); + if(mainTable.equals(tableName)){ + cfg.setMainTableType(String.valueOf(type)); + if(Constants.TABLE_TYPE_COMPLEX==type){//增强字符串类型 + ComplexkeywordCfg _cfg=cfg.getComplexCfg()==null?new ComplexkeywordCfg():cfg.getComplexCfg(); + _cfg.setTableName(mainTable); + this.setProperties(cfg, null, null, null, _cfg); + Page mainPage=complexStringCfgService.findPage(new Page(request,response,"r"), _cfg); + setPageProps(mainPage,resultPage); + mainList=mainPage.getList();//主表结果 + if(mainList!=null){ + //遍历主表结果,将主表结果数据set到到返回结果中 + for(int i=0;i cfgMap=new HashMap(); + cfgMap.put(mainTable, (ComplexkeywordCfg)mainList.get(i)); + resultCfg.setComplexCfg(cfgMap); + this.setPropertiesToMultipleCfg(resultCfg, mainList.get(i),"select"); + resultList.add(resultCfg); + } + } + }else{ + logger.info("no data"); + return "/cfg/multipleCfgList"; + } + + }else if(Constants.TABLE_TYPE_STRING==type){//字符串类型 + BaseStringCfg _cfg=cfg.getStringCfg()==null?new BaseStringCfg():cfg.getStringCfg(); + _cfg.setTableName(mainTable); + this.setProperties(cfg, null, _cfg, null,null); + Page mainPage=stringCfgService.findPage(new Page(request,response,"r"), _cfg); + mainList=mainPage.getList();//主表结果 + setPageProps(mainPage,resultPage); + if(mainList!=null){ + //遍历主表结果,将主表结果数据set到到返回结果中 + for(int i=0;i cfgMap=new HashMap(); + cfgMap.put(mainTable, (BaseStringCfg)mainList.get(i)); + resultCfg.setStringCfg(cfgMap); + this.setPropertiesToMultipleCfg(resultCfg, mainList.get(i),"select"); + resultList.add(resultCfg); + } + } + }else{ + logger.info("no data"); + return "/cfg/multipleCfgList"; + } + }else if(Constants.TABLE_TYPE_IP==type){//字符串类型 + BaseIpCfg _cfg=cfg.getIpCfg()==null?new BaseIpCfg():cfg.getIpCfg(); + _cfg.setTableName(mainTable); + this.setProperties(cfg, _cfg,null,null,null); + Page mainPage=ipCfgService.findPage(new Page(request,response,"r"), _cfg); + mainList=mainPage.getList();//主表结果 + setPageProps(mainPage,resultPage); + if(mainList!=null){ + //遍历主表结果,将主表结果数据set到到返回结果中 + for(int i=0;i cfgMap=new HashMap(); + cfgMap.put(mainTable, (BaseIpCfg)mainList.get(i)); + resultCfg.setIpCfg(cfgMap); + this.setPropertiesToMultipleCfg(resultCfg, mainList.get(i),"select"); + resultList.add(resultCfg); + } + } + }else{ + logger.info("no data"); + return "/cfg/multipleCfgList"; + } + }else if(Constants.TABLE_TYPE_NUMBER==type){ + NumBoundaryCfg _cfg=cfg.getNumCfg()==null?new NumBoundaryCfg():cfg.getNumCfg(); + _cfg.setTableName(mainTable); + this.setProperties(cfg, null,null,_cfg,null); + Page mainPage=numCfgService.findPage(new Page(request,response,"r"), _cfg); + mainList=mainPage.getList();//主表结果 + setPageProps(mainPage,resultPage); + if(mainList!=null){ + //遍历主表结果,将主表结果数据set到到返回结果中 + for(int i=0;i cfgMap=new HashMap(); + cfgMap.put(mainTable, (NumBoundaryCfg)mainList.get(i)); + resultCfg.setNumCfg(cfgMap); + this.setPropertiesToMultipleCfg(resultCfg, mainList.get(i),"select"); + resultList.add(resultCfg); + } + } + }else{ + logger.info("no data"); + return "/cfg/multipleCfgList"; + } + } + break; + } + } + + if(mainList!=null&&mainList.size()>0){ + Page page=new Page(request,response,"r"); + StringBuffer compileIds=new StringBuffer(); + for(int i=0;i list=complexStringCfgService + .findPage(page, _cfg) + .getList(); + for(MultipleCfg resultCfg:resultPage.getList()){ + BaseCfg main=null; + if(resultCfg.getComplexCfg()!=null&&resultCfg.getComplexCfg().containsKey(mainTable)){ + main=resultCfg.getComplexCfg().get(mainTable); + }else if(resultCfg.getStringCfg()!=null&&resultCfg.getStringCfg().containsKey(mainTable)){ + main=resultCfg.getStringCfg().get(mainTable); + }else if(resultCfg.getIpCfg().containsKey(mainTable)){ + main=resultCfg.getIpCfg().get(mainTable); + }else if(resultCfg.getNumCfg().containsKey(mainTable)){ + main=resultCfg.getNumCfg().get(mainTable); + } + for(ComplexkeywordCfg prop:list){ + if(main.getCompileId().longValue()==prop.getCompileId().longValue()){ + prop.setTableName(info.getTableName()); + if(resultCfg.getComplexCfg()==null){ + Map map=new HashMap(); + map.put(info.getTableName(), prop); + resultCfg.setComplexCfg(map); + }else{ + resultCfg.getComplexCfg().put(info.getTableName(), prop); + } + break; + } + } + } + }else if(Constants.TABLE_TYPE_STRING==type){//字符串类型 + BaseStringCfg _cfg=cfg.getStringCfg()==null?new BaseStringCfg():cfg.getStringCfg(); + _cfg.setTableName(info.getTableName()); + this.setProperties(cfg, null, _cfg, null,null); + List list=stringCfgService + .findPage(page, _cfg) + .getList(); + for(MultipleCfg resultCfg:resultPage.getList()){ + BaseCfg main=null; + if(resultCfg.getComplexCfg()!=null&&resultCfg.getComplexCfg().containsKey(mainTable)){ + main=resultCfg.getComplexCfg().get(mainTable); + }else if(resultCfg.getStringCfg()!=null&&resultCfg.getStringCfg().containsKey(mainTable)){ + main=resultCfg.getStringCfg().get(mainTable); + }else if(resultCfg.getIpCfg()!=null&&resultCfg.getIpCfg().containsKey(mainTable)){ + main=resultCfg.getIpCfg().get(mainTable); + }else if(resultCfg.getNumCfg()!=null&&resultCfg.getNumCfg().containsKey(mainTable)){ + main=resultCfg.getNumCfg().get(mainTable); + } + for(BaseStringCfg prop:list){ + if(main.getCompileId().longValue()==prop.getCompileId().longValue()){ + prop.setTableName(info.getTableName()); + if(resultCfg.getStringCfg()==null){ + Map map=new HashMap(); + map.put(info.getTableName(), prop); + resultCfg.setStringCfg(map); + }else{ + resultCfg.getStringCfg().put(info.getTableName(), prop); + } + break; + } + } + } + }else if(Constants.TABLE_TYPE_IP==type){//IP类型 + tableBean.setCanEmpty(true); + BaseIpCfg _cfg=cfg.getIpCfg()==null?new BaseIpCfg():cfg.getIpCfg(); + _cfg.setTableName(info.getTableName()); + this.setProperties(cfg, _cfg,null,null,null); + List list=ipCfgService + .findPage(page, _cfg) + .getList(); + for(MultipleCfg resultCfg:resultPage.getList()){ + BaseCfg main=null; + if(resultCfg.getComplexCfg()!=null&&resultCfg.getComplexCfg().containsKey(mainTable)){ + main=resultCfg.getComplexCfg().get(mainTable); + }else if(resultCfg.getStringCfg()!=null&&resultCfg.getStringCfg().containsKey(mainTable)){ + main=resultCfg.getStringCfg().get(mainTable); + }else if(resultCfg.getIpCfg()!=null&&resultCfg.getIpCfg().containsKey(mainTable)){ + main=resultCfg.getIpCfg().get(mainTable); + }else if(resultCfg.getNumCfg()!=null&&resultCfg.getNumCfg().containsKey(mainTable)){ + main=resultCfg.getNumCfg().get(mainTable); + } + for(BaseIpCfg prop:list){ + if(main.getCompileId().longValue()==prop.getCompileId().longValue()){ + prop.setTableName(info.getTableName()); + if(resultCfg.getIpCfg()==null){ + Map map=new HashMap(); + map.put(info.getTableName(), prop); + resultCfg.setIpCfg(map); + }else{ + resultCfg.getIpCfg().put(info.getTableName(), prop); + } + break; + } + } + } + }else if(Constants.TABLE_TYPE_NUMBER==type){ + NumBoundaryCfg _cfg=cfg.getNumCfg()==null?new NumBoundaryCfg():cfg.getNumCfg(); + _cfg.setTableName(info.getTableName()); + this.setProperties(cfg, null,null,_cfg,null); + List list=numCfgService + .findPage(page, _cfg) + .getList(); + for(MultipleCfg resultCfg:resultPage.getList()){ + BaseCfg main=null; + if(resultCfg.getComplexCfg()!=null&&resultCfg.getComplexCfg().containsKey(mainTable)){ + main=resultCfg.getComplexCfg().get(mainTable); + }else if(resultCfg.getStringCfg()!=null&&resultCfg.getStringCfg().containsKey(mainTable)){ + main=resultCfg.getStringCfg().get(mainTable); + }else if(resultCfg.getIpCfg()!=null&&resultCfg.getIpCfg().containsKey(mainTable)){ + main=resultCfg.getIpCfg().get(mainTable); + }else if(resultCfg.getNumCfg()!=null&&resultCfg.getNumCfg().containsKey(mainTable)){ + main=resultCfg.getNumCfg().get(mainTable); + } + for(NumBoundaryCfg prop:list){ + if(main.getCompileId().longValue()==prop.getCompileId().longValue()){ + prop.setTableName(info.getTableName()); + if(resultCfg.getNumCfg()==null){ + Map map=new HashMap(); + map.put(info.getTableName(), prop); + resultCfg.setNumCfg(map); + }else{ + resultCfg.getNumCfg().put(info.getTableName(), prop); + } + break; + } + } + } + } + } + } + }else{ + for(ServiceConfigInfo info:serviceConfigInfos){ + int type=info.getTableType(); + TableBean tableBean=new TableBean(info.getTableName(),String.valueOf(type)); + if(!mainTable.equals(info.getTableName())){ + otherTables.add(tableBean); + } + } + + } + } + model.addAttribute("mainTableType", cfg.getMainTableType()); + model.addAttribute("action", cfg.getAction()); + model.addAttribute("page", resultPage); + List requestInfos=requestInfoService.getAllRequestInfo(); + model.addAttribute("requestInfos", requestInfos); + List fls=serviceDictInfoService.findAllFlDict(); + model.addAttribute("fls", fls); + List xzs=serviceDictInfoService.findAllXzDict(); + model.addAttribute("xzs", xzs); + List lables=serviceDictInfoService.findAllLableDict(); + model.addAttribute("lables", lables); + return "/cfg/multipleCfgList"; + } + @RequestMapping(value = {"form"}) + public String cfgForm(int action,String mainTable,String cfgName,Integer serviceId,Model model,HttpServletRequest request,HttpServletResponse response) { + model.addAttribute("cfgName", cfgName); + model.addAttribute("action", action); + model.addAttribute("serviceId", serviceId); + model.addAttribute("audit", Constants.CFG_PAGE); + model.addAttribute("mainTable", mainTable); + model.addAttribute("operator", "save"); + logger.info("sercice id is "+serviceId); + MultipleCfg cfg=new MultipleCfg(); + cfg.setMainTable(mainTable); + cfg.setAction(action); + cfg.setServiceId(serviceId); + List serviceConfigInfos=serviceConfigInfoService.findList(serviceId); + List otherTables=new ArrayList(); + cfg.setOtherTables(otherTables); + for(ServiceConfigInfo info:serviceConfigInfos){ + int type=info.getTableType(); + TableBean tableBean=new TableBean(info.getTableName(), String.valueOf(type)); + if(mainTable.equals(info.getTableName())){ + cfg.setMainTableType(String.valueOf(type)); + model.addAttribute("mainTableType", String.valueOf(type)); + }else{ + otherTables.add(tableBean); + } + String tableName=info.getTableName(); + if(Constants.TABLE_TYPE_IP==type){//ip类型 + tableBean.setCanEmpty(true); + BaseIpCfg ipCfg=(BaseIpCfg)this.getClassBean(info.getTableName(), true); + if(cfg.getIpCfg()==null){ + Map map=new HashMap(); + map.put(tableName,ipCfg); + cfg.setIpCfg(map); + }else{ + Map map=cfg.getIpCfg(); + map.put(tableName,ipCfg); + } + }else if(Constants.TABLE_TYPE_STRING==type){//字符串类型 + BaseStringCfg stringCfg=(BaseStringCfg)this.getClassBean(info.getTableName(), true); + if(cfg.getStringCfg()==null){ + Map map=new HashMap(); + map.put(tableName,stringCfg); + cfg.setStringCfg(map); + }else{ + Map map=cfg.getStringCfg(); + map.put(tableName,stringCfg); + } + }else if(Constants.TABLE_TYPE_NUMBER==type){//数值类型 + NumBoundaryCfg numCfg=(NumBoundaryCfg)this.getClassBean(info.getTableName(), true); + if(cfg.getNumCfg()==null){ + Map map=new HashMap(); + map.put(tableName,numCfg); + cfg.setNumCfg(map); + }else{ + Map map=cfg.getNumCfg(); + map.put(tableName,numCfg); + } + + }else if(Constants.TABLE_TYPE_COMPLEX==type){//增强字符串类型 + ComplexkeywordCfg complexCfg=(ComplexkeywordCfg)this.getClassBean(info.getTableName(), true); + if(cfg.getComplexCfg()==null){ + Map map=new HashMap(); + map.put(tableName,complexCfg); + cfg.setComplexCfg(map); + }else{ + Map map=cfg.getComplexCfg(); + map.put(tableName,complexCfg); + } + + } + } + cfg.setAction(action); + cfg.setServiceId(serviceId); + model.addAttribute("_cfg", cfg); + List requestInfos=requestInfoService.getValidRequestInfo(); + model.addAttribute("requestInfos", requestInfos); + List fls=serviceDictInfoService.findFlDict(); + model.addAttribute("fls", fls); + List xzs=serviceDictInfoService.findXzDict(); + model.addAttribute("xzs", xzs); + List lables=serviceDictInfoService.findLableDict(); + model.addAttribute("lables", lables); + + return "/cfg/multipleCfgForm"; + } + @RequestMapping(value = {"updateForm"}) + public String updateCfgForm(String cfgName,MultipleCfg cfg,Model model,HttpServletRequest request,HttpServletResponse response) { + model.addAttribute("operator", "update"); + model.addAttribute("cfgName", cfgName); + model.addAttribute("serviceId", cfg.getServiceId()); + model.addAttribute("action", cfg.getAction()); + model.addAttribute("audit", Constants.CFG_PAGE); + MultipleCfg resultCfg=new MultipleCfg(); + String mainTable=cfg.getMainTable(); + model.addAttribute("mainTable", mainTable); + resultCfg.setMainTable(mainTable); + String mainTableType=cfg.getMainTableType(); + model.addAttribute("mainTableType", mainTableType); + resultCfg.setMainTableType(mainTableType); + resultCfg.setAction(cfg.getAction()); + int serviceId=cfg.getServiceId(); + cfg.setServiceId(serviceId); + int compileId=cfg.getCompileId().intValue(); + resultCfg.setCompileId(compileId); + List serviceConfigInfos=serviceConfigInfoService.findList(serviceId); + List otherTables=new ArrayList(); + resultCfg.setOtherTables(otherTables); + for(ServiceConfigInfo info:serviceConfigInfos){ + String tableName=info.getTableName(); + int type=info.getTableType(); + if(!tableName.equals(mainTable)){ + TableBean bean=new TableBean(tableName,String.valueOf(type)); + if(Constants.TABLE_TYPE_IP==type){ + bean.setCanEmpty(true); + } + otherTables.add(bean); + } + if(Constants.TABLE_TYPE_IP==type){ + BaseIpCfg searchIpCfg=new BaseIpCfg(); + searchIpCfg.setTableName(info.getTableName()); + searchIpCfg.setCompileId(compileId); + BaseIpCfg resultIpCfg=ipCfgService.get(searchIpCfg); + if(resultIpCfg!=null){ + if(resultCfg.getIpCfg()==null){ + Map map=new HashMap(); + map.put(info.getTableName(), resultIpCfg); + resultCfg.setIpCfg(map); + }else{ + Map map=resultCfg.getIpCfg(); + map.put(info.getTableName(), resultIpCfg); + } + if(mainTable.equals(info.getTableName())){ + this.setPropertiesToMultipleCfg(resultCfg, resultIpCfg,"update"); + } + } + }else if(Constants.TABLE_TYPE_STRING==type){ + BaseStringCfg searchStringCfg=new BaseStringCfg(); + searchStringCfg.setTableName(info.getTableName()); + searchStringCfg.setCompileId(compileId); + BaseStringCfg resultStringCfg=stringCfgService.get(searchStringCfg); + if(resultStringCfg!=null){ + if(resultCfg.getStringCfg()==null){ + Map map=new HashMap(); + map.put(info.getTableName(), resultStringCfg); + resultCfg.setStringCfg(map); + }else{ + Map map=resultCfg.getStringCfg(); + map.put(info.getTableName(), resultStringCfg); + } + if(mainTable.equals(info.getTableName())){ + this.setPropertiesToMultipleCfg(resultCfg, resultStringCfg,"update"); + } + } + }else if(Constants.TABLE_TYPE_NUMBER==type){ + NumBoundaryCfg searchNumCfg=new NumBoundaryCfg(); + searchNumCfg.setTableName(info.getTableName()); + searchNumCfg.setCompileId(compileId); + NumBoundaryCfg resultNumCfg=numCfgService.get(searchNumCfg); + if(resultNumCfg!=null){ + if(resultCfg.getNumCfg()==null){ + Map map=new HashMap(); + map.put(info.getTableName(), resultNumCfg); + resultCfg.setNumCfg(map); + }else{ + Map map=resultCfg.getNumCfg(); + map.put(info.getTableName(), resultNumCfg); + } + if(mainTable.equals(info.getTableName())){ + this.setPropertiesToMultipleCfg(resultCfg, resultNumCfg,"update"); + } + } + }else if(Constants.TABLE_TYPE_COMPLEX==type){ + ComplexkeywordCfg searchComplexCfg=new ComplexkeywordCfg(); + searchComplexCfg.setTableName(info.getTableName()); + searchComplexCfg.setCompileId(compileId); + ComplexkeywordCfg resultComplexCfg=complexStringCfgService.get(searchComplexCfg); + if(resultComplexCfg!=null){ + if(resultCfg.getComplexCfg()==null){ + Map map=new HashMap(); + map.put(info.getTableName(), resultComplexCfg); + resultCfg.setComplexCfg(map); + }else{ + Map map=resultCfg.getComplexCfg(); + map.put(info.getTableName(), resultComplexCfg); + } + if(mainTable.equals(info.getTableName())){ + this.setPropertiesToMultipleCfg(resultCfg, resultComplexCfg,"update"); + } + } + } + } + model.addAttribute("_cfg", resultCfg); + List requestInfos=requestInfoService.getAllRequestInfo(); + model.addAttribute("requestInfos", requestInfos); + List fls=serviceDictInfoService.findAllFlDict(); + model.addAttribute("fls", fls); + List xzs=serviceDictInfoService.findAllXzDict(); + model.addAttribute("xzs", xzs); + List lables=serviceDictInfoService.findAllLableDict(); + model.addAttribute("lables", lables); + + return "/cfg/multipleCfgForm"; + } + @RequestMapping(value = {"deleteCfg"}) + public String deleteCfg(String cfgName,MultipleCfg cfg,Model model,HttpServletRequest request,HttpServletResponse response) { + model.addAttribute("operator", "delete"); + model.addAttribute("cfgName", cfgName); + model.addAttribute("cfgType", "multiple"); + model.addAttribute("serviceId", cfg.getServiceId()); + model.addAttribute("action", cfg.getAction()); + model.addAttribute("audit", Constants.CFG_PAGE); + MultipleCfg resultCfg=new MultipleCfg(); + String mainTable=cfg.getMainTable(); + model.addAttribute("mainTable", mainTable); + resultCfg.setMainTable(mainTable); + String mainTableType=cfg.getMainTableType(); + model.addAttribute("mainTableType", mainTableType); + resultCfg.setMainTableType(mainTableType); + resultCfg.setAction(cfg.getAction()); + int serviceId=cfg.getServiceId(); + cfg.setServiceId(serviceId); + int compileId=cfg.getCompileId().intValue(); + resultCfg.setCompileId(compileId); + List serviceConfigInfos=serviceConfigInfoService.findList(serviceId); + Date date=new Date(); + for(ServiceConfigInfo info:serviceConfigInfos){ + int type=info.getTableType(); + if(Constants.TABLE_TYPE_IP==type){ + BaseIpCfg searchIpCfg=new BaseIpCfg(); + searchIpCfg.setTableName(info.getTableName()); + searchIpCfg.setCompileId(compileId); + searchIpCfg.setIsValid(Constants.VALID_DEL); + searchIpCfg.setIsAudit(Constants.AUDIT_NOT_YET); + searchIpCfg.setEditorId(cfg.getCurrentUser().getId()); + searchIpCfg.setEditTime(date); + if(resultCfg.getIpCfg()==null){ + Map map=new HashMap(); + map.put(info.getTableName(), searchIpCfg); + resultCfg.setIpCfg(map); + }else{ + Map map=resultCfg.getIpCfg(); + map.put(info.getTableName(), searchIpCfg); + } + }else if(Constants.TABLE_TYPE_STRING==type){ + BaseStringCfg searchStringCfg=new BaseStringCfg(); + searchStringCfg.setTableName(info.getTableName()); + searchStringCfg.setCompileId(compileId); + searchStringCfg.setIsValid(Constants.VALID_DEL); + searchStringCfg.setIsAudit(Constants.AUDIT_NOT_YET); + searchStringCfg.setEditorId(cfg.getCurrentUser().getId()); + searchStringCfg.setEditTime(date); + if(resultCfg.getStringCfg()==null){ + Map map=new HashMap(); + map.put(info.getTableName(), searchStringCfg); + resultCfg.setStringCfg(map); + }else{ + Map map=resultCfg.getStringCfg(); + map.put(info.getTableName(), searchStringCfg); + } + }else if(Constants.TABLE_TYPE_NUMBER==type){ + NumBoundaryCfg searchNumCfg=new NumBoundaryCfg(); + searchNumCfg.setTableName(info.getTableName()); + searchNumCfg.setCompileId(compileId); + searchNumCfg.setIsValid(Constants.VALID_DEL); + searchNumCfg.setIsAudit(Constants.AUDIT_NOT_YET); + searchNumCfg.setEditorId(cfg.getCurrentUser().getId()); + searchNumCfg.setEditTime(date); + if(resultCfg.getNumCfg()==null){ + Map map=new HashMap(); + map.put(info.getTableName(), searchNumCfg); + resultCfg.setNumCfg(map); + }else{ + Map map=resultCfg.getNumCfg(); + map.put(info.getTableName(), searchNumCfg); + } + }else if(Constants.TABLE_TYPE_COMPLEX==type){ + ComplexkeywordCfg searchComplexCfg=new ComplexkeywordCfg(); + searchComplexCfg.setTableName(info.getTableName()); + searchComplexCfg.setCompileId(compileId); + searchComplexCfg.setIsValid(Constants.VALID_DEL); + searchComplexCfg.setIsAudit(Constants.AUDIT_NOT_YET); + searchComplexCfg.setEditorId(cfg.getCurrentUser().getId()); + searchComplexCfg.setEditTime(date); + if(resultCfg.getComplexCfg()==null){ + Map map=new HashMap(); + map.put(info.getTableName(), searchComplexCfg); + resultCfg.setComplexCfg(map); + }else{ + Map map=resultCfg.getComplexCfg(); + map.put(info.getTableName(), searchComplexCfg); + } + } + } + try{ + multipleCfgService.deleteCfg(resultCfg); + }catch (Exception e) { + logger.error("删除失败"); + addMessage(model,"删除,正在为您跳转页面..."); + } + addMessage(model,"删除成功,正在为您跳转页面..."); + return "/cfg/resultPage"; + } + + /** + * + * saveOrUpdateCfg(保存配置) + * (这里描述这个方法适用条件 – 可选) + * @return + *String + * @exception + * @since 1.0.0 + */ + @RequestMapping(value = {"saveOrUpdateCfg"}) + public String saveOrUpdateCfg(String operator,String cfgName,Model model, MultipleCfg cfg) { + model.addAttribute("cfgName",cfgName); + model.addAttribute("action",cfg.getAction()); + model.addAttribute("cfgType", "multiple"); + model.addAttribute("audit", Constants.CFG_PAGE); + logger.info("saveOrUpdateCfg loaded"); + int serviceId=cfg.getServiceId(); + Date date=new Date(); + String mainTable=cfg.getMainTable(); + model.addAttribute("mainTable",mainTable); + model.addAttribute("serviceId",serviceId); + model.addAttribute("action",cfg.getAction()); + try{ + List serviceConfigInfos=serviceConfigInfoService.findList(cfg.getServiceId()); + Integer compileId=0; + if(operator.equals("save")){ + compileId=new ConvertTool().getCompileId(); + }else if(operator.equals("update")){ + compileId=cfg.getCompileId(); + } + for(ServiceConfigInfo info:serviceConfigInfos){ + if(Constants.TABLE_TYPE_IP==info.getTableType()){ + if(cfg.getIpCfg()!=null){ + for(Entry ipCfg:cfg.getIpCfg().entrySet()){ + if(!isNull(ipCfg.getValue())){ + ipCfg.getValue().setTableName(ipCfg.getKey()); + ipCfg.getValue().setIsValid(Constants.VALID_NO); + ipCfg.getValue().setIsAudit(Constants.AUDIT_NOT_YET); + ipCfg.getValue().setCompileId(compileId); + setProperties(cfg,ipCfg.getValue(),null,null,null); + if(ipCfg.getValue().getCfgId()==null){ + ipCfg.getValue().setCreatorId(cfg.getCurrentUser().getId()); + ipCfg.getValue().setCreateTime(date); + }else{ + ipCfg.getValue().setEditorId(cfg.getCurrentUser().getId()); + ipCfg.getValue().setEditTime(date); + } + } + } + } + }else if(Constants.TABLE_TYPE_STRING==info.getTableType()){ + if(cfg.getStringCfg()!=null){ + for(Entry stringCfg:cfg.getStringCfg().entrySet()){ + if(!isNull(stringCfg.getValue())){ + stringCfg.getValue().setTableName(stringCfg.getKey()); + stringCfg.getValue().setIsValid(Constants.VALID_NO); + stringCfg.getValue().setIsAudit(Constants.AUDIT_NOT_YET); + stringCfg.getValue().setCompileId(compileId); + setProperties(cfg,null,stringCfg.getValue(),null,null); + if(stringCfg.getValue().getCfgId()==null){ + stringCfg.getValue().setCreatorId(cfg.getCurrentUser().getId()); + stringCfg.getValue().setCreateTime(date); + }else{ + stringCfg.getValue().setEditorId(cfg.getCurrentUser().getId()); + stringCfg.getValue().setEditTime(date); + } + } + } + } + }else if(Constants.TABLE_TYPE_NUMBER==info.getTableType()){ + if(cfg.getNumCfg()!=null){ + for(Entry numCfg:cfg.getNumCfg().entrySet()){ + if(!isNull(numCfg.getValue())){ + numCfg.getValue().setTableName(info.getTableName()); + numCfg.getValue().setIsValid(Constants.VALID_NO); + numCfg.getValue().setIsAudit(Constants.AUDIT_NOT_YET); + numCfg.getValue().setCompileId(compileId); + setProperties(cfg,null,null,numCfg.getValue(),null); + if(numCfg.getValue().getCfgId()==null){ + numCfg.getValue().setCreatorId(cfg.getCurrentUser().getId()); + numCfg.getValue().setCreateTime(date); + }else{ + numCfg.getValue().setEditorId(cfg.getCurrentUser().getId()); + numCfg.getValue().setEditTime(date); + } + } + } + + } + }else if(Constants.TABLE_TYPE_COMPLEX==info.getTableType()){ + if(cfg.getComplexCfg()!=null){ + for(Entry complexCfg:cfg.getComplexCfg().entrySet()){ + if(!isNull(complexCfg.getValue())){ + complexCfg.getValue().setTableName(info.getTableName()); + complexCfg.getValue().setIsValid(Constants.VALID_NO); + complexCfg.getValue().setIsAudit(Constants.AUDIT_NOT_YET); + complexCfg.getValue().setCompileId(compileId); + setProperties(cfg,null,null,null,complexCfg.getValue()); + if(complexCfg.getValue().getCfgId()==null){ + complexCfg.getValue().setCreatorId(cfg.getCurrentUser().getId()); + complexCfg.getValue().setCreateTime(date); + }else{ + complexCfg.getValue().setEditorId(cfg.getCurrentUser().getId()); + complexCfg.getValue().setEditTime(new Date()); + } + } + } + + } + } + } + if("save".equals(operator)){ + multipleCfgService.addCfg(cfg); + }else if("update".equals(operator)){ + multipleCfgService.updateCfg(cfg); + } + addMessage(model,"保存成功,正在为您跳转页面..."); + }catch (Exception e) { + e.printStackTrace(); + logger.error("保存失败!",e); + // TODO: handle exception + addMessage(model,"保存失败!"); + } + return "/cfg/resultPage"; + } + /** + * + * auditIpCfg(审核IP配置) + * (审核流程只在审核页面) + * @return + *String + * @exception + * @since 1.0.0 + */ + @RequestMapping(value = {"auditCfg"}) + public String auditCfg(String cfgName,MultipleCfg cfg,Model model) { + model.addAttribute("cfgName", cfgName); + model.addAttribute("audit", Constants.AUDIT_PAGE); + model.addAttribute("serviceId", cfg.getServiceId()); + model.addAttribute("action", cfg.getAction()); + model.addAttribute("mainTable", cfg.getMainTable()); + int compileId=cfg.getCompileId().intValue(); + int audit=cfg.getIsAudit(); + MultipleCfg searchCfg=new MultipleCfg(); + List serviceConfigInfos=serviceConfigInfoService.findList(cfg.getServiceId()); + Date date=new Date(); + for(ServiceConfigInfo info:serviceConfigInfos){ + int type=info.getTableType(); + String tableName=info.getTableName(); + if(Constants.TABLE_TYPE_IP==type){ + BaseIpCfg searchIpCfg=new BaseIpCfg(); + searchIpCfg.setTableName(tableName); + searchIpCfg.setCompileId(compileId); + searchIpCfg.setAuditorId(searchIpCfg.getCurrentUser().getId()); + searchIpCfg.setAuditTime(date); + if(audit==Constants.AUDIT_NOT_YES){//取消审核通过,设置有效标志为0 + searchIpCfg.setIsValid(Constants.VALID_NO); + }else if(audit==Constants.AUDIT_YES){//审核通过,设置有效标志为1 + searchIpCfg.setIsValid(Constants.VALID_YES); + } + if(searchCfg.getIpCfg()==null){ + Map map=new HashMap(); + map.put(tableName, searchIpCfg); + searchCfg.setIpCfg(map); + }else{ + Map map=searchCfg.getIpCfg(); + map.put(tableName, searchIpCfg); + } + }else if(Constants.TABLE_TYPE_STRING==type){ + BaseStringCfg searchStringCfg=new BaseStringCfg(); + searchStringCfg.setTableName(tableName); + searchStringCfg.setCompileId(compileId); + searchStringCfg.setAuditorId(searchStringCfg.getCurrentUser().getId()); + searchStringCfg.setAuditTime(date); + if(audit==Constants.AUDIT_NOT_YES){//取消审核通过,设置有效标志为0 + searchStringCfg.setIsValid(Constants.VALID_NO); + }else if(audit==Constants.AUDIT_YES){//审核通过,设置有效标志为1 + searchStringCfg.setIsValid(Constants.VALID_YES); + } + if(searchCfg.getStringCfg()==null){ + Map map=new HashMap(); + map.put(tableName, searchStringCfg); + searchCfg.setStringCfg(map); + }else{ + Map map=searchCfg.getStringCfg(); + map.put(tableName, searchStringCfg); + } + }else if(Constants.TABLE_TYPE_NUMBER==type){ + NumBoundaryCfg searchNumCfg=new NumBoundaryCfg(); + searchNumCfg.setTableName(tableName); + searchNumCfg.setCompileId(compileId); + searchNumCfg.setAuditorId(searchNumCfg.getCurrentUser().getId()); + searchNumCfg.setAuditTime(date); + if(audit==Constants.AUDIT_NOT_YES){//取消审核通过,设置有效标志为0 + searchNumCfg.setIsValid(Constants.VALID_NO); + }else if(audit==Constants.AUDIT_YES){//审核通过,设置有效标志为1 + searchNumCfg.setIsValid(Constants.VALID_YES); + } + if(searchCfg.getNumCfg()==null){ + Map map=new HashMap(); + map.put(tableName, searchNumCfg); + searchCfg.setNumCfg(map); + }else{ + Map map=searchCfg.getNumCfg(); + map.put(tableName, searchNumCfg); + } + }else if(Constants.TABLE_TYPE_COMPLEX==type){ + ComplexkeywordCfg searchComplexCfg=new ComplexkeywordCfg(); + searchComplexCfg.setTableName(tableName); + searchComplexCfg.setCompileId(compileId); + searchComplexCfg.setAuditorId(searchComplexCfg.getCurrentUser().getId()); + searchComplexCfg.setAuditTime(date); + if(audit==Constants.AUDIT_NOT_YES){//取消审核通过,设置有效标志为0 + searchComplexCfg.setIsValid(Constants.VALID_NO); + }else if(audit==Constants.AUDIT_YES){//审核通过,设置有效标志为1 + searchComplexCfg.setIsValid(Constants.VALID_YES); + } + if(searchCfg.getComplexCfg()==null){ + Map map=new HashMap(); + map.put(tableName, searchComplexCfg); + searchCfg.setComplexCfg(map); + }else{ + Map map=searchCfg.getComplexCfg(); + map.put(tableName, searchComplexCfg); + } + } + } + multipleCfgService.auditCfg(searchCfg); + + return "redirect:" + adminPath + "/cfg/multiple/list"; + } + /** + * + * getClassBean(通过表名获取类) + * (这里描述这个方法适用条件 – 可选) + * @param tableName 表名 + * @param initDefaultValue 是否初始化bean的默认值 + * @return + *BaseCfg + * @exception + * @since 1.0.0 + */ + @SuppressWarnings("rawtypes") + protected BaseCfg getClassBean(String tableName,boolean initDefaultValue){ + logger.info("table name is "+tableName); + String className=ipCfgService.getClassName(tableName); + logger.info("class name is "+className); + String packageName=BaseCfg.class.getPackage().getName(); + + //通过反射获得BaseCfg的子类的实例,并调用子类的initDefaultValue初始化默认值 + try { + Class clazz = Class.forName(packageName+"."+className); + BaseCfg cfg=(BaseCfg)clazz.newInstance(); + cfg.setTableName(tableName); + if(initDefaultValue){ + cfg.initDefaultValue(); + } + return cfg; + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return null; + } + @SuppressWarnings("rawtypes") + protected boolean isNull(BaseCfg cfg) { + if(cfg==null)return true; + try { + Field[] fieldArray=cfg.getClass().getDeclaredFields(); + for(Field field:fieldArray){ + field.setAccessible(true); + if(field.get(cfg)!=null&&!"serialVersionUID".equals(field.getName())){ + return false; + } + } + } catch (IllegalArgumentException | IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return true; + } + @SuppressWarnings("rawtypes") + protected void setPropertiesToMultipleCfg(MultipleCfg resultCfg,BaseCfg _cfg,String option){ + resultCfg.setAction(_cfg.getAction()); + resultCfg.setAreaEffectiveIds(_cfg.getAreaEffectiveIds()); + resultCfg.setAttribute(_cfg.getAttribute()); + resultCfg.setClassify(_cfg.getClassify()); + resultCfg.setLable(_cfg.getLable()); + resultCfg.setCompileId(_cfg.getCompileId()); + resultCfg.setIsAreaEffective(_cfg.getIsAreaEffective()); + resultCfg.setIsAudit(_cfg.getIsAudit()); + resultCfg.setIsValid(_cfg.getIsValid()); + resultCfg.setRequestId(_cfg.getRequestId()); + resultCfg.setServiceId(_cfg.getServiceId()); + if("select".equals(option)){//列表时设置以下属性 + resultCfg.setCreatorId(_cfg.getCreatorId()); + resultCfg.setCreatorName(_cfg.getCreatorName()); + resultCfg.setCreateTime(_cfg.getCreateTime()); + resultCfg.setEditorId(_cfg.getEditorId()); + resultCfg.setEditorName(_cfg.getEditorName()); + resultCfg.setEditTime(_cfg.getEditTime()); + resultCfg.setAuditorId(_cfg.getAuditorId()); + resultCfg.setAuditorName(_cfg.getAuditorName()); + resultCfg.setAuditTime(_cfg.getAuditTime()); + } + } + protected void setProperties(MultipleSearchCfg source,BaseIpCfg ipCfg,BaseStringCfg stringCfg,NumBoundaryCfg numCfg,ComplexkeywordCfg complexCfg){ + if(ipCfg!=null){ + ipCfg.setAction(source.getAction()); + ipCfg.setAreaEffectiveIds(source.getAreaEffectiveIds()); + ipCfg.setAttribute(source.getAttribute()); + ipCfg.setClassify(source.getClassify()); + ipCfg.setLable(source.getLable()); + ipCfg.setIsAreaEffective(source.getIsAreaEffective()); + ipCfg.setRequestId(source.getRequestId()); + ipCfg.setServiceId(source.getServiceId()); + ipCfg.setCreatorId(source.getCreatorId()); + ipCfg.setCreatorName(source.getCreatorName()); + ipCfg.setCreateTime(source.getCreateTime()); + ipCfg.setEditorId(source.getEditorId()); + ipCfg.setEditorName(source.getEditorName()); + ipCfg.setEditTime(source.getEditTime()); + ipCfg.setAuditorId(source.getAuditorId()); + ipCfg.setAuditorName(source.getAuditorName()); + ipCfg.setAuditTime(source.getAuditTime()); + } + if(stringCfg!=null){ + stringCfg.setAction(source.getAction()); + stringCfg.setAreaEffectiveIds(source.getAreaEffectiveIds()); + stringCfg.setAttribute(source.getAttribute()); + stringCfg.setClassify(source.getClassify()); + stringCfg.setLable(source.getLable()); + stringCfg.setIsAreaEffective(source.getIsAreaEffective()); + stringCfg.setRequestId(source.getRequestId()); + stringCfg.setServiceId(source.getServiceId()); + stringCfg.setCreatorId(source.getCreatorId()); + stringCfg.setCreatorName(source.getCreatorName()); + stringCfg.setCreateTime(source.getCreateTime()); + stringCfg.setEditorId(source.getEditorId()); + stringCfg.setEditorName(source.getEditorName()); + stringCfg.setEditTime(source.getEditTime()); + stringCfg.setAuditorId(source.getAuditorId()); + stringCfg.setAuditorName(source.getAuditorName()); + stringCfg.setAuditTime(source.getAuditTime()); + } + if(numCfg!=null){ + numCfg.setAction(source.getAction()); + numCfg.setAreaEffectiveIds(source.getAreaEffectiveIds()); + numCfg.setAttribute(source.getAttribute()); + numCfg.setClassify(source.getClassify()); + numCfg.setLable(source.getLable()); + numCfg.setIsAreaEffective(source.getIsAreaEffective()); + numCfg.setRequestId(source.getRequestId()); + numCfg.setServiceId(source.getServiceId()); + numCfg.setCreatorId(source.getCreatorId()); + numCfg.setCreatorName(source.getCreatorName()); + numCfg.setCreateTime(source.getCreateTime()); + numCfg.setEditorId(source.getEditorId()); + numCfg.setEditorName(source.getEditorName()); + numCfg.setEditTime(source.getEditTime()); + numCfg.setAuditorId(source.getAuditorId()); + numCfg.setAuditorName(source.getAuditorName()); + numCfg.setAuditTime(source.getAuditTime()); + } + if(complexCfg!=null){ + complexCfg.setAction(source.getAction()); + complexCfg.setAreaEffectiveIds(source.getAreaEffectiveIds()); + complexCfg.setAttribute(source.getAttribute()); + complexCfg.setClassify(source.getClassify()); + complexCfg.setLable(source.getLable()); + complexCfg.setIsAreaEffective(source.getIsAreaEffective()); + complexCfg.setRequestId(source.getRequestId()); + complexCfg.setServiceId(source.getServiceId()); + complexCfg.setCreatorId(source.getCreatorId()); + complexCfg.setCreatorName(source.getCreatorName()); + complexCfg.setCreateTime(source.getCreateTime()); + complexCfg.setEditorId(source.getEditorId()); + complexCfg.setEditorName(source.getEditorName()); + complexCfg.setEditTime(source.getEditTime()); + complexCfg.setAuditorId(source.getAuditorId()); + complexCfg.setAuditorName(source.getAuditorName()); + complexCfg.setAuditTime(source.getAuditTime()); + } + } + protected void setProperties(MultipleCfg source,BaseIpCfg ipCfg,BaseStringCfg stringCfg,NumBoundaryCfg numCfg,ComplexkeywordCfg complexCfg){ + if(ipCfg!=null){ + ipCfg.setAction(source.getAction()); + ipCfg.setAreaEffectiveIds(source.getAreaEffectiveIds()); + ipCfg.setAttribute(source.getAttribute()); + ipCfg.setClassify(source.getClassify()); + ipCfg.setLable(source.getLable()); + ipCfg.setIsAreaEffective(source.getIsAreaEffective()); + ipCfg.setRequestId(source.getRequestId()); + ipCfg.setServiceId(source.getServiceId()); + } + if(stringCfg!=null){ + stringCfg.setAction(source.getAction()); + stringCfg.setAreaEffectiveIds(source.getAreaEffectiveIds()); + stringCfg.setAttribute(source.getAttribute()); + stringCfg.setClassify(source.getClassify()); + stringCfg.setLable(source.getLable()); + stringCfg.setIsAreaEffective(source.getIsAreaEffective()); + stringCfg.setRequestId(source.getRequestId()); + stringCfg.setServiceId(source.getServiceId()); + } + if(numCfg!=null){ + numCfg.setAction(source.getAction()); + numCfg.setAreaEffectiveIds(source.getAreaEffectiveIds()); + numCfg.setAttribute(source.getAttribute()); + numCfg.setClassify(source.getClassify()); + numCfg.setLable(source.getLable()); + numCfg.setIsAreaEffective(source.getIsAreaEffective()); + numCfg.setRequestId(source.getRequestId()); + numCfg.setServiceId(source.getServiceId()); + } + if(complexCfg!=null){ + complexCfg.setAction(source.getAction()); + complexCfg.setAreaEffectiveIds(source.getAreaEffectiveIds()); + complexCfg.setAttribute(source.getAttribute()); + complexCfg.setClassify(source.getClassify()); + complexCfg.setLable(source.getLable()); + complexCfg.setIsAreaEffective(source.getIsAreaEffective()); + complexCfg.setRequestId(source.getRequestId()); + complexCfg.setServiceId(source.getServiceId()); + } + } + protected void setPageProps(Page source,Page target){ + target.setCount(source.getCount()); + target.setPageNo(source.getPageNo()); + target.setPageSize(source.getPageSize()); + } +} diff --git a/src/main/java/com/nis/web/controller/configuration/NumCfgController.java b/src/main/java/com/nis/web/controller/configuration/NumCfgController.java index f064d3d71..52e509a12 100644 --- a/src/main/java/com/nis/web/controller/configuration/NumCfgController.java +++ b/src/main/java/com/nis/web/controller/configuration/NumCfgController.java @@ -13,9 +13,9 @@ import org.springframework.web.bind.annotation.RequestMapping; import com.nis.domain.Page; import com.nis.domain.ServiceConfigInfo; import com.nis.domain.basics.ServiceDictInfo; -import com.nis.domain.configuration.BaseCfg; import com.nis.domain.configuration.NumBoundaryCfg; import com.nis.domain.configuration.RequestInfo; +import com.nis.main.ConvertTool; import com.nis.util.Constants; import com.nis.web.controller.BaseController; @@ -27,7 +27,6 @@ import com.nis.web.controller.BaseController; @Controller @RequestMapping("${adminPath}/cfg/num") public class NumCfgController extends BaseController{ - @RequestMapping(value = {"list"}) public String cfgList(Model model,Integer audit,Integer pageNo,Integer pageSize,String cfgName,@ModelAttribute("cfg")NumBoundaryCfg cfg,HttpServletRequest request,HttpServletResponse response) { model.addAttribute("cfgName", cfgName); @@ -136,16 +135,11 @@ public class NumCfgController extends BaseController{ model.addAttribute("cfgType","num"); model.addAttribute("audit", Constants.CFG_PAGE); logger.info("saveOrUpdateStringCfg loaded"); - if(cfg==null){ - logger.error("无法保存空的配置!"); - addMessage(model,"保存失败!"); - }else if(cfg.getServiceId()!=null){ + try{ int serviceId=cfg.getServiceId(); ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); if(serviceConfigInfo!=null){ - long compileId=getCompileId(cfg); -// cfg.setCreatorId(cfg.getCurrentUser().getId()); -// cfg.setCreateTime(new Date()); + int compileId=new ConvertTool().getCompileId(); cfg.setIsValid(Constants.VALID_NO); cfg.setIsAudit(Constants.AUDIT_NOT_YET); cfg.setCompileId(compileId); @@ -162,11 +156,11 @@ public class NumCfgController extends BaseController{ model.addAttribute("action",cfg.getAction()); addMessage(model,"保存成功,正在为您跳转页面..."); } - }else{ + }catch(Exception e){ + logger.error("保存失败", e); addMessage(model,"保存失败!"); - logger.error("无法确定IP配置的表名!"); } - return "/cfg/resultPage";//StringEscapeUtils.escapeHtml4("?serviceId="+cfg.getServiceId()+"&action="+cfg.getAction()+"&cfgName="+cfgName); + return "/cfg/resultPage"; } /** @@ -182,33 +176,46 @@ public class NumCfgController extends BaseController{ public String auditStringCfg(String cfgName,NumBoundaryCfg cfg,Model model) { model.addAttribute("cfgName", cfgName); model.addAttribute("audit", Constants.AUDIT_PAGE); - if(cfg==null){ - logger.error("无法审核空的配置!"); - }else if(cfg.getServiceId()!=null){ + model.addAttribute("cfgType","num"); + model.addAttribute("serviceId", cfg.getServiceId()); + model.addAttribute("action", cfg.getAction()); + try{ int serviceId=cfg.getServiceId(); ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); if(serviceConfigInfo!=null){ - int audit=numCfgService.getIsAudit(cfg); + NumBoundaryCfg bean=numCfgService.getNumCfgById(cfg); + bean.setTableName(serviceConfigInfo.getTableName()); + int audit=bean.getIsAudit().intValue(); if(audit==Constants.AUDIT_YES&&cfg.getIsAudit()!=Constants.AUDIT_NOT_YES){ logger.error("审核通过的配置只能取消审核通过!"); }else{ cfg.setAuditorId(cfg.getCurrentUser().getId()); cfg.setAuditTime(new Date()); - + bean.setIsAudit(cfg.getIsAudit()); if(cfg.getIsAudit()==Constants.AUDIT_NOT_YES){//取消审核通过,设置有效标志为0 cfg.setIsValid(Constants.VALID_NO); + bean.setIsValid(Constants.VALID_NO); + bean.setMaatTable(serviceConfigInfo.getMaatTable()); }else if(cfg.getIsAudit()==Constants.AUDIT_YES){//审核通过,设置有效标志为1 cfg.setIsValid(Constants.VALID_YES); + bean.setIsValid(Constants.VALID_YES); + bean.setMaatTable(serviceConfigInfo.getMaatTable()); } - int result=numCfgService.auditNumCfg(cfg); - model.addAttribute("serviceId", serviceId); - model.addAttribute("action", cfg.getAction()); + int result=numCfgService.auditNumCfg(bean,cfg); + if(result!=0){ + addMessage(model, "审核成功"); + }else{ + addMessage(model, "审核失败"); + } + } } - }else{ - logger.error("无法确定IP配置的表名!"); + }catch (Exception e) { + // TODO: handle exception + logger.error("审核失败",e); + addMessage(model, "审核失败"); } - return "redirect:" + adminPath + "/cfg/num/list"; + return "/cfg/resultPage"; } /** * @@ -257,7 +264,14 @@ public class NumCfgController extends BaseController{ * @exception * @since 1.0.0 */ - protected long getCompileId(BaseCfg cfg){ - return 0; + protected long getCompileId(NumBoundaryCfg cfg){ + long compileId=0l; + try { + compileId = cfg.getCompileId()==null?new ConvertTool().getCompileId():cfg.getCompileId(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return compileId; } } diff --git a/src/main/java/com/nis/web/controller/configuration/StringCfgController.java b/src/main/java/com/nis/web/controller/configuration/StringCfgController.java index c1da0c564..6b7a5d4a1 100644 --- a/src/main/java/com/nis/web/controller/configuration/StringCfgController.java +++ b/src/main/java/com/nis/web/controller/configuration/StringCfgController.java @@ -14,9 +14,9 @@ import org.springframework.web.bind.annotation.RequestMapping; import com.nis.domain.Page; import com.nis.domain.ServiceConfigInfo; import com.nis.domain.basics.ServiceDictInfo; -import com.nis.domain.configuration.BaseCfg; import com.nis.domain.configuration.BaseStringCfg; import com.nis.domain.configuration.RequestInfo; +import com.nis.main.ConvertTool; import com.nis.util.Constants; import com.nis.web.controller.BaseController; @@ -121,7 +121,13 @@ public class StringCfgController extends BaseController{ model.addAttribute("action", action); model.addAttribute("tableName", tableName); model.addAttribute("audit", Constants.CFG_PAGE); - if(!StringUtils.isBlank(tableName)){ + try{ + if(StringUtils.isBlank(tableName)){ + ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); + if(serviceConfigInfo!=null){ + tableName=serviceConfigInfo.getTableName(); + } + } logger.info("table name is "+tableName); BaseStringCfg searchBean=new BaseStringCfg(); searchBean.setCfgId(cfgId); @@ -136,32 +142,10 @@ public class StringCfgController extends BaseController{ model.addAttribute("xzs", xzs); List lables=serviceDictInfoService.findAllLableDict(); model.addAttribute("lables", lables); - }else if(serviceId!=null){ - ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); - if(serviceConfigInfo!=null){ - tableName=serviceConfigInfo.getTableName(); - if(!StringUtils.isBlank(tableName)){ - logger.info("table name is "+tableName); - BaseStringCfg searchBean=new BaseStringCfg(); - searchBean.setCfgId(cfgId); - searchBean.setTableName(tableName); - BaseStringCfg stringCfg=stringCfgService.getStringCfgById(searchBean); - model.addAttribute("_cfg", stringCfg); - List requestInfos=requestInfoService.getAllRequestInfo(); - model.addAttribute("requestInfos", requestInfos); - List fls=serviceDictInfoService.findAllFlDict(); - model.addAttribute("fls", fls); - List xzs=serviceDictInfoService.findAllXzDict(); - model.addAttribute("xzs", xzs); - List lables=serviceDictInfoService.findAllLableDict(); - model.addAttribute("lables", lables); - - } - } - }else{ - logger.error("未获取到正确的表名"); + }catch (Exception e) { + // TODO: handle exception + logger.error("发生异常",e); } - return "/cfg/stringCfgForm"; } @@ -179,15 +163,20 @@ public class StringCfgController extends BaseController{ model.addAttribute("cfgName",cfgName); model.addAttribute("cfgType","string"); model.addAttribute("audit", Constants.CFG_PAGE); + model.addAttribute("serviceId",stringCfg.getServiceId()); + model.addAttribute("action",stringCfg.getAction()); logger.info("saveOrUpdateStringCfg loaded"); - if(stringCfg==null){ - logger.error("无法保存空的配置!"); - addMessage(model,"保存失败!"); - }else if(!StringUtils.isBlank(stringCfg.getTableName())){ + try{ + String tableName=stringCfg.getTableName(); int serviceId=stringCfg.getServiceId(); - long compileId=getCompileId(stringCfg); -// stringCfg.setCreatorId(stringCfg.getCurrentUser().getId()); -// stringCfg.setCreateTime(new Date()); + if(StringUtils.isBlank(stringCfg.getTableName())){ + ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); + if(serviceConfigInfo!=null){ + tableName=serviceConfigInfo.getTableName(); + stringCfg.setTableName(tableName); + } + } + int compileId=new ConvertTool().getCompileId(); stringCfg.setIsValid(Constants.VALID_NO); stringCfg.setIsAudit(Constants.AUDIT_NOT_YET); stringCfg.setCompileId(compileId); @@ -200,41 +189,13 @@ public class StringCfgController extends BaseController{ stringCfg.setEditTime(new Date()); stringCfgService.updateStringCfg(stringCfg); } - model.addAttribute("serviceId",serviceId); - model.addAttribute("action",stringCfg.getAction()); addMessage(model,"保存成功,正在为您跳转页面..."); - }else if(stringCfg.getServiceId()!=null){ - int serviceId=stringCfg.getServiceId(); - ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); - if(serviceConfigInfo!=null){ - String tableName=serviceConfigInfo.getTableName(); - if(!StringUtils.isBlank(tableName)){ - long compileId=getCompileId(stringCfg); - stringCfg.setTableName(tableName); -// stringCfg.setCreatorId(stringCfg.getCurrentUser().getId()); -// stringCfg.setCreateTime(new Date()); - stringCfg.setIsValid(Constants.VALID_NO); - stringCfg.setIsAudit(Constants.AUDIT_NOT_YET); - stringCfg.setCompileId(compileId); - if(stringCfg.getCfgId()==null){ - stringCfg.setCreatorId(stringCfg.getCurrentUser().getId()); - stringCfg.setCreateTime(new Date()); - stringCfgService.addStringCfg(stringCfg); - }else{ - stringCfg.setEditorId(stringCfg.getCurrentUser().getId()); - stringCfg.setEditTime(new Date()); - stringCfgService.updateStringCfg(stringCfg); - } - model.addAttribute("serviceId",serviceId); - model.addAttribute("action",stringCfg.getAction()); - addMessage(model,"保存成功,正在为您跳转页面..."); - } - } - }else{ - addMessage(model,"保存失败!"); - logger.error("无法确定IP配置的表名!"); + }catch (Exception e) { + // TODO: handle exception + logger.error("保存失败!",e); + addMessage(model,"保存失败!"); } - return "/cfg/resultPage";//StringEscapeUtils.escapeHtml4("?serviceId="+stringCfg.getServiceId()+"&action="+stringCfg.getAction()+"&cfgName="+cfgName); + return "/cfg/resultPage"; } /** @@ -250,55 +211,54 @@ public class StringCfgController extends BaseController{ public String auditStringCfg(String cfgName,BaseStringCfg stringCfg,Model model) { model.addAttribute("cfgName", cfgName); model.addAttribute("audit", Constants.AUDIT_PAGE); - if(stringCfg==null){ - logger.error("无法审核空的配置!"); - }else if(!StringUtils.isBlank(stringCfg.getTableName())){ - int audit=stringCfgService.getIsAudit(stringCfg); + model.addAttribute("cfgType","string"); + model.addAttribute("serviceId", stringCfg.getServiceId()); + model.addAttribute("action", stringCfg.getAction()); + try{ + String tableName=stringCfg.getTableName(); + int serviceId=stringCfg.getServiceId(); + String maatTable=null; + ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); + if(serviceConfigInfo!=null){ + if(StringUtils.isBlank(tableName)){ + tableName=serviceConfigInfo.getTableName(); + stringCfg.setTableName(tableName); + } + maatTable=serviceConfigInfo.getMaatTable(); + } + + BaseStringCfg bean=stringCfgService.getStringCfgById(stringCfg); + bean.setTableName(tableName); + int audit=bean.getIsAudit().intValue(); if(audit==Constants.AUDIT_YES&&stringCfg.getIsAudit()!=Constants.AUDIT_NOT_YES){ logger.error("审核通过的配置只能取消审核通过!"); }else{ stringCfg.setAuditorId(stringCfg.getCurrentUser().getId()); stringCfg.setAuditTime(new Date()); - + bean.setIsAudit(stringCfg.getIsAudit()); if(stringCfg.getIsAudit()==Constants.AUDIT_NOT_YES){//取消审核通过,设置有效标志为0 stringCfg.setIsValid(Constants.VALID_NO); + bean.setIsValid(Constants.VALID_NO); + bean.setMaatTable(maatTable); }else if(stringCfg.getIsAudit()==Constants.AUDIT_YES){//审核通过,设置有效标志为1 stringCfg.setIsValid(Constants.VALID_YES); + bean.setIsValid(Constants.VALID_YES); + bean.setMaatTable(maatTable); } - int result=stringCfgService.auditStringCfg(stringCfg); - model.addAttribute("serviceId", stringCfg.getServiceId()); - model.addAttribute("action", stringCfg.getAction()); - } - - }else if(stringCfg.getServiceId()!=null){ - int serviceId=stringCfg.getServiceId(); - ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); - if(serviceConfigInfo!=null){ - String tableName=serviceConfigInfo.getTableName(); - if(!StringUtils.isBlank(tableName)){ - stringCfg.setTableName(tableName); - int audit=stringCfgService.getIsAudit(stringCfg); - if(audit==Constants.AUDIT_YES&&stringCfg.getIsAudit()!=Constants.AUDIT_NOT_YES){ - logger.error("审核通过的配置只能取消审核通过!"); - }else{ - stringCfg.setAuditorId(stringCfg.getCurrentUser().getId()); - stringCfg.setAuditTime(new Date()); - - if(stringCfg.getIsAudit()==Constants.AUDIT_NOT_YES){//取消审核通过,设置有效标志为0 - stringCfg.setIsValid(Constants.VALID_NO); - }else if(stringCfg.getIsAudit()==Constants.AUDIT_YES){//审核通过,设置有效标志为1 - stringCfg.setIsValid(Constants.VALID_YES); - } - int result=stringCfgService.auditStringCfg(stringCfg); - model.addAttribute("serviceId", serviceId); - model.addAttribute("action", stringCfg.getAction()); - } + int result=stringCfgService.auditStringCfg(bean,stringCfg); + if(result!=0){ + addMessage(model,"审核成功!"); + }else{ + addMessage(model,"审核失败!"); } + } - }else{ - logger.error("无法确定IP配置的表名!"); + }catch (Exception e) { + // TODO: handle exception + logger.error("审核失败", e); + addMessage(model,"审核失败!"); } - return "redirect:" + adminPath + "/cfg/string/list"; + return "/cfg/resultPage"; } /** * @@ -316,7 +276,13 @@ public class StringCfgController extends BaseController{ model.addAttribute("action", action); model.addAttribute("cfgType","string"); model.addAttribute("audit", Constants.CFG_PAGE); - if(!StringUtils.isBlank(tableName)){ + try{ + if(StringUtils.isBlank(tableName)){ + ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); + if(serviceConfigInfo!=null){ + tableName=serviceConfigInfo.getTableName(); + } + } int audit=stringCfgService.getIsAudit(tableName,cfgId); //未审核时可删除 if(audit!=Constants.AUDIT_YES){ @@ -332,42 +298,10 @@ public class StringCfgController extends BaseController{ logger.error("通过审核的配置不能删除!"); } - }else if(serviceId!=null){ - ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); - if(serviceConfigInfo!=null){ - tableName=serviceConfigInfo.getTableName(); - if(!StringUtils.isBlank(tableName)){ - BaseStringCfg stringCfg=new BaseStringCfg(); - stringCfg.setCfgId(cfgId); - stringCfg.setTableName(tableName); - int audit=stringCfgService.getIsAudit(stringCfg); - //未审核时可删除 - if(audit!=Constants.AUDIT_YES){ - stringCfg.setEditorId(stringCfg.getCurrentUser().getId()); - stringCfg.setEditTime(new Date()); - stringCfg.setIsValid(Constants.VALID_DEL); - int result=stringCfgService.deleteStringCfg(stringCfg); - addMessage(model,"删除成功,正在为您跳转页面..."); - }else{ - logger.error("通过审核的配置不能删除!"); - } - } - } - }else{ - logger.error("无法确定IP配置的表名!"); + }catch(Exception e){ + logger.error("删除失败",e); + addMessage(model,"删除失败!"); } return "/cfg/resultPage"; } - /** - * - * getCompileId(获取编译ID) - * (这里描述这个方法适用条件 – 可选) - * @return - *long - * @exception - * @since 1.0.0 - */ - protected long getCompileId(BaseCfg cfg){ - return 0; - } } diff --git a/src/main/java/com/nis/web/controller/systemService/SystemServiceController.java b/src/main/java/com/nis/web/controller/systemService/SystemServiceController.java index de448b540..0bf3d1000 100644 --- a/src/main/java/com/nis/web/controller/systemService/SystemServiceController.java +++ b/src/main/java/com/nis/web/controller/systemService/SystemServiceController.java @@ -105,9 +105,9 @@ public class SystemServiceController extends BaseController { try { systemServiceService.save(systemServiceInfo, insertServiceConfigInfoList, updateServiceConfigInfoList); - addMessage(redirectAttributes, "保存成功"); + addMessage(redirectAttributes, "save_success"); } catch (Exception e) { - addMessage(redirectAttributes, "保存失败:" + e.getMessage()); + addMessage(redirectAttributes, "save_failed"); e.printStackTrace(); } @@ -122,9 +122,9 @@ public class SystemServiceController extends BaseController { systemServiceInfo.setIsValid(1); Page page = systemServiceService.findPage(new Page(request, response, 1), systemServiceInfo); model.addAttribute("page", page); - addMessage(model, "删除成功"); + addMessage(model, "delete_success"); } catch (Exception e) { - addMessage(model, "删除失败:" + e.getMessage()); + addMessage(model, "delete_failed"); e.printStackTrace(); } return "/systemService/list"; @@ -138,11 +138,12 @@ public class SystemServiceController extends BaseController { return "true"; } else { if (id != null) { - if (list.get(0).getId() == id) { - return "true"; - } else { - return "false"; + for (SystemServiceInfo info : list) { + if (info.getIsValid() == 1 && info.getId().longValue() == id.longValue()) { + return "true"; + } } + return "false"; } else { return "false"; } diff --git a/src/main/java/com/nis/web/dao/configuration/ComplexStringCfgDao.java b/src/main/java/com/nis/web/dao/configuration/ComplexStringCfgDao.java index 8d1b2b608..9d052efbb 100644 --- a/src/main/java/com/nis/web/dao/configuration/ComplexStringCfgDao.java +++ b/src/main/java/com/nis/web/dao/configuration/ComplexStringCfgDao.java @@ -26,4 +26,5 @@ public interface ComplexStringCfgDao extends CrudDao{ public int getIsValid(ComplexkeywordCfg entity); public int getIsAudit(@Param("tableName")String tableName,@Param("cfgId")Long id); public int getIsAudit(ComplexkeywordCfg entity); + public int deleteByCompileId(ComplexkeywordCfg entity); } diff --git a/src/main/java/com/nis/web/dao/configuration/ComplexStringCfgDao.xml b/src/main/java/com/nis/web/dao/configuration/ComplexStringCfgDao.xml index 7267ef454..a9c411c7c 100644 --- a/src/main/java/com/nis/web/dao/configuration/ComplexStringCfgDao.xml +++ b/src/main/java/com/nis/web/dao/configuration/ComplexStringCfgDao.xml @@ -481,4 +481,7 @@ SELECT IS_AUDIT FROM ${tableName} WHERE CFG_ID = #{cfgId,jdbcType=BIGINT} + + update ${tableName} set is_valid = #{isValid,jdbcType=INTEGER}, editor_id = #{editorId,jdbcType=INTEGER} , edit_time = #{editTime,jdbcType=TIMESTAMP} where compile_id = #{compileId,jdbcType=INTEGER} + \ No newline at end of file diff --git a/src/main/java/com/nis/web/dao/configuration/DnsIpCfgDao.xml b/src/main/java/com/nis/web/dao/configuration/DnsIpCfgDao.xml index 696cc60a8..8c43cc875 100644 --- a/src/main/java/com/nis/web/dao/configuration/DnsIpCfgDao.xml +++ b/src/main/java/com/nis/web/dao/configuration/DnsIpCfgDao.xml @@ -116,6 +116,9 @@ #{isValid}, #{isAudit}, #{creator.id}, #{createTime}, #{request.id}, #{fakeId}, #{classify}, #{attribute}, #{lable} ) + + select LAST_INSERT_ID() as cfg_id + diff --git a/src/main/java/com/nis/web/dao/configuration/IpCfgDao.java b/src/main/java/com/nis/web/dao/configuration/IpCfgDao.java index b96fe0341..9fb764cb2 100644 --- a/src/main/java/com/nis/web/dao/configuration/IpCfgDao.java +++ b/src/main/java/com/nis/web/dao/configuration/IpCfgDao.java @@ -26,4 +26,5 @@ public interface IpCfgDao extends CrudDao{ public int getIsValid(BaseIpCfg entity); public int getIsAudit(@Param("tableName")String tableName,@Param("cfgId")Long id); public int getIsAudit(BaseIpCfg entity); + public int deleteByCompileId(BaseIpCfg entity); } diff --git a/src/main/java/com/nis/web/dao/configuration/IpCfgDao.xml b/src/main/java/com/nis/web/dao/configuration/IpCfgDao.xml index 145cdf383..70ff708a0 100644 --- a/src/main/java/com/nis/web/dao/configuration/IpCfgDao.xml +++ b/src/main/java/com/nis/web/dao/configuration/IpCfgDao.xml @@ -291,7 +291,7 @@ AND ${page.alias}.IP_TYPE=#{ipType,jdbcType=INTEGER} - AND ${page.alias}.SRC_IP=#{srcIp,jdbcType=VARCHAR} + AND ${page.alias}.SRC_IP like concat('%', #{srcIp,jdbcType=VARCHAR}, '%') AND ${page.alias}.SRC_IP_MASK=#{srcIpMask,jdbcType=VARCHAR} @@ -303,7 +303,7 @@ AND ${page.alias}.SRC_PORT_MASK=#{srcPortMask,jdbcType=VARCHAR} - AND ${page.alias}.DST_IP=#{dstIp,jdbcType=VARCHAR} + AND ${page.alias}.DST_IP like concat('%', #{dstIp,jdbcType=VARCHAR}, '%') AND ${page.alias}.DST_IP_MASK=#{dstIpMask,jdbcType=VARCHAR} @@ -583,7 +583,7 @@ editor_id = #{editorId,jdbcType=INTEGER}, - + edit_time = #{editTime,jdbcType=TIMESTAMP}, @@ -639,4 +639,7 @@ SELECT IS_AUDIT FROM ${tableName} WHERE CFG_ID = #{cfgId,jdbcType=BIGINT} + + update ${tableName} set is_valid = #{isValid,jdbcType=INTEGER}, editor_id = #{editorId,jdbcType=INTEGER} , edit_time = #{editTime,jdbcType=TIMESTAMP} where compile_id = #{compileId,jdbcType=INTEGER} + \ No newline at end of file diff --git a/src/main/java/com/nis/web/dao/configuration/MultipleCfgDao.java b/src/main/java/com/nis/web/dao/configuration/MultipleCfgDao.java new file mode 100644 index 000000000..0f5fa9c2e --- /dev/null +++ b/src/main/java/com/nis/web/dao/configuration/MultipleCfgDao.java @@ -0,0 +1,25 @@ +package com.nis.web.dao.configuration; + +import java.util.List; + +import org.apache.ibatis.annotations.Param; + +import com.nis.domain.configuration.MultipleSearchCfg; +import com.nis.web.dao.CrudDao; +import com.nis.web.dao.MyBatisDao; + +/** + * 多域配置数据处理类 + * @author dell + * + */ +@MyBatisDao +public interface MultipleCfgDao extends CrudDao{ + public MultipleSearchCfg getById(@Param("tableName")String tableName,@Param("cfgId")Long id) ; + public MultipleSearchCfg get(MultipleSearchCfg entity) ; + public List findList(MultipleSearchCfg entity) ; + public int insert(MultipleSearchCfg entity) ; + public int updateByPrimaryKeySelective(MultipleSearchCfg entity) ; + public int updateValid(MultipleSearchCfg entity) ; + public int audit(MultipleSearchCfg entity) ; +} diff --git a/src/main/java/com/nis/web/dao/configuration/MultipleCfgDao.xml b/src/main/java/com/nis/web/dao/configuration/MultipleCfgDao.xml new file mode 100644 index 000000000..567b6438e --- /dev/null +++ b/src/main/java/com/nis/web/dao/configuration/MultipleCfgDao.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/main/java/com/nis/web/dao/configuration/NumCfgDao.java b/src/main/java/com/nis/web/dao/configuration/NumCfgDao.java index 2d79f65b3..c32fee7a0 100644 --- a/src/main/java/com/nis/web/dao/configuration/NumCfgDao.java +++ b/src/main/java/com/nis/web/dao/configuration/NumCfgDao.java @@ -26,4 +26,5 @@ public interface NumCfgDao extends CrudDao{ public int getIsValid(NumBoundaryCfg entity); public int getIsAudit(@Param("cfgId")Long id); public int getIsAudit(NumBoundaryCfg entity); + public int deleteByCompileId(NumBoundaryCfg entity); } diff --git a/src/main/java/com/nis/web/dao/configuration/NumCfgDao.xml b/src/main/java/com/nis/web/dao/configuration/NumCfgDao.xml index d59d28801..af9902a24 100644 --- a/src/main/java/com/nis/web/dao/configuration/NumCfgDao.xml +++ b/src/main/java/com/nis/web/dao/configuration/NumCfgDao.xml @@ -492,4 +492,7 @@ SELECT IS_AUDIT FROM NUM_BOUNDARY_CFG WHERE CFG_ID = #{cfgId,jdbcType=BIGINT} + + update NUM_BOUNDARY_CFG set is_valid = #{isValid,jdbcType=INTEGER}, editor_id = #{editorId,jdbcType=INTEGER} , edit_time = #{editTime,jdbcType=TIMESTAMP} where compile_id = #{compileId,jdbcType=INTEGER} + \ No newline at end of file diff --git a/src/main/java/com/nis/web/dao/configuration/StringCfgDao.java b/src/main/java/com/nis/web/dao/configuration/StringCfgDao.java index 284765c03..489c5914a 100644 --- a/src/main/java/com/nis/web/dao/configuration/StringCfgDao.java +++ b/src/main/java/com/nis/web/dao/configuration/StringCfgDao.java @@ -26,4 +26,5 @@ public interface StringCfgDao extends CrudDao{ public int getIsValid(BaseStringCfg entity); public int getIsAudit(@Param("tableName")String tableName,@Param("cfgId")Long id); public int getIsAudit(BaseStringCfg entity); + public int deleteByCompileId(BaseStringCfg entity); } diff --git a/src/main/java/com/nis/web/dao/configuration/StringCfgDao.xml b/src/main/java/com/nis/web/dao/configuration/StringCfgDao.xml index a818ea17d..bfe11fdf6 100644 --- a/src/main/java/com/nis/web/dao/configuration/StringCfgDao.xml +++ b/src/main/java/com/nis/web/dao/configuration/StringCfgDao.xml @@ -491,4 +491,7 @@ SELECT IS_AUDIT FROM ${tableName} WHERE CFG_ID = #{cfgId,jdbcType=BIGINT} + + update ${tableName} set is_valid = #{isValid,jdbcType=INTEGER}, editor_id = #{editorId,jdbcType=INTEGER} , edit_time = #{editTime,jdbcType=TIMESTAMP} where compile_id = #{compileId,jdbcType=INTEGER} + \ No newline at end of file diff --git a/src/main/java/com/nis/web/dao/systemService/SystemServiceInfoDao.xml b/src/main/java/com/nis/web/dao/systemService/SystemServiceInfoDao.xml index c9dfe4b18..a599620d7 100644 --- a/src/main/java/com/nis/web/dao/systemService/SystemServiceInfoDao.xml +++ b/src/main/java/com/nis/web/dao/systemService/SystemServiceInfoDao.xml @@ -99,7 +99,7 @@ diff --git a/src/main/webapp/WEB-INF/include/form/ipInfo.jsp b/src/main/webapp/WEB-INF/include/form/ipInfo.jsp index d7a425267..efc3aa2fd 100644 --- a/src/main/webapp/WEB-INF/include/form/ipInfo.jsp +++ b/src/main/webapp/WEB-INF/include/form/ipInfo.jsp @@ -4,7 +4,7 @@
- +
diff --git a/src/main/webapp/WEB-INF/include/form/stringInfo.jsp b/src/main/webapp/WEB-INF/include/form/stringInfo.jsp index ec8061d3b..9da9b031a 100644 --- a/src/main/webapp/WEB-INF/include/form/stringInfo.jsp +++ b/src/main/webapp/WEB-INF/include/form/stringInfo.jsp @@ -4,7 +4,7 @@
- +
diff --git a/src/main/webapp/WEB-INF/tags/sys/iconselect.tag b/src/main/webapp/WEB-INF/tags/sys/iconselect.tag index 76b749340..e3ca7efed 100644 --- a/src/main/webapp/WEB-INF/tags/sys/iconselect.tag +++ b/src/main/webapp/WEB-INF/tags/sys/iconselect.tag @@ -3,12 +3,12 @@ <%@ attribute name="id" type="java.lang.String" required="true" description="编号"%> <%@ attribute name="name" type="java.lang.String" required="true" description="输入框名称"%> <%@ attribute name="value" type="java.lang.String" required="true" description="输入框值"%> -   -选择   +   +   diff --git a/src/main/webapp/WEB-INF/views/cfg/stringCfgForm.jsp b/src/main/webapp/WEB-INF/views/cfg/stringCfgForm.jsp index aa68243c1..ee70af6ea 100644 --- a/src/main/webapp/WEB-INF/views/cfg/stringCfgForm.jsp +++ b/src/main/webapp/WEB-INF/views/cfg/stringCfgForm.jsp @@ -7,9 +7,6 @@ $(function(){ $("#cfgFrom").validate({ rules: { - 'cfgDesc':{ - required:true - }, 'cfgKeywords':{ required:true }, @@ -33,9 +30,6 @@ $(function(){ } }, messages: { - 'cfgDesc':{ - required:'' - }, 'cfgKeywords':{ required:'' }, diff --git a/src/main/webapp/WEB-INF/views/cfg/stringCfgList.jsp b/src/main/webapp/WEB-INF/views/cfg/stringCfgList.jsp index ff409f0a3..6200f4d48 100644 --- a/src/main/webapp/WEB-INF/views/cfg/stringCfgList.jsp +++ b/src/main/webapp/WEB-INF/views/cfg/stringCfgList.jsp @@ -5,6 +5,17 @@ <spring:message code="${cfgName}"></spring:message>
- " value="${systemServiceInfo.serviceId }"/> + " value="${systemServiceInfo.serviceId }" onkeyup="checkNum(this)"/>
@@ -119,7 +127,7 @@ function deleteService(id) { - ${ssi.creator.loginId } + ${ssi.creator.name } ${ssi.serviceDesc } diff --git a/src/main/webapp/static/global/css/components.css b/src/main/webapp/static/global/css/components.css index 1b7f78bfb..bb0b02513 100644 --- a/src/main/webapp/static/global/css/components.css +++ b/src/main/webapp/static/global/css/components.css @@ -5065,9 +5065,10 @@ Form Layouts .control-label .required, .form-group .required { - color: #e02222; +/* color: #e02222; font-size: 12px; - padding-left: 2px; } + padding-left: 2px; */ +} .form { padding: 0 !important; } @@ -6156,36 +6157,12 @@ Customized Bootstrap Labels h6 .label { font-size: 75%; } -/* Labels variants */ -.label-default { - background-color: #bac3d0; } - .label-default[href]:hover, .label-default[href]:focus { - background-color: #9ca8bb; } - -.label-primary { - background-color: #337ab7; } - .label-primary[href]:hover, .label-primary[href]:focus { - background-color: #286090; } - -.label-success { - background-color: #36c6d3; } - .label-success[href]:hover, .label-success[href]:focus { - background-color: #27a4b0; } - -.label-info { - background-color: #659be0; } - .label-info[href]:hover, .label-info[href]:focus { - background-color: #3a80d7; } - -.label-warning { - background-color: #F1C40F; } - .label-warning[href]:hover, .label-warning[href]:focus { - background-color: #c29d0b; } - -.label-danger { - background-color: #ed6b75; } - .label-danger[href]:hover, .label-danger[href]:focus { - background-color: #e73d4a; } +/* Labels variants */ + .label-warning { + background-color: #e6911a; } + .label-warning[href]:hover, .label-warning[href]:focus { + background-color: #c88220; } + /*** Iconic labels