diff --git a/src/main/java/com/nis/domain/configuration/AppComplexKeywordCfg.java b/src/main/java/com/nis/domain/configuration/AppComplexKeywordCfg.java new file mode 100644 index 000000000..eb3266010 --- /dev/null +++ b/src/main/java/com/nis/domain/configuration/AppComplexKeywordCfg.java @@ -0,0 +1,54 @@ +/** + *@Title: BaseEnhancedStringConfig.java + *@Package com.nis.domain.restful + *@Description TODO + *@author dell + *@date 2018年2月5日 下午5:42:52 + *@version 版本号 + */ +package com.nis.domain.configuration; + +import org.apache.commons.lang3.StringUtils; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +/** + * @ClassName: BaseEnhancedStringConfig.java + * @Description: APP增强字符串类配置 + * @author (zhangwei) + * @date 2018年4月3日 下午5:42:52 + * @version V1.0 + */ +public class AppComplexKeywordCfg extends ComplexkeywordCfg{ + /** + * @Fields serialVersionUID:TODO(用一句话描述这个变量表示什么) + * + * @since 1.0.0 + */ + + /** + * + */ + private static final long serialVersionUID = -8058690163147881374L; + @Expose + private Integer compileId; + + public Integer getCompileId() { + return compileId; + } + public void setCompileId(Integer compileId) { + this.compileId = compileId; + } + /* (non-Javadoc) + * @see com.nis.domain.configuration.BaseCfg#initDefaultValue() + */ + @Override + public void initDefaultValue() { + // TODO Auto-generated method stub + super.initDefaultValue(); + this.exprType=0; + this.isHexbin = 0 ; + this.matchMethod=3; + } +} diff --git a/src/main/java/com/nis/domain/configuration/AppIdCfg.java b/src/main/java/com/nis/domain/configuration/AppIdCfg.java index 3d3a64483..a287f2e4d 100644 --- a/src/main/java/com/nis/domain/configuration/AppIdCfg.java +++ b/src/main/java/com/nis/domain/configuration/AppIdCfg.java @@ -32,7 +32,7 @@ public class AppIdCfg extends BaseCfg { /** * 应用协议id */ - private Long appId; + private Integer appId; /** * 编译id @@ -42,12 +42,17 @@ public class AppIdCfg extends BaseCfg { /** * 协议字符串特征表信息列表 */ - private List complexFeaturesList; + private List complexFeaturesList; /** * 协议增强字符串特征配置信息列表 */ - private List strFeaturesCfgList; + private List strFeaturesCfgList; + + /** + * 协议服务器IP配置信息列表 + */ + private List ipCfgList; private List featuresList; @@ -111,14 +116,14 @@ public class AppIdCfg extends BaseCfg { * @return appId */ - public Long getAppId() { + public Integer getAppId() { return appId; } /** * @param appId the appId to set */ - public void setAppId(Long appId) { + public void setAppId(Integer appId) { this.appId = appId; } @@ -149,19 +154,19 @@ public class AppIdCfg extends BaseCfg { } - public List getComplexFeaturesList() { + public List getComplexFeaturesList() { return complexFeaturesList; } - public void setComplexFeaturesList(List complexFeaturesList) { + public void setComplexFeaturesList(List complexFeaturesList) { this.complexFeaturesList = complexFeaturesList; } - public List getStrFeaturesCfgList() { + public List getStrFeaturesCfgList() { return strFeaturesCfgList; } - public void setStrFeaturesCfgList(List strFeaturesCfgList) { + public void setStrFeaturesCfgList(List strFeaturesCfgList) { this.strFeaturesCfgList = strFeaturesCfgList; } @@ -172,5 +177,13 @@ public class AppIdCfg extends BaseCfg { public void setFeaturesList(List featuresList) { this.featuresList = featuresList; } + + public List getIpCfgList() { + return ipCfgList; + } + + public void setIpCfgList(List ipCfgList) { + this.ipCfgList = ipCfgList; + } } diff --git a/src/main/java/com/nis/domain/configuration/AppStringCfg.java b/src/main/java/com/nis/domain/configuration/AppStringCfg.java new file mode 100644 index 000000000..6c95b5e23 --- /dev/null +++ b/src/main/java/com/nis/domain/configuration/AppStringCfg.java @@ -0,0 +1,50 @@ +/** + *@Title: BaseStringConfig.java + *@Package com.nis.domain.restful + *@Description TODO + *@author dell + *@date 2018年2月5日 下午5:26:02 + *@version 版本号 + */ +package com.nis.domain.configuration; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +/** + * @ClassName: BaseStringConfig.java + * @Description: 基础字符串类配置 + * @author (dell) + * @date 2018年2月5日 下午5:26:02 + * @version V1.0 + */ +public class AppStringCfg extends BaseStringCfg { + + + /** + * @Fields serialVersionUID:TODO(用一句话描述这个变量表示什么) + * + * @since 1.0.0 + */ + private static final long serialVersionUID = 4938724489988587634L; + @Expose + private Integer compileId; + + /* (non-Javadoc) + * @see com.nis.domain.configuration.BaseCfg#initDefaultValue() + */ + @Override + public void initDefaultValue() { + // TODO Auto-generated method stub + super.initDefaultValue(); + this.isHexbin = 0; + } + + public Integer getCompileId() { + return compileId; + } + public void setCompileId(Integer compileId) { + this.compileId = compileId; + } + +} diff --git a/src/main/java/com/nis/domain/maat/AppMaatCfg.java b/src/main/java/com/nis/domain/maat/AppMaatCfg.java new file mode 100644 index 000000000..a4c47484b --- /dev/null +++ b/src/main/java/com/nis/domain/maat/AppMaatCfg.java @@ -0,0 +1,200 @@ +/** + *@Title: MaatCfg.java + *@Package com.nis.domain.maat + *@Description TODO + *@author dell + *@date 2018年3月1日 上午10:29:29 + *@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; +import com.nis.domain.configuration.AppComplexKeywordCfg; +import com.nis.domain.configuration.AppStringCfg; +import com.nis.domain.configuration.AreaIpCfg; +import com.nis.domain.configuration.BaseIpCfg; +import com.nis.domain.configuration.BaseStringCfg; +import com.nis.domain.configuration.ComplexkeywordCfg; +import com.nis.domain.configuration.NumBoundaryCfg; +import com.nis.domain.specific.SpecificServiceHostCfg; + +/** + * @ClassName: MaatCfg.java + * @Description: TODO + * @author (dell) + * @date 2018年3月1日 上午10:29:29 + * @version V1.0 + */ +public class AppMaatCfg implements Serializable { + + /** + * @Fields serialVersionUID:TODO(用一句话描述这个变量表示什么) + * + * @since 1.0.0 + */ + + private static final long serialVersionUID = -7745084076394247318L; + /** + * APP字符串特征配置 + */ + @Expose + @SerializedName("strFeaturesCfg") + private List strCfg; + /** + * APP服务器IP配置 + */ + @Expose + @SerializedName("specificServiceIpCfg") + private List ipCfg; + /** + * APP服务器IP生效区域配置 + */ + @Expose + @SerializedName("areaCfg") + private List areaCfg; + /** + * APP增强字符串特征配置 + */ + @Expose + @SerializedName("complexStrFeaturesCfg") + private List complexStrCfg; + + @Expose + @SerializedName("action") + private Integer action; + @Expose + @SerializedName("areaEffectiveIds") + private String areaEffectiveIds; + @Expose + @SerializedName("attribute") + private String attribute; + @Expose + @SerializedName("classify") + private String classify; + @Expose + @SerializedName("lable") + private String lable; + @Expose + @SerializedName("compileId") + private Integer compileId; + @Expose + @SerializedName("isAreaEffective") + private Integer isAreaEffective; + @Expose + @SerializedName("isValid") + private Integer isValid; + @Expose + @SerializedName("requestId") + private Integer requestId; + @Expose + @SerializedName("serviceId") + private Integer serviceId; + @Expose + @SerializedName("specificServiceId") + private Integer specificServiceId; + + @Expose + private String maatTable; + + public List getStrCfg() { + return strCfg; + } + public void setStrCfg(List strCfg) { + this.strCfg = strCfg; + } + public List getIpCfg() { + return ipCfg; + } + public void setIpCfg(List ipCfg) { + this.ipCfg = ipCfg; + } + public List getComplexStrCfg() { + return complexStrCfg; + } + public void setComplexStrCfg(List complexStrCfg) { + this.complexStrCfg = complexStrCfg; + } + public List getAreaCfg() { + return areaCfg; + } + public void setAreaCfg(List areaCfg) { + this.areaCfg = areaCfg; + } + public Integer getAction() { + return action; + } + public void setAction(Integer action) { + this.action = action; + } + public String getAreaEffectiveIds() { + return areaEffectiveIds; + } + public void setAreaEffectiveIds(String areaEffectiveIds) { + this.areaEffectiveIds = areaEffectiveIds; + } + 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 String getLable() { + return lable; + } + public void setLable(String lable) { + this.lable = lable; + } + public Integer getCompileId() { + return compileId; + } + public void setCompileId(Integer compileId) { + this.compileId = compileId; + } + public Integer getIsAreaEffective() { + return isAreaEffective; + } + public void setIsAreaEffective(Integer isAreaEffective) { + this.isAreaEffective = isAreaEffective; + } + public Integer getIsValid() { + return isValid; + } + public void setIsValid(Integer isValid) { + this.isValid = isValid; + } + public Integer getRequestId() { + return requestId; + } + public void setRequestId(Integer requestId) { + this.requestId = requestId; + } + public Integer getServiceId() { + return serviceId; + } + public void setServiceId(Integer serviceId) { + this.serviceId = serviceId; + } + public Integer getSpecificServiceId() { + return specificServiceId; + } + public void setSpecificServiceId(Integer specificServiceId) { + this.specificServiceId = specificServiceId; + } + public String getMaatTable() { + return maatTable; + } + public void setMaatTable(String maatTable) { + this.maatTable = maatTable; + } + +} diff --git a/src/main/java/com/nis/domain/specific/ConfigGroupInfo.java b/src/main/java/com/nis/domain/specific/ConfigGroupInfo.java new file mode 100644 index 000000000..e51dc5bd9 --- /dev/null +++ b/src/main/java/com/nis/domain/specific/ConfigGroupInfo.java @@ -0,0 +1,56 @@ +package com.nis.domain.specific; + +import java.util.Date; + +public class ConfigGroupInfo { + private Integer id; + private Integer groupId; + private String groupName; + private Integer isIssued; + private Date insertTime; + private Date updateTime; + private Integer groupType; + public Integer getId() { + return id; + } + public void setId(Integer id) { + this.id = id; + } + public Integer getGroupId() { + return groupId; + } + public void setGroupId(Integer groupId) { + this.groupId = groupId; + } + public String getGroupName() { + return groupName; + } + public void setGroupName(String groupName) { + this.groupName = groupName; + } + public Integer getIsIssued() { + return isIssued; + } + public void setIsIssued(Integer isIssued) { + this.isIssued = isIssued; + } + public Date getInsertTime() { + return insertTime; + } + public void setInsertTime(Date insertTime) { + this.insertTime = insertTime; + } + public Date getUpdateTime() { + return updateTime; + } + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + public Integer getGroupType() { + return groupType; + } + public void setGroupType(Integer groupType) { + this.groupType = groupType; + } + +} diff --git a/src/main/java/com/nis/domain/specific/SpecificServiceHostCfg.java b/src/main/java/com/nis/domain/specific/SpecificServiceHostCfg.java index 3446c93db..7369c57f4 100644 --- a/src/main/java/com/nis/domain/specific/SpecificServiceHostCfg.java +++ b/src/main/java/com/nis/domain/specific/SpecificServiceHostCfg.java @@ -4,6 +4,8 @@ import java.util.Date; import java.util.List; import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; import com.nis.domain.BaseEntity; import com.nis.domain.SysUser; @@ -15,21 +17,34 @@ import com.nis.domain.SysUser; public class SpecificServiceHostCfg extends BaseEntity{ private static final long serialVersionUID = -301627652860717175L; - + @Expose + @SerializedName("cfgId") private Integer hostId; //host_id 配置ID bigint N 主键,自增 private Integer specServiceId; //spec_service_id 协议id int N protocol_info_cfg.protocol_id + @Expose private Integer ipType; //ip地址类型 ipV4=4 ipV6=6 + @Expose private String srcIp; //src_ip 源IP地址 varchar(64) N 缺省0.0.0.0值表示任意 + @Expose private String srcIpMask; //src_ip_mask 源地址掩码 varchar(64) N IPV4:255.255.255.255表示无掩码,即精确IP匹配,0.0.0.0值表示任意; //IPV6:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF表示无掩码,::(两个半角冒号)表示任意。非0掩码值必须是2的指数幂,下同。 + @Expose private String srcPort; //src_port 源端口 varchar(6) N 0表示任意值 + @Expose private String srcPortMask; //src_port_mask 源端口掩码 varchar(6) N 65535表示无掩码,即精确端口匹配,0表示任意 + @Expose private String dstIp; //dst_ip 目的IP地址 varchar(64) N 缺省0.0.0.0值表示任意 + @Expose private String dstIpMask; //dst_ip_mask 目的地址掩码 varchar(64) N 同源ip地址掩码 + @Expose private String dstPort; //dst_port 目的端口 varchar(6) N 目的端口,0表示任意值 + @Expose private String dstPortMask; //dst_port_mask 目的端口掩码 varchar(6) N 同源端口掩码 + @Expose private Integer direction;; //direction 方向 int N 0双向,1单向,默认缺省为双向。 + @Expose private Integer protocol; //protocol 协议 int N 6表示tcp,17表示udp,0表示任意 + private Integer isValid; //is_valid 有效标识 int N 0无效,1有效 private Integer isAudit; //is_audit 是否审核 int N 0未审核,1审核通过,2审核未通过,3取消审核通过(即删除) private SysUser creator; //creator_id 创建人员 int N 取自sys_user.id @@ -38,9 +53,12 @@ public class SpecificServiceHostCfg extends BaseEntity{ private Date editTime; //edit_time 修改时间 date Y private SysUser auditor; //auditor_id 审核人员 int Y 取自sys_user.id private Date auditTime; //audit_time 审核时间 date Y - - - + @Expose + private Integer protocolId;//配置转json下发时使用 + @Expose + private String maatTable;//配置转json下发时使用 + @Expose + private Integer groupId;//配置转json下发时使用 private Date beginDate; private Date endDate; @@ -226,11 +244,23 @@ public class SpecificServiceHostCfg extends BaseEntity{ public static void sort(List list, List sourceList, Integer ParentId, boolean cascade){ } - - - - - - + public Integer getProtocolId() { + return protocolId; + } + public void setProtocolId(Integer protocolId) { + this.protocolId = protocolId; + } + public String getMaatTable() { + return maatTable; + } + public void setMaatTable(String maatTable) { + this.maatTable = maatTable; + } + public Integer getGroupId() { + return groupId; + } + public void setGroupId(Integer groupId) { + this.groupId = groupId; + } } diff --git a/src/main/java/com/nis/web/controller/configuration/AppCfgController.java b/src/main/java/com/nis/web/controller/configuration/AppCfgController.java index a8b78fa1d..25f798537 100644 --- a/src/main/java/com/nis/web/controller/configuration/AppCfgController.java +++ b/src/main/java/com/nis/web/controller/configuration/AppCfgController.java @@ -102,6 +102,14 @@ public class AppCfgController extends BaseController { //协议特征配置 List featuresList = serviceConfigInfoService.findList(serviceId); model.addAttribute("featuresList",featuresList); + if(featuresList!=null){ + for(ServiceConfigInfo s:featuresList){ + if(s.getTableType()==2 || s.getTableType()==4){ + model.addAttribute("isContainFeaturesCfg", true); + break; + } + } + } //特征作用域信息 /*SysDictInfo sysDictInfo = new SysDictInfo(); sysDictInfo.setItemType(3); @@ -247,7 +255,13 @@ public class AppCfgController extends BaseController { }else if(cfg.getIsAudit()==Constants.AUDIT_YES){//审核通过,设置有效标志为1 cfg.setIsValid(Constants.VALID_YES); } - int result=appCfgService.auditAppCfg(cfg); + try { + int result=appCfgService.auditAppCfg(cfg); + } catch (Exception e) { + e.printStackTrace(); + logger.error("配置下发maat失败,"+e.getMessage()); + addMessage(model,"配置审核下发失败!"); + } model.addAttribute("serviceId", cfg.getServiceId()); model.addAttribute("action", cfg.getAction()); } @@ -264,11 +278,11 @@ public class AppCfgController extends BaseController { * @since 1.0.0 */ @RequestMapping(value = {"deleteCfg"}) - public String deleteAppCfg(int action,long cfgId,String cfgName,Integer serviceId,Model model) { + public String deleteAppCfg(int action,long cfgId,Integer compileId,String cfgName,Integer serviceId,Model model) { model.addAttribute("serviceId", serviceId); model.addAttribute("cfgName", cfgName); model.addAttribute("action", action); - model.addAttribute("cfgType","complex"); + model.addAttribute("cfgType","app"); model.addAttribute("audit", Constants.CFG_PAGE); int audit=appCfgService.getIsAudit(cfgId); //未审核时可删除 @@ -278,6 +292,7 @@ public class AppCfgController extends BaseController { cfg.setEditorId(cfg.getCurrentUser().getId()); cfg.setEditTime(new Date()); cfg.setIsValid(Constants.VALID_DEL); + cfg.setCompileId(compileId); int result=appCfgService.deleteAppCfg(cfg); addMessage(model,"删除成功,正在为您跳转页面..."); }else{ diff --git a/src/main/java/com/nis/web/dao/configuration/AppCfgDao.java b/src/main/java/com/nis/web/dao/configuration/AppCfgDao.java index 9fe92589f..5e2fe35e1 100644 --- a/src/main/java/com/nis/web/dao/configuration/AppCfgDao.java +++ b/src/main/java/com/nis/web/dao/configuration/AppCfgDao.java @@ -1,11 +1,14 @@ package com.nis.web.dao.configuration; +import java.util.Date; import java.util.List; import org.apache.ibatis.annotations.Param; +import com.nis.domain.configuration.AppComplexKeywordCfg; import com.nis.domain.configuration.AppIdCfg; import com.nis.domain.configuration.AppIdCfg.AppFeaturesIndex; +import com.nis.domain.configuration.AppStringCfg; import com.nis.domain.configuration.BaseStringCfg; import com.nis.domain.configuration.ComplexkeywordCfg; import com.nis.web.dao.CrudDao; @@ -26,16 +29,19 @@ public interface AppCfgDao extends CrudDao { public int updateByPrimaryKeySelective(AppIdCfg entity) ; public int updateValid(AppIdCfg entity) ; public int audit(AppIdCfg entity) ; -// public int getIsValid(@Param("tableName")String tableName,@Param("cfgId")Long id); + public int updateFeaturesTableValid(@Param("tableName")String tableName,@Param("compileId")Integer compileId, + @Param("isValid")Integer isValid,@Param("editorId")Long editorId,@Param("editTime")Date editTime) ; + public int auditFeaturesTable(@Param("tableName")String tableName,@Param("compileId")Integer compileId, + @Param("isValid")Integer isValid,@Param("isAudit")Integer isAudit, + @Param("auditorId")Long auditorId,@Param("auditTime")Date auditTime) ; + public int getIsValid(@Param("tableName")String tableName,@Param("cfgId")Long id); public int getIsValid(@Param("cfgId")Long id); -// public int getIsAudit(@Param("tableName")String tableName,@Param("cfgId")Long id); + public int getIsAudit(@Param("tableName")String tableName,@Param("cfgId")Long id); public int getIsAudit(@Param("cfgId")Long id); - public List getComplexkeywordCfgList(); public List getFeaturesTableListByAppCompileId(@Param("appCompileId")Integer appCompileId) ; - public List getFeaturesCfgListByCompileId(@Param("compileId")Integer compileId) ; public int insertFeatures(AppFeaturesIndex entity) ; public int updateFeaturesByAppId(AppFeaturesIndex entity) ; public int deleteFeaturesByAppId(AppFeaturesIndex entity) ; - public List getComplexkeywordFeaturesCfgListByCompileId(@Param("featuresTable") String featuresTable,@Param("compileId")Integer compileId); - public List getStrFeaturesCfgListByCompileId(@Param("featuresTable") String featuresTable,@Param("compileId")Integer compileId); + public List getComplexkeywordFeaturesCfgListByCompileId(@Param("featuresTable") String featuresTable,@Param("compileId")Integer compileId); + public List getStrFeaturesCfgListByCompileId(@Param("featuresTable") String featuresTable,@Param("compileId")Integer compileId); } diff --git a/src/main/java/com/nis/web/dao/configuration/AppCfgDao.xml b/src/main/java/com/nis/web/dao/configuration/AppCfgDao.xml index 5264a2e00..0a61ec8b0 100644 --- a/src/main/java/com/nis/web/dao/configuration/AppCfgDao.xml +++ b/src/main/java/com/nis/web/dao/configuration/AppCfgDao.xml @@ -38,7 +38,7 @@ - + @@ -64,7 +64,7 @@ - + @@ -504,6 +504,16 @@ 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} + + + update ${tableName} set is_audit = #{isAudit,jdbcType=INTEGER}, auditor_id = #{auditorId,jdbcType=INTEGER}, audit_time = #{auditTime,jdbcType=TIMESTAMP} + + ,is_valid = #{isValid,jdbcType=INTEGER} + + where compile_id = #{compileId,jdbcType=INTEGER} + SELECT * FROM specific_service_cfg s WHERE s.is_valid = 1 and s.parent_id = #{specServiceId} + + + + + + + UPDATE config_group_info set is_issued = #{isIssued},update_time=now() where group_id = #{groupId} + + + + + insert into config_group_info (id,group_id,group_name,is_issued,insert_time,group_type) + values(#{id},#{groupId},#{groupName},#{isIssued},now(),#{groupType}) + \ No newline at end of file diff --git a/src/main/java/com/nis/web/service/configuration/AppCfgService.java b/src/main/java/com/nis/web/service/configuration/AppCfgService.java index afff26429..95581b21f 100644 --- a/src/main/java/com/nis/web/service/configuration/AppCfgService.java +++ b/src/main/java/com/nis/web/service/configuration/AppCfgService.java @@ -1,25 +1,40 @@ package com.nis.web.service.configuration; +import java.lang.annotation.Annotation; +import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.Map; import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; import com.nis.domain.Page; import com.nis.domain.ServiceConfigInfo; +import com.nis.domain.configuration.AppComplexKeywordCfg; import com.nis.domain.configuration.AppIdCfg; -import com.nis.domain.configuration.BaseStringCfg; +import com.nis.domain.configuration.AppStringCfg; +import com.nis.domain.configuration.AreaIpCfg; +import com.nis.domain.configuration.BaseIpCfg; import com.nis.domain.configuration.AppIdCfg.AppFeaturesIndex; -import com.nis.domain.configuration.ComplexkeywordCfg; +import com.nis.domain.maat.AppMaatCfg; +import com.nis.domain.specific.ConfigGroupInfo; +import com.nis.domain.specific.SpecificServiceCfg; +import com.nis.domain.specific.SpecificServiceHostCfg; import com.nis.main.ConvertTool; +import com.nis.util.Constants; import com.nis.util.StringUtil; import com.nis.web.dao.configuration.AppCfgDao; import com.nis.web.dao.configuration.ComplexStringCfgDao; +import com.nis.web.dao.configuration.IpCfgDao; import com.nis.web.dao.configuration.StringCfgDao; +import com.nis.web.dao.specific.SpecificServiceCfgDao; +import com.nis.web.dao.specific.SpecificServiceHostCfgDao; import com.nis.web.dao.systemService.ServiceConfigInfoDao; import com.nis.web.service.CrudService; @@ -39,6 +54,12 @@ public class AppCfgService extends CrudService { protected StringCfgDao stringCfgDao; @Autowired protected ComplexStringCfgDao complexStringCfgDao; + @Autowired + private SpecificServiceCfgDao specificServiceCfgDao; + @Autowired + private SpecificServiceHostCfgDao specificServiceHostCfgDao; + @Autowired + protected IpCfgDao ipCfgDao; public Page findPage(Page page, AppIdCfg entity) { entity.setPage(page); @@ -49,18 +70,18 @@ public class AppCfgService extends CrudService { public AppIdCfg findAppIdCfg(AppIdCfg entity) { //查询协议关联特征表 List featuresTableList = appCfgDao.getFeaturesTableListByAppCompileId(entity.getCompileId()); - List complexList = new ArrayList(); - List strList = new ArrayList(); + List complexList = new ArrayList(); + List strList = new ArrayList(); if(!StringUtil.isEmpty(featuresTableList)){ for(AppFeaturesIndex features:featuresTableList){ if(features.getFeaturesTableType().equals(4)){//增强字符串特征配置 - List complexFeaturesList = appCfgDao.getComplexkeywordFeaturesCfgListByCompileId( + List complexFeaturesList = appCfgDao.getComplexkeywordFeaturesCfgListByCompileId( features.getFeaturesTable(),features.getFeaturesCompileId()); complexList.addAll(complexFeaturesList); }else if(features.getFeaturesTableType().equals(2)){//普通字符串特征配置 - List strFeaturesCfgList = appCfgDao.getStrFeaturesCfgListByCompileId( + List strFeaturesCfgList = appCfgDao.getStrFeaturesCfgListByCompileId( features.getFeaturesTable(),features.getFeaturesCompileId()); strList.addAll(strFeaturesCfgList); } @@ -90,7 +111,7 @@ public class AppCfgService extends CrudService { cfg.setCompileId(appCompileId); cfgId = appCfgDao.insert(cfg); if(cfg.getComplexFeaturesList()!=null){ - for(ComplexkeywordCfg c:cfg.getComplexFeaturesList()){ + for(AppComplexKeywordCfg c:cfg.getComplexFeaturesList()){ Integer featuresCompileId = new ConvertTool().getCompileId(); AppFeaturesIndex f = new AppFeaturesIndex(); f.setAppCompileId(cfg.getCompileId()); @@ -119,7 +140,7 @@ public class AppCfgService extends CrudService { } } if(cfg.getStrFeaturesCfgList()!=null){ - for(BaseStringCfg s:cfg.getStrFeaturesCfgList()){ + for(AppStringCfg s:cfg.getStrFeaturesCfgList()){ Integer featuresCompileId = new ConvertTool().getCompileId(); AppFeaturesIndex f = new AppFeaturesIndex(); f.setAppCompileId(cfg.getCompileId()); @@ -162,7 +183,7 @@ public class AppCfgService extends CrudService { @Transactional(readOnly=false,rollbackFor=RuntimeException.class) public int updateAppCfg(AppIdCfg cfg) throws Exception{ if(cfg.getComplexFeaturesList()!=null){ - for(ComplexkeywordCfg c:cfg.getComplexFeaturesList()){ + for(AppComplexKeywordCfg c:cfg.getComplexFeaturesList()){ Integer featuresCompileId = 0; c.setIsAreaEffective(cfg.getIsAreaEffective()); c.setAreaEffectiveIds(cfg.getAreaEffectiveIds()); @@ -191,14 +212,14 @@ public class AppCfgService extends CrudService { c.setIsValid(cfg.getIsValid()); complexStringCfgDao.insert(c); }else{ - complexStringCfgDao.update(c); + complexStringCfgDao.updateByPrimaryKeySelective(c); } } } if(cfg.getStrFeaturesCfgList()!=null){ - for(BaseStringCfg s:cfg.getStrFeaturesCfgList()){ + for(AppStringCfg s:cfg.getStrFeaturesCfgList()){ Integer featuresCompileId = 0; s.setIsAreaEffective(cfg.getIsAreaEffective()); s.setAreaEffectiveIds(cfg.getAreaEffectiveIds()); @@ -227,7 +248,7 @@ public class AppCfgService extends CrudService { s.setIsValid(cfg.getIsValid()); stringCfgDao.insert(s); }else{ - stringCfgDao.update(s); + stringCfgDao.updateByPrimaryKeySelective(s); } } @@ -241,12 +262,235 @@ public class AppCfgService extends CrudService { * @param cfg * @return *int + * @throws Exception * @exception * @since 1.0.0 */ @Transactional(readOnly=false,rollbackFor=RuntimeException.class) - public int auditAppCfg(AppIdCfg cfg){ - return appCfgDao.audit(cfg); + public int auditAppCfg(AppIdCfg entity) throws Exception{ + boolean sendFlag = false; + AppIdCfg appCfg = appCfgDao.getById(entity.getCfgId()); + List featuresTableList = appCfgDao.getFeaturesTableListByAppCompileId(appCfg.getCompileId()); + List strList = new ArrayList(); + List complexList = new ArrayList(); + List hostList =new ArrayList(); + List areaList = new ArrayList(); + ConfigGroupInfo group = null; + + + Gson gson=new GsonBuilder().disableHtmlEscaping() + .excludeFieldsWithoutExposeAnnotation() + .create(); + + //配置审核状态即将改变后的状态 + if(Constants.AUDIT_NOT_YES==entity.getIsAudit().intValue()|| + Constants.AUDIT_YES==entity.getIsAudit().intValue()){//审核通过,取消审核通过需要发到maat + + if(Constants.AUDIT_YES==entity.getIsAudit().intValue()){//审核通过 + if(StringUtil.isEmpty(featuresTableList)){ + SpecificServiceCfg protocol = specificServiceCfgDao.getBySpecServiceId(appCfg.getAppId().intValue()); + group = specificServiceCfgDao.getConfigGroupInfoByGroupId(protocol.getGroupId()); + //featuresTableList为空的时候,该service只有特定服务IP一个配置表 + ServiceConfigInfo serviceCfg=serviceConfigInfoDao.findSysServiceConfigInfo(appCfg.getServiceId()); + if(group==null){ + throw new RuntimeException("配置审核失败,未获取社交应用服务器IP所属分组信息"); + }else{ + if(group.getIsIssued()==0){ + //如果分组信息尚未下发,则下发IP + group.setGroupId(protocol.getGroupId()); + group.setIsIssued(1); + SpecificServiceHostCfg hostCfg = new SpecificServiceHostCfg(); + hostCfg.setSpecServiceId(protocol.getSpecServiceId()); + hostList = specificServiceHostCfgDao.findSpecHostList(hostCfg); + + for(SpecificServiceHostCfg host:hostList){ + SpecificServiceCfg specServiceCfg = specificServiceCfgDao.getBySpecServiceId(host.getSpecServiceId()); + host.setProtocolId(0); + host.setGroupId(specServiceCfg.getGroupId()); + if(StringUtil.isEmpty(serviceCfg)){ + host.setMaatTable("DF_PROTOCOL_APP"); + }else{ + host.setMaatTable(serviceCfg.getMaatTable()); + } + } + }else{ + SpecificServiceHostCfg host = new SpecificServiceHostCfg(); + host.setGroupId(protocol.getGroupId()); + hostList.add(host); + } + } + + + //生效区域列表信息 + if(appCfg.getIsAreaEffective()==1){ + if(StringUtil.isEmpty(appCfg.getAreaEffectiveIds())){ + BaseIpCfg ipCfg = new BaseIpCfg(); + ipCfg.setCompileId(appCfg.getCompileId()); + ipCfg.setTableName("area_ip_cfg"); + areaList = ipCfgDao.findList(ipCfg); + } + } + }else{ + for(AppFeaturesIndex featuresCfg:featuresTableList){ + if(featuresCfg.getFeaturesTableType()==2){ + List list =appCfgDao.getStrFeaturesCfgListByCompileId(featuresCfg.getFeaturesTable(), featuresCfg.getFeaturesCompileId()); + for(AppStringCfg cfg:list){ + List cList = serviceConfigInfoDao.findList(appCfg.getServiceId()); + if(!StringUtil.isEmpty(cList)){ + for(ServiceConfigInfo c:cList){ + if(c.getTableName().equals(featuresCfg.getFeaturesTable())){ + cfg.setMaatTable(c.getMaatTable()); + } + } + + } + cfg.setCompileId(featuresCfg.getFeaturesCompileId()); + strList.add(cfg); + } + } + if(featuresCfg.getFeaturesTableType()==4){ + List list = appCfgDao.getComplexkeywordFeaturesCfgListByCompileId(featuresCfg.getFeaturesTable(), featuresCfg.getFeaturesCompileId()); + for(AppComplexKeywordCfg cfg:list){ + List cList = serviceConfigInfoDao.findList(appCfg.getServiceId()); + if(!StringUtil.isEmpty(cList)){ + for(ServiceConfigInfo c:cList){ + if(c.getTableName().equals(featuresCfg.getFeaturesTable())){ + cfg.setMaatTable(c.getMaatTable()); + } + } + } + + cfg.setCompileId(featuresCfg.getFeaturesCompileId()); + complexList.add(cfg); + } + } + } + } + AppMaatCfg maatCfg = new AppMaatCfg(); + if(StringUtil.isEmpty(featuresTableList)){ + maatCfg.setIpCfg(hostList); + maatCfg.setAreaCfg(areaList); + if(appCfg.getCompileId()==0){ + throw new RuntimeException("转换出错,未获取到正确的compileId"); + }else{ + maatCfg.setCompileId(appCfg.getCompileId()); + } + }else{//特征配置 + maatCfg.setStrCfg(strList); + maatCfg.setComplexStrCfg(complexList); + } + + if(appCfg.getAction()==null){ + throw new RuntimeException("转换出错,未获取到正确的action"); + }else{ + maatCfg.setAction(appCfg.getAction()); + } + if(appCfg.getIsAreaEffective()==null){ + throw new RuntimeException("转换出错,未获取到正确的isAreaEffective"); + }else{ + maatCfg.setIsAreaEffective(appCfg.getIsAreaEffective()); + } + if(appCfg.getIsValid()==null){ + throw new RuntimeException("转换出错,未获取到正确的isValid"); + }else{ + maatCfg.setIsValid(appCfg.getIsValid()); + } + if(appCfg.getRequestId()==null){ + throw new RuntimeException("转换出错,未获取到正确的requestId"); + }else{ + maatCfg.setRequestId(appCfg.getRequestId()); + } + if(appCfg.getServiceId()==null){ + throw new RuntimeException("转换出错,未获取到正确的serviceId"); + }else{ + maatCfg.setServiceId(appCfg.getServiceId()); + } + maatCfg.setSpecificServiceId(appCfg.getAppId()); + maatCfg.setAreaEffectiveIds(appCfg.getAreaEffectiveIds()==null?"":appCfg.getAreaEffectiveIds()); + maatCfg.setAttribute(appCfg.getAttribute()==null?"":appCfg.getAttribute()); + maatCfg.setClassify(appCfg.getClassify()==null?"":appCfg.getClassify()); + maatCfg.setLable(appCfg.getLable()==null?"":appCfg.getLable()); + String json=gson.toJson(maatCfg); + //下发maat +// new ConvertTool().saveAppConfig(json); + sendFlag = true; + + }else{//取消审核通过 + AppMaatCfg maatCfg = new AppMaatCfg(); + if(StringUtil.isEmpty(featuresTableList)){ + ServiceConfigInfo serviceCfg=serviceConfigInfoDao.findSysServiceConfigInfo(appCfg.getServiceId()); + maatCfg.setMaatTable(serviceCfg.getMaatTable()); + if(appCfg.getCompileId()==0){ + throw new RuntimeException("转换出错,未获取到正确的compileId"); + }else{ + maatCfg.setCompileId(appCfg.getCompileId()); + } + }else{//特征配置 + for(AppFeaturesIndex featuresCfg:featuresTableList){ + if(featuresCfg.getFeaturesTableType()==2){ + List list =appCfgDao.getStrFeaturesCfgListByCompileId(featuresCfg.getFeaturesTable(), featuresCfg.getFeaturesCompileId()); + for(AppStringCfg cfg:list){ + AppStringCfg strCfg = new AppStringCfg(); + List cList = serviceConfigInfoDao.findList(appCfg.getServiceId()); + if(!StringUtil.isEmpty(cList)){ + for(ServiceConfigInfo c:cList){ + if(c.getTableName().equals(featuresCfg.getFeaturesTable())){ + strCfg.setMaatTable(c.getMaatTable()); + } + } + + } + strCfg.setCompileId(featuresCfg.getFeaturesCompileId()); + strList.add(strCfg); + } + } + if(featuresCfg.getFeaturesTableType()==4){ + List list = appCfgDao.getComplexkeywordFeaturesCfgListByCompileId(featuresCfg.getFeaturesTable(), featuresCfg.getFeaturesCompileId()); + for(AppComplexKeywordCfg cfg:list){ + AppComplexKeywordCfg complexCfg = new AppComplexKeywordCfg(); + List cList = serviceConfigInfoDao.findList(appCfg.getServiceId()); + if(!StringUtil.isEmpty(cList)){ + for(ServiceConfigInfo c:cList){ + if(c.getTableName().equals(featuresCfg.getFeaturesTable())){ + complexCfg.setMaatTable(c.getMaatTable()); + } + } + } + + complexCfg.setCompileId(featuresCfg.getFeaturesCompileId()); + complexList.add(complexCfg); + } + } + } + maatCfg.setStrCfg(strList); + maatCfg.setComplexStrCfg(complexList); + } + + String json=gson.toJson(maatCfg); + //下发maat +// new ConvertTool().saveAppConfig(json); + sendFlag = true; + } + + }else{ + sendFlag = false; + } + + if(sendFlag){ + //修改appId配置审核下发状态 + appCfgDao.audit(entity); + //修改特定服务IP分组下发状态 + specificServiceCfgDao.updateConfigGroupInfobyGroupId(group); + //修改特征表配置审核下发状态 + for(AppFeaturesIndex cfg:featuresTableList){ + appCfgDao.auditFeaturesTable(cfg.getFeaturesTable(), cfg.getFeaturesCompileId(), entity.getIsValid(), + entity.getIsAudit(), entity.getAuditorId(), entity.getAuditTime()); + + } + return 1; + }else{ + return 0; + } } /** * @@ -259,8 +503,22 @@ public class AppCfgService extends CrudService { * @since 1.0.0 */ @Transactional(readOnly=false,rollbackFor=RuntimeException.class) - public int deleteAppCfg(AppIdCfg cfg){ - return appCfgDao.updateValid(cfg); + public int deleteAppCfg(AppIdCfg entity){ + Integer status = appCfgDao.updateValid(entity); + if(status==1){ + List featuresTableList = appCfgDao.getFeaturesTableListByAppCompileId(entity.getCompileId()); + for(AppFeaturesIndex cfg:featuresTableList){ + status = appCfgDao.updateFeaturesTableValid(cfg.getFeaturesTable(), cfg.getFeaturesCompileId(), + entity.getIsValid(), entity.getEditorId(), entity.getEditTime()); + if(status==0){ + return 0; + } + } + return status; + }else{ + return status; + } +// return appCfgDao.updateValid(cfg); } /** * @@ -288,18 +546,18 @@ public class AppCfgService extends CrudService { public AppIdCfg getAppCfgById(AppIdCfg cfg){ cfg = appCfgDao.get(cfg); List featuresTableList = appCfgDao.getFeaturesTableListByAppCompileId(cfg.getCompileId()); - List complexList = new ArrayList(); - List strList = new ArrayList(); + List complexList = new ArrayList(); + List strList = new ArrayList(); if(!StringUtil.isEmpty(featuresTableList)){ for(AppFeaturesIndex features:featuresTableList){ if(features.getFeaturesTableType().equals(4)){//增强字符串特征配置 - List complexFeaturesList = appCfgDao.getComplexkeywordFeaturesCfgListByCompileId( + List complexFeaturesList = appCfgDao.getComplexkeywordFeaturesCfgListByCompileId( features.getFeaturesTable(),features.getFeaturesCompileId()); complexList.addAll(complexFeaturesList); }else if(features.getFeaturesTableType().equals(2)){//普通字符串特征配置 - List strFeaturesCfgList = appCfgDao.getStrFeaturesCfgListByCompileId( + List strFeaturesCfgList = appCfgDao.getStrFeaturesCfgListByCompileId( features.getFeaturesTable(),features.getFeaturesCompileId()); strList.addAll(strFeaturesCfgList); } @@ -313,13 +571,13 @@ public class AppCfgService extends CrudService { public Integer getIsValid(Long cfgId){ return appCfgDao.getIsValid(cfgId); } - /*public Integer getIsValid(String tableName, long id){ + public Integer getIsValid(String tableName, long id){ return appCfgDao.getIsValid(tableName,id); - }*/ + } public Integer getIsAudit(Long cfgId){ return appCfgDao.getIsAudit(cfgId); } - /*public Integer getIsAudit(String tableName, long id){ + public Integer getIsAudit(String tableName, long id){ return appCfgDao.getIsAudit(tableName,id); - }*/ + } } diff --git a/src/main/java/com/nis/web/service/specific/SpecificServiceCfgService.java b/src/main/java/com/nis/web/service/specific/SpecificServiceCfgService.java index 4e94fdd51..1877e9795 100644 --- a/src/main/java/com/nis/web/service/specific/SpecificServiceCfgService.java +++ b/src/main/java/com/nis/web/service/specific/SpecificServiceCfgService.java @@ -10,7 +10,9 @@ import org.springframework.transaction.annotation.Transactional; import com.beust.jcommander.internal.Lists; import com.nis.domain.Page; +import com.nis.domain.specific.ConfigGroupInfo; import com.nis.domain.specific.SpecificServiceCfg; +import com.nis.main.ConvertTool; import com.nis.util.StringUtil; import com.nis.web.dao.specific.SpecificServiceCfgDao; import com.nis.web.service.BaseService; @@ -60,11 +62,22 @@ public class SpecificServiceCfgService extends BaseService{ /** * 保存或修改 * @param specificServiceCfg + * @throws Exception */ @Transactional(readOnly=false,rollbackFor=RuntimeException.class) - public void saveOrUpdate(SpecificServiceCfg specificServiceCfg, Integer oldId) { - if(specificServiceCfg.getGroupId()==null){ - specificServiceCfg.setGroupId(0); + public void saveOrUpdate(SpecificServiceCfg specificServiceCfg, Integer oldId) throws Exception { + if(specificServiceCfg.getGroupId()==null || specificServiceCfg.getGroupId()==0){ + specificServiceCfg.setGroupId(new ConvertTool().getGroupId()); + } + //新增协议分组 + ConfigGroupInfo group = specificServiceCfgDao.getConfigGroupInfoByGroupId(specificServiceCfg.getGroupId()); + if(group==null){ + group = new ConfigGroupInfo(); + group.setGroupId(specificServiceCfg.getGroupId()); + group.setGroupName(specificServiceCfg.getSpecServiceName()); + group.setIsIssued(0); + group.setGroupType(1); + specificServiceCfgDao.insertConfigGroupInfo(group); } if(oldId==null){//新增 specificServiceCfg.setIsValid(1); diff --git a/src/main/webapp/WEB-INF/views/cfg/appCfgForm.jsp b/src/main/webapp/WEB-INF/views/cfg/appCfgForm.jsp index a762ff797..414d181b8 100644 --- a/src/main/webapp/WEB-INF/views/cfg/appCfgForm.jsp +++ b/src/main/webapp/WEB-INF/views/cfg/appCfgForm.jsp @@ -6,6 +6,45 @@