开始编写插入代码
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* @Author: Kane
|
||||
* @Date: 2023-10-11 16:47:59
|
||||
* @LastEditors: Kane
|
||||
* @FilePath: /desktop_archievement_backend/src/main/java/com/cpic/xim/mybatis/mapper/ImportArchievementDataMapper.java
|
||||
* @Description:
|
||||
*
|
||||
* Copyright (c) ${2023} by Kane, All Rights Reserved.
|
||||
*/
|
||||
package com.cpic.xim.mybatis.mapper;
|
||||
|
||||
import com.cpic.xim.mybatis.pojo.TelsalerAttachingRateRecord;
|
||||
|
||||
public interface ImportArchievementDataMapper
|
||||
{
|
||||
public void importTesalerAttachingRateDataToDB( TelsalerAttachingRateRecord record);
|
||||
}
|
@@ -13,13 +13,15 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import org.apache.ibatis.io.Resources;
|
||||
import org.apache.ibatis.session.ExecutorType;
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
|
||||
|
||||
public class MybatisUtils
|
||||
{
|
||||
private static HashMap<String, SqlSession> SessionMap = new HashMap<>();
|
||||
private static HashMap<String, SqlSession> SessionMap = new HashMap<>(5);
|
||||
private static HashMap<String, SqlSession> SessionMapBatch = new HashMap<>(5);
|
||||
private static String DEFAULT_CONFIGFILE = "mybatis/mybatis-config.xml";
|
||||
|
||||
/**
|
||||
@@ -50,6 +52,26 @@ public class MybatisUtils
|
||||
return session;
|
||||
}
|
||||
|
||||
public static SqlSession getSqlSessionBatch( String configFile ) throws IOException
|
||||
{
|
||||
SqlSession sessionBatch = SessionMapBatch.get( configFile );
|
||||
|
||||
if ( sessionBatch != null )
|
||||
{
|
||||
return sessionBatch;
|
||||
}
|
||||
|
||||
// 没有缓存的就创建一个新的
|
||||
InputStream configIS = Resources.getResourceAsStream( configFile );
|
||||
SqlSessionFactory factory = new SqlSessionFactoryBuilder().build( configIS );
|
||||
sessionBatch = factory.openSession(ExecutorType.BATCH );
|
||||
|
||||
//保存
|
||||
SessionMapBatch.put( configFile, sessionBatch );
|
||||
|
||||
return sessionBatch;
|
||||
}
|
||||
|
||||
public static SqlSession getSqlSession() throws IOException
|
||||
{
|
||||
// 根据配置文件的路径,查找是否已经创建了对应的session
|
||||
@@ -71,4 +93,24 @@ public class MybatisUtils
|
||||
|
||||
return session;
|
||||
}
|
||||
|
||||
public static SqlSession getSqlSessionBatch() throws IOException
|
||||
{
|
||||
SqlSession sessionBatch = SessionMapBatch.get( DEFAULT_CONFIGFILE );
|
||||
|
||||
if ( sessionBatch != null )
|
||||
{
|
||||
return sessionBatch;
|
||||
}
|
||||
|
||||
// 没有缓存的就创建一个新的
|
||||
InputStream configIS = Resources.getResourceAsStream( DEFAULT_CONFIGFILE );
|
||||
SqlSessionFactory factory = new SqlSessionFactoryBuilder().build( configIS );
|
||||
sessionBatch = factory.openSession(ExecutorType.BATCH );
|
||||
|
||||
//保存
|
||||
SessionMapBatch.put( DEFAULT_CONFIGFILE, sessionBatch );
|
||||
|
||||
return sessionBatch;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "https://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.cpic.xim.mybatis.mapper.ImportArchievementDataMapper">
|
||||
<insert id="importTesalerAttachingRateDataToDB" parameterType="com.cpic.xim.mybatis.pojo.TelsalerAttachingRateRecord">
|
||||
insert into 电销坐席车非渗透统计表 ( telsaler_name, moto_premium, nomoto_premium, moto_premium_proportion, attaching_rate, attaching_rate_change )
|
||||
values ( #{telsalerName}, #{motoPremium}, #{nomotoPremium}, #{motoPremiumProportion}, #{attachingRate}, #{attachingRateChange} )
|
||||
</insert>
|
||||
</mapper>
|
@@ -26,5 +26,6 @@
|
||||
<mapper resource="mybatis/mapper/ArchievementMapper.xml" />
|
||||
<mapper resource="mybatis/mapper/RankingListMapper.xml" />
|
||||
<mapper resource="mybatis/mapper/RewardsMapper.xml" />
|
||||
<mapper resource="mybatis/mapper/ImportArchievementDataMapper.xml" />
|
||||
</mappers>
|
||||
</configuration>
|
Reference in New Issue
Block a user