Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
renren-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
吴迪
renren-generator
Commits
d4dbd4eb
Commit
d4dbd4eb
authored
Mar 20, 2018
by
Mark
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新代码生成器,支持adminlte主题
parent
cca20342
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
63 additions
and
166 deletions
+63
-166
GenUtils.java
src/main/java/io/renren/utils/GenUtils.java
+4
-4
Controller.java.vm
src/main/resources/template/Controller.java.vm
+8
-16
Dao.java.vm
src/main/resources/template/Dao.java.vm
+2
-2
Dao.xml.vm
src/main/resources/template/Dao.xml.vm
+0
-67
Entity.java.vm
src/main/resources/template/Entity.java.vm
+13
-5
Service.java.vm
src/main/resources/template/Service.java.vm
+5
-15
ServiceImpl.java.vm
src/main/resources/template/ServiceImpl.java.vm
+12
-38
list.html.vm
src/main/resources/template/adminlte/list.html.vm
+17
-17
list.js.vm
src/main/resources/template/adminlte/list.js.vm
+0
-0
main.html
src/main/resources/views/main.html
+2
-2
No files found.
src/main/java/io/renren/utils/GenUtils.java
View file @
d4dbd4eb
...
...
@@ -36,8 +36,8 @@ public class GenUtils {
templates
.
add
(
"template/Service.java.vm"
);
templates
.
add
(
"template/ServiceImpl.java.vm"
);
templates
.
add
(
"template/Controller.java.vm"
);
templates
.
add
(
"template/list.html.vm"
);
templates
.
add
(
"template/list.js.vm"
);
templates
.
add
(
"template/
adminlte/
list.html.vm"
);
templates
.
add
(
"template/
adminlte/
list.js.vm"
);
templates
.
add
(
"template/menu.sql.vm"
);
return
templates
;
}
...
...
@@ -200,12 +200,12 @@ public class GenUtils {
}
if
(
template
.
contains
(
"list.html.vm"
))
{
return
"main"
+
File
.
separator
+
"resources"
+
File
.
separator
+
"
views
"
+
File
.
separator
return
"main"
+
File
.
separator
+
"resources"
+
File
.
separator
+
"
adminlte
"
+
File
.
separator
+
"modules"
+
File
.
separator
+
moduleName
+
File
.
separator
+
className
.
toLowerCase
()
+
".html"
;
}
if
(
template
.
contains
(
"list.js.vm"
))
{
return
"main"
+
File
.
separator
+
"resources"
+
File
.
separator
+
"
static
"
+
File
.
separator
+
"js"
+
File
.
separator
return
"main"
+
File
.
separator
+
"resources"
+
File
.
separator
+
"
adminlte
"
+
File
.
separator
+
"js"
+
File
.
separator
+
"modules"
+
File
.
separator
+
moduleName
+
File
.
separator
+
className
.
toLowerCase
()
+
".js"
;
}
...
...
src/main/resources/template/Controller.java.vm
View file @
d4dbd4eb
package
${
package
}.${
moduleName
}.
controller
;
import
java
.
util
.
List
;
import
java
.
util
.
Arrays
;
import
java
.
util
.
Map
;
import
org
.
apache
.
shiro
.
authz
.
annotation
.
RequiresPermissions
;
...
...
@@ -14,12 +14,10 @@ import org.springframework.web.bind.annotation.RestController;
import
${
package
}.${
moduleName
}.
entity
.${
className
}
Entity
;
import
${
package
}.${
moduleName
}.
service
.${
className
}
Service
;
import
${
mainPath
}.
common
.
utils
.
PageUtils
;
import
${
mainPath
}.
common
.
utils
.
Query
;
import
${
mainPath
}.
common
.
utils
.
R
;
/**
*
${
comments
}
*
...
...
@@ -28,7 +26,7 @@ import ${mainPath}.common.utils.R;
*
@
date
${
datetime
}
*/
@
RestController
@
RequestMapping
(
"
/
${moduleName}/${pathName}"
)
@
RequestMapping
(
"${moduleName}/${pathName}"
)
public
class
${
className
}
Controller
{
@
Autowired
private
${
className
}
Service
${
classname
}
Service
;
...
...
@@ -39,15 +37,9 @@ public class ${className}Controller {
@
RequestMapping
(
"/list"
)
@
RequiresPermissions
(
"${moduleName}:${pathName}:list"
)
public
R
list
(@
RequestParam
Map
<
String
,
Object
>
params
){
//
查询列表数据
Query
query
=
new
Query
(
params
);
List
<${
className
}
Entity
>
${
classname
}
List
=
${
classname
}
Service
.
queryList
(
query
);
int
total
=
${
classname
}
Service
.
queryTotal
(
query
);
PageUtils
pageUtil
=
new
PageUtils
(${
classname
}
List
,
total
,
query
.
getLimit
(),
query
.
getPage
());
PageUtils
page
=
${
classname
}
Service
.
queryPage
(
params
);
return
R
.
ok
().
put
(
"page"
,
pageUtil
);
return
R
.
ok
().
put
(
"page"
,
page
);
}
...
...
@@ -57,7 +49,7 @@ public class ${className}Controller {
@
RequestMapping
(
"/info/{${pk.attrname}}"
)
@
RequiresPermissions
(
"${moduleName}:${pathName}:info"
)
public
R
info
(@
PathVariable
(
"${pk.attrname}"
)
${
pk
.
attrType
}
${
pk
.
attrname
}){
${
className
}
Entity
${
classname
}
=
${
classname
}
Service
.
queryObject
(${
pk
.
attrname
});
${
className
}
Entity
${
classname
}
=
${
classname
}
Service
.
selectById
(${
pk
.
attrname
});
return
R
.
ok
().
put
(
"${classname}"
,
${
classname
});
}
...
...
@@ -68,7 +60,7 @@ public class ${className}Controller {
@
RequestMapping
(
"/save"
)
@
RequiresPermissions
(
"${moduleName}:${pathName}:save"
)
public
R
save
(@
RequestBody
${
className
}
Entity
${
classname
}){
${
classname
}
Service
.
save
(${
classname
});
${
classname
}
Service
.
insert
(${
classname
});
return
R
.
ok
();
}
...
...
@@ -79,7 +71,7 @@ public class ${className}Controller {
@
RequestMapping
(
"/update"
)
@
RequiresPermissions
(
"${moduleName}:${pathName}:update"
)
public
R
update
(@
RequestBody
${
className
}
Entity
${
classname
}){
${
classname
}
Service
.
update
(${
classname
});
${
classname
}
Service
.
updateById
(${
classname
});
return
R
.
ok
();
}
...
...
@@ -90,7 +82,7 @@ public class ${className}Controller {
@
RequestMapping
(
"/delete"
)
@
RequiresPermissions
(
"${moduleName}:${pathName}:delete"
)
public
R
delete
(@
RequestBody
${
pk
.
attrType
}[]
${
pk
.
attrname
}
s
){
${
classname
}
Service
.
deleteBatch
(${
pk
.
attrname
}
s
);
${
classname
}
Service
.
deleteBatchIds
(
Arrays
.
asList
(${
pk
.
attrname
}
s
)
);
return
R
.
ok
();
}
...
...
src/main/resources/template/Dao.java.vm
View file @
d4dbd4eb
package
${
package
}.${
moduleName
}.
dao
;
import
${
package
}.${
moduleName
}.
entity
.${
className
}
Entity
;
import
${
mainPath
}.
modules
.
sys
.
dao
.
BaseDao
;
import
com
.
baomidou
.
mybatisplus
.
mapper
.
BaseMapper
;
import
org
.
apache
.
ibatis
.
annotations
.
Mapper
;
/**
...
...
@@ -12,6 +12,6 @@ import org.apache.ibatis.annotations.Mapper;
*
@
date
${
datetime
}
*/
@
Mapper
public
interface
${
className
}
Dao
extends
Base
Dao
<${
className
}
Entity
>
{
public
interface
${
className
}
Dao
extends
Base
Mapper
<${
className
}
Entity
>
{
}
src/main/resources/template/Dao.xml.vm
View file @
d4dbd4eb
...
...
@@ -10,71 +10,5 @@
#end
</resultMap>
<select
id=
"queryObject"
resultType=
"${package}.${moduleName}.entity.${className}Entity"
>
select * from ${tableName} where ${pk.columnName} = #{value}
</select>
<select
id=
"queryList"
resultType=
"${package}.${moduleName}.entity.${className}Entity"
>
select * from ${tableName}
<choose>
<when
test=
"sidx != null and sidx.trim() != ''"
>
order by ${sidx} ${order}
</when>
<otherwise>
order by ${pk.columnName} desc
</otherwise>
</choose>
<if
test=
"offset != null and limit != null"
>
limit #{offset}, #{limit}
</if>
</select>
<select
id=
"queryTotal"
resultType=
"int"
>
select count(*) from ${tableName}
</select>
<insert
id=
"save"
parameterType=
"${package}.${moduleName}.entity.${className}Entity"
#if($
pk.extra =
=
'auto_increment')
useGeneratedKeys=
"true"
keyProperty=
"$pk.attrname"
#end
>
insert into ${tableName}
(
#foreach($column in $columns)
#if($column.columnName != $pk.columnName || $pk.extra != 'auto_increment')
`$column.columnName`#if($velocityCount != $columns.size()), #end
#end
#end
)
values
(
#foreach($column in $columns)
#if($column.columnName != $pk.columnName || $pk.extra != 'auto_increment')
#{$column.attrname}#if($velocityCount != $columns.size()), #end
#end
#end
)
</insert>
<update
id=
"update"
parameterType=
"${package}.${moduleName}.entity.${className}Entity"
>
update ${tableName}
<set>
#foreach($column in $columns)
#if($column.columnName != $pk.columnName)
<if
test=
"$column.attrname != null"
>
`$column.columnName` = #{$column.attrname}#if($velocityCount != $columns.size()), #end
</if>
#end
#end
</set>
where ${pk.columnName} = #{${pk.attrname}}
</update>
<delete
id=
"delete"
>
delete from ${tableName} where ${pk.columnName} = #{value}
</delete>
<delete
id=
"deleteBatch"
>
delete from ${tableName} where ${pk.columnName} in
<foreach
item=
"${pk.attrname}"
collection=
"array"
open=
"("
separator=
","
close=
")"
>
#{${pk.attrname}}
</foreach>
</delete>
</mapper>
\ No newline at end of file
src/main/resources/template/Entity.java.vm
View file @
d4dbd4eb
package
${
package
}.${
moduleName
}.
entity
;
import
java
.
io
.
Serializable
;
import
java
.
util
.
Date
;
import
com
.
baomidou
.
mybatisplus
.
annotations
.
TableId
;
import
com
.
baomidou
.
mybatisplus
.
annotations
.
TableName
;
#
if
(${
hasBigDecimal
})
import
java
.
math
.
BigDecimal
;
#
end
import
java
.
io
.
Serializable
;
import
java
.
util
.
Date
;
/**
*
${
comments
}
...
...
@@ -14,12 +16,18 @@ import java.math.BigDecimal;
*
@
email
${
email
}
*
@
date
${
datetime
}
*/
@
TableName
(
"${tableName}"
)
public
class
${
className
}
Entity
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
#
foreach
($
column
in
$
columns
)
//$
column
.
comments
private
$
column
.
attrType
$
column
.
attrname
;
/**
*
$
column
.
comments
*/
#
if
($
column
.
columnName
==
$
pk
.
columnName
)
@
TableId
#
end
private
$
column
.
attrType
$
column
.
attrname
;
#
end
#
foreach
($
column
in
$
columns
)
...
...
src/main/resources/template/Service.java.vm
View file @
d4dbd4eb
package
${
package
}.${
moduleName
}.
service
;
import
com
.
baomidou
.
mybatisplus
.
service
.
IService
;
import
${
mainPath
}.
common
.
utils
.
PageUtils
;
import
${
package
}.${
moduleName
}.
entity
.${
className
}
Entity
;
import
java
.
util
.
List
;
import
java
.
util
.
Map
;
/**
...
...
@@ -12,19 +13,8 @@ import java.util.Map;
*
@
email
${
email
}
*
@
date
${
datetime
}
*/
public
interface
${
className
}
Service
{
public
interface
${
className
}
Service
extends
IService
<${
className
}
Entity
>
{
${
className
}
Entity
queryObject
(${
pk
.
attrType
}
${
pk
.
attrname
});
List
<${
className
}
Entity
>
queryList
(
Map
<
String
,
Object
>
map
);
int
queryTotal
(
Map
<
String
,
Object
>
map
);
void
save
(${
className
}
Entity
${
classname
});
void
update
(${
className
}
Entity
${
classname
});
void
delete
(${
pk
.
attrType
}
${
pk
.
attrname
});
void
deleteBatch
(${
pk
.
attrType
}[]
${
pk
.
attrname
}
s
);
PageUtils
queryPage
(
Map
<
String
,
Object
>
params
);
}
src/main/resources/template/ServiceImpl.java.vm
View file @
d4dbd4eb
package
${
package
}.${
moduleName
}.
service
.
impl
;
import
org
.
springframework
.
beans
.
factory
.
annotation
.
Autowired
;
import
org
.
springframework
.
stereotype
.
Service
;
import
java
.
util
.
List
;
import
java
.
util
.
Map
;
import
com
.
baomidou
.
mybatisplus
.
mapper
.
EntityWrapper
;
import
com
.
baomidou
.
mybatisplus
.
plugins
.
Page
;
import
com
.
baomidou
.
mybatisplus
.
service
.
impl
.
ServiceImpl
;
import
${
mainPath
}.
common
.
utils
.
PageUtils
;
import
${
mainPath
}.
common
.
utils
.
Query
;
import
${
package
}.${
moduleName
}.
dao
.${
className
}
Dao
;
import
${
package
}.${
moduleName
}.
entity
.${
className
}
Entity
;
import
${
package
}.${
moduleName
}.
service
.${
className
}
Service
;
@
Service
(
"${classname}Service"
)
public
class
${
className
}
ServiceImpl
implements
${
className
}
Service
{
@
Autowired
private
${
className
}
Dao
${
classname
}
Dao
;
@
Override
public
${
className
}
Entity
queryObject
(${
pk
.
attrType
}
${
pk
.
attrname
}){
return
${
classname
}
Dao
.
queryObject
(${
pk
.
attrname
});
}
public
class
${
className
}
ServiceImpl
extends
ServiceImpl
<${
className
}
Dao
,
${
className
}
Entity
>
implements
${
className
}
Service
{
@
Override
public
List
<${
className
}
Entity
>
queryList
(
Map
<
String
,
Object
>
map
){
return
${
classname
}
Dao
.
queryList
(
map
);
}
public
PageUtils
queryPage
(
Map
<
String
,
Object
>
params
)
{
Page
<${
className
}
Entity
>
page
=
this
.
selectPage
(
new
Query
<${
className
}
Entity
>(
params
).
getPage
(),
new
EntityWrapper
<${
className
}
Entity
>()
);
@
Override
public
int
queryTotal
(
Map
<
String
,
Object
>
map
){
return
${
classname
}
Dao
.
queryTotal
(
map
);
}
@
Override
public
void
save
(${
className
}
Entity
${
classname
}){
${
classname
}
Dao
.
save
(${
classname
});
}
@
Override
public
void
update
(${
className
}
Entity
${
classname
}){
${
classname
}
Dao
.
update
(${
classname
});
}
@
Override
public
void
delete
(${
pk
.
attrType
}
${
pk
.
attrname
}){
${
classname
}
Dao
.
delete
(${
pk
.
attrname
});
}
@
Override
public
void
deleteBatch
(${
pk
.
attrType
}[]
${
pk
.
attrname
}
s
){
${
classname
}
Dao
.
deleteBatch
(${
pk
.
attrname
}
s
);
return
new
PageUtils
(
page
);
}
}
src/main/resources/template/list.html.vm
→
src/main/resources/template/
adminlte/
list.html.vm
View file @
d4dbd4eb
<!DOCTYPE html>
<html>
<head>
<title>
${comments}
</title>
<meta
charset=
"UTF-8"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<meta
content=
"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
name=
"viewport"
>
<link
rel=
"stylesheet"
href=
"../../css/bootstrap.min.css"
>
<link
rel=
"stylesheet"
href=
"../../css/font-awesome.min.css"
>
<link
rel=
"stylesheet"
href=
"../../plugins/jqgrid/ui.jqgrid-bootstrap.css"
>
<link
rel=
"stylesheet"
href=
"../../plugins/ztree/css/metroStyle/metroStyle.css"
>
<link
rel=
"stylesheet"
href=
"../../css/main.css"
>
<script
src=
"../../libs/jquery.min.js"
></script>
<script
src=
"../../plugins/layer/layer.js"
></script>
<script
src=
"../../libs/bootstrap.min.js"
></script>
<script
src=
"../../libs/vue.min.js"
></script>
<script
src=
"../../plugins/jqgrid/grid.locale-cn.js"
></script>
<script
src=
"../../plugins/jqgrid/jquery.jqGrid.min.js"
></script>
<script
src=
"../../plugins/ztree/jquery.ztree.all.min.js"
></script>
<script
src=
"../../js/common.js"
></script>
<title>
${comments}
</title>
<meta
charset=
"UTF-8"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<meta
content=
"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
name=
"viewport"
>
<link
rel=
"stylesheet"
href=
"../../css/bootstrap.min.css"
>
<link
rel=
"stylesheet"
href=
"../../css/font-awesome.min.css"
>
<link
rel=
"stylesheet"
href=
"../../plugins/jqgrid/ui.jqgrid-bootstrap.css"
>
<link
rel=
"stylesheet"
href=
"../../plugins/ztree/css/metroStyle/metroStyle.css"
>
<link
rel=
"stylesheet"
href=
"../../css/main.css"
>
<script
src=
"../../libs/jquery.min.js"
></script>
<script
src=
"../../plugins/layer/layer.js"
></script>
<script
src=
"../../libs/bootstrap.min.js"
></script>
<script
src=
"../../libs/vue.min.js"
></script>
<script
src=
"../../plugins/jqgrid/grid.locale-cn.js"
></script>
<script
src=
"../../plugins/jqgrid/jquery.jqGrid.min.js"
></script>
<script
src=
"../../plugins/ztree/jquery.ztree.all.min.js"
></script>
<script
src=
"../../js/common.js"
></script>
</head>
<body>
<div
id=
"rrapp"
v-cloak
>
...
...
src/main/resources/template/list.js.vm
→
src/main/resources/template/
adminlte/
list.js.vm
View file @
d4dbd4eb
File moved
src/main/resources/views/main.html
View file @
d4dbd4eb
...
...
@@ -13,8 +13,8 @@
<div
style=
"padding: 10px 0 20px 10px;"
>
<h3>
获取帮助
</h3>
<ul>
<li>
Git地址:
<a
href=
"http
://git.oschina.net/babaio/renren-generator"
target=
"_blank"
>
http://git.oschina.net/baba
io/renren-generator
</a></li>
<li>
其他项目:
<a
href=
"http://www.renren.io/open/"
target=
"_blank"
>
http://www.renren.io/open/
</a></li>
<li>
Git地址:
<a
href=
"http
s://gitee.com/renrenio/renren-generator"
target=
"_blank"
>
https://gitee.com/renren
io/renren-generator
</a></li>
<li>
官方社区:
<a
href=
"http://www.renren.io/?s=index/Community"
target=
"_blank"
>
http://www.renren.io/?s=index/Community
</a></li>
<li>
如需关注项目最新动态,请Watch、Star项目,同时也是对项目最好的支持
</li>
</ul>
...
...
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