本文整理汇总了Java中com.baomidou.mybatisplus.generator.config.StrategyConfig类的典型用法代码示例。如果您正苦于以下问题:Java StrategyConfig类的具体用法?Java StrategyConfig怎么用?Java StrategyConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StrategyConfig类属于com.baomidou.mybatisplus.generator.config包,在下文中一共展示了StrategyConfig类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setConvert
import com.baomidou.mybatisplus.generator.config.StrategyConfig; //导入依赖的package包/类
protected void setConvert(StrategyConfig strategyConfig) {
if (strategyConfig.containsTablePrefix(name)) {
// 包含前缀
this.convert = true;
} else if (strategyConfig.isCapitalModeNaming(name)) {
// 包含
this.convert = false;
} else {
// 转换字段
if (StrategyConfig.DB_COLUMN_UNDERLINE) {
// 包含大写处理
if (StringUtils.containsUpperCase(name)) {
this.convert = true;
}
} else if (!entityName.equalsIgnoreCase(name)) {
this.convert = true;
}
}
}
示例2: processTypes
import com.baomidou.mybatisplus.generator.config.StrategyConfig; //导入依赖的package包/类
/**
* <p>
* 处理superClassName,IdClassType,IdStrategy配置
* </p>
*
* @param config 策略配置
*/
private void processTypes(StrategyConfig config) {
if (StringUtils.isEmpty(config.getSuperServiceClass())) {
superServiceClass = ConstVal.SUPERD_SERVICE_CLASS;
} else {
superServiceClass = config.getSuperServiceClass();
}
if (StringUtils.isEmpty(config.getSuperServiceImplClass())) {
superServiceImplClass = ConstVal.SUPERD_SERVICEIMPL_CLASS;
} else {
superServiceImplClass = config.getSuperServiceImplClass();
}
if (StringUtils.isEmpty(config.getSuperMapperClass())) {
superMapperClass = ConstVal.SUPERD_MAPPER_CLASS;
} else {
superMapperClass = config.getSuperMapperClass();
}
superEntityClass = config.getSuperEntityClass();
superControllerClass = config.getSuperControllerClass();
}
示例3: setConvert
import com.baomidou.mybatisplus.generator.config.StrategyConfig; //导入依赖的package包/类
protected void setConvert(StrategyConfig strategyConfig) {
if (strategyConfig.isCapitalModeNaming(name)) {
this.convert = false;
} else {
// 转换字段
if (StrategyConfig.DB_COLUMN_UNDERLINE) {
// 包含大写处理
if (StringUtils.containsUpperCase(name)) {
this.convert = true;
}
} else if (!name.equals(propertyName)) {
this.convert = true;
}
}
}
示例4: ConfigBuilder
import com.baomidou.mybatisplus.generator.config.StrategyConfig; //导入依赖的package包/类
/**
* <p>
* 在构造器中处理配置
* </p>
*
* @param packageConfig 包配置
* @param dataSourceConfig 数据源配置
* @param strategyConfig 表配置
* @param template 模板配置
* @param globalConfig 全局配置
*/
public ConfigBuilder(PackageConfig packageConfig, DataSourceConfig dataSourceConfig, StrategyConfig strategyConfig,
TemplateConfig template, GlobalConfig globalConfig) {
// 全局配置
if (null == globalConfig) {
this.globalConfig = new GlobalConfig();
} else {
this.globalConfig = globalConfig;
}
// 模板配置
if (null == template) {
this.template = new TemplateConfig();
} else {
this.template = template;
}
// 包配置
if (null == packageConfig) {
handlerPackage(this.template, this.globalConfig.getOutputDir(), new PackageConfig());
} else {
handlerPackage(this.template, this.globalConfig.getOutputDir(), packageConfig);
}
this.dataSourceConfig = dataSourceConfig;
handlerDataSource(dataSourceConfig);
// 策略配置
if (null == strategyConfig) {
this.strategyConfig = new StrategyConfig();
} else {
this.strategyConfig = strategyConfig;
}
handlerStrategy(this.strategyConfig);
}
示例5: processTable
import com.baomidou.mybatisplus.generator.config.StrategyConfig; //导入依赖的package包/类
/**
* <p>
* 处理表对应的类名称
* </P>
*
* @param tableList 表名称
* @param strategy 命名策略
* @param config 策略配置项
* @return 补充完整信息后的表
*/
private List<TableInfo> processTable(List<TableInfo> tableList, NamingStrategy strategy, StrategyConfig config) {
String[] tablePrefix = config.getTablePrefix();
String[] fieldPrefix = config.getFieldPrefix();
for (TableInfo tableInfo : tableList) {
tableInfo.setEntityName(strategyConfig, NamingStrategy.capitalFirst(processName(tableInfo.getName(), strategy, tablePrefix)));
if (StringUtils.isNotEmpty(globalConfig.getMapperName())) {
tableInfo.setMapperName(String.format(globalConfig.getMapperName(), tableInfo.getEntityName()));
} else {
tableInfo.setMapperName(tableInfo.getEntityName() + ConstVal.MAPPER);
}
if (StringUtils.isNotEmpty(globalConfig.getXmlName())) {
tableInfo.setXmlName(String.format(globalConfig.getXmlName(), tableInfo.getEntityName()));
} else {
tableInfo.setXmlName(tableInfo.getEntityName() + ConstVal.MAPPER);
}
if (StringUtils.isNotEmpty(globalConfig.getServiceName())) {
tableInfo.setServiceName(String.format(globalConfig.getServiceName(), tableInfo.getEntityName()));
} else {
tableInfo.setServiceName("I" + tableInfo.getEntityName() + ConstVal.SERIVCE);
}
if (StringUtils.isNotEmpty(globalConfig.getServiceImplName())) {
tableInfo.setServiceImplName(String.format(globalConfig.getServiceImplName(), tableInfo.getEntityName()));
} else {
tableInfo.setServiceImplName(tableInfo.getEntityName() + ConstVal.SERVICEIMPL);
}
if (StringUtils.isNotEmpty(globalConfig.getControllerName())) {
tableInfo.setControllerName(String.format(globalConfig.getControllerName(), tableInfo.getEntityName()));
} else {
tableInfo.setControllerName(tableInfo.getEntityName() + ConstVal.CONTROLLER);
}
//强制开启字段注解
checkTableIdTableFieldAnnotation(config, tableInfo, fieldPrefix);
}
return tableList;
}
示例6: getStrategy
import com.baomidou.mybatisplus.generator.config.StrategyConfig; //导入依赖的package包/类
public StrategyConfig getStrategy() {
return strategy;
}
示例7: setStrategy
import com.baomidou.mybatisplus.generator.config.StrategyConfig; //导入依赖的package包/类
public AutoGenerator setStrategy(StrategyConfig strategy) {
this.strategy = strategy;
return this;
}
示例8: setPropertyName
import com.baomidou.mybatisplus.generator.config.StrategyConfig; //导入依赖的package包/类
public void setPropertyName(StrategyConfig strategyConfig, String propertyName) {
this.propertyName = propertyName;
this.setConvert(strategyConfig);
}
示例9: setEntityName
import com.baomidou.mybatisplus.generator.config.StrategyConfig; //导入依赖的package包/类
public void setEntityName(StrategyConfig strategyConfig, String entityName) {
this.entityName = entityName;
this.setConvert(strategyConfig);
}
示例10: getStrategyConfig
import com.baomidou.mybatisplus.generator.config.StrategyConfig; //导入依赖的package包/类
public StrategyConfig getStrategyConfig() {
return strategyConfig;
}
示例11: setStrategyConfig
import com.baomidou.mybatisplus.generator.config.StrategyConfig; //导入依赖的package包/类
public ConfigBuilder setStrategyConfig(StrategyConfig strategyConfig) {
this.strategyConfig = strategyConfig;
return this;
}
示例12: generateByTables
import com.baomidou.mybatisplus.generator.config.StrategyConfig; //导入依赖的package包/类
private void generateByTables(String packageName, String... tableNames) {
GlobalConfig config = new GlobalConfig();
String dbUrl = "jdbc:mysql://localhost:3306/mybatis-plus";
DataSourceConfig dataSourceConfig = new DataSourceConfig();
dataSourceConfig.setDbType(DbType.MYSQL)
.setUrl(dbUrl)
.setUsername("root")
.setPassword("")
.setDriverName("com.mysql.jdbc.Driver");
StrategyConfig strategyConfig = new StrategyConfig();
strategyConfig
.setCapitalMode(true)
.setEntityLombokModel(false)
.setDbColumnUnderline(true)
.setNaming(NamingStrategy.underline_to_camel)
.entityTableFieldAnnotationEnable(enableTableFieldAnnotation)
.fieldPrefix(fieldPrefix)//test_id -> id, test_type -> type
.setInclude(tableNames);//修改替换成你需要的表名,多个表名传数组
config.setActiveRecord(false)
.setIdType(tableIdType)
.setAuthor("K神带你飞")
.setOutputDir("d:\\codeGen")
.setFileOverride(true);
if (!serviceClassNameStartWithI) {
config.setServiceName("%sService");
}
new AutoGenerator().setGlobalConfig(config)
.setDataSource(dataSourceConfig)
.setStrategy(strategyConfig)
.setPackageInfo(
new PackageConfig()
.setParent(packageName)
.setController("controller")
.setEntity("entity")
).execute();
}
示例13: handlerStrategy
import com.baomidou.mybatisplus.generator.config.StrategyConfig; //导入依赖的package包/类
/**
* <p>
* 处理数据库表 加载数据库表、列、注释相关数据集
* </p>
*
* @param config StrategyConfig
*/
private void handlerStrategy(StrategyConfig config) {
processTypes(config);
tableInfoList = getTablesInfo(config);
}