当前位置: 首页 > news >正文

购物网站推广怎么做做图网站有哪些

购物网站推广怎么做,做图网站有哪些,武隆网站建设公司,哪个购物软件最便宜今天要有个功能,要进行一批数据的插入和修改,为了不频繁调用数据库,所以想到了批量插入和修改,因为从毕业后,就没写过批量插入和批量修改,所以在这里记录一下,避免后续再遇到忘记怎么写了 批量…

今天要有个功能,要进行一批数据的插入和修改,为了不频繁调用数据库,所以想到了批量插入和修改,因为从毕业后,就没写过批量插入和批量修改,所以在这里记录一下,避免后续再遇到忘记怎么写了

批量插入(传入的参数是List<实体>list):

<insert id="insertList" keyColumn="id" keyProperty="id" useGeneratedKeys="true" parameterType="java.util.List">insert into xhs_collection_data (note_id,`status`,title,`desc`,`time`,user_id,nickname,liked_count,collected_count,comment_count,share_count,image_list,tag_list,batch_number,file_name) values<foreach collection="list" separator="," item="item">( #{item.noteId,jdbcType=VARCHAR}, #{item.status,jdbcType=INTEGER},#{item.title,jdbcType=VARCHAR},#{item.desc,jdbcType=VARCHAR},#{item.time,jdbcType=TIMESTAMP},#{item.userId,jdbcType=VARCHAR}, #{item.nickname,jdbcType=VARCHAR},#{item.likedCount,jdbcType=VARCHAR},#{item.collectedCount,jdbcType=VARCHAR},#{item.commentCount,jdbcType=TIMESTAMP},#{item.shareCount,jdbcType=VARCHAR},#{item.imageList,jdbcType=VARCHAR},#{item.tagList,jdbcType=VARCHAR},#{item.batchNumber,jdbcType=BIGINT},#{item.fileName,jdbcType=VARCHAR})</foreach>
</insert>



批量修改(传入的参数是List<实体>list):

sql原理语句:update table set 要修改的表字段A = case when 表字段 = 实体数据字段 then 实体数据字段 when 表字段 = 实体数据字段 then 实体数据字段 when … then… end,
要修改的表字段B = case when 表字段 = 实体数据字段 then 实体数据字段 when 表字段 = 实体数据字段 then 实体数据字段 when … then… end where 条件

注意:这里踩过一个坑,因为当时不会写批量修改的语句,所以让文心一言帮忙生成了一个批量修改的sql,后续我忘记是不是手动给<foreach>标签手动加的<separator=“,”>这个属性,结果报错了,排查了半天这个sql哪里错了,最后还是放到数据库执行了一下看到了错误原因,当时我还让温馨一样帮忙检查了下我修改后的sql,结果还说没sql没问题,只是可能在拼接时报错

<update id="updateList" parameterType="java.util.List">update xhs_collection_data<trim prefix="set" suffixOverrides=","><trim prefix="`status` = case" suffix="end,"><foreach collection="list" index="index" item="item" >when note_id = #{item.noteId,jdbcType=VARCHAR} then #{item.status,jdbcType=INTEGER}</foreach></trim><trim prefix="title = case" suffix="end,"><foreach collection="list" index="index" item="item">when note_id = #{item.noteId,jdbcType=VARCHAR} then #{item.title,jdbcType=VARCHAR}</foreach></trim><trim prefix="`desc` = case" suffix="end,"><foreach collection="list" index="index" item="item">when note_id = #{item.noteId,jdbcType=VARCHAR} then #{item.desc,jdbcType=VARCHAR}</foreach></trim><trim prefix="time = case" suffix="end,"><foreach collection="list" index="index" item="item">when note_id = #{item.noteId,jdbcType=VARCHAR} then #{item.time,jdbcType=TIMESTAMP}</foreach></trim><trim prefix="user_id = case" suffix="end,"><foreach collection="list" index="index" item="item">when note_id = #{item.noteId,jdbcType=VARCHAR} then #{item.userId,jdbcType=VARCHAR}</foreach></trim><trim prefix="nickname = case" suffix="end,"><foreach collection="list" index="index" item="item">when note_id = #{item.noteId,jdbcType=VARCHAR} then #{item.nickname,jdbcType=VARCHAR}</foreach></trim><trim prefix="liked_count = case" suffix="end,"><foreach collection="list" index="index" item="item">when note_id = #{item.noteId,jdbcType=VARCHAR} then #{item.likedCount,jdbcType=VARCHAR}</foreach></trim><trim prefix="collected_count = case" suffix="end,"><foreach collection="list" index="index" item="item">when note_id = #{item.noteId,jdbcType=VARCHAR} then #{item.collectedCount,jdbcType=VARCHAR}</foreach></trim><trim prefix="comment_count = case" suffix="end,"><foreach collection="list" index="index" item="item">when note_id = #{item.noteId,jdbcType=VARCHAR} then #{item.commentCount,jdbcType=VARCHAR}</foreach></trim><trim prefix="share_count = case" suffix="end,"><foreach collection="list" index="index" item="item">when note_id = #{item.noteId,jdbcType=VARCHAR} then #{item.shareCount,jdbcType=VARCHAR}</foreach></trim><trim prefix="image_list = case" suffix="end,"><foreach collection="list" index="index" item="item">when note_id = #{item.noteId,jdbcType=VARCHAR} then #{item.imageList,jdbcType=VARCHAR}</foreach></trim><trim prefix="tag_list = case" suffix="end,"><foreach collection="list" index="index" item="item">when note_id = #{item.noteId,jdbcType=VARCHAR} then #{item.tagList,jdbcType=VARCHAR}</foreach></trim><trim prefix="batch_number = case" suffix="end,"><foreach collection="list" index="index" item="item"><if test="item.batchNumber != null">when note_id = #{item.noteId,jdbcType=VARCHAR} then #{item.batchNumber,jdbcType=BIGINT}</if></foreach></trim><trim prefix="file_name = case" suffix="end,"><foreach collection="list" index="index" item="item"><if test="item.fileName != null">when note_id = #{item.noteId,jdbcType=VARCHAR} then #{item.fileName,jdbcType=VARCHAR}</if></foreach></trim></trim>where note_id in<foreach close=")" collection="list" item="item" open="(" separator=", ">#{item.noteId,jdbcType=VARCHAR}</foreach>
</update>
http://www.sczhlp.com/news/121239/

相关文章:

  • 电子配件 技术支持 东莞网站建设seo排名优化技术
  • 西宁网站制作多少钱查询网站收录情况的方法
  • 大模型赋能的具身智能:自主决策和具身学习技术最新综述
  • 五屏网站建设价位营销活动管理系统
  • 实业 东莞网站建设wordpress发说说
  • 北京网站建设最便宜的公司哪家好备案的网站名与公司名称
  • 重庆网站到首页排名wordpress 百度地图api接口
  • 申请做网站 论坛版主昆山网页设计报价
  • 国外html5做的音乐网站培训机构招生方案模板
  • 学校门户网站群建设方案怎么制作美图素材图片
  • 网站建设服务合同协议网站做多少分辨率
  • 男男做视频网站开发网站的基本原则
  • python 视频播放网站开发上海闵行区怎么样
  • ST首批中国产MCU,价格曝光
  • wordpress 背景音乐插件结构优化
  • 有专业做网站的学校吗橘子seo历史查询
  • 宜昌市住房和城乡建设局网站wordpress标签引用
  • 天津网站建设求职简历网络营销推广主要做什么?有哪些方法和技巧
  • 汽车贸易网站建设方案网站里图片的作用
  • 郑州商务网站建设国外域名买卖
  • 网站如何做线下推广兰州网络推广推广不了
  • 做网站动态效果心得wordpress分类目录发不了文章
  • 不动产登记门户网站建设淘宝上有做网站的吗
  • 汕头网站seo外包企业管理咨询心得体会
  • 海事网站服务平台珠海做快照网站电话
  • 济南建设高端网站北京软件公司
  • wordpress本站只对会员开放wordpress新建页面不能保存路径
  • 梅州做网站多少钱主题资源网站建设步骤
  • 生态环境工程公司网站建设源码网站怎么做
  • 找网站开发项目项目流程八个阶段