Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
guns-vip
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenjunxiong
guns-vip
Commits
2690c232
Commit
2690c232
authored
May 08, 2017
by
fsn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
对主页面html的模板化
parent
fa5d5b6a
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
105 additions
and
6 deletions
+105
-6
src/main/baseResources/gunsTemplate/Controller.java.btl
+1
-1
src/main/baseResources/gunsTemplate/page.html.btl
+38
-0
src/main/java/com/stylefeng/guns/core/template/config/ContextConfig.java
+12
-0
src/main/java/com/stylefeng/guns/core/template/config/PageConfig.java
+20
-0
src/main/java/com/stylefeng/guns/core/template/engine/AbstractTemplateEngine.java
+10
-0
src/main/java/com/stylefeng/guns/core/template/engine/GunsTemplateEngine.java
+24
-5
No files found.
src/main/baseResources/gunsTemplate/Controller.java.btl
View file @
2690c232
...
@@ -12,7 +12,7 @@ import ${import};
...
@@ -12,7 +12,7 @@ import ${import};
*/
*/
@
Controller
@
Controller
@
RequestMapping
(
"/${context.bizEnName}"
)
@
RequestMapping
(
"/${context.bizEnName}"
)
public
class
${
tool
.
firstLetterToUpper
(
context
.
bizEnName
)
}
Controller
extends
BaseController
{
public
class
${
context
.
bizEnBigName
}
Controller
extends
BaseController
{
private
String
PREFIX
=
"/system/${context.bizEnName}/"
;
private
String
PREFIX
=
"/system/${context.bizEnName}/"
;
...
...
src/main/baseResources/gunsTemplate/page.html.btl
0 → 100644
View file @
2690c232
@layout("/common/_container.html"){
<div class="row">
<div class="col-sm-12">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>${context.bizChName}管理</h5>
</div>
<div class="ibox-content">
<div class="row row-lg">
<div class="col-sm-12">
<div class="row">
<div class="col-sm-3">
<#NameCon id="condition" name="名称" />
</div>
<div class="col-sm-3">
<#button name="搜索" icon="fa-search" clickFun="${context.bizEnBigName}.search()"/>
</div>
</div>
<div class="hidden-xs" id="${context.bizEnBigName}TableToolbar" role="group">
@if(shiro.hasPermission("/${context.bizEnName}/add")){
<#button name="添加" icon="fa-plus" clickFun="${context.bizEnBigName}.openAdd${context.bizEnBigName}()"/>
@}
@if(shiro.hasPermission("/${context.bizEnName}/update")){
<#button name="修改" icon="fa-plus" clickFun="${context.bizEnBigName}.open${context.bizEnBigName}Detail()" space="true"/>
@}
@if(shiro.hasPermission("/${context.bizEnName}/delete")){
<#button name="删除" icon="fa-plus" clickFun="${context.bizEnBigName}.delete()" space="true"/>
@}
</div>
<#table id="${context.bizEnBigName}Table"/>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="\${ctxPath}/static/modular/system/${context.bizEnName}/${context.bizEnName}.js"></script>
@}
src/main/java/com/stylefeng/guns/core/template/config/ContextConfig.java
View file @
2690c232
package
com
.
stylefeng
.
guns
.
core
.
template
.
config
;
package
com
.
stylefeng
.
guns
.
core
.
template
.
config
;
import
com.stylefeng.guns.core.util.ToolUtil
;
/**
/**
* 全局配置
* 全局配置
*
*
...
@@ -11,6 +13,15 @@ public class ContextConfig {
...
@@ -11,6 +13,15 @@ public class ContextConfig {
private
String
projectPath
=
"D:\\ideaSpace\\guns"
;
//模板输出的项目目录
private
String
projectPath
=
"D:\\ideaSpace\\guns"
;
//模板输出的项目目录
private
String
bizChName
;
//业务名称
private
String
bizChName
;
//业务名称
private
String
bizEnName
;
//业务英文名称
private
String
bizEnName
;
//业务英文名称
private
String
bizEnBigName
;
//业务英文名称(大写)
public
String
getBizEnBigName
()
{
return
bizEnBigName
;
}
public
void
setBizEnBigName
(
String
bizEnBigName
)
{
this
.
bizEnBigName
=
bizEnBigName
;
}
public
String
getBizChName
()
{
public
String
getBizChName
()
{
return
bizChName
;
return
bizChName
;
...
@@ -26,6 +37,7 @@ public class ContextConfig {
...
@@ -26,6 +37,7 @@ public class ContextConfig {
public
void
setBizEnName
(
String
bizEnName
)
{
public
void
setBizEnName
(
String
bizEnName
)
{
this
.
bizEnName
=
bizEnName
;
this
.
bizEnName
=
bizEnName
;
this
.
bizEnBigName
=
ToolUtil
.
firstLetterToUpper
(
this
.
bizEnName
);
}
}
public
String
getProjectPath
()
{
public
String
getProjectPath
()
{
...
...
src/main/java/com/stylefeng/guns/core/template/config/PageConfig.java
0 → 100644
View file @
2690c232
package
com
.
stylefeng
.
guns
.
core
.
template
.
config
;
/**
* 控制器模板生成的配置
*
* @author fengshuonan
* @date 2017-05-07 22:12
*/
public
class
PageConfig
{
private
String
pagePathTemplate
=
"\\src\\main\\webapp\\WEB-INF\\view\\system\\{}\\{}.html"
;
public
String
getPagePathTemplate
()
{
return
pagePathTemplate
;
}
public
void
setPagePathTemplate
(
String
pagePathTemplate
)
{
this
.
pagePathTemplate
=
pagePathTemplate
;
}
}
src/main/java/com/stylefeng/guns/core/template/engine/AbstractTemplateEngine.java
View file @
2690c232
...
@@ -2,6 +2,7 @@ package com.stylefeng.guns.core.template.engine;
...
@@ -2,6 +2,7 @@ package com.stylefeng.guns.core.template.engine;
import
com.stylefeng.guns.core.template.config.ContextConfig
;
import
com.stylefeng.guns.core.template.config.ContextConfig
;
import
com.stylefeng.guns.core.template.config.ControllerConfig
;
import
com.stylefeng.guns.core.template.config.ControllerConfig
;
import
com.stylefeng.guns.core.template.config.PageConfig
;
/**
/**
* 模板生成父类
* 模板生成父类
...
@@ -13,6 +14,15 @@ public class AbstractTemplateEngine {
...
@@ -13,6 +14,15 @@ public class AbstractTemplateEngine {
private
ContextConfig
contextConfig
=
new
ContextConfig
();
//全局配置
private
ContextConfig
contextConfig
=
new
ContextConfig
();
//全局配置
private
ControllerConfig
controllerConfig
=
new
ControllerConfig
();
//控制器的配置
private
ControllerConfig
controllerConfig
=
new
ControllerConfig
();
//控制器的配置
private
PageConfig
pageConfig
=
new
PageConfig
();
//页面的控制器
public
PageConfig
getPageConfig
()
{
return
pageConfig
;
}
public
void
setPageConfig
(
PageConfig
pageConfig
)
{
this
.
pageConfig
=
pageConfig
;
}
public
ContextConfig
getContextConfig
()
{
public
ContextConfig
getContextConfig
()
{
return
contextConfig
;
return
contextConfig
;
...
...
src/main/java/com/stylefeng/guns/core/template/engine/GunsTemplateEngine.java
View file @
2690c232
...
@@ -7,6 +7,7 @@ import org.beetl.core.GroupTemplate;
...
@@ -7,6 +7,7 @@ import org.beetl.core.GroupTemplate;
import
org.beetl.core.Template
;
import
org.beetl.core.Template
;
import
org.beetl.core.resource.ClasspathResourceLoader
;
import
org.beetl.core.resource.ClasspathResourceLoader
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.Properties
;
import
java.util.Properties
;
...
@@ -30,6 +31,7 @@ public class GunsTemplateEngine extends AbstractTemplateEngine {
...
@@ -30,6 +31,7 @@ public class GunsTemplateEngine extends AbstractTemplateEngine {
properties
.
put
(
"RESOURCE.root"
,
""
);
properties
.
put
(
"RESOURCE.root"
,
""
);
properties
.
put
(
"DELIMITER_STATEMENT_START"
,
"<%"
);
properties
.
put
(
"DELIMITER_STATEMENT_START"
,
"<%"
);
properties
.
put
(
"DELIMITER_STATEMENT_END"
,
"%>"
);
properties
.
put
(
"DELIMITER_STATEMENT_END"
,
"%>"
);
properties
.
put
(
"HTML_TAG_FLAG"
,
"##"
);
Configuration
cfg
=
null
;
Configuration
cfg
=
null
;
try
{
try
{
cfg
=
new
Configuration
(
properties
);
cfg
=
new
Configuration
(
properties
);
...
@@ -41,15 +43,32 @@ public class GunsTemplateEngine extends AbstractTemplateEngine {
...
@@ -41,15 +43,32 @@ public class GunsTemplateEngine extends AbstractTemplateEngine {
groupTemplate
.
registerFunctionPackage
(
"tool"
,
new
ToolUtil
());
groupTemplate
.
registerFunctionPackage
(
"tool"
,
new
ToolUtil
());
}
}
public
void
start
()
throws
IOException
{
public
void
configTemplate
(
Template
template
){
//初始化控制器模板
Template
template
=
groupTemplate
.
getTemplate
(
"gunsTemplate/Controller.java.btl"
);
template
.
binding
(
"controller"
,
super
.
getControllerConfig
());
template
.
binding
(
"controller"
,
super
.
getControllerConfig
());
template
.
binding
(
"context"
,
super
.
getContextConfig
());
template
.
binding
(
"context"
,
super
.
getContextConfig
());
String
format
=
ToolUtil
.
format
(
super
.
getContextConfig
().
getProjectPath
()
+
super
.
getControllerConfig
().
getControllerPathTemplate
(),
}
public
void
start
()
throws
IOException
{
//初始化控制器模板
Template
controllerTemplate
=
groupTemplate
.
getTemplate
(
"gunsTemplate/Controller.java.btl"
);
configTemplate
(
controllerTemplate
);
String
controllerPath
=
ToolUtil
.
format
(
super
.
getContextConfig
().
getProjectPath
()
+
super
.
getControllerConfig
().
getControllerPathTemplate
(),
ToolUtil
.
firstLetterToUpper
(
super
.
getContextConfig
().
getBizEnName
()));
ToolUtil
.
firstLetterToUpper
(
super
.
getContextConfig
().
getBizEnName
()));
template
.
renderTo
(
new
FileOutputStream
(
format
));
controllerTemplate
.
renderTo
(
new
FileOutputStream
(
controllerPath
));
System
.
out
.
println
(
"生成控制器成功!"
);
System
.
out
.
println
(
"生成控制器成功!"
);
//初始化主页面html
Template
pageTemplate
=
groupTemplate
.
getTemplate
(
"gunsTemplate/page.html.btl"
);
configTemplate
(
pageTemplate
);
String
pagePath
=
ToolUtil
.
format
(
super
.
getContextConfig
().
getProjectPath
()
+
super
.
getPageConfig
().
getPagePathTemplate
(),
super
.
getContextConfig
().
getBizEnName
(),
super
.
getContextConfig
().
getBizEnName
());
File
file
=
new
File
(
pagePath
);
File
parentFile
=
file
.
getParentFile
();
if
(!
parentFile
.
exists
()){
parentFile
.
mkdirs
();
}
pageTemplate
.
renderTo
(
new
FileOutputStream
(
file
));
System
.
out
.
println
(
"生成页面成功!"
);
}
}
public
static
void
main
(
String
[]
args
)
throws
IOException
{
public
static
void
main
(
String
[]
args
)
throws
IOException
{
...
...
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