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
8cfaa557
Commit
8cfaa557
authored
Jun 12, 2019
by
flying-cattle
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
swagger 变成可选择的...
parent
ee4eb793
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
17 deletions
+39
-17
BasisInfo.java
src/main/java/com/github/flying/cattle/mdg/entity/BasisInfo.java
+4
-1
AbstractController.ftl
src/main/resources/freemarker/ftl/AbstractController.ftl
+12
-1
controller.ftl
src/main/resources/freemarker/ftl/controller.ftl
+4
-0
entity.ftl
src/main/resources/freemarker/ftl/entity.ftl
+4
-1
MyGenerator.java
src/test/java/com/flying/cattle/mdg/MyGenerator.java
+15
-14
No files found.
src/main/java/com/github/flying/cattle/mdg/entity/BasisInfo.java
View file @
8cfaa557
...
...
@@ -79,9 +79,11 @@ public class BasisInfo implements Serializable{
private
List
<
PropertyInfo
>
cis
;
private
String
isSwagger
=
"true"
;
public
BasisInfo
(
String
project
,
String
author
,
String
version
,
String
dbUrl
,
String
dbName
,
String
dbPassword
,
String
database
,
String
createTime
,
String
agile
,
String
entityUrl
,
String
daoUrl
,
String
mapperUrl
,
String
serviceUrl
,
String
serviceImplUrl
,
String
controllerUrl
)
{
String
serviceUrl
,
String
serviceImplUrl
,
String
controllerUrl
,
String
isSwagger
)
{
super
();
this
.
project
=
project
;
this
.
author
=
author
;
...
...
@@ -100,5 +102,6 @@ public class BasisInfo implements Serializable{
this
.
controllerUrl
=
controllerUrl
;
this
.
abstractControllerUrl
=
controllerUrl
.
substring
(
0
,
controllerUrl
.
lastIndexOf
(
"."
))+
".aid"
;
this
.
swaggerConfigUrl
=
controllerUrl
.
substring
(
0
,
controllerUrl
.
lastIndexOf
(
"."
))+
".config"
;
this
.
isSwagger
=
isSwagger
;
}
}
src/main/resources/freemarker/ftl/AbstractController.ftl
View file @
8cfaa557
...
...
@@ -16,9 +16,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import
com
.
baomidou
.
mybatisplus
.
extension
.
service
.
IService
;
import
com
.
github
.
flying
.
cattle
.
mdg
.
aid
.
JsonResult
;
import
com
.
github
.
flying
.
cattle
.
mdg
.
aid
.
PageParam
;
<#
if
isSwagger
==
"true"
>
import
io
.
swagger
.
annotations
.
ApiImplicitParam
;
import
io
.
swagger
.
annotations
.
ApiOperation
;
</#
if
>
/**
*
<
p
>
自动生成工具:
mybatis
-
dsc
-
generator
</
p
>
...
...
@@ -42,8 +43,10 @@ public class AbstractController<S extends IService<T>,T>{
*
@
time
2019
年
4
月
9
日
*/
@
GetMapping
(
"/getById/{id}"
)
<#
if
isSwagger
==
"true"
>
@
ApiOperation
(
value
=
"获取对象"
,
notes
=
"作者:${author}"
)
@
ApiImplicitParam
(
paramType
=
"path"
,
name
=
"id"
,
value
=
"对象id"
,
required
=
true
,
dataType
=
"Long"
)
</#
if
>
public
JsonResult
<
T
>
getUserById
(@
PathVariable
(
"id"
)
Long
id
){
T
obj
=
baseService
.
getById
(
id
);
if
(
null
!=obj ) {
...
...
@@ -62,8 +65,10 @@ public class AbstractController<S extends IService<T>,T>{
*
@
time
2019
年
4
月
9
日
*/
@
PostMapping
(
"/deleteById"
)
<#
if
isSwagger
==
"true"
>
@
ApiOperation
(
value
=
"删除"
,
notes
=
"作者:${author}"
)
@
ApiImplicitParam
(
paramType
=
"query"
,
name
=
"id"
,
value
=
"对象id"
,
required
=
true
,
dataType
=
"Long"
)
</#
if
>
public
JsonResult
<
T
>
deleteById
(
Long
id
){
JsonResult
<
T
>
result
=
new
JsonResult
<
T
>();
T
obj
=
baseService
.
getById
(
id
);
...
...
@@ -88,7 +93,9 @@ public class AbstractController<S extends IService<T>,T>{
*
@
time
2019
年
4
月
9
日
*/
@
PostMapping
(
"/insert"
)
<#
if
isSwagger
==
"true"
>
@
ApiOperation
(
value
=
"添加"
,
notes
=
"作者:${author}"
)
</#
if
>
public
JsonResult
<
T
>
insert
(
T
entity
){
JsonResult
<
T
>
result
=
new
JsonResult
<
T
>();
if
(
null
!=entity) {
...
...
@@ -112,7 +119,9 @@ public class AbstractController<S extends IService<T>,T>{
*
@
time
2019
年
4
月
9
日
*/
@
PostMapping
(
"/update"
)
<#
if
isSwagger
==
"true"
>
@
ApiOperation
(
value
=
"修改"
,
notes
=
"作者:${author}"
)
</#
if
>
public
JsonResult
<
T
>
update
(
T
entity
){
JsonResult
<
T
>
result
=
new
JsonResult
<
T
>();
if
(
null
!=entity) {
...
...
@@ -136,7 +145,9 @@ public class AbstractController<S extends IService<T>,T>{
*
@
time
2019
年
5
月
20
日
*/
@
GetMapping
(
"/getPages"
)
<#
if
isSwagger
==
"true"
>
@
ApiOperation
(
value
=
"分页查询"
,
notes
=
"分页查询返回[IPage<T>],作者:边鹏"
)
</#
if
>
public
JsonResult
<
IPage
<
T
>>
getUserPages
(
PageParam
<
T
>
param
){
JsonResult
<
IPage
<
T
>>
returnPage
=
new
JsonResult
<
IPage
<
T
>>();
Page
<
T
>
page
=
new
Page
<
T
>(
param
.
getPageNum
(),
param
.
getPageSize
());
...
...
src/main/resources/freemarker/ftl/controller.ftl
View file @
8cfaa557
...
...
@@ -11,7 +11,9 @@ import ${entityUrl}.${entityName};
import
${
serviceUrl
}.${
entityName
}
Service
;
import
org
.
springframework
.
web
.
bind
.
annotation
.
RequestMapping
;
import
org
.
springframework
.
web
.
bind
.
annotation
.
RestController
;
<#
if
isSwagger
==
"true"
>
import
io
.
swagger
.
annotations
.
Api
;
</#
if
>
import
org
.
slf4j
.
Logger
;
import
org
.
slf4j
.
LoggerFactory
;
/**
...
...
@@ -22,7 +24,9 @@ import org.slf4j.LoggerFactory;
*
@
author
:
${
author
}
*
*/
<#
if
isSwagger
==
"true"
>
@
Api
(
description
=
"${entityComment}"
,
value
=
"${entityComment}"
)
</#
if
>
@
RestController
@
RequestMapping
(
"/${objectName}"
)
public
class
${
entityName
}
Controller
extends
AbstractController
<${
entityName
}
Service
,${
entityName
}>{
...
...
src/main/resources/freemarker/ftl/entity.ftl
View file @
8cfaa557
...
...
@@ -5,12 +5,13 @@
*
All
right
reserved
.
*/
package
${
entityUrl
};
import
com
.
baomidou
.
mybatisplus
.
annotation
.
IdType
;
import
com
.
baomidou
.
mybatisplus
.
annotation
.
TableId
;
import
com
.
baomidou
.
mybatisplus
.
extension
.
activerecord
.
Model
;
import
com
.
fasterxml
.
jackson
.
annotation
.
JsonFormat
;
<#
if
isSwagger
==
"true"
>
import
io
.
swagger
.
annotations
.
ApiModelProperty
;
</#
if
>
import
lombok
.
Data
;
import
lombok
.
EqualsAndHashCode
;
import
lombok
.
experimental
.
Accessors
;
...
...
@@ -49,7 +50,9 @@ public class ${entityName} extends Model<${entityName}> {
<#
if
ci
.
property
==
"id"
>
@
TableId
(
value
=
"id"
,
type
=
IdType
.
AUTO
)
</#
if
>
<#
if
isSwagger
==
"true"
>
@
ApiModelProperty
(
name
=
"${ci.property}"
,
value
=
"${ci.comment}"
)
</#
if
>
private
${
ci
.
javaType
}
${
ci
.
property
};
</#
list
>
@
Override
...
...
src/test/java/com/flying/cattle/mdg/MyGenerator.java
View file @
8cfaa557
...
...
@@ -20,16 +20,16 @@ import com.github.flying.cattle.mdg.util.MySqlToJavaUtil;
* <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://127.0.0.1:3306/
earn_knife
?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&failOverReadOnly=false&useSSL=true&serverTimezone=UTC"
;
public
static
final
String
URL
=
"jdbc:mysql://127.0.0.1:3306/
buybit_wallet_sign
?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&failOverReadOnly=false&useSSL=true&serverTimezone=UTC"
;
public
static
final
String
NAME
=
"root"
;
public
static
final
String
PASS
=
"pwd2020"
;
public
static
final
String
DATABASE
=
"
earn_knife
"
;
// 类信息:类名、
数据库表名
、类说明、时间
public
static
final
String
DATABASE
=
"
buybit_wallet_sign
"
;
// 类信息:类名、
对象名(一般是【类名】的首字母小些)
、类说明、时间
public
static
final
String
CLASSNAME
=
"CollectionRoute"
;
public
static
final
String
TABLE
=
"collection_route"
;
public
static
final
String
CLASSCOMMENT
=
"资金归集"
;
...
...
@@ -42,25 +42,26 @@ public class MyGenerator {
public
static
final
String
SERVICE_URL
=
"com.buybit.ws.service"
;
public
static
final
String
SERVICE_IMPL_URL
=
"com.buybit.ws.service.impl"
;
public
static
final
String
CONTROLLER_URL
=
"com.buybit.ws.web"
;
//是否是Swagger配置
public
static
final
String
IS_SWAGGER
=
"false"
;
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
);
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:\\b_mdg\\infrastructure\\springboot-mybatis\\springboot-mybatis-web\\src\\main\\java\\"
;
// 生成文件存放位置
String
fileUrl
=
"E:\\a_item_work\\wallet\\wallet-manage\\wallet-manage-web\\src\\test\\java\\"
;
// 生成文件存放位置
//开始生成文件
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
();
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
();
...
...
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