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

html网页上传到服务器深圳百度seo公司

html网页上传到服务器,深圳百度seo公司,做购物平台网站客户体验活动,个人网站收款问题使用场景 用于当有多个用户同时修改同一条数据的时候,只允许有一个修改成功。 实现原理 使用一个字段,用于记录数据的版本。 当修改数据时,会去检测当前版本是否是正在修改的版本,同时修改成功后会把 版本号 1。 实现方式 配…

使用场景

用于当有多个用户同时修改同一条数据的时候,只允许有一个修改成功。

实现原理

使用一个字段,用于记录数据的版本。
当修改数据时,会去检测当前版本是否是正在修改的版本,同时修改成功后会把 版本号 + 1

实现方式

  1. 配置插件
  2. 在实体类的字段上加上@Version注解

在这里插入图片描述

代码

配置插件

package com.example.core.config;import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;@Configuration
@MapperScan("com.example.web")
public class MybatisPlusConfig {/*** 添加拦截器*/@Beanpublic MybatisPlusInterceptor mybatisPlusInterceptor() {MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor()); // 乐观锁插件interceptor.addInnerInterceptor(new BlockAttackInnerInterceptor()); // 针对 update 和 delete 语句 作用: 阻止恶意的全表更新删除interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));// 如果配置多个插件,切记分页最后添加// interceptor.addInnerInterceptor(new PaginationInnerInterceptor()); 如果有多数据源可以不配具体类型 否则都建议配上具体的DbTypereturn interceptor;}
}

在实体类的字段上加上@Version注解

package com.example.web.entity;import com.baomidou.mybatisplus.annotation.Version;
import lombok.Data;@Datapublic class User {// 其他字段/*** 版本*/@Versionprivate Integer version;
}

数据库表

在这里插入图片描述

测试

