id生成策略

不同的表应用不同的id生成策略

  • 日志:自增(1,2,3,4,..)
  • 购物订单:特殊规则(FQ23948AK3843)
  • 外卖单:关联地区日期等信息(10 04 20200314 34 91)
  • 关系表:可省略id

package com.xxx.domain;

@Data
@TableName("tbl_user")
public class User {
    @TableId(type = IdType.AUTO)
    private Long id;
    private String name;
    @TableField(value = "pwd", select = false)
    private String password;
    private Integer age;
    private String tel;
    @TableField(exist = false)
    private Integer online;
}

mybatis-plus:
  configuration:
    log-impl: org.apache.itbatis.logging.stdout.StdOutImpl
  global-config:
    banner: false
    db-config:
      id-type: assign_id # 实体类中表名不需要在使用@TableId注解
      table-prefix: tbl_ # 给实体类类名加前缀