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
JeeSpringCloudV3.0
Commits
18c62d62
Commit
18c62d62
authored
Oct 16, 2018
by
HuangBingGui
Browse files
no commit message
parent
cb1753ac
Changes
2
Hide whitespace changes
Inline
Side-by-side
JeeSpringCloud/src/main/java/com/jeespring/common/utils/FreeMarkers.java
View file @
18c62d62
...
...
@@ -21,13 +21,14 @@ import freemarker.template.Template;
*/
public
class
FreeMarkers
{
public
static
String
renderString
(
String
templateString
,
Map
<
String
,
?>
model
)
{
public
static
String
renderString
(
String
name
,
String
templateString
,
Map
<
String
,
?>
model
)
{
try
{
StringWriter
result
=
new
StringWriter
();
Template
t
=
new
Template
(
"name"
,
new
StringReader
(
templateString
),
new
Configuration
());
t
.
process
(
model
,
result
);
return
result
.
toString
();
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"代码生成执行:"
+
name
+
"文件时异常!"
);
throw
Exceptions
.
unchecked
(
e
);
}
}
...
...
JeeSpringCloud/src/main/java/com/jeespring/modules/gen/util/GenUtils.java
View file @
18c62d62
...
...
@@ -317,13 +317,13 @@ public class GenUtils
public
static
String
generateToFile
(
GenTemplate
tpl
,
Map
model
,
boolean
isReplaceFile
)
{
String
fileName
=
Global
.
getProjectPath
()
+
File
.
separator
+
StringUtils
.
replaceEach
(
FreeMarkers
.
renderString
(
new
StringBuilder
(
String
.
valueOf
(
tpl
.
getFilePath
())).
append
(
"/"
).
toString
(),
model
),
StringUtils
.
replaceEach
(
FreeMarkers
.
renderString
(
tpl
.
getFileName
(),
new
StringBuilder
(
String
.
valueOf
(
tpl
.
getFilePath
())).
append
(
"/"
).
toString
(),
model
),
new
String
[]
{
"//"
,
"/"
,
".."
,
"."
},
new
String
[]
{
File
.
separator
,
File
.
separator
,
"__"
,
File
.
separator
}).
replace
(
"__"
,
".."
)
+
FreeMarkers
.
renderString
(
tpl
.
getFileName
(),
model
);
FreeMarkers
.
renderString
(
tpl
.
getFileName
(),
tpl
.
getFileName
(),
model
);
logger
.
debug
(
" fileName === "
+
fileName
);
String
content
=
FreeMarkers
.
renderString
(
StringUtils
.
trimToEmpty
(
tpl
.
getContent
()),
model
);
String
content
=
FreeMarkers
.
renderString
(
tpl
.
getFileName
(),
StringUtils
.
trimToEmpty
(
tpl
.
getContent
()),
model
);
logger
.
debug
(
" content === \r\n"
+
content
);
if
(
isReplaceFile
)
{
FileUtils
.
deleteFile
(
fileName
);
...
...
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