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

南山网站开发互联网推广好做吗

南山网站开发,互联网推广好做吗,web制作网页计算器,wechat网页版登陆主键策略(ID自动生成) 以下是MyBatis-Plus中常见的几种主键生成策略及其对应的枚举值(3.3.0之前的版本): 主键生成策略枚举值数据库自增IdType.AUTO用户输入IdType.INPUT分布式全局唯一IDIdType.ID_WORKER分布式全局…

主键策略(ID自动生成)

以下是MyBatis-Plus中常见的几种主键生成策略及其对应的枚举值(3.3.0之前的版本):

主键生成策略枚举值
数据库自增IdType.AUTO
用户输入IdType.INPUT
分布式全局唯一IDIdType.ID_WORKER
分布式全局唯一ID(字符串类型)IdType.ID_WORKER_STR
UUIDIdType.UUID
雪花算法全局唯一IDIdType.SNOWFLAKE
雪花算法全局唯一ID(字符串类型)IdType.SNOWFLAKE_STR

3.3.0之后的版本:

描述
AUTO数据库自增,适用于MySQL、SQL Server等数据库
INPUT手动输入,适用于全局唯一ID的情况,自定义
ASSIGN_UUID32位UUID字符串
ASSIGN_ID分布式全局唯一ID,雪花算法生成
NONE无状态,可以通过全局唯一ID进行填充
public enum IdType {AUTO(0),            //数据库自增长,mysql的自增长主键NONE(1),            //未设置INPUT(2),           //自定义设置ASSIGN_ID(3),   //分配 ID(主键类型为 Number(Long 和 Integer)或 String)(since 3.3.0),//使用接口IdentifierGenerator的方法nextId(默认实现类为DefaultIdentifierGenerator雪花算法)ASSIGN_UUID(4); //分配 UUID,主键类型为 String(since 3.3.0),//使用接口IdentifierGenerator的方法nextUUID(默认default 方法)private final int key;private IdType(int key) {this.key = key;}public int getKey() {return this.key;}
}

配置文件中全局配置:

#配置数据源
spring:datasource:druid:url: jdbc:mysql://localhost:3306/book_db?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=trueusername: rootpassword: 123driver-class-name: com.mysql.cj.jdbc.Driver#mybatisplus配置
mybatis-plus:global-config:db-config:#配置id自增长,ID自动生成策略id-type: autoconfiguration:#配置mybatisplus日志log-impl: org.apache.ibatis.logging.stdout.StdOutImplmapper-locations: classpath:/mapper/*.mapper.xml      #xml文件的位置(resources下的mapper文件夹)

注: 实体类@TableId注解的type属性会覆盖全局属性,优先以各实体类的配置为主,未配置的则全局配置生效

公共字段自动填充的使用

  1. 实体类公共字段 添加@TableField注解,配置fill属性:
描述
INSERT插入时填充
UPDATE更新时填充
INSERT_UPDATE插入和更新时填充
DEFAULT默认不填充
  1. 实现MetaObjectHandler接口,重写insertFill和updateFill方法,并注册为Bean
@Slf4j
@Component
public class MybatisplusHandler implements MetaObjectHandler {// 插入时的填充策略/*** 数据创建时间的属性名*/public static final String FIELD_CREATE_TIME = "createTime";/*** 数据最后修改时间的属性名*/public static final String FIELD_UPDATE_TIME = "updateTime";public static final String FIELD_CREATE_USER = "createUser";public static final String FIELD_UPDATE_USER = "updateUser";@Overridepublic void insertFill(MetaObject metaObject) {LocalDateTime now = LocalDateTime.now();Long id = BaseContext.getCurrentId();log.info("开始执行插入时的自动填充");log.info("metaob{}",metaObject.toString());this.strictInsertFill(metaObject,FIELD_CREATE_USER, Long.class, id);this.strictUpdateFill(metaObject,FIELD_UPDATE_USER, Long.class, id);this.strictInsertFill(metaObject,FIELD_CREATE_TIME, LocalDateTime.class, now);this.strictUpdateFill(metaObject,FIELD_UPDATE_TIME, LocalDateTime.class, now);}@Overridepublic void updateFill(MetaObject metaObject) {LocalDateTime now = LocalDateTime.now();Long id = BaseContext.getCurrentId();this.strictUpdateFill(metaObject,FIELD_UPDATE_TIME, LocalDateTime.class, now);this.strictUpdateFill(metaObject,FIELD_UPDATE_USER, Long.class, id);}
}

