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
69698d27
Commit
69698d27
authored
Sep 13, 2017
by
WOSHINPC
Committed by
独孤求胜
Sep 13, 2017
Browse files
Options
Browse Files
Download
Plain Diff
!1 修复BigDecimal未导包问题,添加moduleName、mainPath配置
Merge pull request !1 from WOSHINPC/dev
parents
f1bbec38
4bdfca59
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
45 additions
and
43 deletions
+45
-43
GenUtils.java
src/main/java/io/renren/utils/GenUtils.java
+0
-0
generator.properties
src/main/resources/generator.properties
+3
-1
Controller.java.vm
src/main/resources/template/Controller.java.vm
+12
-12
Dao.java.vm
src/main/resources/template/Dao.java.vm
+3
-3
Dao.xml.vm
src/main/resources/template/Dao.xml.vm
+6
-6
Entity.java.vm
src/main/resources/template/Entity.java.vm
+1
-2
Service.java.vm
src/main/resources/template/Service.java.vm
+2
-2
ServiceImpl.java.vm
src/main/resources/template/ServiceImpl.java.vm
+4
-4
list.html.vm
src/main/resources/template/list.html.vm
+5
-4
list.js.vm
src/main/resources/template/list.js.vm
+4
-4
menu.sql.vm
src/main/resources/template/menu.sql.vm
+5
-5
No files found.
src/main/java/io/renren/utils/GenUtils.java
View file @
69698d27
This diff is collapsed.
Click to expand it.
src/main/resources/generator.properties
View file @
69698d27
#\u4EE3\u7801\u751F\u6210\u5668\uFF0C\u914D\u7F6E\u4FE1\u606F
#\u4EE3\u7801\u751F\u6210\u5668\uFF0C\u914D\u7F6E\u4FE1\u606F
mainPath
=
io.renren
#\u5305\u540D
#\u5305\u540D
package
=
io.renren.modules.generator
package
=
io.renren.modules
moduleName
=
generator
#\u4F5C\u8005
#\u4F5C\u8005
author
=
chenshun
author
=
chenshun
#Email
#Email
...
...
src/main/resources/template/Controller.java.vm
View file @
69698d27
package
${
package
}.
controller
;
package
${
package
}.
${
moduleName
}.
controller
;
import
java
.
util
.
List
;
import
java
.
util
.
List
;
import
java
.
util
.
Map
;
import
java
.
util
.
Map
;
...
@@ -11,11 +11,11 @@ import org.springframework.web.bind.annotation.RequestMapping;
...
@@ -11,11 +11,11 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org
.
springframework
.
web
.
bind
.
annotation
.
RequestParam
;
import
org
.
springframework
.
web
.
bind
.
annotation
.
RequestParam
;
import
org
.
springframework
.
web
.
bind
.
annotation
.
RestController
;
import
org
.
springframework
.
web
.
bind
.
annotation
.
RestController
;
import
${
package
}.
entity
.${
className
}
Entity
;
import
${
package
}.
${
moduleName
}.
entity
.${
className
}
Entity
;
import
${
package
}.
service
.${
className
}
Service
;
import
${
package
}.
${
moduleName
}.
service
.${
className
}
Service
;
import
io
.
renren
.
common
.
utils
.
PageUtils
;
import
${
mainPath
}
.
common
.
utils
.
PageUtils
;
import
io
.
renren
.
common
.
utils
.
Query
;
import
${
mainPath
}
.
common
.
utils
.
Query
;
import
io
.
renren
.
common
.
utils
.
R
;
import
${
mainPath
}
.
common
.
utils
.
R
;
...
@@ -28,7 +28,7 @@ import io.renren.common.utils.R;
...
@@ -28,7 +28,7 @@ import io.renren.common.utils.R;
*
@
date
${
datetime
}
*
@
date
${
datetime
}
*/
*/
@
RestController
@
RestController
@
RequestMapping
(
"${pathName}"
)
@
RequestMapping
(
"
/${moduleName}/
${pathName}"
)
public
class
${
className
}
Controller
{
public
class
${
className
}
Controller
{
@
Autowired
@
Autowired
private
${
className
}
Service
${
classname
}
Service
;
private
${
className
}
Service
${
classname
}
Service
;
...
@@ -37,7 +37,7 @@ public class ${className}Controller {
...
@@ -37,7 +37,7 @@ public class ${className}Controller {
*
列表
*
列表
*/
*/
@
RequestMapping
(
"/list"
)
@
RequestMapping
(
"/list"
)
@
RequiresPermissions
(
"${pathName}:list"
)
@
RequiresPermissions
(
"${
moduleName}:${
pathName}:list"
)
public
R
list
(@
RequestParam
Map
<
String
,
Object
>
params
){
public
R
list
(@
RequestParam
Map
<
String
,
Object
>
params
){
//
查询列表数据
//
查询列表数据
Query
query
=
new
Query
(
params
);
Query
query
=
new
Query
(
params
);
...
@@ -55,7 +55,7 @@ public class ${className}Controller {
...
@@ -55,7 +55,7 @@ public class ${className}Controller {
*
信息
*
信息
*/
*/
@
RequestMapping
(
"/info/{${pk.attrname}}"
)
@
RequestMapping
(
"/info/{${pk.attrname}}"
)
@
RequiresPermissions
(
"${pathName}:info"
)
@
RequiresPermissions
(
"${
moduleName}:${
pathName}:info"
)
public
R
info
(@
PathVariable
(
"${pk.attrname}"
)
${
pk
.
attrType
}
${
pk
.
attrname
}){
public
R
info
(@
PathVariable
(
"${pk.attrname}"
)
${
pk
.
attrType
}
${
pk
.
attrname
}){
${
className
}
Entity
${
classname
}
=
${
classname
}
Service
.
queryObject
(${
pk
.
attrname
});
${
className
}
Entity
${
classname
}
=
${
classname
}
Service
.
queryObject
(${
pk
.
attrname
});
...
@@ -66,7 +66,7 @@ public class ${className}Controller {
...
@@ -66,7 +66,7 @@ public class ${className}Controller {
*
保存
*
保存
*/
*/
@
RequestMapping
(
"/save"
)
@
RequestMapping
(
"/save"
)
@
RequiresPermissions
(
"${pathName}:save"
)
@
RequiresPermissions
(
"${
moduleName}:${
pathName}:save"
)
public
R
save
(@
RequestBody
${
className
}
Entity
${
classname
}){
public
R
save
(@
RequestBody
${
className
}
Entity
${
classname
}){
${
classname
}
Service
.
save
(${
classname
});
${
classname
}
Service
.
save
(${
classname
});
...
@@ -77,7 +77,7 @@ public class ${className}Controller {
...
@@ -77,7 +77,7 @@ public class ${className}Controller {
*
修改
*
修改
*/
*/
@
RequestMapping
(
"/update"
)
@
RequestMapping
(
"/update"
)
@
RequiresPermissions
(
"${pathName}:update"
)
@
RequiresPermissions
(
"${
moduleName}:${
pathName}:update"
)
public
R
update
(@
RequestBody
${
className
}
Entity
${
classname
}){
public
R
update
(@
RequestBody
${
className
}
Entity
${
classname
}){
${
classname
}
Service
.
update
(${
classname
});
${
classname
}
Service
.
update
(${
classname
});
...
@@ -88,7 +88,7 @@ public class ${className}Controller {
...
@@ -88,7 +88,7 @@ public class ${className}Controller {
*
删除
*
删除
*/
*/
@
RequestMapping
(
"/delete"
)
@
RequestMapping
(
"/delete"
)
@
RequiresPermissions
(
"${pathName}:delete"
)
@
RequiresPermissions
(
"${
moduleName}:${
pathName}:delete"
)
public
R
delete
(@
RequestBody
${
pk
.
attrType
}[]
${
pk
.
attrname
}
s
){
public
R
delete
(@
RequestBody
${
pk
.
attrType
}[]
${
pk
.
attrname
}
s
){
${
classname
}
Service
.
deleteBatch
(${
pk
.
attrname
}
s
);
${
classname
}
Service
.
deleteBatch
(${
pk
.
attrname
}
s
);
...
...
src/main/resources/template/Dao.java.vm
View file @
69698d27
package
${
package
}.
dao
;
package
${
package
}.
${
moduleName
}.
dao
;
import
${
package
}.
entity
.${
className
}
Entity
;
import
${
package
}.
${
moduleName
}.
entity
.${
className
}
Entity
;
import
io
.
renren
.
modules
.
sys
.
dao
.
BaseDao
;
import
${
mainPath
}
.
modules
.
sys
.
dao
.
BaseDao
;
import
org
.
apache
.
ibatis
.
annotations
.
Mapper
;
import
org
.
apache
.
ibatis
.
annotations
.
Mapper
;
/**
/**
...
...
src/main/resources/template/Dao.xml.vm
View file @
69698d27
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"${package}.dao.${className}Dao"
>
<mapper
namespace=
"${package}.
${moduleName}.
dao.${className}Dao"
>
<!-- 可根据自己的需求,是否要使用 -->
<!-- 可根据自己的需求,是否要使用 -->
<resultMap
type=
"${package}.entity.${className}Entity"
id=
"${classname}Map"
>
<resultMap
type=
"${package}.
${moduleName}.
entity.${className}Entity"
id=
"${classname}Map"
>
#foreach($column in $columns)
#foreach($column in $columns)
<result
property=
"${column.attrname}"
column=
"${column.columnName}"
/>
<result
property=
"${column.attrname}"
column=
"${column.columnName}"
/>
#end
#end
</resultMap>
</resultMap>
<select
id=
"queryObject"
resultType=
"${package}.entity.${className}Entity"
>
<select
id=
"queryObject"
resultType=
"${package}.
${moduleName}.
entity.${className}Entity"
>
select * from ${tableName} where ${pk.columnName} = #{value}
select * from ${tableName} where ${pk.columnName} = #{value}
</select>
</select>
<select
id=
"queryList"
resultType=
"${package}.entity.${className}Entity"
>
<select
id=
"queryList"
resultType=
"${package}.
${moduleName}.
entity.${className}Entity"
>
select * from ${tableName}
select * from ${tableName}
<choose>
<choose>
<when
test=
"sidx != null and sidx.trim() != ''"
>
<when
test=
"sidx != null and sidx.trim() != ''"
>
...
@@ -33,7 +33,7 @@
...
@@ -33,7 +33,7 @@
select count(*) from ${tableName}
select count(*) from ${tableName}
</select>
</select>
<insert
id=
"save"
parameterType=
"${package}.entity.${className}Entity"
#if($
pk.extra =
=
'auto_increment')
useGeneratedKeys=
"true"
keyProperty=
"$pk.attrname"
#end
>
<insert
id=
"save"
parameterType=
"${package}.
${moduleName}.
entity.${className}Entity"
#if($
pk.extra =
=
'auto_increment')
useGeneratedKeys=
"true"
keyProperty=
"$pk.attrname"
#end
>
insert into ${tableName}
insert into ${tableName}
(
(
#foreach($column in $columns)
#foreach($column in $columns)
...
@@ -54,7 +54,7 @@
...
@@ -54,7 +54,7 @@
)
)
</insert>
</insert>
<update
id=
"update"
parameterType=
"${package}.entity.${className}Entity"
>
<update
id=
"update"
parameterType=
"${package}.
${moduleName}.
entity.${className}Entity"
>
update ${tableName}
update ${tableName}
<set>
<set>
#foreach($column in $columns)
#foreach($column in $columns)
...
...
src/main/resources/template/Entity.java.vm
View file @
69698d27
package
${
package
}.
entity
;
package
${
package
}.
${
moduleName
}.
entity
;
import
java
.
io
.
Serializable
;
import
java
.
io
.
Serializable
;
import
java
.
util
.
Date
;
import
java
.
util
.
Date
;
#
if
(${
hasBigDecimal
})
#
if
(${
hasBigDecimal
})
import
java
.
math
.
BigDecimal
;
import
java
.
math
.
BigDecimal
;
#
end
#
end
...
...
src/main/resources/template/Service.java.vm
View file @
69698d27
package
${
package
}.
service
;
package
${
package
}.
${
moduleName
}.
service
;
import
${
package
}.
entity
.${
className
}
Entity
;
import
${
package
}.
${
moduleName
}.
entity
.${
className
}
Entity
;
import
java
.
util
.
List
;
import
java
.
util
.
List
;
import
java
.
util
.
Map
;
import
java
.
util
.
Map
;
...
...
src/main/resources/template/ServiceImpl.java.vm
View file @
69698d27
package
${
package
}.
service
.
impl
;
package
${
package
}.
${
moduleName
}.
service
.
impl
;
import
org
.
springframework
.
beans
.
factory
.
annotation
.
Autowired
;
import
org
.
springframework
.
beans
.
factory
.
annotation
.
Autowired
;
import
org
.
springframework
.
stereotype
.
Service
;
import
org
.
springframework
.
stereotype
.
Service
;
...
@@ -6,9 +6,9 @@ import org.springframework.stereotype.Service;
...
@@ -6,9 +6,9 @@ import org.springframework.stereotype.Service;
import
java
.
util
.
List
;
import
java
.
util
.
List
;
import
java
.
util
.
Map
;
import
java
.
util
.
Map
;
import
${
package
}.
dao
.${
className
}
Dao
;
import
${
package
}.
${
moduleName
}.
dao
.${
className
}
Dao
;
import
${
package
}.
entity
.${
className
}
Entity
;
import
${
package
}.
${
moduleName
}.
entity
.${
className
}
Entity
;
import
${
package
}.
service
.${
className
}
Service
;
import
${
package
}.
${
moduleName
}.
service
.${
className
}
Service
;
...
...
src/main/resources/template/list.html.vm
View file @
69698d27
...
@@ -23,9 +23,9 @@
...
@@ -23,9 +23,9 @@
<div
id=
"rrapp"
v-cloak
>
<div
id=
"rrapp"
v-cloak
>
<div
v-show=
"showList"
>
<div
v-show=
"showList"
>
<div
class=
"grid-btn"
>
<div
class=
"grid-btn"
>
<a
v-if=
"hasPermission('${pathName}:save')"
class=
"btn btn-primary"
@
click=
"add"
><i
class=
"fa fa-plus"
></i>
新增
</a>
<a
v-if=
"hasPermission('${
moduleName}:${
pathName}:save')"
class=
"btn btn-primary"
@
click=
"add"
><i
class=
"fa fa-plus"
></i>
新增
</a>
<a
v-if=
"hasPermission('${pathName}:update')"
class=
"btn btn-primary"
@
click=
"update"
><i
class=
"fa fa-pencil-square-o"
></i>
修改
</a>
<a
v-if=
"hasPermission('${
moduleName}:${
pathName}:update')"
class=
"btn btn-primary"
@
click=
"update"
><i
class=
"fa fa-pencil-square-o"
></i>
修改
</a>
<a
v-if=
"hasPermission('${pathName}:delete')"
class=
"btn btn-primary"
@
click=
"del"
><i
class=
"fa fa-trash-o"
></i>
删除
</a>
<a
v-if=
"hasPermission('${
moduleName}:${
pathName}:delete')"
class=
"btn btn-primary"
@
click=
"del"
><i
class=
"fa fa-trash-o"
></i>
删除
</a>
</div>
</div>
<table
id=
"jqGrid"
></table>
<table
id=
"jqGrid"
></table>
<div
id=
"jqGridPager"
></div>
<div
id=
"jqGridPager"
></div>
...
@@ -53,6 +53,6 @@
...
@@ -53,6 +53,6 @@
</div>
</div>
</div>
</div>
<script
src=
"../../js/modules/
generator
/${pathName}.js"
></script>
<script
src=
"../../js/modules/
${moduleName}
/${pathName}.js"
></script>
</body>
</body>
</html>
</html>
\ No newline at end of file
src/main/resources/template/list.js.vm
View file @
69698d27
$(function () {
$(function () {
$("#jqGrid").jqGrid({
$("#jqGrid").jqGrid({
url: baseURL + '${pathName}/list',
url: baseURL + '${
moduleName}/${
pathName}/list',
datatype: "json",
datatype: "json",
colModel: [
colModel: [
#foreach($column in $columns)
#foreach($column in $columns)
...
@@ -66,7 +66,7 @@ var vm = new Vue({
...
@@ -66,7 +66,7 @@ var vm = new Vue({
vm.getInfo(${pk.attrname})
vm.getInfo(${pk.attrname})
},
},
saveOrUpdate: function (event) {
saveOrUpdate: function (event) {
var url = vm.${classname}.${pk.attrname} == null ? "${
pathName}/save" : "
${pathName}/update";
var url = vm.${classname}.${pk.attrname} == null ? "${
moduleName}/${pathName}/save" : "${moduleName}/
${pathName}/update";
$.ajax({
$.ajax({
type: "POST",
type: "POST",
url: baseURL + url,
url: baseURL + url,
...
@@ -92,7 +92,7 @@ var vm = new Vue({
...
@@ -92,7 +92,7 @@ var vm = new Vue({
confirm('确定要删除选中的记录?', function(){
confirm('确定要删除选中的记录?', function(){
$.ajax({
$.ajax({
type: "POST",
type: "POST",
url: baseURL + "${pathName}/delete",
url: baseURL + "${
moduleName}/${
pathName}/delete",
contentType: "application/json",
contentType: "application/json",
data: JSON.stringify(${pk.attrname}s),
data: JSON.stringify(${pk.attrname}s),
success: function(r){
success: function(r){
...
@@ -108,7 +108,7 @@ var vm = new Vue({
...
@@ -108,7 +108,7 @@ var vm = new Vue({
});
});
},
},
getInfo: function(${pk.attrname}){
getInfo: function(${pk.attrname}){
$.get(baseURL + "${pathName}/info/"+${pk.attrname}, function(r){
$.get(baseURL + "${
moduleName}/${
pathName}/info/"+${pk.attrname}, function(r){
vm.${classname} = r.${classname};
vm.${classname} = r.${classname};
});
});
},
},
...
...
src/main/resources/template/menu.sql.vm
View file @
69698d27
-- 菜单SQL
-- 菜单SQL
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
VALUES ('1', '${comments}', 'modules/
generator
/${pathName}.html', NULL, '1', 'fa fa-file-code-o', '6');
VALUES ('1', '${comments}', 'modules/
${moduleName}
/${pathName}.html', NULL, '1', 'fa fa-file-code-o', '6');
-- 按钮父菜单ID
-- 按钮父菜单ID
set @parentId = @@identity;
set @parentId = @@identity;
-- 菜单对应按钮SQL
-- 菜单对应按钮SQL
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '查看', null, '${pathName}:list,${pathName}:info', '2', null, '6';
SELECT @parentId, '查看', null, '${
moduleName}:${
pathName}:list,${pathName}:info', '2', null, '6';
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '新增', null, '${pathName}:save', '2', null, '6';
SELECT @parentId, '新增', null, '${
moduleName}:${
pathName}:save', '2', null, '6';
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '修改', null, '${pathName}:update', '2', null, '6';
SELECT @parentId, '修改', null, '${
moduleName}:${
pathName}:update', '2', null, '6';
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '删除', null, '${pathName}:delete', '2', null, '6';
SELECT @parentId, '删除', null, '${
moduleName}:${
pathName}:delete', '2', null, '6';
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