Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fgqyxxlr
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
yaru
fgqyxxlr
Commits
b7aa9f3f
Commit
b7aa9f3f
authored
Jul 08, 2020
by
RuoYi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码生成支持选择上级菜单
parent
44df8c4c
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
112 additions
and
8 deletions
+112
-8
ruoyi-common/src/main/java/com/ruoyi/common/constant/GenConstants.java
+6
-0
ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTable.java
+26
-0
ruoyi-generator/src/main/java/com/ruoyi/generator/service/impl/GenTableServiceImpl.java
+6
-0
ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java
+30
-3
ruoyi-generator/src/main/resources/templates/tool/gen/edit.html
+35
-2
ruoyi-generator/src/main/resources/templates/tool/gen/importTable.html
+8
-2
ruoyi-generator/src/main/resources/vm/sql/sql.vm
+1
-1
No files found.
ruoyi-common/src/main/java/com/ruoyi/common/constant/GenConstants.java
View file @
b7aa9f3f
...
...
@@ -25,6 +25,12 @@ public class GenConstants
/** 树名称字段 */
public
static
final
String
TREE_NAME
=
"treeName"
;
/** 上级菜单ID字段 */
public
static
final
String
PARENT_MENU_ID
=
"parentMenuId"
;
/** 上级菜单名称字段 */
public
static
final
String
PARENT_MENU_NAME
=
"parentMenuName"
;
/** 数据库字符串类型 */
public
static
final
String
[]
COLUMNTYPE_STR
=
{
"char"
,
"varchar"
,
"narchar"
,
"varchar2"
,
"tinytext"
,
"text"
,
"mediumtext"
,
"longtext"
};
...
...
ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTable.java
View file @
b7aa9f3f
...
...
@@ -83,6 +83,12 @@ public class GenTable extends BaseEntity
/** 树名称字段 */
private
String
treeName
;
/** 上级菜单ID字段 */
private
String
parentMenuId
;
/** 上级菜单名称字段 */
private
String
parentMenuName
;
public
Long
getTableId
()
{
return
tableId
;
...
...
@@ -273,6 +279,26 @@ public class GenTable extends BaseEntity
this
.
treeName
=
treeName
;
}
public
String
getParentMenuId
()
{
return
parentMenuId
;
}
public
void
setParentMenuId
(
String
parentMenuId
)
{
this
.
parentMenuId
=
parentMenuId
;
}
public
String
getParentMenuName
()
{
return
parentMenuName
;
}
public
void
setParentMenuName
(
String
parentMenuName
)
{
this
.
parentMenuName
=
parentMenuName
;
}
public
boolean
isSub
()
{
return
isSub
(
this
.
tplCategory
);
...
...
ruoyi-generator/src/main/java/com/ruoyi/generator/service/impl/GenTableServiceImpl.java
View file @
b7aa9f3f
...
...
@@ -391,9 +391,14 @@ public class GenTableServiceImpl implements IGenTableService
String
treeCode
=
paramsObj
.
getString
(
GenConstants
.
TREE_CODE
);
String
treeParentCode
=
paramsObj
.
getString
(
GenConstants
.
TREE_PARENT_CODE
);
String
treeName
=
paramsObj
.
getString
(
GenConstants
.
TREE_NAME
);
String
parentMenuId
=
paramsObj
.
getString
(
GenConstants
.
PARENT_MENU_ID
);
String
parentMenuName
=
paramsObj
.
getString
(
GenConstants
.
PARENT_MENU_NAME
);
genTable
.
setTreeCode
(
treeCode
);
genTable
.
setTreeParentCode
(
treeParentCode
);
genTable
.
setTreeName
(
treeName
);
genTable
.
setParentMenuId
(
parentMenuId
);
genTable
.
setParentMenuName
(
parentMenuName
);
}
}
}
\ No newline at end of file
ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java
View file @
b7aa9f3f
...
...
@@ -22,6 +22,9 @@ public class VelocityUtils
/** html空间路径 */
private
static
final
String
TEMPLATES_PATH
=
"main/resources/templates"
;
/** 默认上级菜单,系统工具 */
private
static
final
String
DEFAULT_PARENT_MENU_ID
=
"3"
;
/**
* 设置模板变量信息
...
...
@@ -53,6 +56,7 @@ public class VelocityUtils
velocityContext
.
put
(
"permissionPrefix"
,
getPermissionPrefix
(
moduleName
,
businessName
));
velocityContext
.
put
(
"columns"
,
genTable
.
getColumns
());
velocityContext
.
put
(
"table"
,
genTable
);
setMenuVelocityContext
(
velocityContext
,
genTable
);
if
(
GenConstants
.
TPL_TREE
.
equals
(
tplCategory
))
{
setTreeVelocityContext
(
velocityContext
,
genTable
);
...
...
@@ -64,6 +68,14 @@ public class VelocityUtils
return
velocityContext
;
}
public
static
void
setMenuVelocityContext
(
VelocityContext
context
,
GenTable
genTable
)
{
String
options
=
genTable
.
getOptions
();
JSONObject
paramsObj
=
JSONObject
.
parseObject
(
options
);
String
parentMenuId
=
getParentMenuId
(
paramsObj
);
context
.
put
(
"parentMenuId"
,
parentMenuId
);
}
public
static
void
setTreeVelocityContext
(
VelocityContext
context
,
GenTable
genTable
)
{
String
options
=
genTable
.
getOptions
();
...
...
@@ -284,6 +296,21 @@ public class VelocityUtils
}
/**
* 获取上级菜单ID字段
*
* @param options 生成其他选项
* @return 上级菜单ID字段
*/
public
static
String
getParentMenuId
(
JSONObject
paramsObj
)
{
if
(
paramsObj
.
containsKey
(
GenConstants
.
PARENT_MENU_ID
))
{
return
paramsObj
.
getString
(
GenConstants
.
PARENT_MENU_ID
);
}
return
DEFAULT_PARENT_MENU_ID
;
}
/**
* 获取树编码
*
* @param options 生成其他选项
...
...
@@ -295,7 +322,7 @@ public class VelocityUtils
{
return
StringUtils
.
toCamelCase
(
paramsObj
.
getString
(
GenConstants
.
TREE_CODE
));
}
return
""
;
return
StringUtils
.
EMPTY
;
}
/**
...
...
@@ -310,7 +337,7 @@ public class VelocityUtils
{
return
StringUtils
.
toCamelCase
(
paramsObj
.
getString
(
GenConstants
.
TREE_PARENT_CODE
));
}
return
""
;
return
StringUtils
.
EMPTY
;
}
/**
...
...
@@ -325,7 +352,7 @@ public class VelocityUtils
{
return
StringUtils
.
toCamelCase
(
paramsObj
.
getString
(
GenConstants
.
TREE_NAME
));
}
return
""
;
return
StringUtils
.
EMPTY
;
}
/**
...
...
ruoyi-generator/src/main/resources/templates/tool/gen/edit.html
View file @
b7aa9f3f
...
...
@@ -133,6 +133,18 @@
</div>
</div>
</div>
<div
class=
"col-sm-6"
>
<div
class=
"form-group"
>
<label
class=
"col-sm-4 control-label is-required"
title=
"分配到指定菜单下,例如 系统管理"
>
上级菜单:
<i
class=
"fa fa-question-circle-o"
></i></label>
<div
class=
"col-sm-8"
>
<input
id=
"parentMenuId"
name=
"params[parentMenuId]"
type=
"hidden"
th:value=
"*{parentMenuId}"
/>
<div
class=
"input-group"
>
<input
id=
"parentMenuName"
name=
"params[parentMenuName]"
class=
"form-control"
type=
"text"
onclick=
"selectMenuTree()"
placeholder=
"请选择上级菜单"
maxlength=
"50"
th:value=
"*{parentMenuName}"
required
>
<span
class=
"input-group-addon"
><i
class=
"fa fa-search"
></i></span>
</div>
</div>
</div>
</div>
</div>
<div
class=
"hidden"
id=
"subInfo"
>
<h4
class=
"form-header h4"
>
关联信息
</h4>
...
...
@@ -463,18 +475,39 @@
title
:
'选择字典类型'
,
width
:
"380"
,
url
:
url
,
callBack
:
doSubmit
callBack
:
do
Dict
Submit
};
$
.
modal
.
openOptions
(
options
);
}
function
doSubmit
(
index
,
layero
){
// 选择菜单处理函数
function
selectMenuTree
()
{
var
parentMenuId
=
$
(
"#parentMenuId"
).
val
();
var
menuId
=
parentMenuId
>
0
?
parentMenuId
:
1
;
var
url
=
ctx
+
"system/menu/selectMenuTree/"
+
menuId
;
var
options
=
{
title
:
'菜单选择'
,
width
:
"380"
,
url
:
url
,
callBack
:
doMenuSubmit
};
$
.
modal
.
openOptions
(
options
);
}
function
doDictSubmit
(
index
,
layero
){
var
body
=
layer
.
getChildFrame
(
'body'
,
index
);
var
columnId
=
body
.
find
(
'#columnId'
).
val
();
var
dictType
=
body
.
find
(
'#dictType'
).
val
();
layer
.
close
(
index
);
$
(
"#columns_dict_"
+
columnId
).
val
(
dictType
);
}
function
doMenuSubmit
(
index
,
layero
){
var
body
=
layer
.
getChildFrame
(
'body'
,
index
);
$
(
"#parentMenuId"
).
val
(
body
.
find
(
'#treeId'
).
val
());
$
(
"#parentMenuName"
).
val
(
body
.
find
(
'#treeName'
).
val
());
layer
.
close
(
index
);
}
</script>
</body>
</html>
...
...
ruoyi-generator/src/main/resources/templates/tool/gen/importTable.html
View file @
b7aa9f3f
...
...
@@ -60,13 +60,19 @@
field
:
'tableName'
,
title
:
'表名称'
,
width
:
'20%'
,
sortable
:
true
sortable
:
true
,
formatter
:
function
(
value
,
row
,
index
)
{
return
$
.
table
.
tooltip
(
value
);
}
},
{
field
:
'tableComment'
,
title
:
'表描述'
,
width
:
'20%'
,
sortable
:
true
sortable
:
true
,
formatter
:
function
(
value
,
row
,
index
)
{
return
$
.
table
.
tooltip
(
value
);
}
},
{
field
:
'createTime'
,
...
...
ruoyi-generator/src/main/resources/vm/sql/sql.vm
View file @
b7aa9f3f
-- 菜单 SQL
insert into sys_menu (menu_name, parent_id, order_num, url, menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark)
values('${functionName}', '
3
', '1', '/${moduleName}/${businessName}', 'C', '0', '${permissionPrefix}:view', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '${functionName}菜单');
values('${functionName}', '
${parentMenuId}
', '1', '/${moduleName}/${businessName}', 'C', '0', '${permissionPrefix}:view', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '${functionName}菜单');
-- 按钮父菜单ID
SELECT @parentId := LAST_INSERT_ID();
...
...
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