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
f33982ac
Commit
f33982ac
authored
Oct 30, 2017
by
stylefeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
升级代码生成
parent
b9ebe93c
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
22 deletions
+54
-22
guns-admin/src/main/java/generator/GunsCodeGenerator.java
+11
-8
guns-admin/src/main/java/generator/config/AbstractGeneratorConfig.java
+34
-6
guns-admin/src/main/java/generator/config/GunsGeneratorConfig.java
+9
-8
No files found.
guns-admin/src/main/java/generator/GunsCodeGenerator.java
View file @
f33982ac
package
generator
;
import
com.baomidou.mybatisplus.generator.AutoGenerator
;
import
com.stylefeng.guns.core.template.engine.base.GunsTemplateEngine
;
import
generator.config.GunsGeneratorConfig
;
/**
...
...
@@ -14,14 +12,18 @@ public class GunsCodeGenerator {
public
static
void
main
(
String
[]
args
)
{
//mp的生成器
/**
* Mybatis-Plus的代码生成器:
* mp的代码生成器可以生成实体,mapper,mapper对应的xml,service
*/
GunsGeneratorConfig
gunsGeneratorConfig
=
new
GunsGeneratorConfig
();
AutoGenerator
generator
=
gunsGeneratorConfig
.
getGenerator
();
generator
.
execute
();
gunsGeneratorConfig
.
doMpGeneration
();
//guns的生成器
GunsTemplateEngine
gunsTemplateEngine
=
gunsGeneratorConfig
.
getGunsTemplateEngine
();
gunsTemplateEngine
.
start
();
/**
* guns的生成器:
* guns的代码生成器可以生成controller,html页面,页面对应的js
*/
gunsGeneratorConfig
.
doGunsGeneration
();
}
}
\ No newline at end of file
guns-admin/src/main/java/generator/config/AbstractGeneratorConfig.java
View file @
f33982ac
...
...
@@ -8,6 +8,9 @@ import com.baomidou.mybatisplus.generator.config.StrategyConfig;
import
com.stylefeng.guns.core.template.config.ContextConfig
;
import
com.stylefeng.guns.core.template.engine.SimpleTemplateEngine
;
import
com.stylefeng.guns.core.template.engine.base.GunsTemplateEngine
;
import
com.stylefeng.guns.core.util.FileUtil
;
import
java.io.File
;
/**
* 代码生成的抽象配置
...
...
@@ -51,28 +54,53 @@ public abstract class AbstractGeneratorConfig {
packageConfig
();
contextConfig
();
//controller没用掉,生成之后会自动删掉
packageConfig
.
setController
(
"TTT"
);
packageConfig
.
setService
(
"com.stylefeng.guns.modular."
+
contextConfig
.
getModuleName
()
+
".service"
);
packageConfig
.
setServiceImpl
(
"com.stylefeng.guns.modular."
+
contextConfig
.
getModuleName
()
+
".service.impl"
);
//controller没用掉,生成之后会自动删掉
packageConfig
.
setController
(
"TTT"
);
if
(!
contextConfig
.
getEntitySwitch
()){
packageConfig
.
setEntity
(
"TTT"
);
}
if
(!
contextConfig
.
getDaoSwitch
()){
packageConfig
.
setMapper
(
"TTT"
);
packageConfig
.
setXml
(
"TTT"
);
}
if
(!
contextConfig
.
getServiceSwitch
()){
packageConfig
.
setService
(
"TTT"
);
packageConfig
.
setServiceImpl
(
"TTT"
);
}
}
/**
* 删除不必要的代码
*/
public
void
destory
(){
String
outputDir
=
globalConfig
.
getOutputDir
()
+
"/TTT"
;
FileUtil
.
deleteDir
(
new
File
(
outputDir
));
}
public
AbstractGeneratorConfig
()
{
init
();
}
public
AutoGenerator
getGenerator
()
{
public
void
doMpGeneration
()
{
AutoGenerator
autoGenerator
=
new
AutoGenerator
();
autoGenerator
.
setGlobalConfig
(
globalConfig
);
autoGenerator
.
setDataSource
(
dataSourceConfig
);
autoGenerator
.
setStrategy
(
strategyConfig
);
autoGenerator
.
setPackageInfo
(
packageConfig
);
return
autoGenerator
;
autoGenerator
.
execute
();
destory
();
}
public
GunsTemplateEngine
getGunsTemplateEngine
()
{
public
void
doGunsGeneration
()
{
GunsTemplateEngine
gunsTemplateEngine
=
new
SimpleTemplateEngine
();
gunsTemplateEngine
.
setContextConfig
(
contextConfig
);
return
gunsTemplateEngine
;
gunsTemplateEngine
.
start
()
;
}
}
guns-admin/src/main/java/generator/config/GunsGeneratorConfig.java
View file @
f33982ac
...
...
@@ -18,6 +18,7 @@ public class GunsGeneratorConfig extends AbstractGeneratorConfig {
globalConfig
.
setEnableCache
(
false
);
globalConfig
.
setBaseResultMap
(
true
);
globalConfig
.
setBaseColumnList
(
true
);
globalConfig
.
setOpen
(
false
);
globalConfig
.
setAuthor
(
"stylefeng"
);
}
...
...
@@ -33,7 +34,7 @@ public class GunsGeneratorConfig extends AbstractGeneratorConfig {
@Override
protected
void
strategyConfig
()
{
//strategy.setTablePrefix(new String[]{"_"});// 此处可以修改为您的表前缀
strategyConfig
.
setInclude
(
new
String
[]{
"bill"
});
//
strategyConfig.setInclude(new String[]{"bill"});
strategyConfig
.
setNaming
(
NamingStrategy
.
underline_to_camel
);
}
...
...
@@ -57,13 +58,13 @@ public class GunsGeneratorConfig extends AbstractGeneratorConfig {
* 生成器开关
*/
contextConfig
.
setEntitySwitch
(
true
);
contextConfig
.
setControllerSwitch
(
tru
e
);
contextConfig
.
setControllerSwitch
(
fals
e
);
contextConfig
.
setDaoSwitch
(
true
);
contextConfig
.
setServiceSwitch
(
tru
e
);
contextConfig
.
setIndexPageSwitch
(
tru
e
);
contextConfig
.
setAddPageSwitch
(
tru
e
);
contextConfig
.
setEditPageSwitch
(
tru
e
);
contextConfig
.
setJsSwitch
(
tru
e
);
contextConfig
.
setInfoJsSwitch
(
tru
e
);
contextConfig
.
setServiceSwitch
(
fals
e
);
contextConfig
.
setIndexPageSwitch
(
fals
e
);
contextConfig
.
setAddPageSwitch
(
fals
e
);
contextConfig
.
setEditPageSwitch
(
fals
e
);
contextConfig
.
setJsSwitch
(
fals
e
);
contextConfig
.
setInfoJsSwitch
(
fals
e
);
}
}
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