diff --git a/src/main/java/com/nis/domain/configuration/DnsKeywordCfg.java b/src/main/java/com/nis/domain/configuration/DnsKeywordCfg.java new file mode 100644 index 000000000..fb8907346 --- /dev/null +++ b/src/main/java/com/nis/domain/configuration/DnsKeywordCfg.java @@ -0,0 +1,234 @@ +/** + *@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 java.util.List; + +import org.apache.commons.lang3.StringEscapeUtils; +import org.apache.taglibs.standard.functions.Functions; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; +import com.nis.util.excel.ExcelField; + +/** + * @ClassName: BaseEnhancedStringConfig.java + * @Description: 基础增强字符串类配置 + * @author (wx) + * @date 2018年2月5日 下午5:42:52 + * @version V1.0 + */ +public class DnsKeywordCfg extends BaseCfg{ + /** + * @Fields serialVersionUID:TODO(用一句话描述这个变量表示什么) + * + * @since 1.0.0 + */ + + private static final long serialVersionUID = -1417089397345367232L; + private static final String tableName="dns_domain_cfg"; + /** + * 匹配区域 + */ + @Expose + @ExcelField(title="district",sort=301) + @SerializedName("district") + protected String district ; + protected String districtShowName; + /** + * 关键字 + */ + @Expose + @SerializedName("keywords") + @ExcelField(title="key_word",sort=302) + protected String cfgKeywords; + protected String keywordsShowName; + /** + * 表达式类型 + */ + @Expose + @SerializedName("exprType") + @ExcelField(title="expression_type",dictType="EXPRESSION_TYPE",sort=303) + protected Integer exprType ; + /** + * 匹配方式 + */ + @Expose + @ExcelField(title="match_method",dictType="MATCH_METHOD",sort=304) + @SerializedName("matchMethod") + protected Integer matchMethod ; + + /** + * 是否hex + */ + @ExcelField(title="is_hex",sort=305) + protected Integer isHex; + /** + * 是否hex + */ + @ExcelField(title="is_case_insenstive",sort=306) + protected Integer isCaseInsenstive; + + /** + * 是否hex二进制 + */ + @Expose + @SerializedName("isHexbin") + protected Integer isHexbin ; + /** + * district + * @return district + */ + + public String getDistrict() { + return district; + } + /** + * copy属性使用 + */ + protected Long dnsStrategyId; + protected Integer appCode;//仅用于copy属性使用 + protected Integer behavCode;//仅用于copy属性使用 + protected Integer specServiceId;//仅用于copy属性使用 + + public Integer getAppCode() { + return appCode; + } + public void setAppCode(Integer appCode) { + this.appCode = appCode; + } + public Integer getBehavCode() { + return behavCode; + } + public void setBehavCode(Integer behavCode) { + this.behavCode = behavCode; + } + public Integer getSpecServiceId() { + return specServiceId; + } + public void setSpecServiceId(Integer specServiceId) { + this.specServiceId = specServiceId; + } + public Long getDnsStrategyId() { + return dnsStrategyId; + } + public void setDnsStrategyId(Long dnsStrategyId) { + this.dnsStrategyId = dnsStrategyId; + } + /** + * @param district the district to set + */ + public void setDistrict(String district) { + this.district = district; + } + public String getCfgKeywords() { +// cfgKeywords = StringEscapeUtils.unescapeHtml4(cfgKeywords); + return cfgKeywords; + } + public void setCfgKeywords(String cfgKeywords) { + this.cfgKeywords = cfgKeywords; + } + public String getDistrictShowName() { + return districtShowName; + } + public void setDistrictShowName(String districtShowName) { + this.districtShowName = districtShowName; + } + /** + * exprType + * 继承此类的类会覆盖该方法写自己的缺省值 + * @return exprType + */ + + public Integer getExprType() { + return this.exprType; + } + /** + * @param exprType the exprType to set + */ + public void setExprType(Integer exprType) { + this.exprType = exprType; + } + /** + * matchMethod + * 继承此类的类会覆盖该方法写自己的缺省值 + * @return matchMethod + */ + + public Integer getMatchMethod() { + return this.matchMethod; + } + /** + * @param matchMethod the matchMethod to set + */ + public void setMatchMethod(Integer matchMethod) { + this.matchMethod = matchMethod; + } + /** + * isHexbin + * @return isHexbin + */ + + public Integer getIsHexbin() { + return isHexbin; + } + /** + * @param isHexbin the isHexbin to set + */ + public void setIsHexbin(Integer isHexbin) { + this.isHexbin = isHexbin; + } + public Integer getIsHex() { + return isHex; + } + public void setIsHex(Integer isHex) { + this.isHex =isHex; + } + public Integer getIsCaseInsenstive() { + return isCaseInsenstive; + } + public void setIsCaseInsenstive(Integer isCaseInsenstive) { + this.isCaseInsenstive =isCaseInsenstive; + } + /* (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; + } + + public static List replaceComplexKeyList(List list){ + for (int i = 0; i < list.size(); i++) { + DnsKeywordCfg base=(DnsKeywordCfg)list.get(i); + base.setIsHex(base.getIsHexbin()); + // '默认为0:大小写不敏感,且非HEX;1:HEX格式二进制;2:大小写敏感,且非HEX', + if(base.getIsHexbin()==2){ + base.setIsCaseInsenstive(1); + }else{ + base.setIsCaseInsenstive(0); + } + base.setCfgKeywords(Functions.replace(base.getCfgKeywords(), "***and***"," ")); + } + return list; + } + public Integer getIndex() { + return index; + } + public void setIndex(Integer index) { + this.index = index; + } + public static String getTablename() { + return tableName; + } +} diff --git a/src/main/java/com/nis/web/controller/BaseController.java b/src/main/java/com/nis/web/controller/BaseController.java index 165ffec9a..2a44f7680 100644 --- a/src/main/java/com/nis/web/controller/BaseController.java +++ b/src/main/java/com/nis/web/controller/BaseController.java @@ -156,6 +156,7 @@ import com.nis.web.service.SystemService; import com.nis.web.service.UserService; import com.nis.web.service.basics.AsnGroupInfoService; import com.nis.web.service.basics.AsnIpCfgService; +import com.nis.web.service.basics.DnsKeywordCfgService; import com.nis.web.service.basics.IpReuseIpCfgService; import com.nis.web.service.basics.PolicyGroupInfoService; import com.nis.web.service.basics.ServiceDictInfoService; @@ -332,6 +333,8 @@ public class BaseController { protected PxyObjSpoofingIpPoolService pxyObjSpoofingIpPoolService;// 欺骗IP池 @Autowired protected AsnGroupInfoService asnGroupInfoService;// asn组 + @Autowired + protected DnsKeywordCfgService dnsKeywordCfgService;//DNS关键字分组配置 /** * 管理基础路径 */ diff --git a/src/main/java/com/nis/web/controller/basics/DnsKeywordController.java b/src/main/java/com/nis/web/controller/basics/DnsKeywordController.java new file mode 100644 index 000000000..141533868 --- /dev/null +++ b/src/main/java/com/nis/web/controller/basics/DnsKeywordController.java @@ -0,0 +1,194 @@ +package com.nis.web.controller.basics; + +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 jersey.repackaged.com.google.common.collect.Lists; + +import org.apache.commons.lang.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.servlet.mvc.support.RedirectAttributes; + +import com.google.common.collect.Maps; +import com.nis.domain.FunctionRegionDict; +import com.nis.domain.FunctionServiceDict; +import com.nis.domain.Page; +import com.nis.domain.basics.AsnGroupInfo; +import com.nis.domain.basics.AsnIpCfg; +import com.nis.domain.configuration.CfgIndexInfo; +import com.nis.domain.configuration.ComplexkeywordCfg; +import com.nis.domain.configuration.DnsKeywordCfg; +import com.nis.exceptions.MaatConvertException; +//import com.nis.util.AsnCacheUtils; +import com.nis.util.Constants; +import com.nis.util.DictUtils; +import com.nis.util.StringUtil; +import com.nis.web.controller.BaseController; +import com.nis.web.security.UserUtils; +@Controller +@RequestMapping(value = "${adminPath}/basics/dns/keyword") +public class DnsKeywordController extends BaseController{ + @RequestMapping(value = {"/list"}) + public String list(Model model,HttpServletRequest request + ,HttpServletResponse response,@ModelAttribute("cfg")DnsKeywordCfg entity + ){ + Page page = dnsKeywordCfgService.findPage(new Page(request, response,"r"), entity); + model.addAttribute("page", page); + initPageCondition(model, entity); + List regionList = DictUtils.getFunctionRegionDictList(entity.getFunctionId()); + model.addAttribute("regionList", regionList); + List serviceList = DictUtils.getFunctionServiceDictList(entity.getFunctionId()); + model.addAttribute("serviceList", serviceList); + return "/basics/dnsKeywordCfgList"; + } + @RequestMapping(value = {"/addForm"}) + public String addForm(Model model,HttpServletRequest request + ,HttpServletResponse response,@ModelAttribute("cfg")CfgIndexInfo cfg + ,RedirectAttributes redirectAttributes){ + cfg.setGroupType(12); + initFormCondition(model,cfg); + model.addAttribute("_cfg", cfg); + return "/basics/dnsKeywordCfgFormAdd"; + } + @RequestMapping(value = {"/updateForm"}) + public String updateForm(Model model,HttpServletRequest request + ,HttpServletResponse response,String ids,@ModelAttribute("cfg")DnsKeywordCfg cfg + ,RedirectAttributes redirectAttributes){ + cfg = dnsKeywordCfgService.get(Long.parseLong(ids)); + cfg.setGroupType(12); + initFormCondition(model, cfg); + //List groupInfos=configGroupInfoService.findAllList(4); + //model.addAttribute("policyGroups", groupInfos); + model.addAttribute("cfg", cfg); + return "/basics/dnsKeywordCfgFormUpdate"; + } + @RequestMapping(value = {"/save"}) + @RequiresPermissions(value={"dns:keyword:config"}) + public String save(Model model,HttpServletRequest request,HttpServletResponse response,@ModelAttribute("cfg")CfgIndexInfo cfg,RedirectAttributes redirectAttributes){ + try{ + dnsKeywordCfgService.saveDnsKeywordCfg(cfg); + addMessage(redirectAttributes,"success","save_success"); + }catch(Exception e){ + logger.error("信息保存失败",e); + e.printStackTrace(); + if(e instanceof MaatConvertException) { + addMessage(redirectAttributes,"error",e.getMessage()); + }else { + addMessage(redirectAttributes,"error","save_failed"); + } + } + + return "redirect:" + adminPath +"/basics/dns/keyword/list?functionId="+cfg.getFunctionId(); + } + @RequestMapping(value = {"/update"}) + @RequiresPermissions(value={"dns:keyword:config"}) + public String update(Model model,HttpServletRequest request,HttpServletResponse response,@ModelAttribute("cfg")DnsKeywordCfg cfg,RedirectAttributes redirectAttributes){ + try{ + + dnsKeywordCfgService.update(cfg); + addMessage(redirectAttributes,"success","save_success"); + }catch(Exception e){ + logger.error("信息保存失败",e); + e.printStackTrace(); + addMessage(redirectAttributes,"error","save_failed"); + } + + return "redirect:" + adminPath +"/basics/dns/keyword/list?functionId="+cfg.getFunctionId(); + } + @RequestMapping(value = {"/audit"}) + @RequiresPermissions(value={"dns:keyword:config"}) + public String audit(Model model,@ModelAttribute("cfg")DnsKeywordCfg cfg + ,Integer isAudit + ,Integer isValid + ,String ids + ,Integer functionId + , HttpServletRequest request + ,HttpServletResponse response + ,RedirectAttributes redirectAttributes) { + //选中配置审核 + /*if(!StringUtil.isEmpty(ids)) { + List infoList=dnsKeywordCfgService.getByIds(ids); + Map> dnsKeywordMap=Maps.newHashMap(); + for(DnsKeywordCfg entity:infoList) { + entity.setIsAudit(isAudit); + entity.setIsValid(isValid); + entity.setAuditorId(UserUtils.getUser().getId()); + entity.setAuditTime(new Date()); + entity.setFunctionId(functionId); + if(dnsKeywordMap.containsKey(Long.parseLong(entity.getUserRegion1()))) { + dnsKeywordMap.get(Long.parseLong(entity.getUserRegion1())).add(entity); + }else { + List keywords=Lists.newArrayList(); + keywords.add(entity); + dnsKeywordMap.put(Long.parseLong(entity.getUserRegion1()), keywords); + } + } + *//********************每次下发一个组的region,保证事物********************//* + for (Long groupId : dnsKeywordMap.keySet()) { + try { + dnsKeywordCfgService.auditDnsKeywordBatch(dnsKeywordMap.get(groupId),groupId,isValid); + } catch (Exception e) { + logger.error("配置下发失败:",e); + if(e instanceof MaatConvertException) { + addMessage(redirectAttributes,"error", "request_service_failed"); + }else { + addMessage(redirectAttributes,"error", "audit_failed"); + } + + } + } + }else { + //条件下所有配置审核 + Page searchPage=new Page(request,response,"a"); + Page auditPage=new Page(request,response,"a"); + BeanUtils.copyProperties(searchPage, auditPage); + try { + auditAll(auditPage,isValid , cfg); + addMessage(redirectAttributes,"success", "audit_success"); + } catch (Exception e) { + logger.error("配置下发失败:",e); + if(e instanceof MaatConvertException) { + addMessage(redirectAttributes,"error", "request_service_failed"); + }else { + addMessage(redirectAttributes,"error", "audit_failed"); + } + + } + + return list(model, request, response, cfg); + }*/ + return "redirect:" + adminPath +"/basics/dns/keyword/list?functionId="+cfg.getFunctionId(); + } + @RequestMapping(value = {"/delete"}) + @RequiresPermissions(value={"dns:keyword:config"}) + public String delete(Integer isValid + ,String ids,Integer functionId + ,RedirectAttributes redirectAttributes){ + try{ + dnsKeywordCfgService.delete(ids); + addMessage(redirectAttributes,"success","delete_success"); + }catch(Exception e){ + logger.error("Delete failed",e); + if(e instanceof MaatConvertException) { + addMessage(redirectAttributes,"error",e.getMessage()); + }else { + addMessage(redirectAttributes,"error","delete_failed"); + } + } + + return "redirect:" + adminPath +"/basics/dns/keyword/list?functionId="+functionId; + } +} diff --git a/src/main/java/com/nis/web/dao/configuration/DnsKeywordCfgDao.java b/src/main/java/com/nis/web/dao/configuration/DnsKeywordCfgDao.java new file mode 100644 index 000000000..aac208365 --- /dev/null +++ b/src/main/java/com/nis/web/dao/configuration/DnsKeywordCfgDao.java @@ -0,0 +1,27 @@ +package com.nis.web.dao.configuration; + +import java.util.List; + +import org.apache.ibatis.annotations.Param; + +import com.nis.domain.basics.AsnIpCfg; +import com.nis.domain.configuration.CfgIndexInfo; +import com.nis.domain.configuration.ComplexkeywordCfg; +import com.nis.domain.configuration.DnsKeywordCfg; +import com.nis.web.dao.CrudDao; +import com.nis.web.dao.MyBatisDao; + +/** + * @ClassName:DnsKeyworkCfgDao + * @Description:TODO(这里用一句话描述这个类的作用) + * @author zdx + * @date 2019年2月15日 下午5:55:26 + * @version V1.0 + */ +@MyBatisDao +public interface DnsKeywordCfgDao extends CrudDao{ + public void saveDnsKeywordsCfg(ComplexkeywordCfg entity); + public List findPage(DnsKeywordCfg entity); + public List getByIds(@Param("ids")String ids); + public void delete(@Param("ids")String ids); +} diff --git a/src/main/java/com/nis/web/dao/configuration/DnsKeywordCfgDao.xml b/src/main/java/com/nis/web/dao/configuration/DnsKeywordCfgDao.xml new file mode 100644 index 000000000..a9aa40d26 --- /dev/null +++ b/src/main/java/com/nis/web/dao/configuration/DnsKeywordCfgDao.xml @@ -0,0 +1,340 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + a.CFG_ID,a.CFG_DESC,a.ACTION,a.IS_VALID,a.IS_AUDIT, + a.CREATOR_ID,a.CREATE_TIME,a.EDITOR_ID,a.EDIT_TIME,a.AUDITOR_ID,a.AUDIT_TIME, + a.SERVICE_ID,a.REQUEST_ID,a.COMPILE_ID,a.IS_AREA_EFFECTIVE,a.CLASSIFY, + a.ATTRIBUTE,a.LABLE,a.AREA_EFFECTIVE_IDS,a.function_id,a.dns_strategy_id,a.user_region1, + a.user_region2,a.user_region3,a.user_region4,a.user_region5,a.do_log,a.source_compile_id,a.cancel_request_id, + a.do_blacklist + + + a.cfg_id,a.cfg_desc,a.ip_type,a.src_ip_address,a.ip_pattern,a.port_pattern,a.src_port + ,a.protocol,a.protocol_id,a.direction,a.cfg_type,a.action,a.dest_port,a.dest_ip_address + ,a.is_valid,a.is_audit,a.creator_id,a.create_time,a.editor_id + ,a.edit_time,a.auditor_id,a.audit_time,a.service_id,a.request_id, + a.compile_id,a.is_area_effective,a.classify,a.attribute,a.lable + ,a.area_effective_ids,a.function_id,a.cfg_region_code + + + a.cfg_id,a.cfg_desc,a.cfg_keywords,a.cfg_type, + a.action,a.is_valid,a.is_audit,a.creator_id,a.create_time,a.editor_id,a.edit_time, a.auditor_id, + a.audit_time,a.service_id,a.request_id,a.compile_id,a.is_area_effective,a.classify,a.attribute,a.lable, + a.expr_type,a.match_method,a.is_hexbin,a.area_effective_ids,a.function_id,a.cfg_region_code + + + a.cfg_id,a.cfg_desc,a.cfg_keywords,a.cfg_type,a.district,a.user_region1, + a.action,a.is_valid,a.is_audit,a.creator_id,a.create_time,a.editor_id,a.edit_time, a.auditor_id, + a.audit_time,a.service_id,a.request_id,a.compile_id,a.is_area_effective,a.classify,a.attribute,a.lable, + a.expr_type,a.match_method,a.is_hexbin,a.area_effective_ids,a.function_id,a.cfg_region_code + + + + + + + + update ${tableName} set is_valid = #{isValid,jdbcType=INTEGER}, + editor_id = #{editorId,jdbcType=INTEGER} , + edit_time = #{editTime,jdbcType=TIMESTAMP} + + ,is_audit = #{isAudit,jdbcType=BIGINT} + + + + AND cfg_id = #{cfgId,jdbcType=BIGINT} + + + AND compile_id = #{compileId,jdbcType=INTEGER} + + and function_id=#{functionId,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} + + + + AND cfg_id = #{cfgId,jdbcType=BIGINT} + + + AND compile_id = #{compileId,jdbcType=INTEGER} + + and function_id=#{functionId,jdbcType=INTEGER} + + + + + + insert into dns_domain_cfg ( + 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, + district, + cfg_keywords, + cfg_type, + cfg_region_code, + expr_type, + match_method, + is_hexbin, + user_region1 + )values ( + #{cfgDesc,jdbcType=VARCHAR}, + #{action,jdbcType=INTEGER}, + 0, + 0, + #{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}, + #{district,jdbcType=VARCHAR}, + #{cfgKeywords,jdbcType=VARCHAR}, + #{cfgType,jdbcType=VARCHAR}, + #{cfgRegionCode,jdbcType=INTEGER}, + #{exprType,jdbcType=INTEGER}, + #{matchMethod,jdbcType=INTEGER}, + #{isHexbin,jdbcType=INTEGER}, + #{userRegion1,jdbcType=VARCHAR} + ) + + + + delete from dns_domain_cfg where compile_id=#{compileId} and function_id=#{functionId} + + + delete from dns_domain_cfg where cfg_id in (${ids}) + + + update dns_domain_cfg + + + + cfg_desc = #{cfgDesc,jdbcType=VARCHAR}, + + + action = #{action,jdbcType=INTEGER}, + + + is_valid = #{isValid,jdbcType=INTEGER}, + + + is_audit = #{isAudit,jdbcType=INTEGER}, + + + editor_id = #{editorId,jdbcType=INTEGER}, + + + edit_time = #{editTime,jdbcType=TIMESTAMP}, + + + AUDITOR_ID = #{auditorId,jdbcType=INTEGER}, + + + AUDIT_TIME = #{auditTime,jdbcType=TIMESTAMP}, + + + service_id = #{serviceId,jdbcType=INTEGER}, + + + request_id = #{requestId,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}, + + + district = #{district,jdbcType=VARCHAR}, + + + cfg_keywords = #{cfgKeywords,jdbcType=VARCHAR}, + + + cfg_type = #{cfgType,jdbcType=INTEGER}, + + + cfg_region_code = #{cfgRegionCode,jdbcType=INTEGER}, + + + expr_type = #{exprType,jdbcType=VARCHAR}, + + + match_method = #{matchMethod,jdbcType=INTEGER}, + + + is_hexbin = #{isHexbin,jdbcType=INTEGER}, + + + user_region1 = #{userRegion1,jdbcType=VARCHAR}, + + + compile_id = #{compileId,jdbcType=INTEGER}, + + + + + and cfg_id = #{cfgId,jdbcType=INTEGER} + + + + \ No newline at end of file diff --git a/src/main/java/com/nis/web/service/basics/DnsKeywordCfgService.java b/src/main/java/com/nis/web/service/basics/DnsKeywordCfgService.java new file mode 100644 index 000000000..0c3c30eda --- /dev/null +++ b/src/main/java/com/nis/web/service/basics/DnsKeywordCfgService.java @@ -0,0 +1,195 @@ +package com.nis.web.service.basics; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import org.apache.commons.lang3.StringUtils; +import org.apache.ibatis.session.ExecutorType; +import org.apache.ibatis.session.SqlSession; +import org.apache.ibatis.session.SqlSessionFactory; +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.beust.jcommander.internal.Lists; +import com.google.common.collect.Maps; +import com.nis.domain.FunctionServiceDict; +import com.nis.domain.Page; +import com.nis.domain.basics.AsnGroupInfo; +import com.nis.domain.basics.AsnIpCfg; +import com.nis.domain.basics.PolicyGroupInfo; +import com.nis.domain.configuration.BaseStringCfg; +import com.nis.domain.configuration.CfgIndexInfo; +import com.nis.domain.configuration.ComplexkeywordCfg; +import com.nis.domain.configuration.DnsKeywordCfg; +import com.nis.domain.maat.GroupReuseAddBean; +import com.nis.domain.maat.GroupReuseCfg; +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.domain.specific.ConfigGroupInfo; +import com.nis.util.ConfigServiceUtil; +import com.nis.util.Constants; +import com.nis.util.StringUtil; +import com.nis.web.dao.CrudDao; +import com.nis.web.dao.basics.AsnGroupInfoDao; +import com.nis.web.dao.basics.AsnIpCfgDao; +import com.nis.web.dao.basics.PolicyGroupInfoDao; +import com.nis.web.dao.configuration.DnsKeywordCfgDao; +import com.nis.web.dao.configuration.StringCfgDao; +import com.nis.web.dao.specific.ConfigGroupInfoDao; +import com.nis.web.security.UserUtils; +import com.nis.web.service.CrudService; +import com.nis.web.service.SpringContextHolder; +@Service +public class DnsKeywordCfgService extends CrudService, DnsKeywordCfg> { + @Autowired + private AsnIpCfgDao asnIpCfgDao; + + @Autowired + protected DnsKeywordCfgDao dnsKeywordCfgDao; +// @Autowired +// private SpecificServiceCfgDao specificServiceCfgDao; + @Autowired + private ConfigGroupInfoDao configGroupInfoDao; + @Autowired + private AsnGroupInfoDao asnGroupInfoDao; + + @Autowired + private PolicyGroupInfoDao policyGroupInfoDao; + /** + * @param page + * @param entity + * @return + */ + public Page findPage(Page page, DnsKeywordCfg entity) { + entity.getSqlMap().put("dsf", configScopeFilter(entity.getCurrentUser(),"r")); + entity.setPage(page); + List list=dnsKeywordCfgDao.findPage(entity); + page.setList(list); + return page; + } + + public List findByPage(String ids) { + List list=asnIpCfgDao.findByPage(ids); + return list; + } + public DnsKeywordCfg get(Long id ) { + return dnsKeywordCfgDao.get(id); + } + + @Transactional(readOnly=false,rollbackFor=RuntimeException.class) + public void update(DnsKeywordCfg entity){ + Date editTime=new Date(); + entity.setEditTime(editTime); + entity.setEditorId(entity.getCurrentUser().getId()); + List auditList=new ArrayList(); + /** + * isvalid=0 and asnNo=false 直接修改 + * isvalid=0 and asnNo=true 需要下发 + * isvalid=1 需要下发asnNo下所有的域配置 + */ + /*if(groupInfo.getIsUsed().equals(1) && entity.getIsValid().equals(Constants.VALID_NO)){ + entity.setAuditTime(editTime); + entity.setAuditorId(entity.getCurrentUser().getId()); + entity.setIsValid(Constants.VALID_YES); + entity.setIsAudit(Constants.AUDIT_YES); + auditAsnIpList.add(entity); + } + if(groupInfo.getIsUsed().equals(1) && entity.getIsValid().equals(Constants.VALID_YES)){ + entity.setAuditTime(editTime); + entity.setAuditorId(entity.getCurrentUser().getId()); + entity.setIsValid(Constants.VALID_YES); + entity.setIsAudit(Constants.AUDIT_YES); + auditAsnGroupList.add(groupInfo); + }*/ + if(entity.getIsValid() ==1){ + entity.setAuditTime(editTime); + entity.setAuditorId(entity.getCurrentUser().getId()); + entity.setEditTime(editTime); + entity.setEditorId(entity.getCurrentUser().getId()); + entity.setIsValid(Constants.VALID_YES); + entity.setIsAudit(Constants.AUDIT_YES); + }else{ + entity.setEditTime(editTime); + entity.setEditorId(entity.getCurrentUser().getId()); + entity.setIsValid(Constants.VALID_NO); + entity.setIsAudit(Constants.VALID_NO); + } + dnsKeywordCfgDao.update(entity); + //ASN下发状态时可以更改,更改之后直接下发 + if(entity.getIsValid() ==1){ + auditList.add(entity); +// dnsKeywordRegionSendToMaat(auditList,Constants.VALID_YES,Constants.OPACTION_PUT); + } + //common group 新增下发 ASN IP配置 + /*if(!StringUtil.isEmpty(auditAsnIpList)){ + asnIPRegionSendToMaat(auditAsnIpList,Constants.VALID_YES,Constants.OPACTION_POST); + }*/ + + //common group 修改已下发过的配置,全量下发 ASN NO下的所有有效配置 + /*if(entity.getIsAudit().equals(Constants.VALID_YES)){ + auditAllAsnRegionCfg(entity,auditAsnGroupList,null); + }*/ + } + @Transactional(readOnly=false,rollbackFor=RuntimeException.class) + public void saveDnsKeywordCfg(CfgIndexInfo entity) { +// entity.setCompileId(compileId); + entity.setCreateTime(new Date()); + entity.setCreatorId(entity.getCurrentUser().getId()); + if (!StringUtil.isEmpty(entity.getDomainList())) { + for(ComplexkeywordCfg cfg:entity.getDomainList()){ + if(StringUtils.isNotBlank(cfg.getCfgKeywords())){ + BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"}); + if(StringUtils.isNoneBlank(cfg.getDistrictShowName()) && cfg.getDistrict().equals("others")){ + cfg.setDistrict(cfg.getDistrictShowName()); + } + dnsKeywordCfgDao.saveDnsKeywordsCfg(cfg); + } + } + } + //TODO 注意:被策略引用并下发过的ASN NO,配置新增后直接下发【此功能暂时不做自动,asnip拥有审核功能】 + /*if(!StringUtil.isEmpty(auditAsnIpList)){ + asnIPRegionSendToMaat(auditAsnIpList,Constants.VALID_YES,Constants.OPACTION_POST); + }*/ + } + @Transactional(readOnly=false,rollbackFor=RuntimeException.class) + public void delete(String ids) { + List issuedList=new ArrayList<>(); + List dnsKwdCfgList= dnsKeywordCfgDao.getByIds(ids); + for(DnsKeywordCfg entity:dnsKwdCfgList) { + if(entity.getIsValid()==Constants.VALID_YES) {//代表下发过了 + entity.setIsValid(Constants.VALID_DEL); + issuedList.add(entity); + // groupId=asnIpCfg.getAsnIpGroup(); + //List result=asnIpCfgDao.findOtherIps(groupId, asnIpCfg.getCfgId().intValue()); + //if(result==null||result.size()==0) { + // throw new RuntimeException("Cant not delete ip from asn group, there is only one ip left in the group!"); + //} + } + } + dnsKeywordCfgDao.delete(ids); + //已经下发过的,调用分组复用配置删除接口 +// splitAndSend(issuedList,Constants.VALID_NO); + if(issuedList.size() > 0){ +// dnsKeywordRegionSendToMaat(issuedList,Constants.VALID_NO,Constants.OPACTION_PUT); + } + } + + public List getByIds(String ids) { + if(ids==null) { + throw new RuntimeException("ids is null!"); + } + return dnsKeywordCfgDao.getByIds(ids); + } +} diff --git a/src/main/resources/sql/20190215/add_function_region&service.sql b/src/main/resources/sql/20190215/add_function_region&service.sql new file mode 100644 index 000000000..4378b73dc --- /dev/null +++ b/src/main/resources/sql/20190215/add_function_region&service.sql @@ -0,0 +1,5 @@ +--添加dns和url公共组的function_region和function_service字典 +INSERT INTO `function_region_dict` (`dict_id`, `function_id`, `config_district`, `config_region_code`, `config_region_value`, `config_desc`, `is_valid`, `is_maat`, `region_type`, `creator_id`, `create_time`, `editor_id`, `edit_time`, `config_service_type`, `config_expr_type`, `config_match_method`, `config_ip_type`, `config_hex`, `config_multi_keywords`, `config_ip_pattern`, `config_port_pattern`, `config_direction`, `config_protocol`, `config_ip_port_show`, `config_region_sort`, `is_import`) VALUES ('622', '409', 'QNAME', '2', 'NTC_DNS_REGION', 'DNS域名配置', '1', '1', '3', NULL, '0000-00-00 00:00:00', NULL, '0000-00-00 00:00:00', '', '0', '0,1,2,3', '', '0,1,2', '0', '', '', '', '', '', '1', '1'); +INSERT INTO `function_region_dict` (`dict_id`, `function_id`, `config_district`, `config_region_code`, `config_region_value`, `config_desc`, `is_valid`, `is_maat`, `region_type`, `creator_id`, `create_time`, `editor_id`, `edit_time`, `config_service_type`, `config_expr_type`, `config_match_method`, `config_ip_type`, `config_hex`, `config_multi_keywords`, `config_ip_pattern`, `config_port_pattern`, `config_direction`, `config_protocol`, `config_ip_port_show`, `config_region_sort`, `is_import`) VALUES ('623', '111', '', '2', 'NTC_URL_REGION', 'URL公共组域配置', '1', '1', '2', NULL, '0000-00-00 00:00:00', NULL, '0000-00-00 00:00:00', '', '0,1', '0,1,2,3', '', '0', '1', NULL, NULL, NULL, NULL, NULL, '2', '1'); +INSERT INTO `function_service_dict` (`dict_id`, `function_id`, `protocol_id`, `action`, `action_code`, `service_id`, `service_name`, `service_desc`, `is_valid`, `creator_id`, `create_time`, `editor_id`, `edit_time`, `region_code`, `is_import`, `sort`, `config_do_log`) VALUES ('164', '409', '0', '0', '', '-2', 'NTC_DNS_REGION', NULL, '1', '1', '2019-02-15 16:48:56', NULL, NULL, '1', '1', '1', NULL); +INSERT INTO `function_service_dict` (`dict_id`, `function_id`, `protocol_id`, `action`, `action_code`, `service_id`, `service_name`, `service_desc`, `is_valid`, `creator_id`, `create_time`, `editor_id`, `edit_time`, `region_code`, `is_import`, `sort`, `config_do_log`) VALUES ('165', '111', '0', '0', '', '-1', 'NTC_URL_REGION', NULL, '1', '1', '2019-02-15 16:49:49', NULL, NULL, '1', '1', '1', NULL); diff --git a/src/main/webapp/WEB-INF/views/basics/dnsKeywordCfgFormAdd.jsp b/src/main/webapp/WEB-INF/views/basics/dnsKeywordCfgFormAdd.jsp new file mode 100644 index 000000000..39849444a --- /dev/null +++ b/src/main/webapp/WEB-INF/views/basics/dnsKeywordCfgFormAdd.jsp @@ -0,0 +1,423 @@ +<%@ page contentType="text/html;charset=UTF-8"%> +<%@ include file="/WEB-INF/include/taglib.jsp"%> + + +<spring:message code="dns_keyword_group_configuration"></spring:message> + + + + +
+

+ +

+
+
+
+
+
+ + +
+
+
+ +
+ + + + + + + + + + + + + + + + +
+ +
+
+
+ +
+ +
+
+
+
+
+ +
+ <%-- --%> + <%-- --%> + +
+
+
+
+
+

+ + +

+ +
+
+
+
+
+
+ + +
+
+
+
+
+
+
+ +
+
+
+
+
+ + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/views/basics/dnsKeywordCfgFormUpdate.jsp b/src/main/webapp/WEB-INF/views/basics/dnsKeywordCfgFormUpdate.jsp new file mode 100644 index 000000000..72dd9ead4 --- /dev/null +++ b/src/main/webapp/WEB-INF/views/basics/dnsKeywordCfgFormUpdate.jsp @@ -0,0 +1,368 @@ +<%@ page contentType="text/html;charset=UTF-8"%> +<%@ include file="/WEB-INF/include/taglib.jsp"%> + + +<spring:message code="dns_keyword_group_configuration"></spring:message> + + + + +
+ +

+ +

+ + + + +
+
+
+
+
+ + +
+
+
+ +
+ + + + + + + + + + + + + + + + + +
+ +
+
+
+ +
+ +
+
+
+
+
+ +
+ <%-- --%> + <%-- --%> + +
+
+
+
+
+ + + +
+
+
+ +
+ +
+
+
+
+
+
+
+
+
+ + + + +
+ domainCheck urlCheck " type="text" id="tags_${tabName}${status.index}" + name="cfgKeywords" + value="${cfg.cfgKeywords}"> +
+
+ + +
+ + +
+
+
+
+
+
+
+
+
+ + +
+ + + + + + > + + + + + + + + + + + + + +
+
+ +
+
+ +
+
+ +
+ +
+
+
+
+
+
hidden"> + +
+
+ +
+ + + + +
+
+
+
+
+
+ +
+ + +
+
+
+
+
+ +
+
+ +
+ +
+
+
+
+
+
+ +
+ +
+
+
+
+
+
+ +
+ <%-- <%@include file="/WEB-INF/include/form/basicInfo.jsp" %> --%> +
+
+
+
+
+
+ + +
+
+
+
+
+
+
+ +
+
+
+
+
+ + + + + + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/views/basics/dnsKeywordCfgList.jsp b/src/main/webapp/WEB-INF/views/basics/dnsKeywordCfgList.jsp new file mode 100644 index 000000000..ef696f17b --- /dev/null +++ b/src/main/webapp/WEB-INF/views/basics/dnsKeywordCfgList.jsp @@ -0,0 +1,305 @@ +<%@ page contentType="text/html;charset=UTF-8"%> +<%@ include file="/WEB-INF/include/taglib.jsp"%> + + +<spring:message code="asn_ip_configuration"></spring:message> + + + + +
+ + +

+ + <%-- --%> +

+ +
+
+
+
+ + + + + + + + + + + +
+
+ + + + + + + + +
+ +
+ +
+
+ + + <%-- --%> + + + +
+ + +
+ + + + + +
+
+
+
+ + + +
+
+ + + + + +
+ + +
+ + + +
+ + +
+
+ href="javascript:;"> + + +
+
+ + + +
+
+
+
+ + +
+
+ +
+
+ + " onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/> + +
+
+ +
+
+ + " onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/> + +
+
+ +
+
+ + " onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/> + +
+
+ +
+
+ + " onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/> + +
+
+ +
+
+ + " onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/> + +
+
+
+ + +
+ + +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
${cfg.cfgDesc }${cfg.cfgKeywords }${cfg.userRegion1} + + + + + + + + + + + + ${cfg.creatorName }${cfg.editorName }${cfg.auditorName }
+
${page}
+
+
+
+
+
+ + +<%@include file="/WEB-INF/include/excel/importModal.jsp" %> + + \ No newline at end of file