Skip to content

Commit

Permalink
Merge branch 'XiaoMi:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
TreasureJade authored Aug 20, 2024
2 parents 8a3985f + f3cdec0 commit 583aae3
Showing 1 changed file with 22 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,11 @@
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.jdbc.core.JdbcTemplate;
import run.mone.ai.codegen.bo.FeatureGenerateType;
import run.mone.ai.codegen.bo.FeatureGenerateBo;
import run.mone.ai.codegen.bo.FeatureGenerateType;
import run.mone.ai.codegen.util.TemplateUtils;

import java.lang.reflect.Type;
import run.mone.ai.codegen.bo.FeatureGeneratType;
import run.mone.ai.codegen.bo.FeatureGenerateBo;
import run.mone.ai.codegen.util.TemplateUtils;

import java.util.Base64;
import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -141,26 +137,29 @@ public static void generateWithGenerator(FeatureGenerateBo featureGenerateBo) {
}

//配置数据源
HikariDataSource dataSource = new HikariDataSource();
dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");
dataSource.setJdbcUrl(featureGenerateBo.getJdbcUrl());
dataSource.setUsername(featureGenerateBo.getUserName());
dataSource.setPassword(featureGenerateBo.getPassword());

//创建mapper相关代码

if (FeatureGenerateType.CODE_WITH_TEMPLATE == featureGenType) {
GlobalConfig globalConfig = createGlobalConfigUseStyle(featureGenerateBo);
Generator generator = new Generator(dataSource, globalConfig);
generator.generate();
return;
}
try (HikariDataSource dataSource = new HikariDataSource()) {
dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");
dataSource.setJdbcUrl(featureGenerateBo.getJdbcUrl());
dataSource.setUsername(featureGenerateBo.getUserName());
dataSource.setPassword(featureGenerateBo.getPassword());

//创建mapper相关代码

if (FeatureGenerateType.CODE_WITH_TEMPLATE == featureGenType) {
GlobalConfig globalConfig = createGlobalConfigUseStyle(featureGenerateBo);
Generator generator = new Generator(dataSource, globalConfig);
generator.generate();
return;
}

//创建table
//创建table

if (FeatureGenerateType.TABLE == featureGenType) {
JdbcTemplate jt = new JdbcTemplate(dataSource);
jt.update(featureGenerateBo.getSql());
if (FeatureGenerateType.TABLE == featureGenType) {
JdbcTemplate jt = new JdbcTemplate(dataSource);
jt.update(featureGenerateBo.getSql());
}
} catch (Exception e) {
log.error("generate with template error", e);
}
}

Expand Down

0 comments on commit 583aae3

Please sign in to comment.