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
Eladmin
Commits
98838542
Commit
98838542
authored
Dec 19, 2020
by
zhengjie
Browse files
[代码优化](v2.6):代码生成优化
parent
46393875
Changes
4
Hide whitespace changes
Inline
Side-by-side
eladmin-generator/src/main/java/me/zhengjie/service/impl/GenConfigServiceImpl.java
View file @
98838542
...
@@ -44,27 +44,24 @@ public class GenConfigServiceImpl implements GenConfigService {
...
@@ -44,27 +44,24 @@ public class GenConfigServiceImpl implements GenConfigService {
@Override
@Override
public
GenConfig
update
(
String
tableName
,
GenConfig
genConfig
)
{
public
GenConfig
update
(
String
tableName
,
GenConfig
genConfig
)
{
// 如果 api 路径为空,则自动生成路径
String
separator
=
File
.
separator
;
if
(
StringUtils
.
isBlank
(
genConfig
.
getApiPath
())){
String
[]
paths
;
String
separator
=
File
.
separator
;
String
symbol
=
"\\"
;
String
[]
paths
;
if
(
symbol
.
equals
(
separator
))
{
String
symbol
=
"\\"
;
paths
=
genConfig
.
getPath
().
split
(
"\\\\"
);
if
(
symbol
.
equals
(
separator
))
{
}
else
{
paths
=
genConfig
.
getPath
().
split
(
"\\\\"
);
paths
=
genConfig
.
getPath
().
split
(
File
.
separator
);
}
else
{
}
paths
=
genConfig
.
getPath
().
split
(
File
.
separator
);
StringBuilder
api
=
new
StringBuilder
();
}
for
(
String
path
:
paths
)
{
StringBuilder
api
=
new
StringBuilder
();
api
.
append
(
path
);
for
(
String
path
:
paths
)
{
api
.
append
(
separator
);
api
.
append
(
path
);
if
(
"src"
.
equals
(
path
))
{
api
.
append
(
separator
);
api
.
append
(
"api"
);
if
(
"src"
.
equals
(
path
))
{
break
;
api
.
append
(
"api"
);
break
;
}
}
}
genConfig
.
setApiPath
(
api
.
toString
());
}
}
genConfig
.
setApiPath
(
api
.
toString
());
return
genConfigRepository
.
save
(
genConfig
);
return
genConfigRepository
.
save
(
genConfig
);
}
}
}
}
eladmin-generator/src/main/java/me/zhengjie/utils/GenUtil.java
View file @
98838542
...
@@ -152,7 +152,8 @@ public class GenUtil {
...
@@ -152,7 +152,8 @@ public class GenUtil {
List
<
String
>
templates
=
getAdminTemplateNames
();
List
<
String
>
templates
=
getAdminTemplateNames
();
for
(
String
templateName
:
templates
)
{
for
(
String
templateName
:
templates
)
{
Template
template
=
engine
.
getTemplate
(
"generator/admin/"
+
templateName
+
".ftl"
);
Template
template
=
engine
.
getTemplate
(
"generator/admin/"
+
templateName
+
".ftl"
);
String
filePath
=
getAdminFilePath
(
templateName
,
genConfig
,
genMap
.
get
(
"className"
).
toString
(),
System
.
getProperty
(
"user.dir"
));
String
rootPath
=
System
.
getProperty
(
"user.dir"
);
String
filePath
=
getAdminFilePath
(
templateName
,
genConfig
,
genMap
.
get
(
"className"
).
toString
(),
rootPath
);
assert
filePath
!=
null
;
assert
filePath
!=
null
;
File
file
=
new
File
(
filePath
);
File
file
=
new
File
(
filePath
);
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/MenuServiceImpl.java
View file @
98838542
...
@@ -15,8 +15,8 @@
...
@@ -15,8 +15,8 @@
*/
*/
package
me.zhengjie.modules.system.service.impl
;
package
me.zhengjie.modules.system.service.impl
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.StrUtil
;
import
lombok.RequiredArgsConstructor
;
import
lombok.RequiredArgsConstructor
;
import
me.zhengjie.modules.system.domain.Menu
;
import
me.zhengjie.modules.system.domain.Menu
;
import
me.zhengjie.modules.system.domain.Role
;
import
me.zhengjie.modules.system.domain.Role
;
...
@@ -268,15 +268,16 @@ public class MenuServiceImpl implements MenuService {
...
@@ -268,15 +268,16 @@ public class MenuServiceImpl implements MenuService {
// 如果不是外链
// 如果不是外链
if
(!
menuDTO
.
getIFrame
()){
if
(!
menuDTO
.
getIFrame
()){
if
(
menuDTO
.
getPid
()
==
null
){
if
(
menuDTO
.
getPid
()
==
null
){
menuVo
.
setComponent
(
StrUtil
.
isEmpty
(
menuDTO
.
getComponent
())?
"Layout"
:
menuDTO
.
getComponent
());
menuVo
.
setComponent
(
StringUtils
.
isEmpty
(
menuDTO
.
getComponent
())?
"Layout"
:
menuDTO
.
getComponent
());
}
else
if
(
menuDTO
.
getPid
()
!=
null
&&
menuDTO
.
getType
()
==
0
){
// 如果不是一级菜单,并且菜单类型为目录,则代表是多级菜单
menuVo
.
setComponent
(
StrUtil
.
isEmpty
(
menuDTO
.
getComponent
())?
"ParentView"
:
menuDTO
.
getComponent
());
}
else
if
(
menuDTO
.
getType
()
==
0
){
}
else
if
(!
StrUtil
.
isEmpty
(
menuDTO
.
getComponent
())){
menuVo
.
setComponent
(
StringUtils
.
isEmpty
(
menuDTO
.
getComponent
())?
"ParentView"
:
menuDTO
.
getComponent
());
}
else
if
(
StringUtils
.
isNoneBlank
(
menuDTO
.
getComponent
())){
menuVo
.
setComponent
(
menuDTO
.
getComponent
());
menuVo
.
setComponent
(
menuDTO
.
getComponent
());
}
}
}
}
menuVo
.
setMeta
(
new
MenuMetaVo
(
menuDTO
.
getTitle
(),
menuDTO
.
getIcon
(),!
menuDTO
.
getCache
()));
menuVo
.
setMeta
(
new
MenuMetaVo
(
menuDTO
.
getTitle
(),
menuDTO
.
getIcon
(),!
menuDTO
.
getCache
()));
if
(
menuDtoList
!=
null
&&
menuDtoList
.
size
()!=
0
){
if
(
CollectionUtil
.
isNotEmpty
(
menuDtoList
)
){
menuVo
.
setAlwaysShow
(
true
);
menuVo
.
setAlwaysShow
(
true
);
menuVo
.
setRedirect
(
"noredirect"
);
menuVo
.
setRedirect
(
"noredirect"
);
menuVo
.
setChildren
(
buildMenus
(
menuDtoList
));
menuVo
.
setChildren
(
buildMenus
(
menuDtoList
));
...
...
eladmin-system/src/main/resources/template/generator/admin/Entity.ftl
View file @
98838542
...
@@ -63,7 +63,7 @@ public class ${className} implements Serializable {
...
@@ -63,7 +63,7 @@ public class ${className} implements Serializable {
@
N
otNull
@
N
otNull
</#
if
>
</#
if
>
</#
if
>
</#
if
>
<#
if
(
column
.dateAnnotation
)
??>
<#
if
(
column
.dateAnnotation
)
??
&&
column
.dateAnnotation
!=
''
>
<#
if
column
.dateAnnotation
=
'
C
reationTimestamp
'>
<#
if
column
.dateAnnotation
=
'
C
reationTimestamp
'>
@
C
reationTimestamp
@
C
reationTimestamp
<#
else
>
<#
else
>
...
...
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