Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
ydl-generator
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
余保谷
ydl-generator
Commits
aeb3e06e
Commit
aeb3e06e
authored
Jun 28, 2021
by
yubaogu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tett
parent
0eabf0f1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
154 additions
and
137 deletions
+154
-137
generatorConfig.properties
src/main/resources/config/generatorConfig.properties
+14
-0
SwaggerConfig.ftl
src/main/resources/freemarker/ftl/SwaggerConfig.ftl
+60
-60
MyGenerator.java
src/test/java/com/flying/cattle/mdg/MyGenerator.java
+80
-77
No files found.
src/main/resources/config/generatorConfig.properties
0 → 100644
View file @
aeb3e06e
#数据库配置
jdbc.url
=
jdbc:mysql://192.168.9.246:3306/bitbuy-dev?useSSL=false&serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8
jdbc.user
=
bitbuy-dev
jdbc.pass
=
bitbuy-dev
jdbc.database
=
bitbuy-dev
#包路径
url.entity
=
com.buybit.power.entity
url.dao
=
com.buybit.power.mapper
url.xmlmapper
=
com.buybit.power.mapper.xml
url.service
=
com.buybit.power.service
url.service.impl
=
com.buybit.power.service.impl
url.controller
=
com.buybit.power.web
#Swagger
swagger.enable
=
true
src/main/resources/freemarker/ftl/SwaggerConfig.ftl
View file @
aeb3e06e
/**
*
@
filename
:${
entityName
}
Controller
${
createTime
}
*
@
project
${
project
}
${
version
}
*
Copyright
(
c
)
2020
${
author
}
Co
.
Ltd
.
*
All
right
reserved
.
*/
package
${
swaggerConfigUrl
};
import
org
.
springframework
.
beans
.
factory
.
annotation
.
Value
;
import
org
.
springframework
.
context
.
annotation
.
Bean
;
import
org
.
springframework
.
context
.
annotation
.
Configuration
;
import
springfox
.
documentation
.
builders
.
ApiInfoBuilder
;
import
springfox
.
documentation
.
builders
.
PathSelectors
;
import
springfox
.
documentation
.
builders
.
RequestHandlerSelectors
;
import
springfox
.
documentation
.
service
.
ApiInfo
;
import
springfox
.
documentation
.
spi
.
DocumentationType
;
import
springfox
.
documentation
.
spring
.
web
.
plugins
.
Docket
;
import
springfox
.
documentation
.
swagger2
.
annotations
.
EnableSwagger2
;
/**
*
<
p
>
自动生成工具:
mybatis
-
dsc
-
generator
</
p
>
*
Swagger
核心配置文件
*
========================
*
@
author
${
author
}
*
@
Date
${
createTime
}
*
========================
*/
@
Configuration
@
EnableSwagger2
public
class
SwaggerConfig
{
@
Value
(
"
${swagger.enable}"
)
private
Boolean
swagger_enable
;
public
static
String
CONTROLLER_URL
=
"${controllerUrl}"
;
//
Swagger
扫描的接口路径
public
static
String
SWAGGER_TITLE
=
"API文档-${author}"
;
//
Swagger
接口文档标题
public
static
String
SWAGGER_DESCRIPTION
=
"API文档"
;
//
Swagger
接口文档描述
public
static
String
SWAGGER_VERSION
=
"1.0"
;
//
Swagger
接口文档版本
public
final
static
String
SWAGGER_URL
=
"http://127.0.0.1:8080"
;
//
Swagger
项目服务的
URL
//
验证的页面
http
://
127.0.0.1
:
8080
/
swagger
-
ui
.
html
@
Bean
public
Docket
createRestApi
()
{
return
new
Docket
(
DocumentationType
.
SWAGGER_2
)
.
enable
(
swagger_enable
)
.
apiInfo
(
apiInfo
())
.
select
()
.
apis
(
RequestHandlerSelectors
.
basePackage
(
CONTROLLER_URL
))
.
paths
(
PathSelectors
.
any
())
.
build
();
}
private
ApiInfo
apiInfo
()
{
return
new
ApiInfoBuilder
()
.
title
(
SWAGGER_TITLE
)
.
description
(
SWAGGER_DESCRIPTION
)
.
termsOfServiceUrl
(
SWAGGER_URL
)
.
version
(
SWAGGER_VERSION
)
.
build
();
}
}
/**
*
@
filename
:${
entityName
}
Controller
${
createTime
}
*
@
project
${
project
}
${
version
}
*
Copyright
(
c
)
2020
${
author
}
Co
.
Ltd
.
*
All
right
reserved
.
*/
package
${
swaggerConfigUrl
};
import
org
.
springframework
.
beans
.
factory
.
annotation
.
Value
;
import
org
.
springframework
.
context
.
annotation
.
Bean
;
import
org
.
springframework
.
context
.
annotation
.
Configuration
;
import
springfox
.
documentation
.
builders
.
ApiInfoBuilder
;
import
springfox
.
documentation
.
builders
.
PathSelectors
;
import
springfox
.
documentation
.
builders
.
RequestHandlerSelectors
;
import
springfox
.
documentation
.
service
.
ApiInfo
;
import
springfox
.
documentation
.
spi
.
DocumentationType
;
import
springfox
.
documentation
.
spring
.
web
.
plugins
.
Docket
;
import
springfox
.
documentation
.
swagger2
.
annotations
.
EnableSwagger2
;
/**
*
<
p
>
自动生成工具:
mybatis
-
dsc
-
generator
</
p
>
*
Swagger
核心配置文件
*
========================
*
@
author
${
author
}
*
@
Date
${
createTime
}
*
========================
*/
@
Configuration
@
EnableSwagger2
public
class
SwaggerConfig
{
@
Value
(
"
\\
\$
\\
\{swagger.enable
\\
\}"
)
private
Boolean
swagger_enable
;
public
static
String
CONTROLLER_URL
=
"${controllerUrl}"
;
//
Swagger
扫描的接口路径
public
static
String
SWAGGER_TITLE
=
"API文档-${author}"
;
//
Swagger
接口文档标题
public
static
String
SWAGGER_DESCRIPTION
=
"API文档"
;
//
Swagger
接口文档描述
public
static
String
SWAGGER_VERSION
=
"1.0"
;
//
Swagger
接口文档版本
public
final
static
String
SWAGGER_URL
=
"http://127.0.0.1:8080"
;
//
Swagger
项目服务的
URL
//
验证的页面
http
://
127.0.0.1
:
8080
/
swagger
-
ui
.
html
@
Bean
public
Docket
createRestApi
()
{
return
new
Docket
(
DocumentationType
.
SWAGGER_2
)
.
enable
(
swagger_enable
)
.
apiInfo
(
apiInfo
())
.
select
()
.
apis
(
RequestHandlerSelectors
.
basePackage
(
CONTROLLER_URL
))
.
paths
(
PathSelectors
.
any
())
.
build
();
}
private
ApiInfo
apiInfo
()
{
return
new
ApiInfoBuilder
()
.
title
(
SWAGGER_TITLE
)
.
description
(
SWAGGER_DESCRIPTION
)
.
termsOfServiceUrl
(
SWAGGER_URL
)
.
version
(
SWAGGER_VERSION
)
.
build
();
}
}
src/test/java/com/flying/cattle/mdg/MyGenerator.java
View file @
aeb3e06e
/**
* @filename: MyGenerator.java 2019-10-16
* @project v0.0.1 V1.0
* Copyright(c) 2018 BianPeng Co. Ltd.
* All right reserved.
*/
package
com
.
flying
.
cattle
.
mdg
;
import
java.sql.SQLException
;
import
java.util.Date
;
import
com.gitee.flying.cattle.mdg.entity.BasisInfo
;
import
com.gitee.flying.cattle.mdg.util.EntityInfoUtil
;
import
com.gitee.flying.cattle.mdg.util.Generator
;
import
com.gitee.flying.cattle.mdg.util.MySqlToJavaUtil
;
/**
* Copyright: Copyright (c) 2019
*
* <p>说明: 自动生成工具</P>
* <p>源码地址:https://gitee.com/flying-cattle/mybatis-dsc-generator</P>
*/
public
class
MyGenerator
{
// 基础信息:项目名、作者、版本
public
static
final
String
PROJECT
=
"wallet-sign"
;
public
static
final
String
AUTHOR
=
"BianPeng"
;
public
static
final
String
VERSION
=
"V1.0"
;
// 数据库连接信息:连接URL、用户名、秘密、数据库名
public
static
final
String
URL
=
"jdbc:mysql://192.168.9.246:3306/bitbuy-dev?useSSL=false&serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8"
;
public
static
final
String
NAME
=
"bitbuy-dev"
;
public
static
final
String
PASS
=
"bitbuy-Dev1"
;
public
static
final
String
DATABASE
=
"bitbuy-dev"
;
// 类信息:类名、对象名(一般是【类名】的首字母小些)、类说明、时间
public
static
final
String
CLASSNAME
=
"foreign"
;
public
static
final
String
TABLE
=
"pm_foreign"
;
public
static
final
String
CLASSCOMMENT
=
"API应用KEY"
;
public
static
final
String
TIME
=
"2019年10月16日"
;
public
static
final
String
AGILE
=
new
Date
().
getTime
()
+
""
;
// 路径信息,分开路径方便聚合工程项目,微服务项目
public
static
final
String
ENTITY_URL
=
"com.buybit.power.entity"
;
public
static
final
String
DAO_URL
=
"com.buybit.power.mapper"
;
public
static
final
String
XML_URL
=
"com.buybit.power.mapper.xml"
;
public
static
final
String
SERVICE_URL
=
"com.buybit.power.service"
;
public
static
final
String
SERVICE_IMPL_URL
=
"com.buybit.power.service.impl"
;
public
static
final
String
CONTROLLER_URL
=
"com.buybit.power.web"
;
//是否是Swagger配置
public
static
final
String
IS_SWAGGER
=
"true"
;
public
static
void
main
(
String
[]
args
)
{
BasisInfo
bi
=
new
BasisInfo
(
PROJECT
,
AUTHOR
,
VERSION
,
URL
,
NAME
,
PASS
,
DATABASE
,
TIME
,
AGILE
,
ENTITY_URL
,
DAO_URL
,
XML_URL
,
SERVICE_URL
,
SERVICE_IMPL_URL
,
CONTROLLER_URL
,
IS_SWAGGER
);
bi
.
setTable
(
TABLE
);
bi
.
setEntityName
(
MySqlToJavaUtil
.
getClassName
(
TABLE
));
bi
.
setObjectName
(
MySqlToJavaUtil
.
changeToJavaFiled
(
TABLE
));
bi
.
setEntityComment
(
CLASSCOMMENT
);
try
{
bi
=
EntityInfoUtil
.
getInfo
(
bi
);
String
fileUrl
=
"E:\\"
;
// 生成文件存放位置
//开始生成文件
String
aa1
=
Generator
.
createEntity
(
fileUrl
,
bi
).
toString
();
String
aa2
=
Generator
.
createDao
(
fileUrl
,
bi
).
toString
();
String
aa3
=
Generator
.
createDaoImpl
(
fileUrl
,
bi
).
toString
();
String
aa4
=
Generator
.
createService
(
fileUrl
,
bi
).
toString
();
String
aa5
=
Generator
.
createServiceImpl
(
fileUrl
,
bi
).
toString
();
String
aa6
=
Generator
.
createController
(
fileUrl
,
bi
).
toString
();
// 是否创建swagger配置文件
String
aa7
=
Generator
.
createSwaggerConfig
(
fileUrl
,
bi
).
toString
();
System
.
out
.
println
(
aa1
);
System
.
out
.
println
(
aa2
);
System
.
out
.
println
(
aa3
);
System
.
out
.
println
(
aa4
);
System
.
out
.
println
(
aa5
);
System
.
out
.
println
(
aa6
);
System
.
out
.
println
(
aa7
);
//System.out.println(aa7);
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
}
/**
* @filename: MyGenerator.java 2019-10-16
* @project v0.0.1 V1.0
* Copyright(c) 2018 BianPeng Co. Ltd.
* All right reserved.
*/
package
com
.
flying
.
cattle
.
mdg
;
import
java.sql.SQLException
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
com.gitee.flying.cattle.mdg.entity.BasisInfo
;
import
com.gitee.flying.cattle.mdg.util.EntityInfoUtil
;
import
com.gitee.flying.cattle.mdg.util.Generator
;
import
com.gitee.flying.cattle.mdg.util.MySqlToJavaUtil
;
import
javax.swing.text.DateFormatter
;
/**
* Copyright: Copyright (c) 2019
*
* <p>说明: 自动生成工具</P>
* <p>源码地址:https://gitee.com/flying-cattle/mybatis-dsc-generator</P>
*/
public
class
MyGenerator
{
// 基础信息:项目名、作者、版本
public
static
final
String
PROJECT
=
"wallet-sign"
;
public
static
final
String
AUTHOR
=
"BianPeng"
;
public
static
final
String
VERSION
=
"V1.0"
;
// 数据库连接信息:连接URL、用户名、秘密、数据库名
public
static
final
String
URL
=
"jdbc:mysql://localhost:3306/seata?useSSL=false&serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8"
;
public
static
final
String
NAME
=
"root"
;
public
static
final
String
PASS
=
"12345678"
;
public
static
final
String
DATABASE
=
"seata"
;
// 类信息:类名、对象名(一般是【类名】的首字母小些)、类说明、时间
public
static
final
String
TABLE
=
"undo_log"
;
public
static
final
String
CLASSCOMMENT
=
"日志"
;
public
static
final
String
TIME
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
).
format
(
new
Date
());
public
static
final
String
AGILE
=
new
Date
().
getTime
()
+
""
;
// 路径信息,分开路径方便聚合工程项目,微服务项目
public
static
final
String
ENTITY_URL
=
"com.buybit.power.entity"
;
public
static
final
String
DAO_URL
=
"com.buybit.power.mapper"
;
public
static
final
String
XML_URL
=
"com.buybit.power.mapper.xml"
;
public
static
final
String
SERVICE_URL
=
"com.buybit.power.service"
;
public
static
final
String
SERVICE_IMPL_URL
=
"com.buybit.power.service.impl"
;
public
static
final
String
CONTROLLER_URL
=
"com.buybit.power.web"
;
//是否是Swagger配置
public
static
final
String
IS_SWAGGER
=
"true"
;
public
static
void
main
(
String
[]
args
)
{
BasisInfo
bi
=
new
BasisInfo
(
PROJECT
,
AUTHOR
,
VERSION
,
URL
,
NAME
,
PASS
,
DATABASE
,
TIME
,
AGILE
,
ENTITY_URL
,
DAO_URL
,
XML_URL
,
SERVICE_URL
,
SERVICE_IMPL_URL
,
CONTROLLER_URL
,
IS_SWAGGER
);
bi
.
setTable
(
TABLE
);
bi
.
setEntityName
(
MySqlToJavaUtil
.
getClassName
(
TABLE
));
bi
.
setObjectName
(
MySqlToJavaUtil
.
changeToJavaFiled
(
TABLE
));
bi
.
setEntityComment
(
CLASSCOMMENT
);
try
{
bi
=
EntityInfoUtil
.
getInfo
(
bi
);
String
fileUrl
=
"D:\\ydlwork\\generator\\"
;
// 生成文件存放位置
//开始生成文件
String
aa1
=
Generator
.
createEntity
(
fileUrl
,
bi
).
toString
();
String
aa2
=
Generator
.
createDao
(
fileUrl
,
bi
).
toString
();
String
aa3
=
Generator
.
createDaoImpl
(
fileUrl
,
bi
).
toString
();
String
aa4
=
Generator
.
createService
(
fileUrl
,
bi
).
toString
();
String
aa5
=
Generator
.
createServiceImpl
(
fileUrl
,
bi
).
toString
();
String
aa6
=
Generator
.
createController
(
fileUrl
,
bi
).
toString
();
// 是否创建swagger配置文件
String
aa7
=
Generator
.
createSwaggerConfig
(
fileUrl
,
bi
).
toString
();
System
.
out
.
println
(
aa1
);
System
.
out
.
println
(
aa2
);
System
.
out
.
println
(
aa3
);
System
.
out
.
println
(
aa4
);
System
.
out
.
println
(
aa5
);
System
.
out
.
println
(
aa6
);
System
.
out
.
println
(
aa7
);
//System.out.println(aa7);
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
}
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