diff --git a/src/main/java/com/nis/web/controller/basics/DnsKeywordController.java b/src/main/java/com/nis/web/controller/basics/DnsKeywordController.java index 141533868..31fa97a8b 100644 --- a/src/main/java/com/nis/web/controller/basics/DnsKeywordController.java +++ b/src/main/java/com/nis/web/controller/basics/DnsKeywordController.java @@ -1,39 +1,27 @@ 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.Lists; 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; @@ -119,7 +107,7 @@ public class DnsKeywordController extends BaseController{ ,HttpServletResponse response ,RedirectAttributes redirectAttributes) { //选中配置审核 - /*if(!StringUtil.isEmpty(ids)) { + if(!StringUtil.isEmpty(ids)) { List infoList=dnsKeywordCfgService.getByIds(ids); Map> dnsKeywordMap=Maps.newHashMap(); for(DnsKeywordCfg entity:infoList) { @@ -136,10 +124,10 @@ public class DnsKeywordController extends BaseController{ dnsKeywordMap.put(Long.parseLong(entity.getUserRegion1()), keywords); } } - *//********************每次下发一个组的region,保证事物********************//* + //********************每次下发一个组的region,保证事物********************//* for (Long groupId : dnsKeywordMap.keySet()) { try { - dnsKeywordCfgService.auditDnsKeywordBatch(dnsKeywordMap.get(groupId),groupId,isValid); + dnsKeywordCfgService.auditDnsKeywordBatch(dnsKeywordMap.get(groupId),groupId,isAudit,isValid); } catch (Exception e) { logger.error("配置下发失败:",e); if(e instanceof MaatConvertException) { @@ -150,7 +138,7 @@ public class DnsKeywordController extends BaseController{ } } - }else { + }/*else { //条件下所有配置审核 Page searchPage=new Page(request,response,"a"); Page auditPage=new Page(request,response,"a"); diff --git a/src/main/java/com/nis/web/dao/basics/PolicyGroupInfoDao.java b/src/main/java/com/nis/web/dao/basics/PolicyGroupInfoDao.java index 7689aca52..e5d263316 100644 --- a/src/main/java/com/nis/web/dao/basics/PolicyGroupInfoDao.java +++ b/src/main/java/com/nis/web/dao/basics/PolicyGroupInfoDao.java @@ -27,4 +27,6 @@ public interface PolicyGroupInfoDao extends CrudDao { List findPolicyByGroupInfoList(@Param("ids")String ids); List findPolicyGroupInfosByTypeForUD(@Param("groupType")Integer groupType,@Param("flag")Integer flag); + List getInfoByServiceGroupId(@Param("serviceGroupId")Long serviceGroupId); + int updateUdFlag(PolicyGroupInfo policyGroupInfo); } \ No newline at end of file diff --git a/src/main/java/com/nis/web/dao/basics/PolicyGroupInfoDao.xml b/src/main/java/com/nis/web/dao/basics/PolicyGroupInfoDao.xml index dc4c52815..05b3d30b4 100644 --- a/src/main/java/com/nis/web/dao/basics/PolicyGroupInfoDao.xml +++ b/src/main/java/com/nis/web/dao/basics/PolicyGroupInfoDao.xml @@ -178,7 +178,30 @@ - + + update policy_group_info + + + + ud_flag = #{udFlag,jdbcType=INTEGER}, + + + editor_id = #{editorId,jdbcType=INTEGER}, + + + edit_time = #{editTime,jdbcType=TIMESTAMP}, + + + + + + and group_id = #{groupId,jdbcType=INTEGER} + + + and service_group_id = #{serviceGroupId,jdbcType=INTEGER} + + + - + - SELECT - - ,s.name as creator_name,e.name as editor_name,u.name as auditor_name - FROM dns_domain_cfg a - left join sys_user s on a.creator_id=s.id - left join sys_user e on a.editor_id=e.id + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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.region_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} + where service_id=-2 and function_id=#{functionId} + + and a.cfg_type =#{cfgType,jdbcType=VARCHAR} - - AND compile_id = #{compileId,jdbcType=INTEGER} + + + + + + + + + update ${tableName} set is_valid = #{isValid,jdbcType=INTEGER}, + editor_id = #{editorId,jdbcType=INTEGER} , + edit_time = #{editTime,jdbcType=TIMESTAMP} + + ,is_audit = #{isAudit,jdbcType=BIGINT} - 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 cfg_id = #{cfgId,jdbcType=BIGINT} - AND compile_id = #{compileId,jdbcType=INTEGER} + 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} - - - + + + + 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, + REGION_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}, + #{regionId,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/BaseService.java b/src/main/java/com/nis/web/service/BaseService.java index 1b13fe6b8..539b8dc64 100644 --- a/src/main/java/com/nis/web/service/BaseService.java +++ b/src/main/java/com/nis/web/service/BaseService.java @@ -14,6 +14,9 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; +import javax.ws.rs.client.Entity; +import javax.ws.rs.core.MediaType; + import org.apache.commons.lang3.StringEscapeUtils; import org.apache.ibatis.session.ExecutorType; import org.apache.ibatis.session.SqlSession; @@ -66,6 +69,7 @@ import com.nis.domain.configuration.CfgIndexInfo; import com.nis.domain.configuration.ComplexkeywordCfg; import com.nis.domain.configuration.DdosIpCfg; import com.nis.domain.configuration.DnsIpCfg; +import com.nis.domain.configuration.DnsKeywordCfg; import com.nis.domain.configuration.DnsResStrategy; import com.nis.domain.configuration.FileDigestCfg; import com.nis.domain.configuration.IpReusePolicyCfg; @@ -2954,6 +2958,63 @@ public abstract class BaseService { logger.warn("asnIPRegionSendToMaat finish,cost:"+(end-start)); } + /** + * + * @Description: 公共组域配置 下发 修改 删除 + * @author(zdx) + * @date 2019年2月19日 上午11:37:37 + * @param regionList + * @param action + */ + public void commonGroupRegionSendToMaat(List regionList,Integer action) { + logger.warn("commonGroupRegionSendToMaat start"); + long start=System.currentTimeMillis(); + GroupReuseAddBean maatBean = new GroupReuseAddBean(); + List groupReuseList=new ArrayList<>(); + GroupReuseCfg groupReuseCfg=new GroupReuseCfg(); + List ipRegionList = new ArrayList<>(); + List strRegionList = new ArrayList<>(); + List numRegionList = new ArrayList<>(); + if (!StringUtil.isEmpty(regionList)&®ionList.get(0) instanceof BaseIpCfg) { + ipRegionList = (List) regionList; + } + if (!StringUtil.isEmpty(regionList)&®ionList.get(0) instanceof StringCfg) { + strRegionList = (List) regionList; + } + if (!StringUtil.isEmpty(regionList)&®ionList.get(0) instanceof NumBoundaryCfg) { + numRegionList = (List) regionList; + } + groupReuseCfg.setIpRegionList(ipRegionList); + groupReuseCfg.setStrRegionList(strRegionList); + groupReuseCfg.setNumRegionList(numRegionList); + groupReuseList.add(groupReuseCfg); + maatBean.setGroupReuseCfgList(groupReuseList); + maatBean.setAuditTime(new Date()); + maatBean.setCreatorName(UserUtils.getUser().getName()); + maatBean.setVersion(Constants.MAAT_VERSION); + //公共组域删除接口的访问方式为PUT,所以在配置取消时 应该把opAction设置为2; + maatBean.setOpAction(Constants.OPACTION_DELETE==Integer.valueOf(action)?Constants.OPACTION_PUT:action); + //调用服务接口下发配置数据 + String json=gsonToJson(maatBean); + String optionStr = "添加"; + if(action.equals(Constants.OPACTION_PUT)){ + optionStr = "修改"; + } + if(action.equals(Constants.OPACTION_DELETE)){ + optionStr = "删除"; + } + if(regionList.size()<=100) { + logger.info("公共组域配置 "+optionStr+"操作,参数:"+json); + }else { + logger.info("公共组域配置"+optionStr+"操作数据条数:"+regionList.size()); + } + //调用服务接口下发配置 + ToMaatResult result =ConfigServiceUtil.auditCommonGroupRegionSources(json,action); + //logger.info("asn ip复用域 "+action+" 配置响应信息:"+result.getMsg()); + logger.info("公共组域配置 "+optionStr+"操作,响应信息:"); + long end=System.currentTimeMillis(); + logger.warn("commonGroupRegionSendToMaat finish,cost:"+(end-start)); + } /** * ASN关键字配置处理 * @param asnList diff --git a/src/main/java/com/nis/web/service/basics/DnsKeywordCfgService.java b/src/main/java/com/nis/web/service/basics/DnsKeywordCfgService.java index 33d6cfe93..0bfe60ea8 100644 --- a/src/main/java/com/nis/web/service/basics/DnsKeywordCfgService.java +++ b/src/main/java/com/nis/web/service/basics/DnsKeywordCfgService.java @@ -5,8 +5,6 @@ import java.util.Date; import java.util.HashMap; 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; @@ -17,28 +15,16 @@ 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; @@ -77,7 +63,7 @@ public class DnsKeywordCfgService extends CrudService, Dn entity.getSqlMap().put("dsf", configScopeFilter(entity.getCurrentUser(),"r")); entity.setPage(page); List list=dnsKeywordCfgDao.findPage(entity); - List policyGroupInfos = policyGroupInfoDao.findPolicyGroupInfosByTypeForUD(12,1); + List policyGroupInfos = policyGroupInfoDao.findPolicyGroupInfosByTypeForUD(12,null); Map policyGroupMap = new HashMap(); for (PolicyGroupInfo policyGroupInfo : policyGroupInfos) { if (!StringUtil.isEmpty(policyGroupInfo.getServiceGroupId())) { @@ -159,12 +145,15 @@ public class DnsKeywordCfgService extends CrudService, Dn entity.setCreateTime(new Date()); entity.setCreatorId(entity.getCurrentUser().getId()); if (!StringUtil.isEmpty(entity.getDomainList())) { - for(ComplexkeywordCfg cfg:entity.getDomainList()){ + List regionIdList = ConfigServiceUtil.getId(3, entity.getDomainList().size()); + for (int i = 0; i < entity.getDomainList().size(); i++) { + ComplexkeywordCfg cfg = entity.getDomainList().get(i); if(StringUtils.isNotBlank(cfg.getCfgKeywords())){ - BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"}); + BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode"}); if(StringUtils.isNoneBlank(cfg.getDistrictShowName()) && cfg.getDistrict().equals("others")){ cfg.setDistrict(cfg.getDistrictShowName()); } + cfg.setRegionId(regionIdList.get(i)); dnsKeywordCfgDao.saveDnsKeywordsCfg(cfg); } } @@ -197,6 +186,74 @@ public class DnsKeywordCfgService extends CrudService, Dn } } + /** + * + * @Description:Dns 关键字公共组配置审核功能 + * @author(zdx) + * @date 2019年2月21日 下午6:44:11 + * @param infoList + * @param serviceGroupId + * @param isValid + */ + @Transactional(readOnly=false,rollbackFor=RuntimeException.class) + public void auditDnsKeywordBatch(List infoList,Long serviceGroupId,Integer isAudit,Integer isValid) { + SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class); + final SqlSession batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false); + try{ + if(!StringUtil.isEmpty(infoList)){ + List regionList = new ArrayList(); + for(int index = 0; index < infoList.size();index++){ + DnsKeywordCfg t = infoList.get(index); + BaseStringCfg baseStrCfg=new BaseStringCfg(); + StringCfg strCfg = new StringCfg(); + BeanUtils.copyProperties(t, baseStrCfg); + BeanUtils.copyProperties(t, strCfg); + strCfg.setGroupId(Integer.valueOf(t.getUserRegion1())); + baseStrCfg.setTableName(DnsKeywordCfg.getTablename()); + regionList.add(strCfg); + ((StringCfgDao) batchSqlSession.getMapper(StringCfgDao.class)).audit(baseStrCfg); + } + batchSqlSession.commit(); + if (isAudit!=Constants.AUDIT_NO) {//审核未通过 跳过 + PolicyGroupInfo dnsGroupInfo = null; + List dnsGroupInfoList=policyGroupInfoDao.getInfoByServiceGroupId(serviceGroupId); + if (!StringUtil.isEmpty(dnsGroupInfoList)) { + dnsGroupInfo = dnsGroupInfoList.get(0); + } + List ipRegionList = new ArrayList(); + List strRegionList = new ArrayList(); + List numRegionList = new ArrayList(); + if(isValid==Constants.VALID_YES) {//审核通过 + if (Integer.valueOf(dnsGroupInfo.getUdFlag())==0) { + dnsGroupInfo.setEditorId(UserUtils.getUser().getId()); + dnsGroupInfo.setEditTime(new Date()); + dnsGroupInfo.setUdFlag(1); + policyGroupInfoDao.updateUdFlag(dnsGroupInfo); + } + commonGroupRegionSendToMaat(regionList,Constants.OPACTION_POST); + }else if(isValid==Constants.VALID_NO) {//取消审核通过 + + //如果一个dns组下没有域了,需要把policy的udFlag设置为0(如果还有dns配置未取消提示需要先取消配置才能取消最后一个域) + if(!hasValidDnsKeyword(serviceGroupId)) { + //需要先判断是否有生效配置引用该组 + dnsGroupInfo.setEditorId(UserUtils.getUser().getId()); + dnsGroupInfo.setEditTime(new Date()); + dnsGroupInfo.setUdFlag(0); + policyGroupInfoDao.updateUdFlag(dnsGroupInfo); + } + commonGroupRegionSendToMaat(regionList,Constants.OPACTION_DELETE); + } + } + } + }finally { + if(batchSqlSession != null){ + batchSqlSession.close(); + } + } + } + public boolean hasValidDnsKeyword(Long maatGroupId) { + return dnsKeywordCfgDao.hasValidDnsKeyword(maatGroupId)>0; + } public List getByIds(String ids) { if(ids==null) { throw new RuntimeException("ids is null!"); diff --git a/src/main/webapp/WEB-INF/views/basics/dnsKeywordCfgList.jsp b/src/main/webapp/WEB-INF/views/basics/dnsKeywordCfgList.jsp index 401c0a959..e9265354e 100644 --- a/src/main/webapp/WEB-INF/views/basics/dnsKeywordCfgList.jsp +++ b/src/main/webapp/WEB-INF/views/basics/dnsKeywordCfgList.jsp @@ -157,7 +157,7 @@ -