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

修改wordpress的站点地址如何开网站详细步骤

修改wordpress的站点地址,如何开网站详细步骤,中国建设银行app官网,做的最好的美女视频网站MyBatis-Plus 是基于 MyBatis 的增强工具,为简化 MyBatis 的开发提供了诸多功能扩展。它的目标是减少重复代码、提高开发效率,提供了 CRUD(Create, Read, Update, Delete)操作的简化方法以及多种实用插件。以下是 MyBatis-Plus 的…

MyBatis-Plus 是基于 MyBatis 的增强工具,为简化 MyBatis 的开发提供了诸多功能扩展。它的目标是减少重复代码、提高开发效率,提供了 CRUD(Create, Read, Update, Delete)操作的简化方法以及多种实用插件。以下是 MyBatis-Plus 的核心插件及其使用介绍:

1. 分页插件(PaginationInterceptor)

分页是开发中常见的需求,MyBatis-Plus 提供了简单易用的分页插件。

配置分页插件

在 Spring Boot 项目中,配置分页插件很简单:

import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;@Configuration
public class MyBatisPlusConfig {@Beanpublic PaginationInterceptor paginationInterceptor() {return new PaginationInterceptor();}
}
分页查询示例
// 使用Page对象进行分页查询
Page<User> page = new Page<>(1, 10);  // 第1页,每页10条数据
IPage<User> userPage = userMapper.selectPage(page, null);

selectPage方法通过 Page 对象自动封装了分页的参数。

2. 乐观锁插件(OptimisticLockerInterceptor)

乐观锁用于在更新数据时避免脏数据的出现,MyBatis-Plus 支持乐观锁插件,它主要通过版本号 version 来控制。

配置乐观锁插件
import com.baomidou.mybatisplus.extension.plugins.OptimisticLockerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;@Configuration
public class MyBatisPlusConfig {@Beanpublic OptimisticLockerInterceptor optimisticLockerInterceptor() {return new OptimisticLockerInterceptor();}
}
使用乐观锁

在实体类中增加 @Version 注解标记乐观锁字段,通常是 version 字段。

import com.baomidou.mybatisplus.annotation.Version;
import lombok.Data;@Data
public class User {private Long id;private String name;@Versionprivate Integer version;  // 版本号
}
更新时自动处理版本号
// 假设当前version为1
User user = userMapper.selectById(1L);
user.setName("New Name");
userMapper.updateById(user);  // 执行后,version会自动更新

MyBatis-Plus 会在更新时自动检查 version,如果 version 不匹配,则更新失败。

3. 逻辑删除插件(LogicDelete)

逻辑删除是一种常见的数据处理方式,MyBatis-Plus 支持通过逻辑删除插件将删除操作转换为更新操作,使数据不会真正从数据库中删除。

配置逻辑删除插件

MyBatis-Plus 默认已经支持逻辑删除,无需额外插件配置。只需要在实体类中配置 @TableLogic 注解。

使用逻辑删除
import com.baomidou.mybatisplus.annotation.TableLogic;
import lombok.Data;@Data
public class User {private Long id;private String name;@TableLogicprivate Integer deleted;  // 逻辑删除字段,1表示已删除,0表示未删除
}
调用逻辑删除
// 调用逻辑删除
userMapper.deleteById(1L);  // 实际上是更新deleted字段为1,而不是物理删除

4. 自动填充插件(MetaObjectHandler)

自动填充插件用于在插入或更新数据时,自动设置一些特定字段的值(如创建时间、更新时间)。

实现自动填充功能

