mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-08 01:28:24 +08:00
feat: add "comment" config for table annotations
This commit is contained in:
parent
9fa4ed8633
commit
f94438d9ef
@ -86,4 +86,9 @@ public @interface Column {
|
||||
*/
|
||||
Class<? extends TypeHandler> typeHandler() default UnknownTypeHandler.class;
|
||||
|
||||
}
|
||||
/**
|
||||
* 数据字段注释,在 AI 时代,注释的内容往往可用于 AI 辅助对话
|
||||
*/
|
||||
String comment() default "";
|
||||
|
||||
}
|
||||
|
||||
@ -50,4 +50,9 @@ public @interface Id {
|
||||
*/
|
||||
boolean before() default true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据库字段注释,在 AI 时代,注释的内容往往可用于 AI 辅助对话
|
||||
*/
|
||||
String comment() default "";
|
||||
}
|
||||
|
||||
@ -47,6 +47,11 @@ public @interface Table {
|
||||
*/
|
||||
String dataSource() default "";
|
||||
|
||||
/**
|
||||
* 数据库表注释,在 AI 时代,注释的内容往往可用于 AI 辅助对话
|
||||
*/
|
||||
String comment() default "";
|
||||
|
||||
/**
|
||||
* 监听 entity 的 insert 行为。
|
||||
*/
|
||||
|
||||
@ -53,6 +53,11 @@ public class ColumnInfo {
|
||||
*/
|
||||
protected String property;
|
||||
|
||||
/**
|
||||
* 数据库字段注释,在 AI 时代,注释的内容往往可用于 AI 辅助对话
|
||||
*/
|
||||
protected String comment;
|
||||
|
||||
/**
|
||||
* 属性类型。
|
||||
*/
|
||||
@ -108,6 +113,14 @@ public class ColumnInfo {
|
||||
this.property = property;
|
||||
}
|
||||
|
||||
public String getComment() {
|
||||
return comment;
|
||||
}
|
||||
|
||||
public void setComment(String comment) {
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
public Class<?> getPropertyType() {
|
||||
return propertyType;
|
||||
}
|
||||
|
||||
@ -49,6 +49,7 @@ public class IdInfo extends ColumnInfo {
|
||||
this.keyType = id.keyType();
|
||||
this.value = id.value();
|
||||
this.before = id.before();
|
||||
this.comment = id.comment();
|
||||
|
||||
initDefaultKeyType();
|
||||
}
|
||||
|
||||
@ -99,6 +99,8 @@ public class TableInfo {
|
||||
private String schema; // schema
|
||||
private boolean camelToUnderline = true;
|
||||
private String dataSource;
|
||||
|
||||
private String comment;
|
||||
private String tableName; // 表名
|
||||
private Class<?> entityClass; // 实体类
|
||||
// 逻辑删除数据库列名
|
||||
@ -216,6 +218,14 @@ public class TableInfo {
|
||||
this.dataSource = dataSource;
|
||||
}
|
||||
|
||||
public String getComment() {
|
||||
return comment;
|
||||
}
|
||||
|
||||
public void setComment(String comment) {
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
public String getLogicDeleteColumnOrSkip() {
|
||||
return LogicDeleteManager.getLogicDeleteColumn(logicDeleteColumn);
|
||||
}
|
||||
|
||||
@ -226,6 +226,7 @@ public class TableInfoFactory {
|
||||
tableInfo.setSchema(table.schema());
|
||||
tableInfo.setTableName(table.value());
|
||||
tableInfo.setCamelToUnderline(table.camelToUnderline());
|
||||
tableInfo.setComment(tableInfo.getComment());
|
||||
|
||||
if (table.onInsert().length > 0) {
|
||||
List<InsertListener> insertListeners = Arrays.stream(table.onInsert())
|
||||
@ -424,6 +425,10 @@ public class TableInfoFactory {
|
||||
columnInfo.setPropertyType(fieldType);
|
||||
columnInfo.setIgnore(columnAnnotation != null && columnAnnotation.ignore());
|
||||
|
||||
if (columnAnnotation != null) {
|
||||
columnInfo.setComment(columnAnnotation.comment());
|
||||
}
|
||||
|
||||
|
||||
// 默认查询列 没有忽略且不是大字段
|
||||
if (columnAnnotation == null || (!columnAnnotation.isLarge() && !columnAnnotation.ignore())) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user