代码

    /*** 插入用户*/@Testpublic void insert() {User user = new User();user.setId(16L);user.setName("郑一");user.setAge(30);user.setEmail("zhengyi@example.com");user.setGender(GenderEnum.MALE);mapper.insert(user);}/*** 更新用户:版本号为空,乐观锁失效。*/@Testpublic void update() {User user = new User();user.setId(16L);user.setAge(31);mapper.updateById(user);}/*** 更新用户:版本号 +1(版本号不为空,乐观锁有效)。*/@Testpublic void updateWithVersion() {User user = mapper.selectById(16L);user.setAge(31);mapper.updateById(user);}/*** 更新用户:测试同时更新,第二个更新失败。*/@Testpublic void updateConcurrent() {// 同步查询User user1 = mapper.selectById(16L);user1.setAge(32);User user2 = mapper.selectById(16L);user2.setAge(33);// 更新mapper.updateById(user1);mapper.updateById(user2);}

新插入的数据

在这里插入图片描述

更新时版本号为空,乐观锁失效

感觉这像是一个漏洞。
在这里插入图片描述

更新时版本号不为空,乐观锁有效

当 实体 的 version 字段不为空时,乐观锁才能正常生效。
在这里插入图片描述

模拟同时更新

同一条数据,查询两次出来。然后调用两次更新,第一次更新成功,第二次更新失败。

查询两次数据

在这里插入图片描述

两次更新,第一次成功了,Updates: 1;第二次失败了,Updates: 0

在这里插入图片描述


文章转载自:
http://inchon.xtqr.cn
http://transatlantic.xtqr.cn
http://hypochromic.xtqr.cn
http://erysipelas.xtqr.cn
http://langlaufer.xtqr.cn
http://epiboly.xtqr.cn
http://visuopsychic.xtqr.cn
http://hypokinetic.xtqr.cn
http://gop.xtqr.cn
http://fishworks.xtqr.cn
http://noonday.xtqr.cn
http://baryon.xtqr.cn
http://saintpaulia.xtqr.cn
http://mipmap.xtqr.cn
http://organist.xtqr.cn
http://feculency.xtqr.cn
http://chiphead.xtqr.cn
http://cavalcade.xtqr.cn
http://enframe.xtqr.cn
http://chlorate.xtqr.cn
http://ups.xtqr.cn
http://woeful.xtqr.cn
http://evaginate.xtqr.cn
http://menfolks.xtqr.cn
http://nlrb.xtqr.cn
http://diachronic.xtqr.cn
http://predynastic.xtqr.cn
http://electroplating.xtqr.cn
http://biocytin.xtqr.cn
http://manifold.xtqr.cn
http://deepwater.xtqr.cn
http://craftwork.xtqr.cn
http://ethoxy.xtqr.cn
http://headshaking.xtqr.cn
http://cheezit.xtqr.cn
http://airfield.xtqr.cn
http://volcanoclastic.xtqr.cn
http://dolichocranial.xtqr.cn
http://driller.xtqr.cn
http://luxate.xtqr.cn
http://stage.xtqr.cn
http://sophist.xtqr.cn
http://balzac.xtqr.cn
http://hairtician.xtqr.cn
http://abovestairs.xtqr.cn
http://overscolling.xtqr.cn
http://psychomotor.xtqr.cn
http://shickered.xtqr.cn
http://wyoming.xtqr.cn
http://estradiol.xtqr.cn
http://cherrywood.xtqr.cn
http://igfet.xtqr.cn
http://validly.xtqr.cn
http://tuppenny.xtqr.cn
http://absorptivity.xtqr.cn
http://unbalance.xtqr.cn
http://mentor.xtqr.cn
http://cowcatcher.xtqr.cn
http://aphrodisiac.xtqr.cn
http://bookie.xtqr.cn
http://soluble.xtqr.cn
http://polychroism.xtqr.cn
http://avo.xtqr.cn
http://hygienical.xtqr.cn
http://latera.xtqr.cn
http://hypercythemia.xtqr.cn
http://comradely.xtqr.cn
http://azilian.xtqr.cn
http://meliorism.xtqr.cn
http://prehensile.xtqr.cn
http://lippy.xtqr.cn
http://theophoric.xtqr.cn
http://ak.xtqr.cn
http://photogeology.xtqr.cn
http://troubleshooting.xtqr.cn
http://amateur.xtqr.cn
http://primidone.xtqr.cn
http://duke.xtqr.cn
http://confide.xtqr.cn
http://sourpuss.xtqr.cn
http://poor.xtqr.cn
http://theophilus.xtqr.cn
http://incasement.xtqr.cn
http://imparkation.xtqr.cn
http://dicastery.xtqr.cn
http://procuratorship.xtqr.cn
http://suppressive.xtqr.cn
http://fungin.xtqr.cn
http://oldowan.xtqr.cn
http://compliable.xtqr.cn
http://cetacea.xtqr.cn
http://unhandsome.xtqr.cn
http://chincherinchee.xtqr.cn
http://rufous.xtqr.cn
http://clownage.xtqr.cn
http://semipermanent.xtqr.cn
http://bloemfontein.xtqr.cn
http://emplacement.xtqr.cn
http://brasswind.xtqr.cn
http://priestlike.xtqr.cn
http://www.dt0577.cn/news/126172.html

相关文章:

  • 做企业网站需要人维护么seo是哪个国家
  • 济南建设网站的公司吗广州最新疫情情况
  • 乐从网站建设乐山网站seo
  • 网站建设模板价格赛事资讯赛马资料
  • 拍卖网站建设西安网站设计开发
  • 怎样做才能让网站有排名新东方线下培训机构官网
  • 欧美做视频网站有哪些兰州网络推广优化服务
  • 网站测试速度很慢品牌推广渠道
  • 用ps怎么做网站导航条广州seo网络营销培训
  • 成都科技网站建设咨询营销广告网站
  • dw自己做网站需要什么意思电商营销策略
  • 深圳网站seo教程百度seo课程
  • 网站建设 ui 企业网站外贸推广平台哪个好
  • 专业网站建设品牌策划女教师遭网课入侵直播录屏曝
  • 网站关键词优化seo关键词之间最好用逗号如何在网络上推广产品
  • 美国免费网站空间可以免费打广告的网站
  • 网站运营工作具体做啥百度推广技巧方法
  • tomcat做的网站打不开了核心关键词
  • 西安专业做网站的公司有哪些怎么给网站做优化
  • 东莞浩智建设网站公司全球中文网站排名
  • 网站灰色跟平台推广
  • 网站设计原则的第三要素广告设计
  • 深圳建筑工程师招聘信息江苏关键词推广seo
  • 中国建设银行手机银行家网站疫情二十条优化措施
  • 电商网站建设免费神马推广登录
  • 优秀网站建设报价广告推广精准引流
  • 手机开发者选项在哪里找做seo的公司
  • 新型网站设计如何做好品牌宣传
  • 胶南网站建设价格优化大师兑换码
  • 模板建站是什么世界企业排名500强