Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
finance-manage
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
finance-oa
finance-manage
Commits
b2d79b62
Commit
b2d79b62
authored
Jul 21, 2020
by
RuoYi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码生成支持选择上级菜单
parent
8a076e17
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
120 additions
and
19 deletions
+120
-19
ruoyi-common/src/main/java/com/ruoyi/common/constant/GenConstants.java
...src/main/java/com/ruoyi/common/constant/GenConstants.java
+6
-0
ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTable.java
...or/src/main/java/com/ruoyi/generator/domain/GenTable.java
+27
-1
ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java
...java/com/ruoyi/generator/service/GenTableServiceImpl.java
+6
-1
ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java
...src/main/java/com/ruoyi/generator/util/VelocityUtils.java
+32
-10
ruoyi-generator/src/main/resources/vm/sql/sql.vm
ruoyi-generator/src/main/resources/vm/sql/sql.vm
+1
-1
ruoyi-ui/src/views/tool/gen/editTable.vue
ruoyi-ui/src/views/tool/gen/editTable.vue
+11
-2
ruoyi-ui/src/views/tool/gen/genInfoForm.vue
ruoyi-ui/src/views/tool/gen/genInfoForm.vue
+35
-2
ruoyi-ui/src/views/tool/gen/importTable.vue
ruoyi-ui/src/views/tool/gen/importTable.vue
+2
-2
No files found.
ruoyi-common/src/main/java/com/ruoyi/common/constant/GenConstants.java
View file @
b2d79b62
...
@@ -22,6 +22,12 @@ public class GenConstants
...
@@ -22,6 +22,12 @@ public class GenConstants
/** 树名称字段 */
/** 树名称字段 */
public
static
final
String
TREE_NAME
=
"treeName"
;
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"
,
public
static
final
String
[]
COLUMNTYPE_STR
=
{
"char"
,
"varchar"
,
"narchar"
,
"varchar2"
,
"tinytext"
,
"text"
,
"mediumtext"
,
"longtext"
};
"mediumtext"
,
"longtext"
};
...
...
ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTable.java
View file @
b2d79b62
...
@@ -74,6 +74,12 @@ public class GenTable extends BaseEntity
...
@@ -74,6 +74,12 @@ public class GenTable extends BaseEntity
/** 树名称字段 */
/** 树名称字段 */
private
String
treeName
;
private
String
treeName
;
/** 上级菜单ID字段 */
private
String
parentMenuId
;
/** 上级菜单名称字段 */
private
String
parentMenuName
;
public
Long
getTableId
()
public
Long
getTableId
()
{
{
return
tableId
;
return
tableId
;
...
@@ -234,6 +240,26 @@ public class GenTable extends BaseEntity
...
@@ -234,6 +240,26 @@ public class GenTable extends BaseEntity
this
.
treeName
=
treeName
;
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
isTree
()
public
boolean
isTree
()
{
{
return
isTree
(
this
.
tplCategory
);
return
isTree
(
this
.
tplCategory
);
...
@@ -268,4 +294,4 @@ public class GenTable extends BaseEntity
...
@@ -268,4 +294,4 @@ public class GenTable extends BaseEntity
}
}
return
StringUtils
.
equalsAnyIgnoreCase
(
javaField
,
GenConstants
.
BASE_ENTITY
);
return
StringUtils
.
equalsAnyIgnoreCase
(
javaField
,
GenConstants
.
BASE_ENTITY
);
}
}
}
}
\ No newline at end of file
ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java
View file @
b2d79b62
...
@@ -337,9 +337,14 @@ public class GenTableServiceImpl implements IGenTableService
...
@@ -337,9 +337,14 @@ public class GenTableServiceImpl implements IGenTableService
String
treeCode
=
paramsObj
.
getString
(
GenConstants
.
TREE_CODE
);
String
treeCode
=
paramsObj
.
getString
(
GenConstants
.
TREE_CODE
);
String
treeParentCode
=
paramsObj
.
getString
(
GenConstants
.
TREE_PARENT_CODE
);
String
treeParentCode
=
paramsObj
.
getString
(
GenConstants
.
TREE_PARENT_CODE
);
String
treeName
=
paramsObj
.
getString
(
GenConstants
.
TREE_NAME
);
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
.
setTreeCode
(
treeCode
);
genTable
.
setTreeParentCode
(
treeParentCode
);
genTable
.
setTreeParentCode
(
treeParentCode
);
genTable
.
setTreeName
(
treeName
);
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 @
b2d79b62
...
@@ -11,18 +11,16 @@ import com.ruoyi.common.utils.StringUtils;
...
@@ -11,18 +11,16 @@ import com.ruoyi.common.utils.StringUtils;
import
com.ruoyi.generator.domain.GenTable
;
import
com.ruoyi.generator.domain.GenTable
;
import
com.ruoyi.generator.domain.GenTableColumn
;
import
com.ruoyi.generator.domain.GenTableColumn
;
/**
* 代码生成模板处理
*
* @author ruoyi
*/
public
class
VelocityUtils
public
class
VelocityUtils
{
{
/** 项目空间路径 */
/** 项目空间路径 */
private
static
final
String
PROJECT_PATH
=
"main/java"
;
private
static
final
String
PROJECT_PATH
=
"main/java"
;
/** mybatis空间路径 */
/** mybatis空间路径 */
private
static
final
String
MYBATIS_PATH
=
"main/resources/mapper"
;
private
static
final
String
MYBATIS_PATH
=
"main/resources/mybatis"
;
/** 默认上级菜单,系统工具 */
private
static
final
String
DEFAULT_PARENT_MENU_ID
=
"3"
;
/**
/**
* 设置模板变量信息
* 设置模板变量信息
...
@@ -55,6 +53,7 @@ public class VelocityUtils
...
@@ -55,6 +53,7 @@ public class VelocityUtils
velocityContext
.
put
(
"permissionPrefix"
,
getPermissionPrefix
(
moduleName
,
businessName
));
velocityContext
.
put
(
"permissionPrefix"
,
getPermissionPrefix
(
moduleName
,
businessName
));
velocityContext
.
put
(
"columns"
,
genTable
.
getColumns
());
velocityContext
.
put
(
"columns"
,
genTable
.
getColumns
());
velocityContext
.
put
(
"table"
,
genTable
);
velocityContext
.
put
(
"table"
,
genTable
);
setMenuVelocityContext
(
velocityContext
,
genTable
);
if
(
GenConstants
.
TPL_TREE
.
equals
(
tplCategory
))
if
(
GenConstants
.
TPL_TREE
.
equals
(
tplCategory
))
{
{
setTreeVelocityContext
(
velocityContext
,
genTable
);
setTreeVelocityContext
(
velocityContext
,
genTable
);
...
@@ -62,6 +61,14 @@ public class VelocityUtils
...
@@ -62,6 +61,14 @@ public class VelocityUtils
return
velocityContext
;
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
)
public
static
void
setTreeVelocityContext
(
VelocityContext
context
,
GenTable
genTable
)
{
{
String
options
=
genTable
.
getOptions
();
String
options
=
genTable
.
getOptions
();
...
@@ -224,6 +231,21 @@ public class VelocityUtils
...
@@ -224,6 +231,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
;
}
/**
/**
* 获取树编码
* 获取树编码
*
*
...
@@ -236,7 +258,7 @@ public class VelocityUtils
...
@@ -236,7 +258,7 @@ public class VelocityUtils
{
{
return
StringUtils
.
toCamelCase
(
paramsObj
.
getString
(
GenConstants
.
TREE_CODE
));
return
StringUtils
.
toCamelCase
(
paramsObj
.
getString
(
GenConstants
.
TREE_CODE
));
}
}
return
""
;
return
StringUtils
.
EMPTY
;
}
}
/**
/**
...
@@ -251,7 +273,7 @@ public class VelocityUtils
...
@@ -251,7 +273,7 @@ public class VelocityUtils
{
{
return
StringUtils
.
toCamelCase
(
paramsObj
.
getString
(
GenConstants
.
TREE_PARENT_CODE
));
return
StringUtils
.
toCamelCase
(
paramsObj
.
getString
(
GenConstants
.
TREE_PARENT_CODE
));
}
}
return
""
;
return
StringUtils
.
EMPTY
;
}
}
/**
/**
...
@@ -266,7 +288,7 @@ public class VelocityUtils
...
@@ -266,7 +288,7 @@ public class VelocityUtils
{
{
return
StringUtils
.
toCamelCase
(
paramsObj
.
getString
(
GenConstants
.
TREE_NAME
));
return
StringUtils
.
toCamelCase
(
paramsObj
.
getString
(
GenConstants
.
TREE_NAME
));
}
}
return
""
;
return
StringUtils
.
EMPTY
;
}
}
/**
/**
...
@@ -295,4 +317,4 @@ public class VelocityUtils
...
@@ -295,4 +317,4 @@ public class VelocityUtils
}
}
return
num
;
return
num
;
}
}
}
}
\ No newline at end of file
ruoyi-generator/src/main/resources/vm/sql/sql.vm
View file @
b2d79b62
-- 菜单 SQL
-- 菜单 SQL
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('${functionName}', '
3
', '1', '${businessName}', '${moduleName}/${businessName}/index', 1, 'C', '0', '0', '${permissionPrefix}:list', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '${functionName}菜单');
values('${functionName}', '
${parentMenuId}
', '1', '${businessName}', '${moduleName}/${businessName}/index', 1, 'C', '0', '0', '${permissionPrefix}:list', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '${functionName}菜单');
-- 按钮父菜单ID
-- 按钮父菜单ID
SELECT @parentId := LAST_INSERT_ID();
SELECT @parentId := LAST_INSERT_ID();
...
...
ruoyi-ui/src/views/tool/gen/editTable.vue
View file @
b2d79b62
...
@@ -110,7 +110,7 @@
...
@@ -110,7 +110,7 @@
</el-table>
</el-table>
</el-tab-pane>
</el-tab-pane>
<el-tab-pane
label=
"生成信息"
name=
"genInfo"
>
<el-tab-pane
label=
"生成信息"
name=
"genInfo"
>
<gen-info-form
ref=
"genInfo"
:info=
"info"
/>
<gen-info-form
ref=
"genInfo"
:info=
"info"
:menus=
"menus"
/>
</el-tab-pane>
</el-tab-pane>
</el-tabs>
</el-tabs>
<el-form
label-width=
"100px"
>
<el-form
label-width=
"100px"
>
...
@@ -124,9 +124,11 @@
...
@@ -124,9 +124,11 @@
<
script
>
<
script
>
import
{
getGenTable
,
updateGenTable
}
from
"
@/api/tool/gen
"
;
import
{
getGenTable
,
updateGenTable
}
from
"
@/api/tool/gen
"
;
import
{
optionselect
as
getDictOptionselect
}
from
"
@/api/system/dict/type
"
;
import
{
optionselect
as
getDictOptionselect
}
from
"
@/api/system/dict/type
"
;
import
{
listMenu
as
getMenuTreeselect
}
from
"
@/api/system/menu
"
;
import
basicInfoForm
from
"
./basicInfoForm
"
;
import
basicInfoForm
from
"
./basicInfoForm
"
;
import
genInfoForm
from
"
./genInfoForm
"
;
import
genInfoForm
from
"
./genInfoForm
"
;
import
Sortable
from
'
sortablejs
'
import
Sortable
from
'
sortablejs
'
export
default
{
export
default
{
name
:
"
GenEdit
"
,
name
:
"
GenEdit
"
,
components
:
{
components
:
{
...
@@ -143,6 +145,8 @@ export default {
...
@@ -143,6 +145,8 @@ export default {
cloumns
:
[],
cloumns
:
[],
// 字典信息
// 字典信息
dictOptions
:
[],
dictOptions
:
[],
// 菜单信息
menus
:
[],
// 表详细信息
// 表详细信息
info
:
{}
info
:
{}
};
};
...
@@ -159,6 +163,10 @@ export default {
...
@@ -159,6 +163,10 @@ export default {
getDictOptionselect
().
then
(
response
=>
{
getDictOptionselect
().
then
(
response
=>
{
this
.
dictOptions
=
response
.
data
;
this
.
dictOptions
=
response
.
data
;
});
});
/** 查询菜单下拉列表 */
getMenuTreeselect
().
then
(
response
=>
{
this
.
menus
=
this
.
handleTree
(
response
.
data
,
"
menuId
"
);
});
}
}
},
},
methods
:
{
methods
:
{
...
@@ -174,7 +182,8 @@ export default {
...
@@ -174,7 +182,8 @@ export default {
genTable
.
params
=
{
genTable
.
params
=
{
treeCode
:
genTable
.
treeCode
,
treeCode
:
genTable
.
treeCode
,
treeName
:
genTable
.
treeName
,
treeName
:
genTable
.
treeName
,
treeParentCode
:
genTable
.
treeParentCode
treeParentCode
:
genTable
.
treeParentCode
,
parentMenuId
:
genTable
.
parentMenuId
};
};
updateGenTable
(
genTable
).
then
(
res
=>
{
updateGenTable
(
genTable
).
then
(
res
=>
{
this
.
msgSuccess
(
res
.
msg
);
this
.
msgSuccess
(
res
.
msg
);
...
...
ruoyi-ui/src/views/tool/gen/genInfoForm.vue
View file @
b2d79b62
...
@@ -58,6 +58,18 @@
...
@@ -58,6 +58,18 @@
<el-input
v-model=
"info.functionName"
/>
<el-input
v-model=
"info.functionName"
/>
</el-form-item>
</el-form-item>
</el-col>
</el-col>
<el-col
:span=
"12"
>
<el-form-item
prop=
"functionName"
>
<span
slot=
"label"
>
上级菜单
<el-tooltip
content=
"分配到指定菜单下,例如 系统管理"
placement=
"top"
>
<i
class=
"el-icon-question"
></i>
</el-tooltip>
</span>
<treeselect
:append-to-body=
"true"
v-model=
"info.parentMenuId"
:options=
"menus"
:normalizer=
"normalizer"
:show-count=
"true"
placeholder=
"请选择系统菜单"
/>
</el-form-item>
</el-col>
</el-row>
</el-row>
<el-row
v-show=
"info.tplCategory == 'tree'"
>
<el-row
v-show=
"info.tplCategory == 'tree'"
>
...
@@ -120,13 +132,21 @@
...
@@ -120,13 +132,21 @@
</el-form>
</el-form>
</
template
>
</
template
>
<
script
>
<
script
>
import
Treeselect
from
"
@riophae/vue-treeselect
"
;
import
"
@riophae/vue-treeselect/dist/vue-treeselect.css
"
;
export
default
{
export
default
{
name
:
"
BasicInfoForm
"
,
name
:
"
BasicInfoForm
"
,
components
:
{
Treeselect
},
props
:
{
props
:
{
info
:
{
info
:
{
type
:
Object
,
type
:
Object
,
default
:
null
default
:
null
}
},
menus
:
{
type
:
Array
,
default
:
[]
},
},
},
data
()
{
data
()
{
return
{
return
{
...
@@ -149,6 +169,19 @@ export default {
...
@@ -149,6 +169,19 @@ export default {
}
}
};
};
},
},
created
()
{}
created
()
{},
methods
:
{
/** 转换菜单数据结构 */
normalizer
(
node
)
{
if
(
node
.
children
&&
!
node
.
children
.
length
)
{
delete
node
.
children
;
}
return
{
id
:
node
.
menuId
,
label
:
node
.
menuName
,
children
:
node
.
children
};
}
}
};
};
</
script
>
</
script
>
ruoyi-ui/src/views/tool/gen/importTable.vue
View file @
b2d79b62
...
@@ -28,8 +28,8 @@
...
@@ -28,8 +28,8 @@
<el-row>
<el-row>
<el-table
@
row-click=
"clickRow"
ref=
"table"
:data=
"dbTableList"
@
selection-change=
"handleSelectionChange"
height=
"260px"
>
<el-table
@
row-click=
"clickRow"
ref=
"table"
:data=
"dbTableList"
@
selection-change=
"handleSelectionChange"
height=
"260px"
>
<el-table-column
type=
"selection"
width=
"55"
></el-table-column>
<el-table-column
type=
"selection"
width=
"55"
></el-table-column>
<el-table-column
prop=
"tableName"
label=
"表名称"
></el-table-column>
<el-table-column
prop=
"tableName"
label=
"表名称"
:show-overflow-tooltip=
"true"
></el-table-column>
<el-table-column
prop=
"tableComment"
label=
"表描述"
></el-table-column>
<el-table-column
prop=
"tableComment"
label=
"表描述"
:show-overflow-tooltip=
"true"
></el-table-column>
<el-table-column
prop=
"createTime"
label=
"创建时间"
></el-table-column>
<el-table-column
prop=
"createTime"
label=
"创建时间"
></el-table-column>
<el-table-column
prop=
"updateTime"
label=
"更新时间"
></el-table-column>
<el-table-column
prop=
"updateTime"
label=
"更新时间"
></el-table-column>
</el-table>
</el-table>
...
...
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