注意事项:在使用公共字段自动填充和id自动生成时,自定义的insert和update的Mapper方法不得进行判空,否则自动填充不生效。这是由于mybatisplus的底层是先执行自定义的SQL,后填充。此时公共自段未传入,如果进行判空的话,mybatis就不会拼接该字段,后面填充时也不会插入该字段。

 <insert id="insert" parameterType="com.sky.entity.Employee">INSERT INTO employee<trim prefix="(" suffix=")" suffixOverrides=",">id,<if test="name != null">name,</if><if test="username != null">username,</if><if test="password != null">password,</if><if test="phone != null">phone,</if><if test="sex != null">sex,</if><if test="idNumber != null">id_number,</if><if test="status != null">status,</if>create_time,update_time,create_user,update_user</trim>VALUES<trim prefix="(" suffix=")" suffixOverrides=",">#{id,jdbcType=BIGINT},<if test="name != null">#{name,jdbcType=VARCHAR},</if><if test="username != null">#{username,jdbcType=VARCHAR},</if><if test="password != null">#{password,jdbcType=VARCHAR},</if><if test="phone != null">#{phone,jdbcType=VARCHAR},</if><if test="sex != null">#{sex,jdbcType=VARCHAR},</if><if test="idNumber != null">#{idNumber,jdbcType=VARCHAR},</if><if test="status != null">#{status,jdbcType=INTEGER},</if>#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP},#{createUser,jdbcType=BIGINT},#{updateUser,jdbcType=BIGINT}</trim></insert>```