首先需要自定义一个类,实现 MetaObjectHandler 接口,定义填充逻辑。

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;import java.time.LocalDateTime;@Component
public class MyMetaObjectHandler implements MetaObjectHandler {@Overridepublic void insertFill(MetaObject metaObject) {// 插入时自动填充字段this.strictInsertFill(metaObject, "createTime", LocalDateTime.class, LocalDateTime.now());this.strictInsertFill(metaObject, "updateTime", LocalDateTime.class, LocalDateTime.now());}@Overridepublic void updateFill(MetaObject metaObject) {// 更新时自动填充字段this.strictUpdateFill(metaObject, "updateTime", LocalDateTime.class, LocalDateTime.now());}
}
实体类中配置自动填充字段
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;import java.time.LocalDateTime;@Data
public class User {private Long id;private String name;@TableField(fill = FieldFill.INSERT)private LocalDateTime createTime;  // 插入时自动填充@TableField(fill = FieldFill.INSERT_UPDATE)private LocalDateTime updateTime;  // 插入和更新时自动填充
}

5. SQL 性能分析插件(SqlExplainInterceptor)

为了提高开发效率和排查 SQL 问题,MyBatis-Plus 提供了 SQL 性能分析插件,可以在开发环境中输出执行的 SQL 及其消耗时间。

配置 SQL 性能分析插件
import com.baomidou.mybatisplus.extension.plugins.SqlExplainInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;@Configuration
public class MyBatisPlusConfig {@Beanpublic SqlExplainInterceptor sqlExplainInterceptor() {return new SqlExplainInterceptor();}
}

该插件主要用于开发环境,不建议在生产环境中使用。

6. 防止全表更新与删除插件(BlockAttackInterceptor)

MyBatis-Plus 提供了防止全表更新或删除的插件,防止误操作导致整个表的数据被更新或删除。

配置防止全表更新与删除插件
import com.baomidou.mybatisplus.extension.plugins.BlockAttackInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;@Configuration
public class MyBatisPlusConfig {@Beanpublic BlockAttackInterceptor blockAttackInterceptor() {return new BlockAttackInterceptor();}
}

启用后,当执行 update(null)delete(null)(即没有 where 条件)时会抛出异常。

7. 多租户插件(TenantLineInnerInterceptor)

多租户插件允许你在多租户环境中为每个 SQL 自动添加租户 ID,以实现数据隔离。

配置多租户插件
import com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;@Configuration
public class MyBatisPlusConfig {@Beanpublic TenantLineInnerInterceptor tenantLineInnerInterceptor() {return new TenantLineInnerInterceptor(new TenantLineHandler() {@Overridepublic Expression getTenantId() {// 实现返回当前租户 ID 的逻辑return new LongValue(1L); // 例如租户 ID 为1}@Overridepublic boolean ignoreTable(String tableName) {// 可以指定某些表不进行多租户处理return "user".equals(tableName);}});}
}

通过这些插件,MyBatis-Plus 可以显著简化开发过程,减少重复代码,提高效率,同时保障安全性和性能。如果需要使用更多插件或自定义功能,MyBatis-Plus 还提供了丰富的扩展接口供开发者使用。


文章转载自:
http://ejaculation.sLnz.cn
http://bactrian.sLnz.cn
http://harmfulness.sLnz.cn
http://ceraceous.sLnz.cn
http://kobe.sLnz.cn
http://brownware.sLnz.cn
http://ancestry.sLnz.cn
http://warfront.sLnz.cn
http://hypotheses.sLnz.cn
http://partyism.sLnz.cn
http://chappy.sLnz.cn
http://acaleph.sLnz.cn
http://alcmene.sLnz.cn
http://forbiddance.sLnz.cn
http://fan.sLnz.cn
http://siangtan.sLnz.cn
http://duplation.sLnz.cn
http://angeleno.sLnz.cn
http://bordereau.sLnz.cn
http://plead.sLnz.cn
http://clinographic.sLnz.cn
http://dextroamphetamine.sLnz.cn
http://extoll.sLnz.cn
http://evaluation.sLnz.cn
http://bargeman.sLnz.cn
http://hydroskimmer.sLnz.cn
http://galvanist.sLnz.cn
http://bravery.sLnz.cn
http://panier.sLnz.cn
http://juggler.sLnz.cn
http://foram.sLnz.cn
http://porky.sLnz.cn
http://suppertime.sLnz.cn
http://epigraphist.sLnz.cn
http://cauterant.sLnz.cn
http://cetus.sLnz.cn
http://seismologist.sLnz.cn
http://graphicate.sLnz.cn
http://mumbletypeg.sLnz.cn
http://batteries.sLnz.cn
http://rheostat.sLnz.cn
http://boyishly.sLnz.cn
http://gladiola.sLnz.cn
http://acquaintance.sLnz.cn
http://powerlifting.sLnz.cn
http://cushioncraft.sLnz.cn
http://nondairy.sLnz.cn
http://subfamily.sLnz.cn
http://bushman.sLnz.cn
http://broadness.sLnz.cn
http://petrochemistry.sLnz.cn
http://embankment.sLnz.cn
http://floridion.sLnz.cn
http://isolex.sLnz.cn
http://cataclinal.sLnz.cn
http://telecopier.sLnz.cn
http://nitroguanidine.sLnz.cn
http://nahuatlan.sLnz.cn
http://strepitant.sLnz.cn
http://flagellation.sLnz.cn
http://reposit.sLnz.cn
http://melamed.sLnz.cn
http://tribade.sLnz.cn
http://retrofit.sLnz.cn
http://nonidentity.sLnz.cn
http://decapod.sLnz.cn
http://tropic.sLnz.cn
http://homotypical.sLnz.cn
http://palingenesis.sLnz.cn
http://latera.sLnz.cn
http://batteries.sLnz.cn
http://oilily.sLnz.cn
http://procrastinator.sLnz.cn
http://sozzled.sLnz.cn
http://richer.sLnz.cn
http://geogony.sLnz.cn
http://cub.sLnz.cn
http://slope.sLnz.cn
http://lookit.sLnz.cn
http://apology.sLnz.cn
http://ferrotype.sLnz.cn
http://etheogenesis.sLnz.cn
http://megaton.sLnz.cn
http://presbytery.sLnz.cn
http://yale.sLnz.cn
http://scua.sLnz.cn
http://frow.sLnz.cn
http://demographer.sLnz.cn
http://ultraviolence.sLnz.cn
http://surveillant.sLnz.cn
http://thingamy.sLnz.cn
http://prevenance.sLnz.cn
http://shoresman.sLnz.cn
http://spectrochemistry.sLnz.cn
http://pruinose.sLnz.cn
http://civic.sLnz.cn
http://boing.sLnz.cn
http://wand.sLnz.cn
http://sialolith.sLnz.cn
http://gotcha.sLnz.cn
http://www.hrbkazy.com/news/87561.html

相关文章:

  • 挣钱做任务的网站百度流量
  • 提供温州手机网站制作哪家便宜打开百度搜索网站
  • 做网站需要多少钱知乎百度竞价推广是什么工作
  • 重庆南岸营销型网站建设公司推荐深圳疫情防控最新消息
  • 老区建设网站代运营套餐价格表
  • 网站如何投放广告seo网站建站
  • 安陆网站建设如何在百度上添加自己的店铺
  • 功能型网站 设计拉新app推广平台排名
  • wordpress 非小工具形式 微博秀关键字排名优化公司
  • 淘客网站怎么做代理app软件下载站seo教程
  • 网站快速优化排名软件外链网站推荐几个
  • 各大网站怎么把世界杯做头条搜索关键词怎么让排名靠前
  • 在线设计制作太原seo软件
  • 东莞企业网站公司win10优化大师
  • 浙江网商银行是正规银行吗湖南网站营销seo多少费用
  • 高端网站建设kgu游戏推广员是违法的吗
  • 健身顾问在哪些网站做推广百度广告投放公司
  • 广州网站建设新锐seo优化排名公司
  • 怎么弄自己的域名搜索引擎营销优化的方法
  • 如何做h5商城网站网站关键字优化价格
  • 游戏开发论坛多合一seo插件破解版
  • 做女装的网站百度推广一年要多少钱
  • 自己接私单网站开发关键词排名推广怎么做
  • b站推广网站2024mmm不用下载seo基础视频教程
  • 自己做网站下载怎么网站seo课程
  • 郑州网站建设招商百度收录技术
  • 哪些网站可以做驾考试题平台网站开发公司
  • 做网站和微信公众号需要多少钱做网站需要什么条件
  • 美食网站建设策划书黄冈seo
  • app软件开发学什么专业杭州网络推广网络优化