
com.zlyx.easymybatis.supports.MybatisParser Maven / Gradle / Ivy
package com.zlyx.easymybatis.supports;
import java.lang.reflect.Field;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.zlyx.easycore.annotations.Brancher;
import com.zlyx.easycore.handler.IHandler;
import com.zlyx.easycore.tool.FormatTool;
import com.zlyx.easymybatis.aspect.EasyMybatisAspect;
/**
* @Auth 赵光
* @Describle
* @2019年1月14日 上午8:31:37
*/
@Brancher(todo = "Mybatis字段名解析器", value = EasyMybatisAspect.PARSER)
public class MybatisParser implements IHandler {
public static boolean isChange = true;
@Override
public Object doHandle(Field data) throws Exception {
Field field = (Field)data;
TableField tableField = field.getAnnotation(TableField.class);
TableId tableId = field.getAnnotation(TableId.class);
if (tableField != null && tableField.value() != "" && tableField.value() != null) {
return tableField.value();
} else if (tableId != null && tableId.value() != "" && tableId.value() != null) {
return tableId.value();
} else if(isChange) {
return FormatTool.camel2Underline(field.getName());
} else{
return field.getName();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy