新增APP复杂特征配置组合功能,根据功能业务字典与功能配置域字典灵活增加权限菜单,实现APP特征的灵活组合与新增。

This commit is contained in:
zhangwei
2018-09-23 15:02:01 +08:00
parent 26e885ceed
commit 8fb9cd6934
21 changed files with 3030 additions and 113 deletions

View File

@@ -0,0 +1,164 @@
/**
*@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 java.util.ArrayList;
import java.util.List;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import com.nis.util.excel.ExcelField;
/**
* APP Header层头特征配置
* @author dell
*
*/
public class AppComplexFeatureCfg extends BaseCfg<AppComplexFeatureCfg> {
/**
*
*/
private static final long serialVersionUID = 5718725405113991364L;
/**
*
*/
private static final String tableName="app_complex_feature_cfg";
@Expose
private Integer compileId;
private Integer appCode;//specific_service_cfg表一级节点的spec_service_code
private Integer behavCode;//specific_service_cfg表二级节点的spec_service_code
private Integer specServiceId;
private String district;
private String cfgKeywords;
private String appName;
private List<AppIpCfg> ipPortList = new ArrayList();
private String cfgRegionCode1;
public String getCfgRegionCode1() {
return cfgRegionCode1;
}
public void setCfgRegionCode1(String cfgRegionCode1) {
this.cfgRegionCode1 = cfgRegionCode1;
}
@Expose
@ExcelField(title="expression_type")
@SerializedName("exprType")
protected Integer exprType ;
@Expose
@ExcelField(title="match_method")
@SerializedName("matchMethod")
protected Integer matchMethod ;
@Expose
@ExcelField(title="whether_hexbinary")
@SerializedName("isHexbin")
protected Integer isHexbin;
public Integer getExprType() {
return exprType;
}
public void setExprType(Integer exprType) {
this.exprType = exprType;
}
public Integer getMatchMethod() {
return matchMethod;
}
public void setMatchMethod(Integer matchMethod) {
this.matchMethod = matchMethod;
}
public Integer getIsHexbin() {
return isHexbin;
}
public void setIsHexbin(Integer isHexbin) {
this.isHexbin = isHexbin;
}
@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;
}
public static String getTablename() {
return tableName;
}
public Integer getAppCode() {
return appCode;
}
public void setAppCode(Integer appCode) {
this.appCode = appCode;
}
public Integer getSpecServiceId() {
return specServiceId;
}
public void setSpecServiceId(Integer specServiceId) {
this.specServiceId = specServiceId;
}
public String getDistrict() {
return district;
}
public void setDistrict(String district) {
this.district = district;
}
public String getCfgKeywords() {
return cfgKeywords;
}
public void setCfgKeywords(String cfgKeywords) {
this.cfgKeywords = cfgKeywords;
}
public String getAppName() {
return appName;
}
public void setAppName(String appName) {
this.appName = appName;
}
public Integer getBehavCode() {
return behavCode;
}
public void setBehavCode(Integer behavCode) {
this.behavCode = behavCode;
}
public List<AppIpCfg> getIpPortList() {
if(ipPortList.size()==0){
ipPortList.add(new AppIpCfg());
}
return ipPortList;
}
public void setIpPortList(List<AppIpCfg> ipPortList) {
this.ipPortList = ipPortList;
}
}

View File

@@ -0,0 +1,128 @@
/**
*@Title: CfgIndexInfo.java
*@Package com.nis.domain.restful
*@Description 索引公共表
*@author dell
*@date 2018年5月17日 下午16:59:17
*@version 版本号
*/
package com.nis.domain.configuration;
import java.util.ArrayList;
import java.util.List;
import com.nis.domain.basics.AsnIpCfg;
/**
* @ClassName: CfgIndexInfo.java
* @author (dell)
* @date 2018年5月17日 下午16:59:17
* @version V1.0
*/
public class AppFeatureIndex extends BaseCfg<AppFeatureIndex> {
/**
*
*/
private static final long serialVersionUID = -8069201965300255275L;
private static final String tableName="app_feature_index";
private Integer appCode;//specific_service_cfg表一级节点的spec_service_code
private String appName;
private Integer specServiceId;
private Integer behavCode;//specific_service_cfg表二级节点的spec_service_code
private AppHttpCfg complexStrCfg;
private AppByteCfg strCfg;
private AppIpCfg ipCfg;
private List<AppIpCfg> ipPortList = new ArrayList();
private List<AppStringFeatureCfg> strList = new ArrayList();
private List<AppComplexFeatureCfg> complexList = new ArrayList();
protected Integer exprType ;
protected Integer matchMethod ;
protected Integer isHexbin;
private String cfgRegionType;
private String cfgRegionValue;
private String cfgRegionCode1;
public static String getTablename() {
return tableName;
}
public Integer getAppCode() {
return appCode;
}
public void setAppCode(Integer appCode) {
this.appCode = appCode;
}
public Integer getSpecServiceId() {
return specServiceId;
}
public void setSpecServiceId(Integer specServiceId) {
this.specServiceId = specServiceId;
}
public List<AppIpCfg> getIpPortList() {
return ipPortList;
}
public void setIpPortList(List<AppIpCfg> ipPortList) {
this.ipPortList = ipPortList;
}
public List<AppComplexFeatureCfg> getComplexList() {
return complexList;
}
public void setComplexList(List<AppComplexFeatureCfg> complexList) {
this.complexList = complexList;
}
public AppHttpCfg getComplexStrCfg() {
return complexStrCfg;
}
public void setComplexStrCfg(AppHttpCfg complexStrCfg) {
this.complexStrCfg = complexStrCfg;
}
public AppByteCfg getStrCfg() {
return strCfg;
}
public void setStrCfg(AppByteCfg strCfg) {
this.strCfg = strCfg;
}
public AppIpCfg getIpCfg() {
return ipCfg;
}
public void setIpCfg(AppIpCfg ipCfg) {
this.ipCfg = ipCfg;
}
public List<AppStringFeatureCfg> getStrList() {
return strList;
}
public void setStrList(List<AppStringFeatureCfg> strList) {
this.strList = strList;
}
public String getAppName() {
return appName;
}
public void setAppName(String appName) {
this.appName = appName;
}
public Integer getBehavCode() {
return behavCode;
}
public void setBehavCode(Integer behavCode) {
this.behavCode = behavCode;
}
public String getCfgRegionType() {
return cfgRegionType;
}
public void setCfgRegionType(String cfgRegionType) {
this.cfgRegionType = cfgRegionType;
}
public String getCfgRegionValue() {
return cfgRegionValue;
}
public void setCfgRegionValue(String cfgRegionValue) {
this.cfgRegionValue = cfgRegionValue;
}
public String getCfgRegionCode1() {
return cfgRegionCode1;
}
public void setCfgRegionCode1(String cfgRegionCode1) {
this.cfgRegionCode1 = cfgRegionCode1;
}
}

View File

@@ -0,0 +1,139 @@
/**
*@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;
import com.nis.util.excel.ExcelField;
/**
* @Description: APP策略配置
* @author (dell)
* @date 2018年2月5日 下午5:26:02
* @version V1.0
*/
public class AppStringFeatureCfg extends BaseCfg<AppStringFeatureCfg> {
/**
*
*/
private static final long serialVersionUID = 8677301658049443801L;
private static final String tableName="app_string_feature_cfg";
@Expose
private Integer compileId;
private Integer appCode;//specific_service_cfg表一级节点的spec_service_code
private Integer behavCode;//specific_service_cfg表二级节点的spec_service_code
private Integer specServiceId;
private String bytes;
private String cfgKeywords;
private String appName;
@Expose
@ExcelField(title="expression_type")
@SerializedName("exprType")
protected Integer exprType ;
@Expose
@ExcelField(title="match_method")
@SerializedName("matchMethod")
protected Integer matchMethod ;
@Expose
@ExcelField(title="whether_hexbinary")
@SerializedName("isHexbin")
protected Integer isHexbin;
public Integer getExprType() {
return exprType;
}
public void setExprType(Integer exprType) {
this.exprType = exprType;
}
public Integer getMatchMethod() {
return matchMethod;
}
public void setMatchMethod(Integer matchMethod) {
this.matchMethod = matchMethod;
}
public Integer getIsHexbin() {
return isHexbin;
}
public void setIsHexbin(Integer isHexbin) {
this.isHexbin = isHexbin;
}
@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;
}
public static String getTablename() {
return tableName;
}
public Integer getAppCode() {
return appCode;
}
public void setAppCode(Integer appCode) {
this.appCode = appCode;
}
public Integer getSpecServiceId() {
return specServiceId;
}
public void setSpecServiceId(Integer specServiceId) {
this.specServiceId = specServiceId;
}
public String getBytes() {
return bytes;
}
public void setBytes(String bytes) {
this.bytes = bytes;
}
public String getCfgKeywords() {
return cfgKeywords;
}
public void setCfgKeywords(String cfgKeywords) {
this.cfgKeywords = cfgKeywords;
}
public String getAppName() {
return appName;
}
public void setAppName(String appName) {
this.appName = appName;
}
public Integer getBehavCode() {
return behavCode;
}
public void setBehavCode(Integer behavCode) {
this.behavCode = behavCode;
}
}

