Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Springboot Plus
Commits
0c282664
Commit
0c282664
authored
Apr 29, 2018
by
xiandafu
Browse files
add menu auto gen
parent
71995bc5
Changes
4
Hide whitespace changes
Inline
Side-by-side
admin-core/src/main/java/com/ibeetl/admin/core/gen/model/Entity.java
View file @
0c282664
...
...
@@ -19,6 +19,8 @@ public class Entity {
boolean
attachment
=
false
;
//是否生成代码,也同时生成功能点
boolean
autoAddFunction
=
false
;
boolean
autoAddMenu
=
false
;
public
String
getName
()
{
return
name
;
}
...
...
@@ -106,5 +108,11 @@ public class Entity {
public
void
setAutoAddFunction
(
boolean
autoAddFunction
)
{
this
.
autoAddFunction
=
autoAddFunction
;
}
public
boolean
isAutoAddMenu
()
{
return
autoAddMenu
;
}
public
void
setAutoAddMenu
(
boolean
autoAddMenu
)
{
this
.
autoAddMenu
=
autoAddMenu
;
}
}
admin-core/src/main/java/com/ibeetl/admin/core/service/CoreCodeGenService.java
View file @
0c282664
...
...
@@ -5,6 +5,8 @@ import java.util.Date;
import
java.util.List
;
import
java.util.Set
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.beetl.sql.core.JavaType
;
import
org.beetl.sql.core.NameConversion
;
import
org.beetl.sql.core.SQLManager
;
...
...
@@ -16,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
com.ibeetl.admin.core.entity.CoreFunction
;
import
com.ibeetl.admin.core.entity.CoreMenu
;
import
com.ibeetl.admin.core.gen.model.Attribute
;
import
com.ibeetl.admin.core.gen.model.Entity
;
...
...
@@ -31,6 +34,8 @@ public class CoreCodeGenService {
@Autowired
CorePlatformService
platformService
;
Log
log
=
LogFactory
.
getLog
(
CoreCodeGenService
.
class
);
public
List
<
Entity
>
getAllEntityInfo
(){
MetadataManager
meta
=
sqlManager
.
getMetaDataManager
();
Set
<
String
>
set
=
meta
.
allTable
();
...
...
@@ -103,7 +108,7 @@ public class CoreCodeGenService {
return
e
;
}
public
boolean
insertFunction
(
Entity
data
,
String
urlBase
){
public
Long
insertFunction
(
Entity
data
,
String
urlBase
){
String
preffix
=
urlBase
.
replace
(
'/'
,
'.'
);
String
functionCode
=
preffix
+
"."
+
data
.
getCode
();
String
indexFunctonCode
=
functionCode
+
".query"
;
...
...
@@ -111,10 +116,10 @@ public class CoreCodeGenService {
query
.
setCode
(
indexFunctonCode
);
Object
o
=
sqlManager
.
templateOne
(
query
);
if
(
o
!=
null
){
return
true
;
return
-
1
l
;
}
//设置功能点
//设置
父
功能点
CoreFunction
rootFunction
=
new
CoreFunction
();
rootFunction
.
setName
(
data
.
getDisplayName
());
rootFunction
.
setCode
(
functionCode
);
...
...
@@ -167,6 +172,27 @@ public class CoreCodeGenService {
//刷新缓存
platformService
.
clearFunctionCache
();
return
indexFunction
.
getId
();
}
public
boolean
insertMenu
(
Long
functionId
,
Entity
data
,
String
urlBase
){
CoreMenu
query
=
new
CoreMenu
();
query
.
setCode
(
"代码生成导航"
);
CoreMenu
menu
=
this
.
sqlManager
.
templateOne
(
query
);
if
(
menu
==
null
)
{
log
.
warn
(
"未找到对应的父菜单:"
+
query
.
getCode
());
return
false
;
}
Long
parentId
=
query
.
getId
();
CoreMenu
newMenu
=
new
CoreMenu
();
newMenu
.
setCode
(
data
.
getName
()+
".Manager"
);
newMenu
.
setName
(
data
.
getName
()+
"管理"
);
newMenu
.
setParentMenuId
(
parentId
);
newMenu
.
setFunctionId
(
functionId
);
newMenu
.
setType
(
"MENU_M"
);
this
.
sqlManager
.
insert
(
newMenu
);
this
.
platformService
.
clearMenuCache
();
return
true
;
}
...
...
admin-core/src/main/java/com/ibeetl/admin/core/web/CoreCodeGenController.java
View file @
0c282664
...
...
@@ -284,6 +284,10 @@ public class CoreCodeGenController {
String
code
=
entry
.
getValue
();
content
.
put
(
gen
.
getName
(),
code
);
}
return
JsonResult
.
success
(
content
);
}
...
...
@@ -320,6 +324,7 @@ public class CoreCodeGenController {
entity
.
setAttachment
(
data
.
entity
.
isAttachment
());
entity
.
setIncludeExcel
(
data
.
entity
.
isIncludeExcel
());
entity
.
setAutoAddFunction
(
info
.
isAutoAddFunction
());
entity
.
setAutoAddMenu
(
info
.
isAutoAddFunction
());
for
(
int
i
=
0
;
i
<
entity
.
getList
().
size
();
i
++)
{
Attribute
attr
=
entity
.
getList
().
get
(
i
);
attr
.
setDisplayName
(
info
.
getList
().
get
(
i
).
getDisplayName
());
...
...
admin-core/src/main/resources/templates/core/codeGen/edit.html
View file @
0c282664
...
...
@@ -145,10 +145,19 @@
<div
class=
"layui-input-inline"
>
<input
type=
"checkbox"
name=
"entity.autoAddFunction"
lay-skin=
"primary"
value=
"true"
title=
"自动配置到功能点"
/>
lay-skin=
"primary"
value=
"true"
title=
" 自动配置功能点"
/>
</div>
<div
class=
"layui-input-inline"
>
<input
type=
"checkbox"
name=
"entity.autoAddMenu"
lay-skin=
"primary"
value=
"true"
title=
"自动添加到菜单"
/>
</div>
</div>
</div>
</div>
...
...
Write
Preview
Supports
Markdown
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