(1)app domain导入提交

(2)asn no字段扩展为long类型,数据库对应字段扩展为bigint
This commit is contained in:
wangxin
2018-11-05 16:26:02 +08:00
parent 97eb005a6d
commit 29b6ff8207
20 changed files with 247 additions and 61 deletions

View File

@@ -55,6 +55,7 @@ import com.nis.domain.configuration.DnsResStrategy;
import com.nis.domain.configuration.IpPortCfg;
import com.nis.domain.configuration.RequestInfo;
import com.nis.domain.configuration.StringCfgTemplate;
import com.nis.domain.configuration.template.AppDomainTemplate;
import com.nis.domain.configuration.template.AsnIpTemplate;
import com.nis.domain.configuration.template.ComplexStringAllTemplate;
import com.nis.domain.configuration.template.DdosIpTemplate;
@@ -857,6 +858,7 @@ public class BaseController {
}
StringBuffer errTip = new StringBuffer();
Pattern pattern = Pattern.compile("\t|\r|\n|\b|\f");
Pattern domainPattern = Pattern.compile(Constants.DOMAIN_REGEXP);
for (int i = 0; i < list.size(); i++) {
StringBuffer errInfo = new StringBuffer();
BaseStringCfg baseStringCfg = new BaseStringCfg();
@@ -880,47 +882,71 @@ public class BaseController {
}
}
String keyword = baseStringCfg.getCfgKeywords();
if (StringUtils.isBlank(keyword)) {
errInfo.append(
String.format(prop.getProperty("can_not_null"), prop.getProperty("key_word") + " ") + ";");
}
if (mulityKeywordsP.equals("0")) {
if (keyword.indexOf("\n") > -1) {
if (!regionDict.getFunctionId().equals(403)) {
if (StringUtils.isBlank(keyword)) {
errInfo.append(
String.format(prop.getProperty("not_multiple"), prop.getProperty("key_word")) + ";");
String.format(prop.getProperty("can_not_null"), prop.getProperty("key_word") + " ") + ";");
}
Matcher m = pattern.matcher(keyword);
if (m.find()) {
errInfo.append(String.format(prop.getProperty("has_invisible_char"),
prop.getProperty("key_word") + " '" + keyword + "'") + ";");
}
} else {
boolean has = false;
Set<String> keywordSet=Sets.newHashSet();
for (String key : keyword.split("\n")) {
Matcher m = pattern.matcher(key);
if (mulityKeywordsP.equals("0")) {
if (keyword.indexOf("\n") > -1) {
errInfo.append(
String.format(prop.getProperty("not_multiple"), prop.getProperty("key_word")) + ";");
}
Matcher m = pattern.matcher(keyword);
if (m.find()) {
has = true;
errInfo.append(String.format(prop.getProperty("has_invisible_char"),
prop.getProperty("key_word") + " '" + key + "'") + ";");
break;
prop.getProperty("key_word") + " '" + keyword + "'") + ";");
}
if(!keywordSet.contains(key)) {
keywordSet.add(key);
}else {
errInfo.append(prop.getProperty("key_word") + " '" + key + "'"+" "+prop.getProperty("repeat") + ";");
} else {
boolean has = false;
Set<String> keywordSet=Sets.newHashSet();
for (String key : keyword.split("\n")) {
Matcher m = pattern.matcher(key);
if (m.find()) {
has = true;
errInfo.append(String.format(prop.getProperty("has_invisible_char"),
prop.getProperty("key_word") + " '" + key + "'") + ";");
break;
}
if(!keywordSet.contains(key)) {
keywordSet.add(key);
}else {
errInfo.append(prop.getProperty("key_word") + " '" + key + "'"+" "+prop.getProperty("repeat") + ";");
}
}
if (!has) {
if(keyword.replaceAll("\n","").length()>1024) {
errInfo.append(String.format(prop.getProperty("most_keywords"),
prop.getProperty("key_word")) + ";");
}else {
String reWord = keyword.replaceAll("\n", Constants.KEYWORD_EXPR);
baseStringCfg.setCfgKeywords(reWord);
}
}
}
if (!has) {
if(keyword.replaceAll("\n","").length()>1024) {
errInfo.append(String.format(prop.getProperty("most_keywords"),
prop.getProperty("key_word")) + ";");
}else {
if (StringUtils.isBlank(keyword)) {
errInfo.append(
String.format(prop.getProperty("can_not_null"), prop.getProperty("domain_name") + " ") + ";");
}else {
Matcher m = pattern.matcher(keyword);
if (m.find()) {
errInfo.append(String.format(prop.getProperty("has_invisible_char"),
prop.getProperty("domain_name") + " '" + keyword + "'") + ";");
}else {
String reWord = keyword.replaceAll("\n", Constants.KEYWORD_EXPR);
baseStringCfg.setCfgKeywords(reWord);
m = domainPattern.matcher(keyword);
if(!m.matches()) {
errInfo.append(String.format(prop.getProperty("not_valid_domain"),
prop.getProperty("domain_name") + " '" + keyword + "'") + ";");
}else {
baseStringCfg.setDomain(keyword);
}
}
}
}
Integer exprType = baseStringCfg.getExprType();
boolean has = false;
if (exprType == null) {
@@ -1474,7 +1500,7 @@ public class BaseController {
+ ";");
}else {
try {
Integer.parseInt(userRegion1);
Long asnNo=Long.parseLong(userRegion1);
/*ConfigGroupInfo configGroupInfo=asnIpCfgService.getConfigGroupInfoByAsnNo(asnNo);
if(configGroupInfo==null) {//不存在则新增
PolicyGroupInfo info=new PolicyGroupInfo();
@@ -1486,6 +1512,11 @@ public class BaseController {
configGroupInfo=asnIpCfgService.getConfigGroupInfoByAsnNo(asnNo);
}
baseIpCfg.setAsnIpGroup(configGroupInfo.getGroupId());*/
if(asnNo.longValue()>4294967295l||asnNo.longValue()<1) {
errInfo.append(prop.getProperty("asn_no")+" "+
String.format(prop.getProperty("must_between"),"1","4294967295" )
+ ";");
}
}catch (Exception e) {
// TODO: handle exception
errInfo.append(
@@ -3272,6 +3303,10 @@ public class BaseController {
List<P2pHashStringTemplate> list = ei.getDataList(P2pHashStringTemplate.class,
this.getMsgProp(),regionDict,serviceDict);
stringCfgs = this.checkStringCfg(serviceDict, regionDict, list);
}else if (regionDict.getFunctionId().equals(403)) {
List<AppDomainTemplate> list = ei.getDataList(AppDomainTemplate.class,
this.getMsgProp(),regionDict,serviceDict);
stringCfgs = this.checkStringCfg(serviceDict, regionDict, list);
} else {
List<StringAllTemplate> list = ei.getDataList(StringAllTemplate.class, this.getMsgProp(),regionDict,serviceDict);
stringCfgs = this.checkStringCfg(serviceDict, regionDict, list);
@@ -3307,6 +3342,7 @@ public class BaseController {
|| serviceDict.getServiceId().intValue() == 148
|| serviceDict.getServiceId().intValue() == 1028// app ip
|| serviceDict.getServiceId().intValue() == 1024//app http
|| serviceDict.getServiceId().intValue() == 1026//app domain
)) {
if (StringUtils.isNotBlank(specServiceId)) {
specificServiceCfg = specificServiceCfgService
@@ -3507,9 +3543,12 @@ public class BaseController {
appPolicyCfgs.add(appPolicyCfg);
}
} else {
CfgIndexInfo cfgIndexInfo = new CfgIndexInfo();
BeanUtils.copyProperties(cfg, cfgIndexInfo, new String[] {"cfgId"});
cfgIndexInfos.add(cfgIndexInfo);
if(!regionDict.getFunctionId().equals(403)) {
CfgIndexInfo cfgIndexInfo = new CfgIndexInfo();
BeanUtils.copyProperties(cfg, cfgIndexInfo, new String[] {"cfgId"});
cfgIndexInfos.add(cfgIndexInfo);
}
}
ind++;
}
@@ -3547,6 +3586,9 @@ public class BaseController {
if(regionDict.getDictId().intValue()==16){
avContentCfgService.saveVoIpAccountCfg(stringCfgs);
}
if(regionDict.getDictId().intValue()==64){
appCfgService.saveAppDomainCfg(stringCfgs);
}
} else if (regionDict.getRegionType().equals(3)) {
List<Integer> compileIds=Lists.newArrayList();
try {

View File

@@ -28,6 +28,7 @@ import com.nis.domain.SysDataDictionaryItem;
import com.nis.domain.configuration.CfgIndexInfo;
import com.nis.domain.configuration.IpPortCfg;
import com.nis.domain.configuration.NtcSubscribeIdCfg;
import com.nis.domain.configuration.template.AppDomainTemplate;
import com.nis.domain.configuration.template.AsnIpTemplate;
import com.nis.domain.configuration.template.ComplexStringAllTemplate;
import com.nis.domain.configuration.template.DdosIpTemplate;
@@ -309,6 +310,11 @@ public class IpController extends BaseController{
ExportExcel excel=new ExportExcel(serviceDict,regionDict,this.getMsgProp(),null, P2pHashStringTemplate.class, 2);
excel.setDataList(this.getMsgProp(),classList,null).
write(request,response, fileName).dispose();
}else if(regionDict.getFunctionId().equals(403)) {//app domain
List<AppDomainTemplate> classList=new ArrayList<AppDomainTemplate>();
ExportExcel excel=new ExportExcel(serviceDict,regionDict,this.getMsgProp(),null, AppDomainTemplate.class, 2);
excel.setDataList(this.getMsgProp(),classList,null).
write(request,response, fileName).dispose();
}else{
List<StringAllTemplate> classList=new ArrayList<StringAllTemplate>();
ExportExcel excel=new ExportExcel(serviceDict,regionDict,this.getMsgProp(),null, StringAllTemplate.class, 2);

View File

@@ -19,7 +19,7 @@ public interface AsnIpCfgDao extends CrudDao<AsnIpCfg>{
// public List<ConfigGroupInfo> findPolicyGroupInfosByType(@Param("groupId")Integer groupId);
public List<Integer> findOtherIps(@Param("groupId")Integer groupId,@Param("cfgId")Integer cfgId);
public List<Integer> countValidIPs(@Param("groups")String groups,@Param("ids")String ids);
public ConfigGroupInfo getInfoByAsnNo(@Param("asnId")Integer asnNo);
public List<AsnIpCfg> getByAsnGroup(@Param("groupId")Integer groupId,@Param("asnId")Integer asnNo);
public void deleteByAsnGroup(@Param("groupId")Integer groupId,@Param("asnId")Integer asnNo);
public ConfigGroupInfo getInfoByAsnNo(@Param("asnId")Long asnNo);
public List<AsnIpCfg> getByAsnGroup(@Param("groupId")long groupId,@Param("asnId")long asnNo);
public void deleteByAsnGroup(@Param("groupId")long groupId,@Param("asnId")long asnNo);
}

View File

@@ -206,7 +206,7 @@
from asn_ip_cfg r
where r.cfg_id in (${ids}) and is_valid !=-1
</select>
<select id="getByAsnGroup" resultMap="asnIpCfgMap" parameterType="java.lang.Integer" >
<select id="getByAsnGroup" resultMap="asnIpCfgMap" parameterType="java.lang.Long" >
select
<include refid="columns"></include>
from asn_ip_cfg r where r.is_valid!=-1 and r.asn_ip_group=#{groupId} and r.user_region1=#{asnId}
@@ -399,7 +399,7 @@
<!-- <update id="deleteByAsnGroup" parameterType="java.lang.Integer" >
update asn_ip_cfg set is_valid=-1 where asn_ip_group=#{groupId} and user_region1=#{asnId}
</update> -->
<delete id="deleteByAsnGroup" parameterType="java.lang.Integer" >
<delete id="deleteByAsnGroup" parameterType="java.lang.Long" >
delete from asn_ip_cfg where asn_ip_group=#{groupId} and user_region1=#{asnId}
</delete>
<select id="findOtherIps" resultType="java.lang.Integer" parameterType="java.lang.Integer">
@@ -411,7 +411,7 @@
<select id="countValidIPs" resultType="java.lang.Integer" parameterType="java.lang.String">
select count(1) from asn_ip_cfg where is_valid !=-1 and asn_ip_group in(${groups}) and cfg_id not in(${ids}) GROUP BY asn_ip_group;
</select>
<select id="getInfoByAsnNo" resultType="com.nis.domain.specific.ConfigGroupInfo" parameterType="java.lang.Integer">
<select id="getInfoByAsnNo" resultType="com.nis.domain.specific.ConfigGroupInfo" parameterType="java.lang.Long">
select id,group_id,group_name,is_issued,insert_time,update_time,group_type,compile_id,asn_id
from config_group_info c where c.asn_id= #{asnId} and c.group_type=4
</select>

View File

@@ -12,7 +12,7 @@
<result column="creator_id" property="creatorId" jdbcType="INTEGER" />
<result column="editor_id" property="editorId" jdbcType="INTEGER" />
<result column="service_group_id" property="serviceGroupId" jdbcType="INTEGER" />
<result column="asn_no" property="asnNo" jdbcType="INTEGER" />
<result column="asn_no" property="asnNo" jdbcType="BIGINT" />
<result column="description" property="description" jdbcType="VARCHAR" />
</resultMap>
<sql id="PolicyGroupInfoColumns">

View File

@@ -93,11 +93,11 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
List<AsnIpCfg> toSaveAsnIpCfgs=Lists.newArrayList();
List<SysDataDictionaryItem> isImportAll=DictUtils.getDictList("IS_ASN_IP_IMPORT_ALL");
for(Entry<String,List<AsnIpCfg>> entry:cfgs.entrySet()) {
Integer asnNo=Integer.parseInt(entry.getKey());
Long asnNo=Long.parseLong(entry.getKey());
ConfigGroupInfo configGroupInfo=this.getConfigGroupInfoByAsnNo(asnNo);
if(configGroupInfo==null) {//不存在则新增
PolicyGroupInfo info=new PolicyGroupInfo();
info.setAsnNo(Integer.parseInt(entry.getKey()));
info.setAsnNo(Long.parseLong(entry.getKey()));
info.setDescription("Create by import excel");
info.setGroupName("Import"+asnNo);
info.setGroupType(4);
@@ -281,19 +281,19 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
}
return false;
}
public ConfigGroupInfo getConfigGroupInfoByAsnNo(Integer asnNo) {
public ConfigGroupInfo getConfigGroupInfoByAsnNo(Long asnNo) {
return asnIpCfgDao.getInfoByAsnNo(asnNo);
}
public List<AsnIpCfg> getByAsnGroup(Integer groupId,Integer asnNo) {
public List<AsnIpCfg> getByAsnGroup(Integer groupId,Long asnNo) {
if(groupId==null||asnNo==null) {
throw new RuntimeException("groupId or asnNo is null!");
}
return asnIpCfgDao.getByAsnGroup(groupId,asnNo);
return asnIpCfgDao.getByAsnGroup(groupId.longValue(),asnNo.longValue());
}
public void deleteByAsnGroup(Integer groupId,Integer asnNo) {
public void deleteByAsnGroup(Integer groupId,Long asnNo) {
if(groupId==null||asnNo==null) {
throw new RuntimeException("groupId or asnNo is null!");
}
asnIpCfgDao.deleteByAsnGroup(groupId,asnNo);
asnIpCfgDao.deleteByAsnGroup(groupId.longValue(),asnNo.longValue());
}
}

View File

@@ -25,6 +25,7 @@ import com.nis.domain.configuration.AppTcpCfg;
import com.nis.domain.configuration.AppTopicDomainCfg;
import com.nis.domain.configuration.AreaIpCfg;
import com.nis.domain.configuration.BaseIpCfg;
import com.nis.domain.configuration.BaseStringCfg;
import com.nis.domain.configuration.ComplexkeywordCfg;
import com.nis.domain.configuration.IpPortCfg;
import com.nis.domain.configuration.NtcSubscribeIdCfg;
@@ -512,7 +513,15 @@ public class AppCfgService extends BaseService {
}
}
@Transactional(readOnly = false, rollbackFor = RuntimeException.class)
public void saveAppDomainCfg(List<BaseStringCfg<?>> cfgs) throws Exception {
for(BaseStringCfg cfg:cfgs) {
AppDomainCfg entity=new AppDomainCfg();
BeanUtils.copyProperties(cfg, entity);
appCfgDao.insertAppDomainCfg(entity);
}
}
@Transactional(readOnly = false, rollbackFor = RuntimeException.class)
public void saveOrUpdateAppDomainCfg(AppDomainCfg entity) throws Exception {
// 设置区域运营商信息