springboot中怎么实现通过后台创建临时表(springboot,移动开发)

时间:2024-05-05 04:46:25 作者 : 石家庄SEO 分类 : 移动开发
  • TAG :

springboot 如何通过后台创建临时表

其实创建临时表,跟增删改查的原理是一样的,只不过是在xml中写一个创建临时表sql语句,xml中并不是只能写增删改查语句的

1,首先弄一个xml

在xml中写一个修改头标签,因为是建立的是临时表,所以表名要变,需要在表名处接收一个参数$(tableName) ,这时xml文件就写好了

springboot中怎么实现通过后台创建临时表

2,在mapper中写出对应方法

这时需要在参数中加上注解@Param,只有加上这个注解,在xml中才可以接收到我传入的参数

springboot中怎么实现通过后台创建临时表

3,接下来在service层和Controller层中调用这个方法

然后在postman中传入需要的表名,就可以生成这个表了。

springboot mybatis下临时表的创建和删除,可用于查重去重

/***创建临时表*/@Update({"droptemporarytableifexists${tableName};","createtemporarytable${tableName}selectdoctor_idfromcrm_speakerwhere1=2"})voidcreateTemoraryTable(@Param("tableName")StringtableName);/***保存数据到临时表里面以便校验数据重复*/@Insert("<script>"+"insertinto${tableName}(doctor_id)values"+"<foreachcollection="list"item="doct"index="index"separator=",">"+"("+"#{doct.doctorId,jdbcType=VARCHAR}"+")"+"</foreach>"+"</script>")voidinsertBatchCheckDatas(@Param("list")List<SpeakerDO>dOs,@Param("tableName")StringtableName);/***删除临时表*/@Update({"droptemporarytableifexists${tableName}"})voiddropTemporaryTable(@Param("tableName")StringtableName);
 </div> <div class="zixun-tj-product adv-bottom"></div> </div> </div> <div class="prve-next-news">
本文:springboot中怎么实现通过后台创建临时表的详细内容,希望对您有所帮助,信息来源于网络。
上一篇:SpringBoot怎么集成Druid连接MySQL8.0.11下一篇:

9 人围观 / 0 条评论 ↓快速评论↓

(必须)

(必须,保密)

阿狸1 阿狸2 阿狸3 阿狸4 阿狸5 阿狸6 阿狸7 阿狸8 阿狸9 阿狸10 阿狸11 阿狸12 阿狸13 阿狸14 阿狸15 阿狸16 阿狸17 阿狸18