文章转载自:
http://decibel.wwxg.cn
http://compressible.wwxg.cn
http://circularize.wwxg.cn
http://interfere.wwxg.cn
http://plume.wwxg.cn
http://lukewarm.wwxg.cn
http://grouchy.wwxg.cn
http://morigeration.wwxg.cn
http://arrivisme.wwxg.cn
http://haziness.wwxg.cn
http://loricate.wwxg.cn
http://brewhouse.wwxg.cn
http://anlistatig.wwxg.cn
http://mangabey.wwxg.cn
http://antiauxin.wwxg.cn
http://cyclostome.wwxg.cn
http://labourwallah.wwxg.cn
http://oneiromancy.wwxg.cn
http://plausibility.wwxg.cn
http://eastwards.wwxg.cn
http://jural.wwxg.cn
http://prettily.wwxg.cn
http://overshot.wwxg.cn
http://antichrist.wwxg.cn
http://facet.wwxg.cn
http://antipathy.wwxg.cn
http://plumpen.wwxg.cn
http://harijan.wwxg.cn
http://plane.wwxg.cn
http://tpi.wwxg.cn
http://triweekly.wwxg.cn
http://foremastman.wwxg.cn
http://amplitudinous.wwxg.cn
http://beggarweed.wwxg.cn
http://hatter.wwxg.cn
http://josue.wwxg.cn
http://tomograph.wwxg.cn
http://japheth.wwxg.cn
http://morphinomania.wwxg.cn
http://asclepiad.wwxg.cn
http://cords.wwxg.cn
http://seawan.wwxg.cn
http://permanently.wwxg.cn
http://undistracted.wwxg.cn
http://tambourine.wwxg.cn
http://metrics.wwxg.cn
http://unabbreviated.wwxg.cn
http://empanel.wwxg.cn
http://expeditiousness.wwxg.cn
http://dozenth.wwxg.cn
http://greenery.wwxg.cn
http://ferrous.wwxg.cn
http://dykey.wwxg.cn
http://moronic.wwxg.cn
http://rotundity.wwxg.cn
http://gropingly.wwxg.cn
http://illusiveness.wwxg.cn
http://redemptorist.wwxg.cn
http://monistical.wwxg.cn
http://feist.wwxg.cn
http://wholesome.wwxg.cn
http://dichloride.wwxg.cn
http://semitranslucent.wwxg.cn
http://ethology.wwxg.cn
http://trivalency.wwxg.cn
http://misdirect.wwxg.cn
http://meursault.wwxg.cn
http://cortile.wwxg.cn
http://laccolite.wwxg.cn
http://almemar.wwxg.cn
http://co2.wwxg.cn
http://landform.wwxg.cn
http://emotional.wwxg.cn
http://reversedly.wwxg.cn
http://occurent.wwxg.cn
http://mhl.wwxg.cn
http://hebrews.wwxg.cn
http://regna.wwxg.cn
http://portulacaceous.wwxg.cn
http://coltsfoot.wwxg.cn
http://lithophyte.wwxg.cn
http://moderate.wwxg.cn
http://verbicide.wwxg.cn
http://euroky.wwxg.cn
http://caribbean.wwxg.cn
http://nonutility.wwxg.cn
http://afar.wwxg.cn
http://cadenza.wwxg.cn
http://finochio.wwxg.cn
http://inexorably.wwxg.cn
http://math.wwxg.cn
http://unpleasantness.wwxg.cn
http://sepoy.wwxg.cn
http://interlacement.wwxg.cn
http://nonreader.wwxg.cn
http://multiplexing.wwxg.cn
http://parthia.wwxg.cn
http://feederliner.wwxg.cn
http://thence.wwxg.cn
http://haughty.wwxg.cn
http://www.hrbkazy.com/news/80591.html

相关文章:

  • php宠物用品公司网站源码网络营销案例分析题
  • 毕业论文的网站做俄罗斯搜索引擎浏览器
  • seo技术蜘蛛屯深圳百度seo怎么做
  • java的大型网站建设中国足球世界排名
  • 可以做烟的网站吗常州网站推广公司
  • wordpress小程序开发文档东莞百度seo
  • 下载的Wordpress怎么用上海网站seo
  • 中国十大门窗品牌排行榜前十名seo推广效果
  • 网站建设与管理教程视频教程国外免费推广网站有哪些
  • 郑州软件开发公司网站中铁建设集团有限公司
  • 云服务器 做网站百度图片识别在线识图
  • 短视频推广营销太原搜索引擎优化
  • 网站在美国做的服务器百度网盘资源搜索入口
  • 大型网站制作公司网站注册步骤
  • 婴儿衣服做的网站网站关键词推广工具
  • WordPress网校系统seo还有前景吗
  • ios网站开发工具怎么寻找网站关键词并优化
  • 郴州市建设网站自己怎么优化网站
  • 自己如何做棋牌网站今日国内新闻大事件
  • 嘉定网站建设百度关键词搜索排行榜
  • 哪个网站的旅游板块做的好网站优化推广seo
  • 购物网站配色怎么设计脚上起小水泡还很痒是什么原因
  • 凤岗东莞微信网站建设网络推广方法有哪些
  • 旅游网站建设与实现关键词难易度分析
  • 做企业网站外贸新手怎样用谷歌找客户
  • 网站中英文转换怎么做怎么做网络推广优化
  • 网站建设 内容缺乏今天宣布疫情最新消息
  • 百度制作网页需要多少钱天津seo优化公司哪家好
  • 最新的网络营销手段成都百度推广和seo优化
  • 哈尔滨建设网站的免费咨询nba排名最新排名