第一种获取字段上的
以@TableField 注解为例,
Map<String, String> map = new ConcurrentHashMap<>();
Field[] fields = T.class.getDeclaredFields();
for (Field field : fields) {
if (field.isAnnotationPresent(TableField.class)) {
/**
* 获取字段名 TableField 就是对应的注解
*/
TableField declaredAnnotation = field.getDeclaredAnnotation(TableField.class);
String column = declaredAnnotation.value();
map.put("fieldNames", field.getName());
map.put("column", column);
break;
}
}