在项目配置文件里application.yml里加上配置type-handlers-package 和 type-aliases-package:分别指出你的类型转换器所在包名和自定义类所在包名。
mybatis-plus:
global-config:
db-config:
logic-delete-field: deleted
logic-not-delete-value: "0"
logic-delete-value: "1"
mapper-locations: "classpath*:/mapper/**/*.xml"
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
type-handlers-package: com.banxian.mybatis.typehandler
type-aliases-package: com.banxian.mybatis.alias
当然上面web项目的查询、新增和修改使用方法这里也是可以正常使用的
1)在实体类上使用注解 @TableName(autoResultMap = true)
2)在加密字段上指明类型@TableField(value = "sfz", typeHandler = SecretFieldTypeHandler.class)
@Data
@TableName(autoResultMap = true)
public class User implements Serializable {
private static final long serialVersionUID = 4344848828462926573L;
@TableId(value = "id", type = IdType.ASSIGN_ID)
private Integer id;
/**
* 名称
*/
private String userName;
/**
* 是否删除 1:是 0:否
*/
@TableLogic
private String deleted;
/**
* 是否有效 1:是 0:否
*/
private String valid;
/**
* 创建时间
*/
@TableField(value = "create_at", fill = FieldFill.INSERT)
private LocalDateTime createAt;
/**
* 更新时间
*/
@TableField(value = "update_at", fill = FieldFill.INSERT_UPDATE)
private LocalDateTime updateAt;
@TableField(value = "sfz", typeHandler = SecretFieldTypeHandler.class)
private String sfz;
}
留言与评论(共有 0 条评论) “” |