cfg_index_info保存改为批量,dao保存sql不带last_insert_id
This commit is contained in:
@@ -39,6 +39,7 @@ public interface IpCfgDao extends CrudDao<BaseIpCfg>{
|
||||
public CfgIndexInfo getCfgIndexInfo(Long id);
|
||||
public List<IpPortCfg> getIpPortList(CfgIndexInfo entity);
|
||||
public void saveCfgIndex(CfgIndexInfo entity);
|
||||
public void saveCfgIndexForBatch(CfgIndexInfo entity);
|
||||
public void saveIpPortCfg(IpPortCfg entity);
|
||||
public void updateCfgIndex(CfgIndexInfo entity);
|
||||
public void deleteIpCfg(CfgIndexInfo entity);
|
||||
|
||||
@@ -831,6 +831,63 @@
|
||||
#{doLog,jdbcType=INTEGER}
|
||||
)
|
||||
</insert>
|
||||
<insert id="saveCfgIndexForBatch" parameterType="com.nis.domain.configuration.CfgIndexInfo" >
|
||||
insert into cfg_index_info(
|
||||
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,
|
||||
dns_strategy_id,
|
||||
user_region1,
|
||||
user_region2,
|
||||
user_region3,
|
||||
user_region4,
|
||||
user_region5,
|
||||
do_log
|
||||
)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},
|
||||
#{dnsStrategyId,jdbcType=INTEGER},
|
||||
#{userRegion1,jdbcType=VARCHAR},
|
||||
#{userRegion2,jdbcType=VARCHAR},
|
||||
#{userRegion3,jdbcType=VARCHAR},
|
||||
#{userRegion4,jdbcType=VARCHAR},
|
||||
#{userRegion5,jdbcType=VARCHAR},
|
||||
#{doLog,jdbcType=INTEGER}
|
||||
)
|
||||
</insert>
|
||||
<!-- insert ip_port_cfg表信息 -->
|
||||
<insert id="saveIpPortCfg" parameterType="com.nis.domain.configuration.IpPortCfg" >
|
||||
<selectKey resultType="java.lang.Long" order="AFTER" keyProperty="cfgId">
|
||||
|
||||
@@ -7,6 +7,9 @@ import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
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.context.i18n.LocaleContextHolder;
|
||||
@@ -44,6 +47,7 @@ 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;
|
||||
|
||||
/**
|
||||
* IP相关配置事务类
|
||||
@@ -108,8 +112,19 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
}
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void saveCfgIndexOf(List<CfgIndexInfo> cfgIndexInfos){
|
||||
for (CfgIndexInfo cfgIndexInfo : cfgIndexInfos) {
|
||||
ipCfgDao.saveCfgIndex(cfgIndexInfo);
|
||||
SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class);
|
||||
SqlSession batchSqlSession = null;
|
||||
try{
|
||||
batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
|
||||
for(int index = 0; index < cfgIndexInfos.size();index++){
|
||||
CfgIndexInfo cfgIndexInfo = cfgIndexInfos.get(index);
|
||||
((IpCfgDao) batchSqlSession.getMapper(IpCfgDao.class)).saveCfgIndex(cfgIndexInfo);
|
||||
}
|
||||
batchSqlSession.commit();
|
||||
}finally {
|
||||
if(batchSqlSession != null){
|
||||
batchSqlSession.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
|
||||
Reference in New Issue
Block a user