Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
黄嘉阳
/
iot-platform-server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
ebaf12d3
authored
Aug 30, 2023
by
huangjy
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fix:jar包问题
parent
ee907e37
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
1 additions
and
137 deletions
server-generator/pom.xml
server-web/pom.xml
server-web/src/test/java/CodeGenerator.java
server-generator/pom.xml
View file @
ebaf12d3
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
<dependency>
<dependency>
<groupId>
com.makeit
</groupId>
<groupId>
com.makeit
</groupId>
<artifactId>
server-common
</artifactId>
<artifactId>
server-common
</artifactId>
<version>
1.0.
1
</version>
<version>
1.0.
0
</version>
</dependency>
</dependency>
<dependency>
<dependency>
...
...
server-web/pom.xml
View file @
ebaf12d3
...
@@ -48,12 +48,6 @@
...
@@ -48,12 +48,6 @@
<version>
2.0
</version>
<version>
2.0
</version>
</dependency>
</dependency>
<dependency>
<groupId>
com.baomidou
</groupId>
<artifactId>
mybatis-plus-generator
</artifactId>
<version>
3.4.0
</version>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
...
...
server-web/src/test/java/CodeGenerator.java
deleted
100644 → 0
View file @
ee907e37
import
com.baomidou.mybatisplus.annotation.DbType
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.generator.AutoGenerator
;
import
com.baomidou.mybatisplus.generator.InjectionConfig
;
import
com.baomidou.mybatisplus.generator.config.*
;
import
com.baomidou.mybatisplus.generator.config.rules.NamingStrategy
;
import
com.makeit.common.entity.BaseBusEntity
;
import
org.junit.jupiter.api.Test
;
public
class
CodeGenerator
{
@Test
public
void
run
()
{
// 可多表 用,隔开
//String tables_name = "address";
//String tables_name = "address,admin,admin_province,admin_role,advertisement,advertisement_city,advertisement_day,advertisement_price,advertisement_price_rule,agreement,agriculture_goods,agriculture_goods_bid,agriculture_goods_category,area,area_info,contractor,dictionary_data,goods,goods_category,goods_order,goods_town,info_top_price,job,job_category,job_category_job,land,land_bid,land_bid_user,land_order,operation_log,permission,platform,point,point_rule,publish_price,role,role_permission,rural,rural_category,rural_unit,sensitive_word,supplier,template,tree,user,user_audit";
// 1、创建代码生成器
AutoGenerator
mpg
=
new
AutoGenerator
();
// 2、全局配置
GlobalConfig
gc
=
new
GlobalConfig
();
// 生成路径
String
projectPath
=
System
.
getProperty
(
"user.dir"
);
gc
.
setOutputDir
(
projectPath
+
"/src/main/java"
);
gc
.
setAuthor
(
"eugene young"
);
gc
.
setOpen
(
false
);
//生成后是否打开资源管理器
gc
.
setFileOverride
(
false
);
//重新生成时文件是否覆盖
//UserService
gc
.
setServiceName
(
"%sService"
);
//去掉Service接口的首字母I
gc
.
setIdType
(
IdType
.
AUTO
);
//主键策略-主键为Long类型 ***
//gc.setDateType(DateType.ONLY_DATE);//定义生成的实体类中日期类型 ***
gc
.
setSwagger2
(
true
);
//开启Swagger2模式
//gc.setBaseColumnList(true);
//gc.setBaseResultMap(true);
mpg
.
setGlobalConfig
(
gc
);
// 3、数据源配置
DataSourceConfig
dsc
=
new
DataSourceConfig
();
// 8.0及以上的数据库配置 5.6自行百度
dsc
.
setUrl
(
"jdbc:mysql://124.71.12.92:3306/dev_sz_tianma?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=GMT%2B8&autoReconnect=true"
);
dsc
.
setDriverName
(
"com.mysql.cj.jdbc.Driver"
);
dsc
.
setUsername
(
"dev_sz_tianma"
);
dsc
.
setPassword
(
"Dev_sz%!2346Tianma"
);
dsc
.
setDbType
(
DbType
.
MYSQL
);
mpg
.
setDataSource
(
dsc
);
// 4、包配置
PackageConfig
pc
=
new
PackageConfig
();
//包 com.atguigu.eduservice
pc
.
setParent
(
"com.makeit"
);
pc
.
setModuleName
(
"server-generator"
);
//模块名
pc
.
setModuleName
(
null
);
//包 com.atguigu.eduservice.com.xxl.job.admin.controller
pc
.
setController
(
"com.makeit.controller"
);
pc
.
setEntity
(
"entity"
);
pc
.
setService
(
"com.makeit.service"
);
pc
.
setMapper
(
"mappers"
);
mpg
.
setPackageInfo
(
pc
);
// 自定义配置
InjectionConfig
cfg
=
new
InjectionConfig
()
{
@Override
public
void
initMap
()
{
// to do nothing
}
};
/* // 如果模板引擎是 freemarker
//String templatePath = "/templates/mapper.xml.ftl";
// 如果模板引擎是 velocity
String templatePath = "/templates/mapper.xml.vm";
// 自定义输出配置
List<FileOutConfig> focList = new ArrayList<>();
// 自定义配置会被优先输出
focList.add(new FileOutConfig(templatePath) {
@Override
public String outputFile(TableInfo tableInfo) {
// 自定义输出文件名 , 如果你 Entity 设置了前后缀、此处注意 xml 的名称会跟着发生变化!!
return projectPath + "/src/main/resources/mapper/" + tableInfo.getEntityName() + "Mapper" + StringPool.DOT_XML;
}
});
cfg.setFileOutConfigList(focList);
*/
mpg
.
setCfg
(
cfg
);
TemplateConfig
templateConfig
=
new
TemplateConfig
();
templateConfig
.
setXml
(
null
);
mpg
.
setTemplate
(
templateConfig
);
// 5、策略配置
StrategyConfig
strategy
=
new
StrategyConfig
();
// 使用重点 下列字段填写表名 运行方法
// strategy.setInclude("edu_teacher","..."); // 多表-逆向工程
strategy
.
setInclude
(
"ins_aging_oven"
,
"ins_aging_car"
,
"ins_aging_undesirable_phenomenon"
,
"ins_aging_exception_handle"
,
"ins_aging_fill_note"
);
strategy
.
setNaming
(
NamingStrategy
.
underline_to_camel
);
//数据库表映射到实体的命名策略
strategy
.
setTablePrefix
(
pc
.
getModuleName
()
+
"_"
);
//生成实体属性时去掉表"_"前缀并且第一个字母大写 如:gmt_create -> gmtCreate
strategy
.
setColumnNaming
(
NamingStrategy
.
underline_to_camel
);
//数据库表字段映射到实体的命名策略
strategy
.
setEntityLombokModel
(
true
);
// lombok 模型 @Accessors(chain = true) setter链式操作
strategy
.
setRestControllerStyle
(
true
);
//restful api风格控制器
strategy
.
setControllerMappingHyphenStyle
(
true
);
//url中驼峰转连字符
//strategy.setTableFillList(Arrays.asList(new TableFill("delete_status", FieldFill.INSERT),new TableFill("gmt_create", FieldFill.INSERT),new TableFill("gmt_modified", FieldFill.INSERT_UPDATE)));
//strategy.setLogicDeleteFieldName("delete_status");
strategy
.
setSuperEntityClass
(
BaseBusEntity
.
class
);
mpg
.
setStrategy
(
strategy
);
// 6、执行
mpg
.
execute
();
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment