(1)index 跟子配置保存放到service同一个事务中

(2)修复是否下发选项隐藏导致的空指针异常
This commit is contained in:
wangxin
2018-11-21 11:19:40 +08:00
parent de34fd9103
commit 6bbb2b6038
10 changed files with 423 additions and 442 deletions

View File

@@ -66,30 +66,6 @@ public class DdosCfgService extends BaseService{
return ddosCfgDao.getDdosIpCfg(cfgId);
}
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public void saveDdosIpCfg(List<BaseIpCfg> ipPortCfgs) {
List<DdosIpCfg> ddosIpCfgS=Lists.newArrayList(ipPortCfgs.size());
for(BaseIpCfg cfg:ipPortCfgs) {
DdosIpCfg ddosIpCfg=new DdosIpCfg();
BeanUtils.copyProperties(cfg, ddosIpCfg);
ddosIpCfgS.add(ddosIpCfg);
}
SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class);
SqlSession batchSqlSession = null;
try{
batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
for(int index = 0; index < ddosIpCfgS.size();index++){
DdosIpCfg ddosIpCfg = ddosIpCfgS.get(index);
//如果insert加入了select last_insert_id会拖慢6~7倍以上的效率
((DdosCfgDao) batchSqlSession.getMapper(DdosCfgDao.class)).insert(ddosIpCfg);
}
batchSqlSession.commit();
}finally {
if(batchSqlSession != null){
batchSqlSession.close();
}
}
}
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public void saveOrUpdate(DdosIpCfg entity){
Date createTime=new Date();
//设置区域运营商信息