Explore Enterprise Education Gitee Premium Gitee AI AI teammates
Fetch the repository succeeded.
Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
Already have an account? Sign in
文件
master
Branches (1)
master
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
The license selected for the repository is subject to the license used by the main branch of the repository.
master
Branches (1)
master
Clone or Download
Clone/Download
Prompt
To download the code, please copy the following command and execute it in the terminal
To ensure that your submitted code identity is correctly recognized by Gitee, please execute the following command.
When using the SSH protocol for the first time to clone or push code, follow the prompts below to complete the SSH configuration.
1 Generate RSA keys.
2 Obtain the content of the RSA public key and configure it in SSH Public Keys
To use SVN on Gitee, please visit the usage guide
When using the HTTPS protocol, the command line will prompt for account and password verification as follows. For security reasons, Gitee recommends configure and use personal access tokens instead of login passwords for cloning, pushing, and other operations.
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # Private Token
master
Branches (1)
master
Java-tools
/
generator
/
AutoGeneratorCode.java
Java-tools
/
generator
/
AutoGeneratorCode.java
AutoGeneratorCode.java 7.88 KB
Copy Edit Raw Blame History
senbusi authored 2025年09月30日 16:37 +08:00 . add generator/AutoGeneratorCode.java.
package com.common;
import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.core.toolkit.StringPool;
import com.baomidou.mybatisplus.generator.AutoGenerator;
import com.baomidou.mybatisplus.generator.InjectionConfig;
import com.baomidou.mybatisplus.generator.config.*;
import com.baomidou.mybatisplus.generator.config.po.TableFill;
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
import java.util.ArrayList;
import java.util.List;
/**
* @ClassName : CodeGenerator 类名
* @Description : 描述
*/
public class CodeGenerator {
public static void main(String[] args) throws InterruptedException {
AutoGenerator mpg = new AutoGenerator();
// String[] tableNameList = {"bi_overall_sales_indicators","bi_sales_revenue","bi_business_income","bi_world_map_data","bi_annual_data","bi_sku_model_number_data",
// 需要生成的表(表中需有is_delete字段,默认0为正常,1为删除)
String[] tableNameList = {"client_order_package_insurance"};
// 作者
String author = "eden";
// 包路径(如需生成admin 更换为 com.yd.mall)
String parent = "com.yd.mall";
// String parent = "com.yd.mall.portal";
// String parent = "com.yd.outer";
// 文件路径 (如需生成admin 更换为 com/yd/mall)
String filePath = "com/yd/mall";
// String filePath = "com/yd/mall/portal";
// String filePath = "com/yd/outer";
// 项目文件 (如需生成admin 更换为 /mall-admin)
String projectDocuments = "/mall-admin";
// String projectDocuments = "/mall-portal";
// String projectDocuments = "/mall-outer";
// 数据库相关信息
String jdbcUrl = "jdbc:mysql://10.0.1.137:3306/aiper?useSSL=false&allowPublicKeyRetrieval=true&rewriteBatchedStatements=true";
String jdbcName = "root";
String jdbcPwd = "FPYz2ZD^gu!*";
// 全局配置
GlobalConfig gc = new GlobalConfig();
String projectPath = System.getProperty("user.dir");
gc.setOutputDir(projectPath + projectDocuments + "/src/main/java");
gc.setFileOverride(true);
gc.setActiveRecord(true);
// XML 二级缓存
gc.setEnableCache(false);
// XML ResultMap
gc.setBaseResultMap(true);
// XML columList
gc.setBaseColumnList(true);
gc.setOpen(false);
gc.setSwagger2(true);
gc.setAuthor(author);
// 自定义文件命名,注意 %s 会自动填充表实体属性!
gc.setMapperName("%sMapper");
gc.setXmlName("%sMapper");
gc.setServiceName("%sService");
gc.setServiceImplName("%sServiceImpl");
gc.setControllerName("%sController");
mpg.setGlobalConfig(gc);
// 数据源配置
DataSourceConfig dsc = new DataSourceConfig();
// 这里以mysql为例
dsc.setDbType(DbType.MYSQL);
dsc.setDriverName("com.mysql.cj.jdbc.Driver");
dsc.setUrl(jdbcUrl);
dsc.setUsername(jdbcName);
dsc.setPassword(jdbcPwd);
mpg.setDataSource(dsc);
// 包配置
PackageConfig pc = new PackageConfig();
pc.setParent(parent)
.setController("controller")
.setEntity("domain")
.setService("service")
.setServiceImpl("service.impl")
.setMapper("mapper");
mpg.setPackageInfo(pc);
// 自定义配置
InjectionConfig cfg = new InjectionConfig() {
@Override
public void initMap() {
// to do nothing
}
};
List<FileOutConfig> focList = new ArrayList<>();
focList.add(new FileOutConfig("/templates/mapper.xml.vm") {
@Override
public String outputFile(TableInfo tableInfo) {
// 自定义输入文件名称
return projectPath + projectDocuments + "/src/main/resources/" + filePath + "/mapper/"
+ tableInfo.getEntityName() + "Mapper" + StringPool.DOT_XML;
}
});
focList.add(new FileOutConfig("/templates/controller.java.vm") {
@Override
public String outputFile(TableInfo tableInfo) {
// 自定义输入文件名称
return projectPath + projectDocuments + "/src/main/java/" + filePath + "/controller/"
+ tableInfo.getEntityName() + "Controller" + StringPool.DOT_JAVA;
}
});
focList.add(new FileOutConfig("/templates/entity.java.vm") {
@Override
public String outputFile(TableInfo tableInfo) {
// 自定义输入文件名称
return projectPath + projectDocuments + "/src/main/java/" + filePath + "/domain/"
+ tableInfo.getEntityName() + StringPool.DOT_JAVA;
}
});
focList.add(new FileOutConfig("/templates/vo.java.vm") {
@Override
public String outputFile(TableInfo tableInfo) {
// 自定义输入文件名称
return projectPath + projectDocuments + "/src/main/java/" + filePath + "/domain/vo/"
+ tableInfo.getEntityName() + "Vo" + StringPool.DOT_JAVA;
}
});
focList.add(new FileOutConfig("/templates/request.java.vm") {
@Override
public String outputFile(TableInfo tableInfo) {
// 自定义输入文件名称
return projectPath + projectDocuments + "/src/main/java/" + filePath + "/domain/request/"
+ tableInfo.getEntityName() + "Request" + StringPool.DOT_JAVA;
}
});
focList.add(new FileOutConfig("/templates/service.java.vm") {
@Override
public String outputFile(TableInfo tableInfo) {
// 自定义输入文件名称
return projectPath + projectDocuments + "/src/main/java/" + filePath + "/service/"
+ tableInfo.getEntityName() + "Service" + StringPool.DOT_JAVA;
}
});
focList.add(new FileOutConfig("/templates/serviceImpl.java.vm") {
@Override
public String outputFile(TableInfo tableInfo) {
// 自定义输入文件名称
return projectPath + projectDocuments + "/src/main/java/" + filePath + "/service/impl/"
+ tableInfo.getEntityName() + "ServiceImpl" + StringPool.DOT_JAVA;
}
});
cfg.setFileOutConfigList(focList);
mpg.setCfg(cfg);
// // 配置模板
TemplateConfig templateConfig = new TemplateConfig();
// templateConfig.setXml("/templates/mapper.xml");
templateConfig.setXml(null);
templateConfig.setController("/templates/controller.java");
templateConfig.setEntity("/templates/entity.java");
templateConfig.setMapper("/templates/mapper.java");
mpg.setTemplate(templateConfig);
// 策略配置
StrategyConfig strategy = new StrategyConfig();
//此处可以修改为您的表前缀
strategy.setTablePrefix(new String[]{""});
strategy.setTableFillList(new ArrayList<TableFill>());
// 表名生成策略
strategy.setNaming(NamingStrategy.underline_to_camel);
strategy.setInclude(tableNameList);
// 排除生成的表
//strategy.setExclude(new String[]{"test"});
// strategy.setSuperControllerClass("com.dev.mybatisPlus.controller.BaseController");
strategy.setEntityLombokModel(true);
mpg.setStrategy(strategy);
// 执行生成
mpg.execute();
}
}
Loading...
Report
Report success
We will send you the feedback within 2 working days through the letter!
Please fill in the reason for the report carefully. Provide as detailed a description as possible.
Please select a report type
Cancel
Send
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

Releases

No release

Contributors

All

Language(Optional)

Activities

can not load any more
Edit
About
Homepage
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/senbusi/Java-tools.git
git@gitee.com:senbusi/Java-tools.git
senbusi
Java-tools
Java-tools
master
Going to Help Center

Search

Comment
Repository Report
Back to the top
Login prompt
This operation requires login to the code cloud account. Please log in before operating.
Go to login
No account. Register

AltStyle によって変換されたページ (->オリジナル) /