Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
布熬夜了
catalpa-code-generator-plugin
提交
d440f4a0
C
catalpa-code-generator-plugin
项目概览
布熬夜了
/
catalpa-code-generator-plugin
通知
21
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
分析
仓库
DevOps
项目成员
Pages
C
catalpa-code-generator-plugin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
Pages
分析
分析
仓库分析
DevOps
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d440f4a0
编写于
4月 10, 2023
作者:
布熬夜了
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改:代码优化
上级
468c1fc6
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
30 addition
and
10 deletion
+30
-10
pom.xml
pom.xml
+21
-8
src/main/java/com/catalpa/commons/dto/GeneratorDto.java
src/main/java/com/catalpa/commons/dto/GeneratorDto.java
+5
-0
src/main/java/com/catalpa/commons/mojo/GeneratorMojo.java
src/main/java/com/catalpa/commons/mojo/GeneratorMojo.java
+2
-0
src/main/java/com/catalpa/commons/utils/GeneratorUtil.java
src/main/java/com/catalpa/commons/utils/GeneratorUtil.java
+2
-2
未找到文件。
pom.xml
浏览文件 @
d440f4a0
...
...
@@ -18,10 +18,23 @@
</build>
<properties>
<!-- Java环境配置 -->
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<java.version>
17
</java.version>
<maven.compiler.source>
1.8
</maven.compiler.source>
<maven.compiler.target>
1.8
</maven.compiler.target>
<!-- 插件依赖 -->
<maven.plugin.api.version>
3.9.0
</maven.plugin.api.version>
<maven.plugin.annotations>
3.8.1
</maven.plugin.annotations>
<!-- MyBatis-Plus依赖 -->
<mybatis.plus.version>
3.5.3.1
</mybatis.plus.version>
<!-- 代码生成器引擎依赖 -->
<velocity.version>
2.3
</velocity.version>
<jakarta.version>
3.0.2
</jakarta.version>
<!-- 数据库驱动依赖 -->
<mysql.driver.version>
8.0.30
</mysql.driver.version>
<!-- 代码简化依赖 -->
<lambok.version>
1.18.26
</lambok.version>
</properties>
<packaging>
maven-plugin
</packaging>
...
...
@@ -30,50 +43,50 @@
<dependency>
<groupId>
org.apache.maven
</groupId>
<artifactId>
maven-plugin-api
</artifactId>
<version>
3.9.0
</version>
<version>
${maven.plugin.api.version}
</version>
</dependency>
<dependency>
<groupId>
org.apache.maven.plugin-tools
</groupId>
<artifactId>
maven-plugin-annotations
</artifactId>
<version>
3.8.1
</version>
<version>
${maven.plugin.annotations}
</version>
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
com.baomidou
</groupId>
<artifactId>
mybatis-plus-boot-starter
</artifactId>
<version>
3.5.3.1
</version>
<version>
${mybatis.plus.version}
</version>
</dependency>
<dependency>
<groupId>
com.baomidou
</groupId>
<artifactId>
mybatis-plus-generator
</artifactId>
<version>
3.5.3.1
</version>
<version>
${mybatis.plus.version}
</version>
</dependency>
<dependency>
<groupId>
org.apache.velocity
</groupId>
<artifactId>
velocity-engine-core
</artifactId>
<version>
2.3
</version>
<version>
${velocity.version}
</version>
</dependency>
<dependency>
<groupId>
jakarta.validation
</groupId>
<artifactId>
jakarta.validation-api
</artifactId>
<version>
3.0.2
</version>
<version>
${jakarta.version}
</version>
</dependency>
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
<version>
8.0.30
</version>
<version>
${mysql.driver.version}
</version>
</dependency>
<dependency>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
<version>
1.18.26
</version>
<version>
${lambok.version}
</version>
</dependency>
</dependencies>
</project>
src/main/java/com/catalpa/commons/dto/GeneratorDto.java
浏览文件 @
d440f4a0
...
...
@@ -92,4 +92,9 @@ public class GeneratorDto {
* 是否覆盖已生成文件
*/
private
Boolean
override
;
/**
* 数据库类型
*/
private
String
databaseType
;
}
src/main/java/com/catalpa/commons/mojo/GeneratorMojo.java
浏览文件 @
d440f4a0
package
com.catalpa.commons.mojo
;
import
com.baomidou.mybatisplus.annotation.DbType
;
import
com.catalpa.commons.dto.GeneratorDto
;
import
com.catalpa.commons.utils.GeneratorUtil
;
import
org.apache.maven.plugin.AbstractMojo
;
...
...
@@ -142,6 +143,7 @@ public class GeneratorMojo extends AbstractMojo {
generatorDto
.
setUserName
(
userName
);
generatorDto
.
setUserPassword
(
userPassword
);
generatorDto
.
setTableName
(
tableName
);
generatorDto
.
setDatabaseType
(
DbType
.
MYSQL
.
getDb
());
new
GeneratorUtil
(
generatorDto
).
generate
();
}
...
...
src/main/java/com/catalpa/commons/utils/GeneratorUtil.java
浏览文件 @
d440f4a0
...
...
@@ -172,7 +172,7 @@ public class GeneratorUtil {
private
DataSourceConfig
.
Builder
dataSourceConfig
()
{
String
databaseUrl
=
""
;
// MySQL数据库支持
if
(
DbType
.
getDbType
(
"mysql"
)
==
DbType
.
MYSQL
)
{
if
(
DbType
.
getDbType
(
generatorDto
.
getDatabaseType
()
)
==
DbType
.
MYSQL
)
{
databaseUrl
=
"jdbc:mysql://"
+
generatorDto
.
getIp
()
+
":"
+
generatorDto
.
getPort
()
+
"/"
+
generatorDto
.
getDatabaseName
()
+
"?&useSSL=true&useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai"
;
}
return
new
DataSourceConfig
.
Builder
(
databaseUrl
,
generatorDto
.
getUserName
(),
generatorDto
.
getUserPassword
());
...
...
@@ -181,7 +181,7 @@ public class GeneratorUtil {
/**
* 重写Dto生成方法的路径
*/
public
class
EnhanceFreemarkerTemplateEngine
extends
VelocityTemplateEngine
{
public
static
class
EnhanceFreemarkerTemplateEngine
extends
VelocityTemplateEngine
{
public
void
outputCustomFile
(
@NotNull
List
<
CustomFile
>
customFiles
,
@NotNull
TableInfo
tableInfo
,
@NotNull
Map
<
String
,
Object
>
objectMap
)
{
String
entityName
=
tableInfo
.
getEntityName
();
String
parentPath
=
this
.
getPathInfo
(
OutputFile
.
parent
)
+
"/"
+
objectMap
.
get
(
"dtoPackage"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录