View File

@@ -69,6 +69,7 @@ import com.nis.web.service.basics.ServiceDictInfoService;
import com.nis.web.service.basics.SysDictInfoService;
import com.nis.web.service.configuration.AppBuiltInFeatureService;
import com.nis.web.service.configuration.AppCfgService;
import com.nis.web.service.configuration.AppMultiFeatureCfgService;
import com.nis.web.service.configuration.AsnPolicyCfgService;
import com.nis.web.service.configuration.AvCfgService;
import com.nis.web.service.configuration.AvContentCfgService;
@@ -200,6 +201,8 @@ public class BaseController {
protected AsnIpCfgService asnIpCfgService;//asn ip service
@Autowired
protected AsnPolicyCfgService asnPolicyCfgService;//asn 策略 service
@Autowired
protected AppMultiFeatureCfgService appMultiFeatureCfgService;
/**
* 管理基础路径
*/

View File

@@ -0,0 +1,247 @@
package com.nis.web.controller.configuration;
import java.io.File;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
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.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.nis.domain.Page;
import com.nis.domain.SysDataDictionaryItem;
import com.nis.domain.configuration.AppBuiltInFeatureFile;
import com.nis.domain.configuration.AppByteCfg;
import com.nis.domain.configuration.AppComplexFeatureCfg;
import com.nis.domain.configuration.AppDomainCfg;
import com.nis.domain.configuration.AppFeatureIndex;
import com.nis.domain.configuration.AppHeaderCfg;
import com.nis.domain.configuration.AppHttpCfg;
import com.nis.domain.configuration.AppIpCfg;
import com.nis.domain.configuration.AppPolicyCfg;
import com.nis.domain.configuration.AppSslCertCfg;
import com.nis.domain.configuration.AppStringFeatureCfg;
import com.nis.domain.configuration.AppTcpCfg;
import com.nis.domain.configuration.AppTopicDomainCfg;
import com.nis.domain.configuration.IpPortCfg;
import com.nis.domain.configuration.NtcSubscribeIdCfg;
import com.nis.domain.configuration.WebsiteDomainTopic;
import com.nis.domain.maat.ToMaatResult;
import com.nis.domain.maat.ToMaatResult.ResponseData;
import com.nis.domain.specific.SpecificServiceCfg;
import com.nis.exceptions.CallExternalProceduresException;
import com.nis.exceptions.MaatConvertException;
import com.nis.util.ConfigServiceUtil;
import com.nis.util.Constants;
import com.nis.util.DictUtils;
import com.nis.util.FileUtils;
import com.nis.util.JsonMapper;
import com.nis.util.StringUtil;
import com.nis.web.controller.BaseController;
import com.nis.web.security.UserUtils;
/**
* 特定协议相关配置控制类
* @author zhangwei
*
*/
@Controller
@RequestMapping("${adminPath}/app/feature/")
public class AppFeatureCfgController extends BaseController {
/**
* app协议复杂特征配置列表
* @param model
* @param cfg
* @param request
* @param response
* @return
*/
@RequestMapping(value = {"multiFeatureCfgList"})
public String multiFeatureCfgList(Model model,@ModelAttribute("cfg")AppFeatureIndex cfg,HttpServletRequest request,HttpServletResponse response) {
Page<AppFeatureIndex> searchPage=new Page<AppFeatureIndex>(request,response,"r");
Page<AppFeatureIndex> page = appMultiFeatureCfgService.findAppFeatureIndexList(searchPage, cfg);
for(AppFeatureIndex entity:page.getList()){
SpecificServiceCfg app = specificServiceCfgService.getBySpecServiceId(entity.getSpecServiceId());
entity.setAppName(app.getSpecServiceName());
}
model.addAttribute("page", page);
initPageCondition(model,cfg);
return "/cfg/app/appMultiFeatureCfgList";
}
/**
* 特征配置表单
* @param model
* @param ids
* @param entity
* @return
*/
@RequestMapping(value = {"multiFeatureCfgForm"})
public String multiFeatureCfgForm(Model model,String ids,AppFeatureIndex entity) {
if(StringUtils.isNotBlank(ids)){
entity = appMultiFeatureCfgService.getAppFeatureIndex(Long.parseLong(ids));
entity.setIpPortList(appMultiFeatureCfgService.getAppIpRangeCfg(entity.getCompileId(), entity.getFunctionId()));
entity.setStrList(appMultiFeatureCfgService.getAppStringFeatureCfg(entity.getCompileId(), entity.getFunctionId(),null));
entity.setComplexList(appMultiFeatureCfgService.getAppComplexFeatureCfg(entity.getCompileId(), entity.getFunctionId(),null));
initUpdateFormCondition(model,entity);
}else{
initFormCondition(model,entity);
}
model.addAttribute("_cfg", entity);
return "/cfg/app/appMultiFeatureCfgForm";
}
/**
* 特征配置新增修改
* @param model
* @param request
* @param response
* @param entity
* @param redirectAttributes
* @return
*/
@RequestMapping(value = {"saveAppMultiFeatureCfg"})
public String saveAppMultiFeatureCfg(Model model,HttpServletRequest request,HttpServletResponse response,
AppFeatureIndex entity,RedirectAttributes redirectAttributes) {
try {
SpecificServiceCfg specificService = specificServiceCfgService.getBySpecServiceId(entity.getSpecServiceId());
if(specificService!=null){
entity.setAppCode(specificService.getSpecServiceCode());
}
appMultiFeatureCfgService.saveOrUpdateAppFeatureCfg(entity);
} catch (Exception e) {
e.printStackTrace();
addMessage(redirectAttributes, e.getMessage());
}
return "redirect:" + adminPath +"/app/feature/multiFeatureCfgList?functionId="+entity.getFunctionId();
}
/**
* 特征配置审核
* @param isAudit
* @param isValid
* @param ids
* @param functionId
* @param redirectAttributes
* @return
*/
@RequestMapping(value = {"auditAppFeatureCfg"})
public String auditAppFeatureCfg(Integer isAudit,Integer isValid,String ids,Integer functionId, RedirectAttributes redirectAttributes) {
AppFeatureIndex entity = new AppFeatureIndex();
String[] idArray = ids.split(",");
for(String id :idArray){
entity = appMultiFeatureCfgService.getAppFeatureIndex(Long.parseLong(id));
entity.setIsAudit(isAudit);
entity.setIsValid(isValid);
entity.setAuditorId(UserUtils.getUser().getId());
entity.setAuditTime(new Date());
entity.setFunctionId(functionId);
try {
appMultiFeatureCfgService.auditAppFeatureCfg(entity,isAudit);
} catch (MaatConvertException e) {
e.printStackTrace();
logger.info("app 特征配置下发失败:"+e.getMessage());
addMessage(redirectAttributes, e.getMessage());
}
}
return "redirect:" + adminPath +"/app/feature/multiFeatureCfgList?functionId="+functionId;
}
/**
* 特征配置删除
* @param isValid
* @param ids
* @param functionId
* @return
*/
@RequestMapping(value = {"updateAppFeatureCfgValid"})
public String updateAppFeatureCfgValid(Integer isValid,String ids,Integer functionId) {
appMultiFeatureCfgService.updateAppFeatureCfgValid(isValid,ids,functionId);
return "redirect:" + adminPath +"/app/feature/multiFeatureCfgList?functionId="+functionId;
}
/**
* 查询特征子配置
* @param model
* @param cfgId
* @param index
* @return
*/
@RequestMapping(value = {"ajaxAppFeatureList"})
public String ajaxAppFeatureList(Model model,Long cfgId,Integer compileId,Integer functionId,Integer index) {
List<AppIpCfg> ipRangeList = appMultiFeatureCfgService.getAppIpRangeCfg(compileId,functionId);
AppFeatureIndex cfg = appMultiFeatureCfgService.getAppFeatureIndex(cfgId);
List<Map<String,Object>> tabList = new ArrayList();
String[] cfgRegionValue = cfg.getCfgRegionValue().split(",");
String[] cfgRegionType = cfg.getCfgRegionType().split(",");
String[] cfgRegionCode = cfg.getCfgRegionCode1().split(",");
if(cfgRegionValue.length == cfgRegionType.length && cfgRegionValue.length==cfgRegionCode.length){
for(int i=0;i<cfgRegionValue.length;i++){
Map<String,Object> map = new HashMap();
map.put("regionType", cfgRegionType[i]);
map.put("regionValue", cfgRegionValue[i]);
if("1".equals(cfgRegionType[i])){
map.put("ipRangeList", ipRangeList);
}
if("2".equals(cfgRegionType[i])){
List<AppStringFeatureCfg> strList = appMultiFeatureCfgService.getAppStringFeatureCfg(compileId,functionId,Integer.valueOf(cfgRegionCode[i]));
map.put("strList", strList);
}
if("3".equals(cfgRegionType[i])){
List<AppComplexFeatureCfg> complexList = appMultiFeatureCfgService.getAppComplexFeatureCfg(compileId,functionId,Integer.valueOf(cfgRegionCode[i]));
map.put("complexList", complexList);
}
tabList.add(map);
}
}else{
Map<String,Object> map = new HashMap();
map.put("regionType", "0");
map.put("regionValue", "query config detail error");
tabList.add(map);
}
/*if(ipRangeList!=null){
String cfgType = null;
for(AppIpCfg ip:ipRangeList){
if(!ip.getCfgType().equals(cfgType)){
tabList.add(new String[]{"1",ip.getCfgType()});
cfgType = ip.getCfgType();
}
}
}
if(strList!=null){
String cfgType = null;
for(AppStringFeatureCfg cfg:strList){
if(!cfg.getCfgType().equals(cfgType)){
tabList.add(new String[]{"2",cfg.getCfgType()});
cfgType = cfg.getCfgType();
}
}
}
if(complexList!=null){
String cfgType = null;
for(AppComplexFeatureCfg cfg:complexList){
if(!cfg.getCfgType().equals(cfgType)){
tabList.add(new String[]{"3",cfg.getCfgType()});
cfgType = cfg.getCfgType();
}
}
}*/
model.addAttribute("index", index);
model.addAttribute("tabList", tabList);
return "/cfg/app/appSubFeatureList";
}
}

View File

@@ -47,7 +47,7 @@
<if test="configRegionSort != null">
AND config_region_sort=#{configRegionSort,jdbcType=VARCHAR}
</if>
order by dict_id,config_region_sort
order by config_region_sort
</select>
</mapper>

View File

@@ -0,0 +1,65 @@
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.AppByteCfg;
import com.nis.domain.configuration.AppComplexFeatureCfg;
import com.nis.domain.configuration.AppComplexKeywordCfg;
import com.nis.domain.configuration.AppDomainCfg;
import com.nis.domain.configuration.AppFeatureIndex;
import com.nis.domain.configuration.AppHeaderCfg;
import com.nis.domain.configuration.AppHttpCfg;
import com.nis.domain.configuration.AppIdCfg;
import com.nis.domain.configuration.AppIdCfg.AppFeaturesIndex;
import com.nis.domain.configuration.AppInnerRuleCfg;
import com.nis.domain.configuration.AppIpCfg;
import com.nis.domain.configuration.AppPolicyCfg;
import com.nis.domain.configuration.AppSslCertCfg;
import com.nis.domain.configuration.AppStringCfg;
import com.nis.domain.configuration.AppStringFeatureCfg;
import com.nis.domain.configuration.AppTcpCfg;
import com.nis.domain.configuration.AppTopicDomainCfg;
import com.nis.domain.configuration.BaseCfg;
import com.nis.domain.configuration.BaseStringCfg;
import com.nis.domain.configuration.CfgIndexInfo;
import com.nis.domain.configuration.ComplexkeywordCfg;
import com.nis.domain.configuration.IpPortCfg;
import com.nis.domain.configuration.WebsiteDomainTopic;
import com.nis.web.dao.CrudDao;
import com.nis.web.dao.MyBatisDao;
/**
* 特定协议相关配置数据处理类
* @author dell
*
*/
@MyBatisDao
public interface AppMultiFeatureCfgDao {
//app复杂多域特征索引配置
public int insertAppFeatureIndex(AppFeatureIndex entity);
public int updateAppFeatureIndex(AppFeatureIndex entity);
public List<AppFeatureIndex> findAppFeatureIndexList(AppFeatureIndex entity);
public AppFeatureIndex getAppFeatureIndex(Long cfgId) ;
//审核配置
public void auditCfg(BaseCfg entity);
//修改配置状态
public void updateCfgValid(BaseCfg entity);
//字符串类特征配置
public List<AppStringFeatureCfg> getAppStringFeatureCfg(@Param("compileId")Integer compileId,
@Param("functionId")Integer functionId,@Param("cfgRegionCode")Integer cfgRegionCode);
public int insertAppStringFeatureCfg(AppStringFeatureCfg entity);
public void deleteAppStringFeatureCfg(BaseCfg entity);
//增强字符串类特征配置
public List<AppComplexFeatureCfg> getAppComplexFeatureCfg(@Param("compileId")Integer compileId,
@Param("functionId")Integer functionId,@Param("cfgRegionCode")Integer cfgRegionCode);
public int insertAppComplexFeatureCfg(AppComplexFeatureCfg entity);
public void deleteAppComplexFeatureCfg(BaseCfg entity);
//IP RANGE配置
public List<AppIpCfg> getAppIpRangeCfg(@Param("compileId")Integer compileId,@Param("functionId")Integer functionId) ;
public int insertAppIpRangeCfg(AppIpCfg entity);
public void deleteAppIpRangeCfg(BaseCfg entity);
}

View File

@@ -0,0 +1,521 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.nis.web.dao.configuration.AppMultiFeatureCfgDao" >
<resultMap id="AppFeatureIndexMap" type="com.nis.domain.configuration.AppFeatureIndex" >
<id column="cfg_id" property="cfgId" jdbcType="BIGINT" />
<result column="cfg_desc" property="cfgDesc" jdbcType="VARCHAR" />
<result column="action" property="action" jdbcType="INTEGER" />
<result column="is_valid" property="isValid" jdbcType="INTEGER" />
<result column="is_audit" property="isAudit" jdbcType="INTEGER" />
<result column="creator_id" property="creatorId" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="editor_id" property="editorId" jdbcType="INTEGER" />
<result column="edit_time" property="editTime" jdbcType="TIMESTAMP" />
<result column="auditor_id" property="auditorId" jdbcType="INTEGER" />
<result column="audit_time" property="auditTime" jdbcType="TIMESTAMP" />
<result column="service_id" property="serviceId" jdbcType="INTEGER" />
<result column="request_id" property="requestId" jdbcType="INTEGER" />
<result column="compile_id" property="compileId" jdbcType="INTEGER" />
<result column="is_area_effective" property="isAreaEffective" jdbcType="INTEGER" />
<result column="classify" property="classify" jdbcType="VARCHAR" />
<result column="attribute" property="attribute" jdbcType="VARCHAR" />
<result column="lable" property="lable" jdbcType="VARCHAR" />
<result column="area_effective_ids" property="areaEffectiveIds" jdbcType="VARCHAR" />
<result column="function_id" property="functionId" jdbcType="INTEGER" />
<result column="do_log" property="doLog" jdbcType="INTEGER" />
<result column="user_region1" property="userRegion1" jdbcType="VARCHAR" />
<result column="user_region2" property="userRegion2" jdbcType="VARCHAR" />
<result column="user_region3" property="userRegion3" jdbcType="VARCHAR" />
<result column="user_region4" property="userRegion4" jdbcType="VARCHAR" />
<result column="user_region5" property="userRegion5" jdbcType="VARCHAR" />
<result column="spec_service_id" property="specServiceId" jdbcType="INTEGER" />
<result column="app_code" property="appCode" jdbcType="INTEGER" />
<result column="behav_code" property="behavCode" jdbcType="INTEGER" />
<result column="cfg_region_type" property="cfgRegionType" jdbcType="VARCHAR" />
<result column="cfg_region_value" property="cfgRegionValue" jdbcType="VARCHAR" />
<result column="cfg_region_code" property="cfgRegionCode1" jdbcType="VARCHAR" />
</resultMap>
<!-- APP IP类配置映射 -->
<resultMap id="AppIpCfgMap" type="com.nis.domain.configuration.AppIpCfg" >
<id column="cfg_id" property="cfgId" jdbcType="BIGINT" />
<result column="spec_service_id" property="specServiceId" jdbcType="INTEGER" />
<result column="app_code" property="appCode" jdbcType="INTEGER" />
<result column="behav_code" property="behavCode" jdbcType="INTEGER" />
<result column="ip_type" property="ipType" jdbcType="INTEGER" />
<result column="ip_pattern" property="ipPattern" jdbcType="INTEGER" />
<result column="src_ip_address" property="srcIpAddress" jdbcType="VARCHAR" />
<result column="dest_ip_address" property="destIpAddress" jdbcType="VARCHAR" />
<result column="port_pattern" property="portPattern" jdbcType="INTEGER" />
<result column="src_port" property="srcPort" jdbcType="VARCHAR" />
<result column="dest_port" property="destPort" jdbcType="VARCHAR" />
<result column="direction" property="direction" jdbcType="INTEGER" />
<result column="protocol" property="protocol" jdbcType="INTEGER" />
<result column="cfg_desc" property="cfgDesc" jdbcType="VARCHAR" />
<result column="action" property="action" jdbcType="INTEGER" />
<result column="is_valid" property="isValid" jdbcType="INTEGER" />
<result column="is_audit" property="isAudit" jdbcType="INTEGER" />
<result column="creator_id" property="creatorId" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="editor_id" property="editorId" jdbcType="INTEGER" />
<result column="edit_time" property="editTime" jdbcType="TIMESTAMP" />
<result column="auditor_id" property="auditorId" jdbcType="INTEGER" />
<result column="audit_time" property="auditTime" jdbcType="TIMESTAMP" />
<result column="service_id" property="serviceId" jdbcType="INTEGER" />
<result column="request_id" property="requestId" jdbcType="INTEGER" />
<result column="compile_id" property="compileId" jdbcType="INTEGER" />
<result column="is_area_effective" property="isAreaEffective" jdbcType="INTEGER" />
<result column="classify" property="classify" jdbcType="VARCHAR" />
<result column="attribute" property="attribute" jdbcType="VARCHAR" />
<result column="lable" property="lable" jdbcType="VARCHAR" />
<result column="area_effective_ids" property="areaEffectiveIds" jdbcType="VARCHAR" />
<result column="function_id" property="functionId" jdbcType="INTEGER" />
<result column="do_log" property="doLog" jdbcType="INTEGER" />
<result column="cfg_type" property="cfgType" jdbcType="VARCHAR" />
</resultMap>
<!-- APP 增强字符串类的配置映射 -->
<resultMap id="AppComplexFeatureCfgMap" type="com.nis.domain.configuration.AppComplexFeatureCfg" >
<id column="cfg_id" property="cfgId" jdbcType="BIGINT" />
<result column="spec_service_id" property="specServiceId" jdbcType="INTEGER" />
<result column="app_code" property="appCode" jdbcType="INTEGER" />
<result column="behav_code" property="behavCode" jdbcType="INTEGER" />
<result column="district" property="district" jdbcType="VARCHAR" />
<result column="cfg_keywords" property="cfgKeywords" jdbcType="VARCHAR" />
<result column="cfg_desc" property="cfgDesc" jdbcType="VARCHAR" />
<result column="action" property="action" jdbcType="INTEGER" />
<result column="is_valid" property="isValid" jdbcType="INTEGER" />
<result column="is_audit" property="isAudit" jdbcType="INTEGER" />
<result column="creator_id" property="creatorId" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="editor_id" property="editorId" jdbcType="INTEGER" />
<result column="edit_time" property="editTime" jdbcType="TIMESTAMP" />
<result column="auditor_id" property="auditorId" jdbcType="INTEGER" />
<result column="audit_time" property="auditTime" jdbcType="TIMESTAMP" />
<result column="service_id" property="serviceId" jdbcType="INTEGER" />
<result column="request_id" property="requestId" jdbcType="INTEGER" />
<result column="compile_id" property="compileId" jdbcType="INTEGER" />
<result column="is_area_effective" property="isAreaEffective" jdbcType="INTEGER" />
<result column="classify" property="classify" jdbcType="VARCHAR" />
<result column="attribute" property="attribute" jdbcType="VARCHAR" />
<result column="lable" property="lable" jdbcType="VARCHAR" />
<result column="expr_type" property="exprType" jdbcType="INTEGER" />
<result column="match_method" property="matchMethod" jdbcType="INTEGER" />
<result column="is_hexbin" property="isHexbin" jdbcType="INTEGER" />
<result column="area_effective_ids" property="areaEffectiveIds" jdbcType="VARCHAR" />
<result column="function_id" property="functionId" jdbcType="INTEGER" />
<result column="do_log" property="doLog" jdbcType="INTEGER" />
<result column="cfg_type" property="cfgType" jdbcType="VARCHAR" />
</resultMap>
<!-- APP字符串类配置映射 -->
<resultMap id="AppStringFeatureCfgMap" type="com.nis.domain.configuration.AppStringFeatureCfg" >
<id column="cfg_id" property="cfgId" jdbcType="BIGINT" />
<result column="spec_service_id" property="specServiceId" jdbcType="INTEGER" />
<result column="app_code" property="appCode" jdbcType="INTEGER" />
<result column="behav_code" property="behavCode" jdbcType="INTEGER" />
<result column="cfg_keywords" property="cfgKeywords" jdbcType="VARCHAR" />
<result column="cfg_desc" property="cfgDesc" jdbcType="VARCHAR" />
<result column="action" property="action" jdbcType="INTEGER" />
<result column="is_valid" property="isValid" jdbcType="INTEGER" />
<result column="is_audit" property="isAudit" jdbcType="INTEGER" />
<result column="creator_id" property="creatorId" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="editor_id" property="editorId" jdbcType="INTEGER" />
<result column="edit_time" property="editTime" jdbcType="TIMESTAMP" />
<result column="auditor_id" property="auditorId" jdbcType="INTEGER" />
<result column="audit_time" property="auditTime" jdbcType="TIMESTAMP" />
<result column="service_id" property="serviceId" jdbcType="INTEGER" />
<result column="request_id" property="requestId" jdbcType="INTEGER" />
<result column="compile_id" property="compileId" jdbcType="INTEGER" />
<result column="is_area_effective" property="isAreaEffective" jdbcType="INTEGER" />
<result column="classify" property="classify" jdbcType="VARCHAR" />
<result column="attribute" property="attribute" jdbcType="VARCHAR" />
<result column="lable" property="lable" jdbcType="VARCHAR" />
<result column="expr_type" property="exprType" jdbcType="INTEGER" />
<result column="match_method" property="matchMethod" jdbcType="INTEGER" />
<result column="is_hexbin" property="isHexbin" jdbcType="INTEGER" />
<result column="area_effective_ids" property="areaEffectiveIds" jdbcType="VARCHAR" />
<result column="function_id" property="functionId" jdbcType="INTEGER" />
<result column="do_log" property="doLog" jdbcType="INTEGER" />
<result column="cfg_type" property="cfgType" jdbcType="VARCHAR" />
</resultMap>
<sql id="AppFeatureIndex_Column" >
r.CFG_ID,r.CFG_DESC,r.ACTION,r.IS_VALID,r.IS_AUDIT,
r.CREATOR_ID,r.CREATE_TIME,r.EDITOR_ID,r.EDIT_TIME,r.AUDITOR_ID,r.AUDIT_TIME,
r.SERVICE_ID,r.REQUEST_ID,r.COMPILE_ID,r.IS_AREA_EFFECTIVE,r.CLASSIFY,
r.ATTRIBUTE,r.LABLE,r.AREA_EFFECTIVE_IDS,r.function_id,r.CFG_REGION_TYPE,r.CFG_REGION_VALUE,r.user_region1,
r.user_region2,r.user_region3,r.user_region4,r.user_region5,r.do_log,r.feature_table,
r.feature_table_type,r.app_code,r.spec_service_id,r.cfg_region_code
</sql>
<sql id="AppIpCfg_Column" >
r.CFG_ID, r.APP_CODE,r.BEHAV_CODE,r.SPEC_SERVICE_ID, r.CFG_DESC,r.ACTION,r.IS_VALID,r.IS_AUDIT,
r.CREATOR_ID,r.CREATE_TIME,r.EDITOR_ID,r.EDIT_TIME,r.AUDITOR_ID,r.AUDIT_TIME,
r.SERVICE_ID,r.REQUEST_ID,r.COMPILE_ID,r.IS_AREA_EFFECTIVE,r.CLASSIFY,
r.ATTRIBUTE,r.LABLE,AREA_EFFECTIVE_IDS,r.FUNCTION_ID,r.CFG_TYPE,r.CFG_REGION_CODE,
r.IP_TYPE, r.IP_PATTERN, r.SRC_IP_ADDRESS,r.DEST_IP_ADDRESS, r.PORT_PATTERN,r.SRC_PORT,DEST_PORT,
r.DIRECTION,r.PROTOCOL,r.DO_LOG,r.USER_REGION1,r.USER_REGION2,r.USER_REGION3,r.USER_REGION4,r.USER_REGION5
</sql>
<sql id="AppComplexFeatureCfg_Column" >
r.CFG_ID, r.APP_CODE,r.BEHAV_CODE,r.SPEC_SERVICE_ID,r.CFG_DESC,ACTION,r.IS_VALID,r.IS_AUDIT,
r.CREATOR_ID,r.CREATE_TIME,r.EDITOR_ID,r.EDIT_TIME,r.AUDITOR_ID,r.AUDIT_TIME,
r.SERVICE_ID,r.REQUEST_ID,r.COMPILE_ID,r.IS_AREA_EFFECTIVE,r.CLASSIFY,
r.ATTRIBUTE,r.LABLE,r.AREA_EFFECTIVE_IDS,r.FUNCTION_ID,r.CFG_TYPE,r.CFG_REGION_CODE,
r.DISTRICT,r.CFG_KEYWORDS,r.EXPR_TYPE,r.MATCH_METHOD,r.IS_HEXBIN,r.DO_LOG
</sql>
<sql id="AppStringFeatureCfg_Column" >
r.CFG_ID, r.APP_CODE,r.BEHAV_CODE,r.SPEC_SERVICE_ID,r.CFG_DESC,r.ACTION,r.IS_VALID,r.IS_AUDIT,
r.CREATOR_ID,r.CREATE_TIME,r.EDITOR_ID,r.EDIT_TIME,r.AUDITOR_ID,r.AUDIT_TIME,
r.SERVICE_ID,r.REQUEST_ID,r.COMPILE_ID,r.IS_AREA_EFFECTIVE,r.CLASSIFY,
r.ATTRIBUTE,r.LABLE,r.AREA_EFFECTIVE_IDS,r.FUNCTION_ID,r.CFG_TYPE,r.CFG_REGION_CODE,
r.CFG_KEYWORDS,r.EXPR_TYPE,r.MATCH_METHOD,r.IS_HEXBIN,r.DO_LOG
</sql>
<sql id="AppCommonCfg_Value_List" >
#{appCode,jdbcType=INTEGER},#{behavCode,jdbcType=INTEGER},#{specServiceId,jdbcType=INTEGER},
#{cfgDesc,jdbcType=VARCHAR},#{action,jdbcType=INTEGER},
#{isValid,jdbcType=INTEGER},#{isAudit,jdbcType=INTEGER},#{creatorId,jdbcType=INTEGER},
#{createTime,jdbcType=TIMESTAMP},#{editorId,jdbcType=INTEGER},#{editTime,jdbcType=TIMESTAMP},
#{auditorId,jdbcType=INTEGER},#{auditTime,jdbcType=TIMESTAMP},#{serviceId,jdbcType=INTEGER},
#{requestId,jdbcType=INTEGER},#{compileId,jdbcType=INTEGER},#{isAreaEffective,jdbcType=INTEGER},
#{classify,jdbcType=VARCHAR},#{attribute,jdbcType=VARCHAR},#{lable,jdbcType=VARCHAR},
#{areaEffectiveIds,jdbcType=VARCHAR},#{functionId,jdbcType=INTEGER}
</sql>
<select id="getAppFeatureIndex" resultMap="AppFeatureIndexMap" parameterType="java.lang.Long" >
SELECT
<include refid="AppFeatureIndex_Column" />
FROM app_feature_index r
WHERE CFG_ID = #{cfgId,jdbcType=BIGINT}
</select>
<select id="findAppFeatureIndexList" resultMap="AppFeatureIndexMap">
select
<include refid="AppFeatureIndex_Column"/>
<trim prefix="," prefixOverrides=",">
, s.name as creator_name,e.name as editor_name,u.name as auditor_name
,ri.request_title as requestName
</trim>
from app_feature_index r
left join sys_user s on r.creator_id=s.id
left join sys_user e on r.editor_id=e.id
left join sys_user u on r.auditor_id=u.id
left join request_info ri on r.request_id=ri.id
<trim prefix="WHERE" prefixOverrides="AND |OR ">
<if test="page !=null and page.where != null and page.where != ''">
AND ${page.where}
</if>
<if test="functionId != null">
AND r.function_id=#{functionId,jdbcType=INTEGER}
</if>
<if test="cfgId != null">
AND r.CFG_ID=#{cfgId,jdbcType=BIGINT}
</if>
<if test="cfgDesc != null and cfgDesc != ''">
AND r.CFG_DESC like concat(concat('%',#{cfgDesc,jdbcType=VARCHAR}),'%')
</if>
<if test="specServiceId != null">
AND r.spec_service_id=#{specServiceId,jdbcType=INTEGER}
</if>
<if test="action != null">
AND r.ACTION=#{action,jdbcType=INTEGER}
</if>
<if test="isValid != null">
AND r.IS_VALID=#{isValid,jdbcType=INTEGER}
</if>
<if test="isValid == null">
AND r.IS_VALID != -1
</if>
<if test="isAudit != null">
AND r.IS_AUDIT=#{isAudit,jdbcType=INTEGER}
</if>
<if test="creatorName != null and creatorName != ''">
AND CREATOR_NAME like concat(concat('%',#{creatorName,jdbcType=VARCHAR}),'%')
</if>
<if test="createTime != null and createTime != ''">
AND r.CREATE_TIME=#{createTime,jdbcType=TIMESTAMP}
</if>
<if test="editorName != null and editorName != ''">
AND EDITOR_NAME like concat(concat('%',#{editorName,jdbcType=VARCHAR}),'%')
</if>
<if test="editTime != null and editTime != ''">
AND r.EDIT_TIME=#{editTime,jdbcType=TIMESTAMP}
</if>
<if test="auditorName != null and auditorName != ''">
AND AUDITOR_NAME like concat(concat('%',#{auditorName,jdbcType=VARCHAR}),'%')
</if>
<if test="auditTime != null and auditTime != ''">
AND r.AUDIT_TIME=#{auditTime,jdbcType=TIMESTAMP}
</if>
<if test="serviceId != null">
AND r.SERVICE_ID=#{serviceId,jdbcType=INTEGER}
</if>
<if test="requestId != null">
AND r.REQUEST_ID=#{requestId,jdbcType=INTEGER}
</if>
<if test="compileId != null">
AND r.COMPILE_ID=#{compileId,jdbcType=INTEGER}
</if>
<if test="isAreaEffective != null">
AND r.IS_AREA_EFFECTIVE=#{isAreaEffective,jdbcType=INTEGER}
</if>
<if test="classify != null and classify != ''">
AND r.classify like concat(concat('%',#{classify,jdbcType=VARCHAR}),'%')
</if>
<if test="attribute != null and attribute != ''">
AND r.attribute like concat(concat('%',#{attribute,jdbcType=VARCHAR}),'%')
</if>
<if test="lable != null and lable != ''">
AND r.lable like concat(concat('%',#{lable,jdbcType=VARCHAR}),'%')
</if>
<if test="areaEffectiveIds != null and areaEffectiveIds != ''">
AND r.AREA_EFFECTIVE_IDS like concat(concat('%',#{areaEffectiveIds,jdbcType=VARCHAR}),'%')
</if>
<if test="complexStrCfg!=null">
AND a.compile_id in (select f.compile_id from app_complex_feature_cfg f
<where>
<if test="complexStrCfg.cfgKeywords != null and complexStrCfg.cfgKeywords != ''">
and f.cfg_keywords like concat(concat('%',#{complexStrCfg.cfgKeywords,jdbcType=VARCHAR}),'%')
</if>
<if test="complexStrCfg.district != null and complexStrCfg.district != ''">
and f.district like concat(concat('%',#{complexStrCfg.district,jdbcType=VARCHAR}),'%')
</if>
</where>
)
</if>
<if test="strCfg!=null">
AND a.compile_id in (select f.compile_id from app_string_feature_cfg f
<where>
<if test="strCfg.cfgKeywords != null and strCfg.cfgKeywords != ''">
and f.cfg_keywords like concat(concat('%',#{strCfg.cfgKeywords,jdbcType=VARCHAR}),'%')
</if>
<if test="strCfg.district != null and strCfg.district != ''">
and f.district like concat(concat('%',#{strCfg.district,jdbcType=VARCHAR}),'%')
</if>
</where>
)
</if>
<!-- 数据范围过滤 -->
${sqlMap.dsf}
</trim>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY CFG_ID desc
</otherwise>
</choose>
</select>
<!-- insert cfgIndexInfox -->
<insert id="insertAppFeatureIndex" parameterType="com.nis.domain.configuration.AppFeatureIndex" >
<selectKey resultType="java.lang.Long" order="AFTER" keyProperty="cfgId">
SELECT LAST_INSERT_ID()
</selectKey>
insert into app_feature_index(
APP_CODE,BEHAV_CODE,SPEC_SERVICE_ID, CFG_DESC,ACTION,IS_VALID,IS_AUDIT,
CREATOR_ID,CREATE_TIME,EDITOR_ID,EDIT_TIME,AUDITOR_ID,AUDIT_TIME,
SERVICE_ID,REQUEST_ID,COMPILE_ID,IS_AREA_EFFECTIVE,CLASSIFY,
ATTRIBUTE,LABLE,AREA_EFFECTIVE_IDS,FUNCTION_ID,CFG_REGION_TYPE,CFG_REGION_VALUE,DO_LOG,
user_region1,user_region2,user_region3,user_region4,user_region5,cfg_region_code
)values (
<include refid="AppCommonCfg_Value_List" />,
#{cfgRegionType,jdbcType=VARCHAR},#{cfgRegionValue,jdbcType=VARCHAR},#{doLog,jdbcType=INTEGER},#{userRegion1,jdbcType=VARCHAR},#{userRegion2,jdbcType=VARCHAR}
,#{userRegion3,jdbcType=VARCHAR},#{userRegion4,jdbcType=VARCHAR},#{userRegion5,jdbcType=VARCHAR},#{cfgRegionCode1,jdbcType=VARCHAR}
)
</insert>
<update id="updateAppFeatureIndex" parameterType="com.nis.domain.configuration.AppFeatureIndex" >
update app_feature_index
<set >
<trim suffixOverrides=",">
cfg_desc = #{cfgDesc,jdbcType=VARCHAR},
APP_CODE = #{appCode,jdbcType=INTEGER},
BEHAV_CODE = #{behavCode,jdbcType=INTEGER},
SPEC_SERVICE_ID = #{specServiceId,jdbcType=INTEGER},
action = #{action,jdbcType=INTEGER},
is_valid = #{isValid,jdbcType=INTEGER},
is_audit = #{isAudit,jdbcType=INTEGER},
<if test="creatorId != null" >
creator_id = #{creatorId,jdbcType=INTEGER},
</if>
<if test="createTime != null and createTime != ''" >
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="editorId != null" >
editor_id = #{editorId,jdbcType=INTEGER},
</if>
<if test="editTime != null and editTime != ''" >
edit_time = #{editTime,jdbcType=TIMESTAMP},
</if>
<if test="auditorId != null" >
auditor_id = #{auditorId,jdbcType=INTEGER},
</if>
<if test="auditTime != null and auditTime != ''" >
audit_time = #{auditTime,jdbcType=TIMESTAMP},
</if>
service_id = #{serviceId,jdbcType=INTEGER},
request_id = #{requestId,jdbcType=INTEGER},
compile_id = #{compileId,jdbcType=INTEGER},
is_area_effective = #{isAreaEffective,jdbcType=INTEGER},
classify = #{classify,jdbcType=VARCHAR},
attribute = #{attribute,jdbcType=VARCHAR},
lable = #{lable,jdbcType=VARCHAR},
area_effective_ids = #{areaEffectiveIds,jdbcType=VARCHAR},
function_id = #{functionId,jdbcType=INTEGER},
CFG_REGION_TYPE=#{cfgRegionType,jdbcType=VARCHAR},
CFG_REGION_VALUE =#{cfgRegionValue,jdbcType=VARCHAR},
cfg_region_code=#{cfgRegionCode1,jdbcType=VARCHAR},
USER_REGION1 =#{userRegion1,jdbcType=VARCHAR},
USER_REGION2 =#{userRegion2,jdbcType=VARCHAR},
USER_REGION1 =#{userRegion3,jdbcType=VARCHAR},
USER_REGION1 =#{userRegion4,jdbcType=VARCHAR},
USER_REGION1 =#{userRegion5,jdbcType=VARCHAR},
DO_LOG=#{doLog,jdbcType=INTEGER},
<if test="exprType != null">
expr_type=#{exprType,jdbcType=INTEGER},
</if>
<if test="matchMethod != null">
match_method=#{matchMethod,jdbcType=INTEGER},
</if>
<if test="isHexbin != null">
is_hexbin=#{isHexbin,jdbcType=INTEGER},
</if>
</trim>
</set>
where cfg_id = #{cfgId,jdbcType=BIGINT}
</update>
<!-- 配置删除-->
<update id="updateCfgValid" parameterType="com.nis.domain.configuration.BaseCfg">
update ${tableName} set is_valid = #{isValid,jdbcType=INTEGER},
editor_id = #{editorId,jdbcType=INTEGER} ,
edit_time = #{editTime,jdbcType=TIMESTAMP}
<trim prefix="WHERE" prefixOverrides="AND |OR ">
<if test="cfgId !=null ">
AND cfg_id = #{cfgId,jdbcType=BIGINT}
</if>
<if test="compileId !=null ">
AND compile_id = #{compileId,jdbcType=INTEGER}
</if>
and function_id=#{functionId,jdbcType=INTEGER}
</trim>
</update>
<!-- 审核通过或取消 -->
<update id="auditCfg" parameterType="com.nis.domain.configuration.BaseCfg">
update ${tableName} set is_audit = #{isAudit,jdbcType=INTEGER},
auditor_id = #{auditorId,jdbcType=INTEGER},
audit_time = #{auditTime,jdbcType=TIMESTAMP}
<if test="isValid != null" >
,is_valid = #{isValid,jdbcType=INTEGER}
</if>
<trim prefix="WHERE" prefixOverrides="AND |OR ">
<if test="cfgId !=null ">
AND cfg_id = #{cfgId,jdbcType=BIGINT}
</if>
<if test="compileId !=null ">
AND compile_id = #{compileId,jdbcType=INTEGER}
</if>
and function_id=#{functionId,jdbcType=INTEGER}
</trim>
</update>
<!-- 查询app_ip_range子配置列表 -->
<select id="getAppIpRangeCfg" resultMap="AppIpCfgMap">
SELECT
<include refid="AppIpCfg_Column" />
FROM app_ip_range_cfg r
WHERE r.compile_id=#{compileId} and r.function_id=#{functionId}
</select>
<!-- 查询字符串类特征子配置列表 -->
<select id="getAppStringFeatureCfg" resultMap="AppStringFeatureCfgMap">
SELECT
<include refid="AppStringFeatureCfg_Column" />
FROM app_string_feature_cfg r
WHERE r.compile_id=#{compileId} and r.function_id=#{functionId}
<if test="cfgRegionCode !=null ">
AND r.cfg_region_code = #{cfgRegionCode,jdbcType=BIGINT}
</if>
</select>
<!-- 查询增强字符串类特征子配置列表 -->
<select id="getAppComplexFeatureCfg" resultMap="AppComplexFeatureCfgMap">
SELECT
<include refid="AppComplexFeatureCfg_Column" />
FROM app_complex_feature_cfg r
WHERE r.compile_id=#{compileId} and r.function_id=#{functionId}
<if test="cfgRegionCode !=null ">
AND r.cfg_region_code = #{cfgRegionCode,jdbcType=BIGINT}
</if>
</select>
<!-- 新增app_ip_range子配置 -->
<insert id="insertAppIpRangeCfg" parameterType="com.nis.domain.configuration.AppIpCfg" >
<selectKey resultType="java.lang.Long" order="AFTER" keyProperty="cfgId">
SELECT LAST_INSERT_ID()
</selectKey>
insert into app_ip_range_cfg (
APP_CODE,BEHAV_CODE,SPEC_SERVICE_ID, CFG_DESC,ACTION,IS_VALID,IS_AUDIT,
CREATOR_ID,CREATE_TIME,EDITOR_ID,EDIT_TIME,AUDITOR_ID,AUDIT_TIME,
SERVICE_ID,REQUEST_ID,COMPILE_ID,IS_AREA_EFFECTIVE,CLASSIFY,
ATTRIBUTE,LABLE,AREA_EFFECTIVE_IDS,FUNCTION_ID,CFG_TYPE,CFG_REGION_CODE,
IP_TYPE, IP_PATTERN, SRC_IP_ADDRESS,DEST_IP_ADDRESS, PORT_PATTERN,SRC_PORT,DEST_PORT,
DIRECTION,PROTOCOL,DO_LOG,user_region1,user_region2,user_region3,user_region4,user_region5
)values (
<include refid="AppCommonCfg_Value_List" />,
#{cfgType,jdbcType=VARCHAR},#{cfgRegionCode,jdbcType=INTEGER},
#{ipType,jdbcType=INTEGER}, #{ipPattern,jdbcType=INTEGER},#{srcIpAddress,jdbcType=VARCHAR},#{destIpAddress,jdbcType=VARCHAR},
#{portPattern,jdbcType=INTEGER},#{srcPort,jdbcType=VARCHAR},#{destPort,jdbcType=VARCHAR},#{direction,jdbcType=INTEGER},
#{protocol,jdbcType=INTEGER},#{doLog,jdbcType=INTEGER},#{userRegion1,jdbcType=VARCHAR},#{userRegion2,jdbcType=VARCHAR}
,#{userRegion3,jdbcType=VARCHAR},#{userRegion4,jdbcType=VARCHAR},#{userRegion5,jdbcType=VARCHAR}
)
</insert>
<!-- 新增APP增强字符串类特征子配置 -->
<insert id="insertAppComplexFeatureCfg" parameterType="com.nis.domain.configuration.AppComplexFeatureCfg" >
<selectKey resultType="java.lang.Long" order="AFTER" keyProperty="cfgId">
SELECT LAST_INSERT_ID()
</selectKey>
insert into app_complex_feature_cfg (
APP_CODE,BEHAV_CODE,SPEC_SERVICE_ID,CFG_DESC,ACTION,IS_VALID,IS_AUDIT,
CREATOR_ID,CREATE_TIME,EDITOR_ID,EDIT_TIME,AUDITOR_ID,AUDIT_TIME,
SERVICE_ID,REQUEST_ID,COMPILE_ID,IS_AREA_EFFECTIVE,CLASSIFY,
ATTRIBUTE,LABLE,AREA_EFFECTIVE_IDS,FUNCTION_ID,CFG_TYPE,CFG_REGION_CODE,
DISTRICT,CFG_KEYWORDS,EXPR_TYPE,MATCH_METHOD,IS_HEXBIN,DO_LOG,user_region1,user_region2,user_region3,user_region4,user_region5
)values (
<include refid="AppCommonCfg_Value_List" />,
#{cfgType,jdbcType=VARCHAR},#{cfgRegionCode,jdbcType=INTEGER},
#{district,jdbcType=VARCHAR},#{cfgKeywords,jdbcType=VARCHAR},
#{exprType,jdbcType=INTEGER},#{matchMethod,jdbcType=INTEGER},#{isHexbin,jdbcType=INTEGER},
#{doLog,jdbcType=INTEGER},#{userRegion1,jdbcType=VARCHAR},#{userRegion2,jdbcType=VARCHAR},
#{userRegion3,jdbcType=VARCHAR},#{userRegion4,jdbcType=VARCHAR},#{userRegion5,jdbcType=VARCHAR}
)
</insert>
<!-- 新增APP字符串类特征子配置 -->
<insert id="insertAppStringFeatureCfg" parameterType="com.nis.domain.configuration.AppStringFeatureCfg" >
<selectKey resultType="java.lang.Long" order="AFTER" keyProperty="cfgId">
SELECT LAST_INSERT_ID()
</selectKey>
insert into app_string_feature_cfg (
APP_CODE,BEHAV_CODE,SPEC_SERVICE_ID,CFG_DESC,ACTION,IS_VALID,IS_AUDIT,
CREATOR_ID,CREATE_TIME,EDITOR_ID,EDIT_TIME,AUDITOR_ID,AUDIT_TIME,
SERVICE_ID,REQUEST_ID,COMPILE_ID,IS_AREA_EFFECTIVE,CLASSIFY,
ATTRIBUTE,LABLE,AREA_EFFECTIVE_IDS,FUNCTION_ID,CFG_TYPE,CFG_REGION_CODE,
CFG_KEYWORDS,EXPR_TYPE,MATCH_METHOD,IS_HEXBIN,DO_LOG,user_region1,user_region2,user_region3,user_region4,user_region5
)values (
<include refid="AppCommonCfg_Value_List" />,
#{cfgType,jdbcType=VARCHAR},#{cfgRegionCode,jdbcType=INTEGER},
#{cfgKeywords,jdbcType=VARCHAR},#{exprType,jdbcType=INTEGER},#{matchMethod,jdbcType=INTEGER},
#{isHexbin,jdbcType=INTEGER},#{doLog,jdbcType=INTEGER},
#{userRegion1,jdbcType=VARCHAR},#{userRegion2,jdbcType=VARCHAR},
#{userRegion3,jdbcType=VARCHAR},#{userRegion4,jdbcType=VARCHAR},#{userRegion5,jdbcType=VARCHAR}
)
</insert>
<!-- 删除app_ip_range子配置 -->
<delete id="deleteAppIpRangeCfg" >
delete from app_ip_range_cfg where compile_id=#{compileId} and function_id=#{functionId}
</delete>
<!-- 删除字符串类特征子配置 -->
<delete id="deleteAppStringFeatureCfg" >
delete from app_string_feature_cfg where compile_id=#{compileId} and function_id=#{functionId}
</delete>
<!-- 删除增强字符串类特征子配置 -->
<delete id="deleteAppComplexFeatureCfg" >
delete from app_complex_feature_cfg where compile_id=#{compileId} and function_id=#{functionId}
</delete>
</mapper>

View File

@@ -291,7 +291,8 @@ public abstract class BaseService {
IpCfg cfg = new IpCfg();
BeanUtils.copyProperties(baseIpCfg, cfg);
//区域IP配置多条IP配置属于同一个分组其他业务配置IP一条配置一个分组
if(groupId==0 || !cfg.getCfgType().equals(Constants.AREA_REGION)){
// if(groupId==0 || !cfg.getCfgType().equals(Constants.AREA_REGION)){
if(groupId==0){
GroupCfg group = new GroupCfg();
groupId = ConfigServiceUtil.getId(2, 1).get(0);
group.setGroupId(groupId);

View File

@@ -0,0 +1,299 @@
package com.nis.web.service.configuration;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.nis.domain.Page;
import com.nis.domain.configuration.AppComplexFeatureCfg;
import com.nis.domain.configuration.AppFeatureIndex;
import com.nis.domain.configuration.AppHttpCfg;
import com.nis.domain.configuration.AppIpCfg;
import com.nis.domain.configuration.AppStringFeatureCfg;
import com.nis.domain.configuration.HttpUrlCfg;
import com.nis.domain.maat.MaatCfg;
import com.nis.domain.maat.MaatCfg.DigestCfg;
import com.nis.domain.maat.MaatCfg.GroupCfg;
import com.nis.domain.maat.MaatCfg.IpCfg;
import com.nis.domain.maat.MaatCfg.NumBoundaryCfg;
import com.nis.domain.maat.MaatCfg.StringCfg;
import com.nis.domain.maat.ToMaatBean;
import com.nis.domain.maat.ToMaatResult;
import com.nis.exceptions.MaatConvertException;
import com.nis.util.ConfigServiceUtil;
import com.nis.util.Constants;
import com.nis.util.StringUtil;
import com.nis.web.dao.configuration.AppMultiFeatureCfgDao;
import com.nis.web.security.UserUtils;
import com.nis.web.service.BaseService;
/**
* 特定协议相关配置事务类
*
* @author dell
*
*/
@Service
public class AppMultiFeatureCfgService extends BaseService {
@Autowired
protected AppMultiFeatureCfgDao appMultiFeatureCfgDao;
//分页查询
public Page<AppFeatureIndex> findAppFeatureIndexList(Page<AppFeatureIndex> page, AppFeatureIndex entity) {
entity.getSqlMap().put("dsf", configScopeFilter(entity.getCurrentUser(), "r"));
entity.setPage(page);
List<AppFeatureIndex> list = appMultiFeatureCfgDao.findAppFeatureIndexList(entity);
page.setList(list);
return page;
}
public AppFeatureIndex getAppFeatureIndex(Long cfgId) {
return appMultiFeatureCfgDao.getAppFeatureIndex(cfgId);
}
//新增或保存复杂特征配置
@Transactional(readOnly = false, rollbackFor = RuntimeException.class)
public void saveOrUpdateAppFeatureCfg(AppFeatureIndex entity) throws Exception {
if (entity.getCfgId() == null) {
Integer compileId = 0;
try {
List<Integer> idList = ConfigServiceUtil.getId(1, 1);
if (idList != null && idList.size() > 0) {
compileId = idList.get(0);
}
entity.setCompileId(compileId);
entity.setCreateTime(new Date());
entity.setCreatorId(entity.getCurrentUser().getId());
entity.setIsValid(0);
entity.setIsAudit(0);
appMultiFeatureCfgDao.insertAppFeatureIndex(entity);
if(entity.getIpPortList()!=null){
for(AppIpCfg cfg:entity.getIpPortList()){
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"});
appMultiFeatureCfgDao.insertAppIpRangeCfg(cfg);
}
}
if(entity.getStrList()!=null){
for(AppStringFeatureCfg cfg:entity.getStrList()){
if(StringUtils.isNotBlank(cfg.getCfgKeywords())){
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"});
appMultiFeatureCfgDao.insertAppStringFeatureCfg(cfg);
}
}
}
if(entity.getComplexList()!=null){
for(AppComplexFeatureCfg cfg:entity.getComplexList()){
if(StringUtils.isNotBlank(cfg.getCfgKeywords())){
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"});
appMultiFeatureCfgDao.insertAppComplexFeatureCfg(cfg);
}
}
}
} catch (Exception e) {
e.printStackTrace();
logger.info("获取编译ID出错");
throw new MaatConvertException(e.getMessage());
}
} else {
entity.setEditorId(entity.getCurrentUser().getId());
entity.setEditTime(new Date());
entity.setIsValid(0);
entity.setIsAudit(0);
appMultiFeatureCfgDao.updateAppFeatureIndex(entity);
appMultiFeatureCfgDao.deleteAppIpRangeCfg(entity);
appMultiFeatureCfgDao.deleteAppStringFeatureCfg(entity);
appMultiFeatureCfgDao.deleteAppComplexFeatureCfg(entity);
entity.setCreateTime(new Date());
entity.setCreatorId(entity.getCurrentUser().getId());
if(entity.getIpPortList()!=null){
for(AppIpCfg cfg:entity.getIpPortList()){
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"});
appMultiFeatureCfgDao.insertAppIpRangeCfg(cfg);
}
}
if(entity.getStrList()!=null){
for(AppStringFeatureCfg cfg:entity.getStrList()){
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"});
appMultiFeatureCfgDao.insertAppStringFeatureCfg(cfg);
}
}
if(entity.getComplexList()!=null){
for(AppComplexFeatureCfg cfg:entity.getComplexList()){
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"});
appMultiFeatureCfgDao.insertAppComplexFeatureCfg(cfg);
}
}
}
}
public void auditAppFeatureCfg(AppFeatureIndex entity, Integer isAudit) {
ToMaatBean maatBean = new ToMaatBean();
MaatCfg maatCfg = new MaatCfg();
List<MaatCfg> configCompileList = new ArrayList();
List<GroupCfg> groupRelationList = new ArrayList();
List<IpCfg> ipRegionList = new ArrayList();
List<StringCfg> strRegionList = new ArrayList();
List<NumBoundaryCfg> numRegionList = new ArrayList();
List<DigestCfg> digestRegionList = new ArrayList();
List<IpCfg> areaIpRegionList = new ArrayList();
entity.setTableName(AppFeatureIndex.getTablename());
appMultiFeatureCfgDao.auditCfg(entity);
/*if (isAudit == 1) {
List<AppFeatureIndex> list = new ArrayList();
list.add(entity);
Map<String, List> map = cfgConvert(strRegionList, list, 2, entity, groupRelationList);
groupRelationList = map.get("groupList");
strRegionList = map.get("dstList");
}*/
//查询APP_IP_RANGE子配置并修改审核状态
List ipRangeList = appMultiFeatureCfgDao.getAppIpRangeCfg(entity.getCompileId(),entity.getFunctionId());
if(ipRangeList!=null && ipRangeList.size()>0){
AppIpCfg cfg = new AppIpCfg();
BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"});
cfg.setTableName("APP_IP_RANGE_CFG");
appMultiFeatureCfgDao.auditCfg(cfg);
if(isAudit==1){
Map<String,List> map = cfgConvert(ipRegionList,ipRangeList,1,entity,groupRelationList);
groupRelationList=map.get("groupList");
ipRegionList=map.get("dstList");
if(map.get("numRegionList")!=null){
numRegionList.addAll(map.get("numRegionList"));
}
}
}
List<AppStringFeatureCfg> strList = appMultiFeatureCfgDao.getAppStringFeatureCfg(entity.getCompileId(),entity.getFunctionId(),null);
if(strList!=null && strList.size()>0){
AppStringFeatureCfg cfg = new AppStringFeatureCfg();
BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"});
cfg.setTableName(AppStringFeatureCfg.getTablename());
appMultiFeatureCfgDao.auditCfg(cfg);
if(isAudit==1){
Map<String,List> map = cfgConvert(strRegionList,strList,2,entity,groupRelationList);
groupRelationList=map.get("groupList");
strRegionList=map.get("dstList");
}
}
List<AppComplexFeatureCfg> complexList = appMultiFeatureCfgDao.getAppComplexFeatureCfg(entity.getCompileId(),entity.getFunctionId(),null);
if(complexList!=null && complexList.size()>0){
AppComplexFeatureCfg cfg = new AppComplexFeatureCfg();
BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"});
cfg.setTableName(AppComplexFeatureCfg.getTablename());
appMultiFeatureCfgDao.auditCfg(cfg);
if(isAudit==1){
Map<String,List> map = cfgConvert(strRegionList,complexList,2,entity,groupRelationList);
groupRelationList=map.get("groupList");
strRegionList=map.get("dstList");
}
}
// 构造提交综合服务参数格式,一条配置提交一次综合服务
if (isAudit == 1) {
maatCfg.initDefaultValue();
BeanUtils.copyProperties(entity, maatCfg);
maatCfg.setAction(entity.getAction());
maatCfg.setAuditTime(entity.getAuditTime());
maatCfg.setIpRegionList(ipRegionList);
maatCfg.setStrRegionList(strRegionList);
maatCfg.setNumRegionList(numRegionList);
maatCfg.setDigestRegionList(digestRegionList);
maatCfg.setGroupRelationList(groupRelationList);
maatCfg.setGroupNum(groupRelationList.size());
maatCfg.setAreaIpRegionList(areaIpRegionList);
maatCfg.setIsValid(entity.getIsValid());
//只有用户自定义域1字段为空才设置maat的自定义域字段信息为APP_ID
if(StringUtil.isEmpty(entity.getUserRegion1())){
// 设置APP自定义域
String userRegion = "APP_ID=" + entity.getAppCode();
maatCfg.setUserRegion(userRegion);
}else{
maatCfg.setUserRegion(entity.getUserRegion1());
}
configCompileList.add(maatCfg);
maatBean.setConfigCompileList(configCompileList);
maatBean.setAuditTime(entity.getAuditTime());
maatBean.setCreatorName(entity.getCurrentUser().getName());
maatBean.setVersion(Constants.MAAT_VERSION);
maatBean.setOpAction(Constants.INSERT_ACTION);
// 调用服务接口下发配置数据
String json = gsonToJson(maatBean);
logger.info("app 特征配置下发配置参数:" + json);
// 调用服务接口下发配置
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
logger.info("app 特征配置下发响应信息:" + result.getMsg());
} else if (isAudit == 3) {
maatCfg.setCompileId(entity.getCompileId());
maatCfg.setServiceId(entity.getServiceId());
maatCfg.setIsValid(0);// 无效
configCompileList.add(maatCfg);
maatBean.setConfigCompileList(configCompileList);
maatBean.setAuditTime(entity.getAuditTime());
maatBean.setCreatorName(entity.getCurrentUser().getName());
maatBean.setVersion(Constants.MAAT_VERSION);
maatBean.setOpAction(Constants.UPDATE_ACTION);
// 调用服务接口取消配置
String json = gsonToJson(maatBean);
logger.info("app 特征配置下发配置参数:" + json);
// 调用服务接口下发配置
ToMaatResult result = ConfigServiceUtil.put(json, 1);
logger.info("app 特征配置取消配置响应信息:" + result.getMsg());
}
}
public void updateAppFeatureCfgValid(Integer isValid, String ids, Integer functionId) {
String[] idArray = ids.split(",");
for (String id : idArray) {
AppFeatureIndex entity = new AppFeatureIndex();
entity.setCfgId(Long.parseLong(id));
entity.setIsValid(isValid);
entity.setEditorId(UserUtils.getUser().getId());
entity.setEditTime(new Date());
entity.setTableName(AppFeatureIndex.getTablename());
entity.setFunctionId(functionId);
appMultiFeatureCfgDao.updateCfgValid(entity);
//修改IP范围配置表状态
if (!StringUtil.isEmpty(entity.getIpPortList())) {
AppIpCfg cfg = new AppIpCfg();
BeanUtils.copyProperties(entity, cfg, new String[] { "cfgId" });
cfg.setTableName("APP_IP_RANGE_CFG");
appMultiFeatureCfgDao.updateCfgValid(cfg);
}
//修改字符串类配置表状态
if (!StringUtil.isEmpty(entity.getStrList())) {
AppStringFeatureCfg cfg = new AppStringFeatureCfg();
BeanUtils.copyProperties(entity, cfg, new String[] { "cfgId" });
cfg.setTableName(AppStringFeatureCfg.getTablename());
appMultiFeatureCfgDao.updateCfgValid(cfg);
}
//修改增强字符串类配置表状态
if (!StringUtil.isEmpty(entity.getComplexList())) {
AppComplexFeatureCfg cfg = new AppComplexFeatureCfg();
BeanUtils.copyProperties(entity, cfg, new String[] { "cfgId" });
cfg.setTableName(AppComplexFeatureCfg.getTablename());
appMultiFeatureCfgDao.updateCfgValid(cfg);
}
}
}
//字符串类特征配置列表
public List<AppStringFeatureCfg> getAppStringFeatureCfg(Integer compileId,Integer functionId,Integer cfgRegionCode){
return appMultiFeatureCfgDao.getAppStringFeatureCfg(compileId,functionId,cfgRegionCode);
}
//增强字符串类特征配置列表
public List<AppComplexFeatureCfg> getAppComplexFeatureCfg(Integer compileId,Integer functionId,Integer cfgRegionCode){
return appMultiFeatureCfgDao.getAppComplexFeatureCfg(compileId,functionId,cfgRegionCode);
}
//IP RANGE配置
public List<AppIpCfg> getAppIpRangeCfg(Integer compileId,Integer functionId){
return appMultiFeatureCfgDao.getAppIpRangeCfg(compileId,functionId);
}
}