public class AutoGenerator extends Object
映射文件自动生成类
| 限定符和类型 | 字段和说明 |
|---|---|
protected ConfigGenerator |
config |
protected static boolean |
FILE_OVERRIDE |
protected static String |
JAVA_SUFFIX |
protected static String |
PATH_ENTITY |
protected static String |
PATH_MAPPER |
protected static String |
PATH_SERVICE |
protected static String |
PATH_SERVICE_IMPL |
protected static String |
PATH_XML |
protected static String |
XML_SUFFIX |
| 构造器和说明 |
|---|
AutoGenerator() |
AutoGenerator(ConfigGenerator config) |
| 限定符和类型 | 方法和说明 |
|---|---|
protected BufferedWriter |
buildClassComment(BufferedWriter bw,
String text)
构建类上面的注释
|
protected void |
buildEntityBean(List<String> columns,
List<String> types,
List<String> comments,
String tableComment,
Map<String,com.baomidou.mybatisplus.generator.AutoGenerator.IdInfo> idMap,
String table,
String beanName)
生成实体类
|
protected void |
buildEntityBeanColumnConstant(List<String> columns,
List<String> types,
List<String> comments,
BufferedWriter bw,
int size) |
protected void |
buildMapper(String beanName,
String mapperName)
构建Mapper文件
|
protected void |
buildMapperXml(List<String> columns,
List<String> types,
List<String> comments,
Map<String,com.baomidou.mybatisplus.generator.AutoGenerator.IdInfo> idMap,
String mapperName,
String mapperXMLName)
构建实体类映射XML文件
|
protected void |
buildService(String beanName,
String serviceName)
构建service文件
|
protected void |
buildServiceImpl(String beanName,
String serviceImplName,
String serviceName,
String mapperName)
构建service实现类文件
|
protected void |
buildSQL(BufferedWriter bw,
Map<String,com.baomidou.mybatisplus.generator.AutoGenerator.IdInfo> idMap,
List<String> columns)
通用返回参数
|
void |
generate()
生成映射文件
|
protected String |
getBeanName(String table,
boolean includePrefix)
生成 beanName
|
ConfigGenerator |
getConfig() |
protected static String |
getFilePath(String savePath,
String segment)
生成文件地址
|
protected static String |
getPathFromPackageName(String packageName)
根据包名转换成具体路径
|
protected Map<String,String> |
getTableComment(Connection conn)
获取所有的数据库表注释
|
protected List<String> |
getTables(Connection conn)
检查配置的所有表是否在dbTables里存在.
|
protected boolean |
isDate(List<String> types)
字段是否为日期类型
|
protected boolean |
isDecimal(List<String> types)
字段是否为浮点数类型
|
protected String |
mysqlProcessType(String type)
MYSQL字段类型转换
|
protected String |
oracleProcessType(String type)
ORACLE字段类型转换
|
protected String |
processField(String field)
字段处理
|
protected String |
processType(String type) |
static void |
run(ConfigGenerator config)
run 执行
|
void |
setConfig(ConfigGenerator config) |
String |
toIdType() |
protected boolean |
valideFile(String dirPath,
String beanName,
String suffix)
根据是否覆盖标志决定是否覆盖当前已存在的文件
|
protected ConfigGenerator config
protected static String PATH_ENTITY
protected static String PATH_MAPPER
protected static String PATH_XML
protected static String PATH_SERVICE
protected static String PATH_SERVICE_IMPL
protected static boolean FILE_OVERRIDE
public AutoGenerator()
public AutoGenerator(ConfigGenerator config)
public ConfigGenerator getConfig()
public void setConfig(ConfigGenerator config)
public static void run(ConfigGenerator config)
protected static String getPathFromPackageName(String packageName)
packageName - protected static String getFilePath(String savePath, String segment)
segment - 文件地址片段public void generate()
protected boolean valideFile(String dirPath, String beanName, String suffix)
dirPath - beanName - suffix - protected List<String> getTables(Connection conn) throws SQLException
SQLExceptionprotected String getBeanName(String table, boolean includePrefix)
table - 表名protected BufferedWriter buildClassComment(BufferedWriter bw, String text) throws IOException
bw - text - IOExceptionprotected void buildEntityBean(List<String> columns, List<String> types, List<String> comments, String tableComment, Map<String,com.baomidou.mybatisplus.generator.AutoGenerator.IdInfo> idMap, String table, String beanName) throws IOException
columns - types - comments - IOExceptionprotected void buildEntityBeanColumnConstant(List<String> columns, List<String> types, List<String> comments, BufferedWriter bw, int size) throws IOException
IOExceptionpublic String toIdType()
protected void buildMapper(String beanName, String mapperName) throws IOException
beanName - mapperName - IOExceptionprotected void buildMapperXml(List<String> columns, List<String> types, List<String> comments, Map<String,com.baomidou.mybatisplus.generator.AutoGenerator.IdInfo> idMap, String mapperName, String mapperXMLName) throws IOException
columns - types - comments - IOExceptionprotected void buildService(String beanName, String serviceName) throws IOException
beanName - serviceName - IOExceptionprotected void buildServiceImpl(String beanName, String serviceImplName, String serviceName, String mapperName) throws IOException
beanName - serviceImplName - mapperName - IOExceptionprotected void buildSQL(BufferedWriter bw, Map<String,com.baomidou.mybatisplus.generator.AutoGenerator.IdInfo> idMap, List<String> columns) throws IOException
bw - idMap - columns - IOExceptionprotected Map<String,String> getTableComment(Connection conn) throws SQLException
SQLExceptionCopyright © 2016. All rights reserved.